[gtranslator] Add gtr folder to path on win, necessary to direct links
- From: Pablo Sanxiao Roca <psanxiao src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gtranslator] Add gtr folder to path on win, necessary to direct links
- Date: Thu, 30 Jul 2009 21:19:17 +0000 (UTC)
commit 5f5c2787c1c4cab50aaa134c97e35f8713765b6c
Author: Francisco Puga <francisco puga ghandalf org>
Date: Thu Jul 23 12:56:35 2009 +0200
Add gtr folder to path on win, necessary to direct links
src/main.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
---
diff --git a/src/main.c b/src/main.c
index c6a5d0f..faecaca 100644
--- a/src/main.c
+++ b/src/main.c
@@ -37,6 +37,15 @@
#include <gio/gio.h>
#include <gconf/gconf.h>
+#ifdef G_OS_WIN32
+#define SAVE_DATADIR DATADIR
+#undef DATADIR
+#define _WIN32_WINNT 0x0500
+#include <windows.h>
+#define DATADIR SAVE_DATADIR
+#undef SAVE_DATADIR
+#endif
+
static gchar **file_arguments = NULL;
@@ -79,6 +88,40 @@ get_command_line_data ()
return file_list;
}
+
+/* Copied from gedit code */
+#ifdef G_OS_WIN32
+static void
+setup_path (void)
+{
+ /* Set PATH to include the gedit executable's folder */
+ wchar_t exe_filename[MAX_PATH];
+ wchar_t *p;
+ gchar *exe_folder_utf8;
+ gchar *path;
+
+ GetModuleFileNameW (NULL, exe_filename, G_N_ELEMENTS (exe_filename));
+
+ p = wcsrchr (exe_filename, L'\\');
+ g_assert (p != NULL);
+
+ *p = L'\0';
+ exe_folder_utf8 = g_utf16_to_utf8 (exe_filename, -1, NULL, NULL, NULL);
+
+ path = g_build_path (";",
+ exe_folder_utf8,
+ g_getenv ("PATH"),
+ NULL);
+ if (!g_setenv ("PATH", path, TRUE))
+ g_warning ("Could not set PATH for gtranslator");
+
+ g_free (exe_folder_utf8);
+ g_free (path);
+}
+#endif
+
+
+
/*
* The ubiquitous main function...
*/
@@ -113,6 +156,10 @@ main (gint argc,
context = g_option_context_new (_("- Edit PO files"));
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
+#ifdef G_OS_WIN32
+ setup_path ();
+#endif
+
/*
* Initialize the GConf library.
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]