summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fdab393)
raw | patch | inline | side by side (parent: fdab393)
author | ishmal <ishmal@users.sourceforge.net> | |
Thu, 29 May 2008 19:15:08 +0000 (19:15 +0000) | ||
committer | ishmal <ishmal@users.sourceforge.net> | |
Thu, 29 May 2008 19:15:08 +0000 (19:15 +0000) |
diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp
index af287dc7ecbfccd73a594be9a6af0825901cc535..7185330e8a1afd7148acb361a78d08c8c0b7f393 100644 (file)
--- a/src/bind/javabind.cpp
+++ b/src/bind/javabind.cpp
*/
static void getJavaRoot(String &javaroot)
{
- javaroot = getExePath();
+ /*
+ javaroot = getExePath();
javaroot.append("\\");
javaroot.append(INKSCAPE_BINDDIR);
javaroot.append("\\java");
+ */
+ javaroot = INKSCAPE_BINDDIR;
+ javaroot.append("\\java");
}
diff --git a/src/extension/init.cpp b/src/extension/init.cpp
index 649a654712b8fc9d5dbea2c62760dbc8ed462f86..458f15e78177a4feb6ebdb313d39ed7cc5ef07be 100644 (file)
--- a/src/extension/init.cpp
+++ b/src/extension/init.cpp
{
Inkscape::Extension::Extension::search_path.push_back(profile_path("extensions"));
-#ifdef WIN32
-/*
- * The native Windows Save dialogs change the current directory of Inkscape to the path selected in the dialog
- * Putting relative paths in the search_path breaks things after the Save dialog ha been shown
- * Especially the XAML-save: https://bugs.launchpad.net/inkscape/+bug/168896
- * This code inserts an absolute path based on the current working dir when Inkscape starts.
- * Only included in WIN32 to avoid messing around with other platforms for the moment
- * After testing on other platforms this code can be enabled on other platforms (it "should" not break anything).
- */
- gchar * cwd = g_get_current_dir();
- gchar * fname = g_build_filename(
- cwd,
- g_strdup(INKSCAPE_EXTENSIONDIR),
- NULL);
- Glib::ustring filename = fname;
- Inkscape::Extension::Extension::search_path.push_back(g_strdup(filename.c_str()));
- g_free(cwd);
- g_free(fname);
-#else
Inkscape::Extension::Extension::search_path.push_back(g_strdup(INKSCAPE_EXTENSIONDIR));
-#endif
}
diff --git a/src/main.cpp b/src/main.cpp
index 463428e0cc809b3a0783a956c6e869677058cdf6..83170931ffec51b5f9de5951bae9257c5b66ce64 100644 (file)
--- a/src/main.cpp
+++ b/src/main.cpp
static bool needToRecodeParams = true;
gchar * blankParam = g_strdup("");
-#ifdef WIN32
-static int _win32_set_inkscape_env(char *argv0)
-{
- CHAR szFullPath[_MAX_PATH];
- CHAR szDrive[_MAX_DRIVE];
- CHAR szDir[_MAX_DIR];
- CHAR szFile[_MAX_FNAME];
- CHAR szExt[_MAX_EXT];
- std::string tmp;
+#ifdef WIN32
- if (GetModuleFileName(NULL, szFullPath, sizeof(szFullPath)) == 0) {
- strcpy(szFullPath, argv0);
- }
+/**
+ * Return the directory of the .exe that is currently running
+ */
+static Glib::ustring _win32_getExePath()
+{
+ char exeName[MAX_PATH+1];
+ GetModuleFileName(NULL, exeName, MAX_PATH);
+ char *slashPos = strrchr(exeName, '\\');
+ if (slashPos)
+ *slashPos = '\0';
+ Glib::ustring s = exeName;
+ return s;
+}
- _splitpath(szFullPath, szDrive, szDir, szFile, szExt);
- strcpy(szFullPath, szDrive);
- strcat(szFullPath, szDir);
+/**
+ * Set up the PATH and PYTHONPATH environment variables on
+ * win32
+ */
+static int _win32_set_inkscape_env(const Glib::ustring &exePath)
+{
char *oldenv = getenv("PATH");
- tmp = "PATH=";
- tmp += szFullPath;
+ Glib::ustring tmp = "PATH=";
+ tmp += exePath;
tmp += ";";
- tmp += szFullPath;
- tmp += "python;";
- tmp += szFullPath;
- tmp += "python\\Scripts;"; // for uniconv.cmd
- tmp += szFullPath;
- tmp += "perl";
+ tmp += exePath;
+ tmp += "\\python;";
+ tmp += exePath;
+ tmp += "\\python\\Scripts;"; // for uniconv.cmd
+ tmp += exePath;
+ tmp += "\\perl";
if(oldenv != NULL) {
tmp += ";";
tmp += oldenv;
oldenv = getenv("PYTHONPATH");
tmp = "PYTHONPATH=";
- tmp += szFullPath;
- tmp += "python;";
- tmp += szFullPath;
- tmp += "python\\Lib;";
- tmp += szFullPath;
- tmp += "python\\DLLs";
+ tmp += exePath;
+ tmp += "\\python;";
+ tmp += exePath;
+ tmp += "\\python\\Lib;";
+ tmp += exePath;
+ tmp += "\\python\\DLLs";
if(oldenv != NULL) {
tmp += ";";
tmp += oldenv;
}
#endif
+
+
+/**
+ * This is the classic main() entry point of the program, though on some
+ * architectures it might be called by something else.
+ */
int
main(int argc, char **argv)
{
fpsetmask(fpgetmask() & ~(FP_X_DZ | FP_X_INV));
#endif
-#ifdef ENABLE_NLS
#ifdef WIN32
- _win32_set_inkscape_env(argv[0]);
+ /*
+ Set the current directory to the directory of the
+ executable. This seems redundant, but is needed for
+ when inkscape.exe is executed from another directory.
+ We use relative paths on win32.
+ HKCR\svgfile\shell\open\command is a good example
+ */
+ Glib::ustring homedir = _win32_getExePath();
+ SetCurrentDirectory(homedir.c_str());
+ _win32_set_inkscape_env(homedir);
RegistryTool rt;
rt.setPathInfo();
- gchar *pathBuf = g_strconcat(g_path_get_dirname(argv[0]), "\\", PACKAGE_LOCALE_DIR, NULL);
- bindtextdomain(GETTEXT_PACKAGE, pathBuf);
- g_free(pathBuf);
+#endif
+
+ /**
+ * Call bindtextdomain() for various machines's paths
+ */
+#ifdef ENABLE_NLS
+#ifdef WIN32
+ Glib::ustring localePath = homedir;
+ localePath += "\\";
+ localePath += PACKAGE_LOCALE_DIR;
+ bindtextdomain(GETTEXT_PACKAGE, localePath.c_str());
#else
#ifdef ENABLE_BINRELOC
bindtextdomain(GETTEXT_PACKAGE, BR_LOCALEDIR(""));
Inkscape::Debug::Logger::init();
gboolean use_gui;
+
#ifndef WIN32
use_gui = (getenv("DISPLAY") != NULL);
#else
- /*
- Set the current directory to the directory of the
- executable. This seems redundant, but is needed for
- when inkscape.exe is executed from another directory.
- We use relative paths on win32.
- HKCR\svgfile\shell\open\command is a good example
- */
- /// \todo FIXME BROKEN - non-UTF-8 sneaks in here.
- char *homedir = g_path_get_dirname(argv[0]);
- SetCurrentDirectory(homedir);
- g_free(homedir);
-
use_gui = TRUE;
#endif
/* Test whether with/without GUI is forced */
return app.run();
}
+
+
+
void fixupSingleFilename( gchar **orig, gchar **spare )
{
if ( orig && *orig && **orig ) {
}
}
+
+
GSList *fixupFilenameEncoding( GSList* fl )
{
GSList *newFl = NULL;
diff --git a/src/path-prefix.h b/src/path-prefix.h
index 72c21ca55d84e3c94638aefea388fe13cec07eae..447ddcf85dd81254642ed05081b9e896b345ae8f 100644 (file)
--- a/src/path-prefix.h
+++ b/src/path-prefix.h
# define CREATE_PATTERNSDIR BR_DATADIR( "/create/patterns/vector" )
#else
# ifdef WIN32
-# define INKSCAPE_APPICONDIR "pixmaps"
-# define INKSCAPE_BINDDIR "share\\bind"
-# define INKSCAPE_EXAMPLESDIR "share\\examples"
-# define INKSCAPE_EXTENSIONDIR "share\\extensions"
-# define INKSCAPE_FILTERDIR "share\\filters"
-# define INKSCAPE_GRADIENTSDIR "share\\gradients"
-# define INKSCAPE_KEYSDIR "share\\keys"
-# define INKSCAPE_PIXMAPDIR "share\\icons"
-# define INKSCAPE_MARKERSDIR "share\\markers"
-# define INKSCAPE_PALETTESDIR "share\\palettes"
-# define INKSCAPE_PATTERNSDIR "share\\patterns"
-# define INKSCAPE_SCREENSDIR "share\\screens"
-# define INKSCAPE_TUTORIALSDIR "share\\tutorials"
-# define INKSCAPE_PLUGINDIR "plugins"
-# define INKSCAPE_TEMPLATESDIR "share\\templates"
-# define INKSCAPE_UIDIR INKSCAPE_DATADIR "\\share\\ui"
+# define INKSCAPE_APPICONDIR WIN32_DATADIR("pixmaps")
+# 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_TUTORIALSDIR WIN32_DATADIR("share\\tutorials")
+# define INKSCAPE_PLUGINDIR WIN32_DATADIR("plugins")
+# define INKSCAPE_TEMPLATESDIR WIN32_DATADIR("share\\templates")
+# define INKSCAPE_UIDIR WIN32_DATADIR("share\\ui")
//CREATE V0.1 WIN32 support
-# define CREATE_GRADIENTSDIR INKSCAPE_DATADIR "create\\gradients\\gimp"
-# define CREATE_PALETTESDIR INKSCAPE_DATADIR "create\\swatches"
-# define CREATE_PATTERNSDIR INKSCAPE_DATADIR "create\\patterns\\vector"
+# define CREATE_GRADIENTSDIR WIN32_DATADIR("create\\gradients\\gimp")
+# define CREATE_PALETTESDIR WIN32_DATADIR("create\\swatches")
+# define CREATE_PATTERNSDIR WIN32_DATADIR("create\\patterns\\vector")
# elif defined ENABLE_OSX_APP_LOCATIONS
# define INKSCAPE_APPICONDIR "Contents/Resources/pixmaps"
# define INKSCAPE_BINDDIR "Contents/Resources/bind"
diff --git a/src/prefix.cpp b/src/prefix.cpp
index 0814bd53f9172d5ba4ff4fc36f2b17fc1a352f19..3af45269c2329065ff7ce1f4199a324bcdada2d9 100644 (file)
--- a/src/prefix.cpp
+++ b/src/prefix.cpp
#include <limits.h>
#include "prefix.h"
+
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
}
#endif /* __cplusplus */
+
+
+#ifdef __WIN32__
+
+/**
+ * Provide a similar mechanism for Win32. Enable a macro,
+ * WIN32_DATADIR, that can look up subpaths for inkscape resources
+ */
+
+#include <windows.h>
+#include <glibmm/ustring.h>
+
+/**
+ * Return the directory of the .exe that is currently running
+ */
+static Glib::ustring win32_getExePath()
+{
+ char exeName[MAX_PATH+1];
+ GetModuleFileName(NULL, exeName, MAX_PATH);
+ char *slashPos = strrchr(exeName, '\\');
+ if (slashPos)
+ *slashPos = '\0';
+ Glib::ustring s = exeName;
+ return s;
+}
+
+
+/**
+ * Return the relocatable version of the datadir,
+ * probably c:\inkscape
+ */
+static Glib::ustring win32_getDataDir()
+{
+ Glib::ustring dir = win32_getExePath();
+ if (INKSCAPE_DATADIR && *INKSCAPE_DATADIR &&
+ strcmp(INKSCAPE_DATADIR, ".") != 0)
+ {
+ dir += "\\";
+ dir += INKSCAPE_DATADIR;
+ }
+ return dir;
+}
+
+static Glib::ustring win32_getResourcePath(const Glib::ustring &childPath)
+{
+ Glib::ustring dir = win32_getDataDir();
+ if (childPath.size() > 0)
+ {
+ dir += "\\";
+ dir += childPath;
+ }
+ return dir;
+}
+
+
+/**
+ * This is the visible utility function
+ */
+char *win32_relative_path(const char *childPath)
+{
+ static char *returnPath = NULL;
+ if (!childPath)
+ childPath = "";
+ Glib::ustring resourcePath = win32_getResourcePath(childPath);
+ if (returnPath)
+ free(returnPath);
+ returnPath = strdup(resourcePath.c_str());
+ return returnPath;
+}
+#endif /* __WIN32__ */
+
+
+
+
#endif /* _PREFIX_C */
diff --git a/src/prefix.h b/src/prefix.h
index 0406f29f8cc8f2f46a34e07acd8995d32e9ed99e..0c2db5b58a6e0eca98095d69ef88aac720bc3106 100644 (file)
--- a/src/prefix.h
+++ b/src/prefix.h
char *br_extract_dir (const char *path);
char *br_extract_prefix(const char *path);
+#ifdef __WIN32__
+
+/**
+ * Win32 version of a relocatable function
+ */
+char *win32_relative_path(const char *childPath);
+
+#define WIN32_DATADIR(suffix) (win32_relative_path(suffix))
+
+#endif
+
#ifdef __cplusplus
}