summaryrefslogtreecommitdiffstats
path: root/src
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
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')
-rw-r--r--src/main.cpp57
-rw-r--r--src/path-prefix.cpp61
-rw-r--r--src/path-prefix.h3
-rw-r--r--src/ui/dialog/inkscape-preferences.cpp7
4 files changed, 71 insertions, 57 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 108e5b0b2..14dcb0fe8 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -612,64 +612,15 @@ static void _win32_set_inkscape_env(gchar const *exe)
static void set_extensions_env()
{
- 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;
- }
-
- g_setenv("PYTHONPATH", new_pythonpath, TRUE);
- g_free(new_pythonpath);
+ gchar *pythonpath = get_extensions_path();
+ g_setenv("PYTHONPATH", pythonpath, TRUE);
+ g_free(pythonpath);
//printf("PYTHONPATH = %s\n", g_getenv("PYTHONPATH"));
}
static void set_datadir_env()
{
- 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;
- }
-
+ gchar *datadir = get_datadir_path();
g_setenv("XDG_DATA_HOME", datadir, TRUE);
g_free(datadir);
//printf("XDG_DATA_HOME = %s\n", g_getenv("XDG_DATA_HOME"));
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++
diff --git a/src/path-prefix.h b/src/path-prefix.h
index a557ca340..598a2eff8 100644
--- a/src/path-prefix.h
+++ b/src/path-prefix.h
@@ -20,7 +20,8 @@
char *append_inkscape_datadir(const char *relative_path);
-
+char *get_datadir_path();
+char *get_extensions_path();
#ifdef _WIN32
#undef INKSCAPE_DATADIR
#define INKSCAPE_DATADIR append_inkscape_datadir(NULL)
diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp
index 9bdc98b47..4808179b6 100644
--- a/src/ui/dialog/inkscape-preferences.cpp
+++ b/src/ui/dialog/inkscape-preferences.cpp
@@ -625,13 +625,14 @@ void InkscapePreferences::symbolicThemeCheck()
}
if (folder == prefs->getString("/theme/iconTheme")) {
#ifdef WIN32
- path += g_win32_locale_filename_from_utf8("/scalable/actions");
+ path += multiplatform_path(("/scalable/actions");
#else
path += "/scalable/actions";
#endif
- std::vector<Glib::ustring> symbolic = get_filenames(path, {"-symbolic.svg"}, {});
- if (symbolic.size() > 0) {
+ std::vector<Glib::ustring> symbolic_icons = get_filenames(path, {"-symbolic.svg"}, {});
+ if (symbolic_icons.size() > 0) {
symbolic = true;
+ symbolic_icons.clear();
}
}
}