summaryrefslogtreecommitdiffstats
path: root/src/path-prefix.cpp
diff options
context:
space:
mode:
authorJabiertxo Arraiza Cenoz <jtx@jtx.markerlab.es>2018-07-25 09:03:47 +0000
committerJabiertxo Arraiza Cenoz <jtx@jtx.markerlab.es>2018-07-25 09:03:47 +0000
commit384a3997b3def9d8382602d97b71649d902e6c38 (patch)
treef2ac1ba3fd818063aa61022dc6b23302ed3f99cf /src/path-prefix.cpp
parentImprove tooltip for open button in preferences (diff)
downloadinkscape-384a3997b3def9d8382602d97b71649d902e6c38.tar.gz
inkscape-384a3997b3def9d8382602d97b71649d902e6c38.zip
Add some Marting sugestions about main.cpp in MR
Diffstat (limited to 'src/path-prefix.cpp')
-rw-r--r--src/path-prefix.cpp61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/path-prefix.cpp b/src/path-prefix.cpp
index 87b756eb4..75dff6a33 100644
--- a/src/path-prefix.cpp
+++ b/src/path-prefix.cpp
@@ -25,6 +25,7 @@
#include <glib.h>
#include "path-prefix.h"
+#include "io/resource.h"
/**
@@ -61,7 +62,67 @@ char *append_inkscape_datadir(const char *relative_path)
return g_build_filename(inkscape_datadir, relative_path, NULL);
}
+gchar *get_extensions_path()
+{
+ using namespace Inkscape::IO::Resource;
+ gchar const *pythonpath = g_getenv("PYTHONPATH");
+ gchar *extdir;
+ gchar *new_pythonpath;
+#ifdef WIN32
+ extdir = g_win32_locale_filename_from_utf8(INKSCAPE_EXTENSIONDIR);
+#else
+ extdir = g_strdup(INKSCAPE_EXTENSIONDIR);
+#endif
+
+ // On some platforms, INKSCAPE_EXTENSIONDIR is not absolute,
+ // but relative to the directory that contains the Inkscape executable.
+ // Since we spawn Python chdir'ed into the script's directory,
+ // we need to obtain the absolute path here.
+ if (!g_path_is_absolute(extdir)) {
+ gchar *curdir = g_get_current_dir();
+ gchar *extdir_new = g_build_filename(curdir, extdir, NULL);
+ g_free(extdir);
+ g_free(curdir);
+ extdir = extdir_new;
+ }
+
+ if (pythonpath) {
+ new_pythonpath = g_strdup_printf("%s" G_SEARCHPATH_SEPARATOR_S "%s",
+ extdir, pythonpath);
+ g_free(extdir);
+ } else {
+ new_pythonpath = extdir;
+ }
+
+ return new_pythonpath;
+}
+
+gchar *get_datadir_path()
+{
+ using namespace Inkscape::IO::Resource;
+ gchar *datadir;
+
+#ifdef WIN32
+ datadir = g_win32_locale_filename_from_utf8(profile_path(""));
+#else
+ datadir = profile_path("");
+#endif
+
+ // On some platforms, INKSCAPE_EXTENSIONDIR is not absolute,
+ // but relative to the directory that contains the Inkscape executable.
+ // Since we spawn Python chdir'ed into the script's directory,
+ // we need to obtain the absolute path here.
+ if (!g_path_is_absolute(datadir)) {
+ gchar *curdir = g_get_current_dir();
+ gchar *datadir_new = g_build_filename(curdir, datadir, NULL);
+ g_free(datadir);
+ g_free(curdir);
+ datadir = datadir_new;
+ }
+
+ return datadir;
+}
/*
Local Variables:
mode:c++