From e052477f15c3e413b6c4c56968da0b7d21e657e1 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Mon, 24 Jan 2022 17:27:43 -0500
Subject: Fix build without Poppler.


diff --git a/CMakeScripts/DefineDependsandFlags.cmake b/CMakeScripts/DefineDependsandFlags.cmake
index 4d77e4d..c1e33a5 100644
--- a/CMakeScripts/DefineDependsandFlags.cmake
+++ b/CMakeScripts/DefineDependsandFlags.cmake
@@ -179,9 +179,11 @@ else()
     set(ENABLE_POPPLER_CAIRO OFF)
 endif()
 
-list(APPEND INKSCAPE_INCS_SYS ${POPPLER_INCLUDE_DIRS})
-list(APPEND INKSCAPE_LIBS     ${POPPLER_LIBRARIES})
-add_definitions(${POPPLER_DEFINITIONS})
+if(ENABLE_POPPLER_CAIRO)
+    list(APPEND INKSCAPE_INCS_SYS ${POPPLER_INCLUDE_DIRS})
+    list(APPEND INKSCAPE_LIBS     ${POPPLER_LIBRARIES})
+    add_definitions(${POPPLER_DEFINITIONS})
+endif()
 
 if(WITH_LIBWPG)
     pkg_check_modules(LIBWPG libwpg-0.3 librevenge-0.0 librevenge-stream-0.0)
-- 
2.30.2


From 28b1c87d4b61f2bf721415361686b59413b30c12 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Mon, 24 Jan 2022 20:07:10 -0500
Subject: tracedialog: Fix build under Haiku.


diff --git a/src/ui/dialog/tracedialog.cpp b/src/ui/dialog/tracedialog.cpp
index 869510d..05f446d 100644
--- a/src/ui/dialog/tracedialog.cpp
+++ b/src/ui/dialog/tracedialog.cpp
@@ -33,6 +33,10 @@
 #include "trace/potrace/inkscape-potrace.h"
 #include "trace/depixelize/inkscape-depixelize.h"
 
+#ifdef __HAIKU__
+#undef B_OK
+#endif
+
 // This maps the column ids in the glade file to useful enums
 static const std::map<std::string, Inkscape::Trace::Potrace::TraceType> trace_types = {
     {"SS_BC", Inkscape::Trace::Potrace::TRACE_BRIGHTNESS},
-- 
2.30.2


From 128dc87b37403f22c6f4437d32f5aee7ee2f2ca8 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Mon, 24 Jan 2022 21:57:22 -0500
Subject: Another no-Poppler fix.


diff --git a/src/inkscape-version-info.cpp b/src/inkscape-version-info.cpp
index e02a575..d460ac1 100644
--- a/src/inkscape-version-info.cpp
+++ b/src/inkscape-version-info.cpp
@@ -21,7 +21,9 @@
 #include <gtkmm.h>
 #include <libxml2/libxml/xmlversion.h>
 #include <libxslt/xsltconfig.h>
+#if 0
 #include <poppler-config.h>
+#endif
 
 #include "inkscape-version.h" // Inkscape version
 
@@ -91,7 +93,9 @@ std::string debug_info() {
     ss << "    Cairo version:    " << cairo_version_string() << std::endl;
     ss << "    Pango version:    " << pango_version_string() << std::endl;
     ss << "    HarfBuzz version: " << hb_version_string() << std::endl;
+#if 0
     ss << "    Poppler version:  " << POPPLER_VERSION << std::endl;
+#endif
     ss << std::endl;
     ss << "    OS version:       " << os_version();
 
@@ -110,4 +114,4 @@ std::string debug_info() {
   fill-column:99
   End:
 */
-// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
\ No newline at end of file
+// vim:filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99:
-- 
2.30.2


From fa5d76c4a094d2b8f85fd95c6fd685fbd0f9d1cb Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Wed, 26 Jan 2022 12:17:06 -0500
Subject: Add mechanism to get the program path under Haiku.


diff --git a/src/path-prefix.cpp b/src/path-prefix.cpp
index 1d61748..a8e8da1 100644
--- a/src/path-prefix.cpp
+++ b/src/path-prefix.cpp
@@ -31,6 +31,10 @@
 #include <sys/sysctl.h>
 #endif
 
+#ifdef __HAIKU__
+#include <kernel/image.h>
+#endif
+
 #include <cassert>
 #include <glib.h>
 #include <glibmm.h>
@@ -152,6 +156,16 @@ char const *get_program_name()
        } else {
            g_warning("get_program_name() - sysctl failed");
        }      
+#elif defined(__HAIKU__)
+		int32 cookie = 0;
+		image_info info;
+		while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+			if (info.type != B_APP_IMAGE)
+				continue;
+
+			program_name = realpath(info.name, nullptr);
+			break;
+		}
 #else
 #warning get_program_name() - no known way to obtain executable name on this platform
         g_info("get_program_name() - no known way to obtain executable name on this platform");
-- 
2.30.2


From a4c73b83baa32c3eaa0a9b6f213ac09a56118b56 Mon Sep 17 00:00:00 2001
From: Gerasim Troeglazov <3dEyes@gmail.com>
Date: Fri, 28 Jan 2022 08:26:36 +1000
Subject: Use glib for datadir


diff --git a/src/inkscape-main.cpp b/src/inkscape-main.cpp
index 7ac16f8..a7445b2 100644
--- a/src/inkscape-main.cpp
+++ b/src/inkscape-main.cpp
@@ -16,6 +16,10 @@
 #include <boost/algorithm/string/join.hpp>
 #endif
 
+#ifdef __HAIKU__
+#include <boost/algorithm/string/join.hpp>
+#endif
+
 #include "inkscape-application.h"
 #include "path-prefix.h"
 
@@ -70,7 +74,7 @@ static void set_themes_env()
 
     if (xdg_data_dirs.empty()) {
         // initialize with reasonable defaults (should match what glib would do if the variable were unset!)
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__HAIKU__)
         // g_get_system_data_dirs is actually not cached on Windows,
         // so we can just call it directly and modify XDG_DATA_DIRS later
         auto data_dirs = Glib::get_system_data_dirs();
-- 
2.30.2

