diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/path-prefix.h | 32 | ||||
| -rw-r--r-- | src/prefix.cpp | 27 | ||||
| -rw-r--r-- | src/prefix.h | 6 |
3 files changed, 39 insertions, 26 deletions
diff --git a/src/path-prefix.h b/src/path-prefix.h index 8a39ede84..e54a80f28 100644 --- a/src/path-prefix.h +++ b/src/path-prefix.h @@ -51,22 +51,22 @@ #else # ifdef WIN32 # define INKSCAPE_APPICONDIR WIN32_DATADIR("pixmaps") -# define INKSCAPE_ATTRRELDIR WIN32_DATADIR("share\\attributes") -# define INKSCAPE_BINDDIR WIN32_DATADIR("share\\bind") -# define INKSCAPE_EXAMPLESDIR WIN32_DATADIR("share\\examples") -# define INKSCAPE_EXTENSIONDIR WIN32_DATADIR("share\\extensions") -# define INKSCAPE_FILTERDIR WIN32_DATADIR("share\\filters") -# define INKSCAPE_GRADIENTSDIR WIN32_DATADIR("share\\gradients") -# define INKSCAPE_KEYSDIR WIN32_DATADIR("share\\keys") -# define INKSCAPE_PIXMAPDIR WIN32_DATADIR("share\\icons") -# define INKSCAPE_MARKERSDIR WIN32_DATADIR("share\\markers") -# define INKSCAPE_PALETTESDIR WIN32_DATADIR("share\\palettes") -# define INKSCAPE_PATTERNSDIR WIN32_DATADIR("share\\patterns") -# define INKSCAPE_SCREENSDIR WIN32_DATADIR("share\\screens") -# define INKSCAPE_SYMBOLSDIR WIN32_DATADIR("share\\symbols") -# define INKSCAPE_TUTORIALSDIR WIN32_DATADIR("share\\tutorials") -# define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("share\\templates") -# define INKSCAPE_UIDIR WIN32_DATADIR("share\\ui") +# define INKSCAPE_ATTRRELDIR WIN32_DATADIR("attributes") +# define INKSCAPE_BINDDIR WIN32_DATADIR("bind") +# define INKSCAPE_EXAMPLESDIR WIN32_DATADIR("examples") +# define INKSCAPE_EXTENSIONDIR WIN32_DATADIR("extensions") +# define INKSCAPE_FILTERDIR WIN32_DATADIR("filters") +# define INKSCAPE_GRADIENTSDIR WIN32_DATADIR("gradients") +# define INKSCAPE_KEYSDIR WIN32_DATADIR("keys") +# define INKSCAPE_PIXMAPDIR WIN32_DATADIR("icons") +# define INKSCAPE_MARKERSDIR WIN32_DATADIR("markers") +# define INKSCAPE_PALETTESDIR WIN32_DATADIR("palettes") +# define INKSCAPE_PATTERNSDIR WIN32_DATADIR("patterns") +# define INKSCAPE_SCREENSDIR WIN32_DATADIR("screens") +# define INKSCAPE_SYMBOLSDIR WIN32_DATADIR("symbols") +# define INKSCAPE_TUTORIALSDIR WIN32_DATADIR("tutorials") +# define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("templates") +# define INKSCAPE_UIDIR WIN32_DATADIR("ui") //CREATE V0.1 WIN32 support # define CREATE_GRADIENTSDIR WIN32_DATADIR("create\\gradients\\gimp") # define CREATE_PALETTESDIR WIN32_DATADIR("create\\swatches") diff --git a/src/prefix.cpp b/src/prefix.cpp index cf0f752d2..c8bf7abec 100644 --- a/src/prefix.cpp +++ b/src/prefix.cpp @@ -425,20 +425,31 @@ br_extract_prefix (const char *path) */ /** - * Gets the directory where folders like "lib" and "share" are located and appends a relative path - * Handles the case where inkscape.exe is located in a "bin" subfolder as well + * Get the Windows-equivalent of INKSCAPE_DATADIR and append a relative path + * + * - by default INKSCAPE_DATADIR will be relative to the called executable + * (typically inkscape/share but also handles the case where the executable is in a /bin subfolder) + * - to override set the INKSCAPE_DATADIR environment variable */ -char *win32_append_module_path(const char *relative_path) +char *win32_append_datadir(const char *relative_path) { + static gchar *datadir; + if (!datadir) { + gchar const *inkscape_datadir = g_getenv("INKSCAPE_DATADIR"); + if (inkscape_datadir) { + datadir = g_strdup(inkscape_datadir); + } else { + gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL); + datadir = g_build_filename(module_path, "share", NULL); + g_free(module_path); + } + } + if (!relative_path) { relative_path = ""; } - gchar *module_path = g_win32_get_package_installation_directory_of_module(NULL); - gchar *return_path = g_build_filename(module_path, relative_path, NULL); - g_free(module_path); - - return return_path; + return g_build_filename(datadir, relative_path, NULL); } #endif /* __WIN32__ */ diff --git a/src/prefix.h b/src/prefix.h index da1295986..d28e896d0 100644 --- a/src/prefix.h +++ b/src/prefix.h @@ -119,8 +119,10 @@ char *br_extract_prefix(const char *path); #endif /* __cplusplus */ #ifdef __WIN32__ -char *win32_append_module_path(const char *relative_path); -#define WIN32_DATADIR(suffix) (win32_append_module_path(suffix)) +char *win32_append_datadir(const char *relative_path); +#undef INKSCAPE_DATADIR +#define INKSCAPE_DATADIR win32_append_datadir(NULL) +#define WIN32_DATADIR(suffix) (win32_append_datadir(suffix)) #endif #endif /* _PREFIX_H_ */ |
