From 680e28f40f5d5e29794c14c86d136d57dde520f4 Mon Sep 17 00:00:00 2001 From: "David C. Rankin" Date: Mon, 14 Aug 2017 13:24:52 -0500 Subject: [PATCH] Reimplement determination of sysdatadir on windows with g_get_dirname (argv[0]) and not convert path to POSIX seps before passing to dialog_about (g_spawn is only one not handling path correctly). --- README.md | 5 ++++- gtk_appdata.c | 33 +++++++++------------------------ 2 files changed, 13 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index b39469d..cb89d24 100644 --- a/README.md +++ b/README.md @@ -125,12 +125,13 @@ To build either on win32 and enable the `-subsystem,windows` link option, add $ make ss=-DWIN -Both **GtkEdit** and **GtkWrite** will compile with either MinGW or TDM-MinGW compilers. If you choose TDM-MinGW (separately or as part of CodeBlocks for windows), you will need to adjust the Makefile as the windows version of mkdir is used. On either, you will need to softlink `libxml2.dll` to `libxml2-2.dll` to run `gtkwrite`. After installing MinGW, the packages required to compile on windows are: +Both **GtkEdit** and **GtkWrite** will compile with either MinGW or TDM-MinGW compilers. If you choose TDM-MinGW (separately or as part of CodeBlocks for windows), you will need to adjust the Makefile as the windows version of mkdir is used. After installing MinGW, the packages required to compile on windows are: * [https://download.gnome.org/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip](https://download.gnome.org/binaries/win32/gtk+/2.24/gtk+-bundle_2.24.10-20120208_win32.zip) * [https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-2.10.0.zip](https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-2.10.0.zip) * [https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-dev-2.10.0.zip](https://download.gnome.org/binaries/win32/gtksourceview/2.10/gtksourceview-dev-2.10.0.zip) * [http://xmlsoft.org/sources/win32/libxml2-2.7.8.win32.zip](http://xmlsoft.org/sources/win32/libxml2-2.7.8.win32.zip) + * [https://download.gnome.org/binaries/win32/dependencies/libxml2_2.9.0-1_win32.zip](https://download.gnome.org/binaries/win32/dependencies/libxml2_2.9.0-1_win32.zip) (Msys has `libxml2` available, but it requires adding it to your path if you use it) @@ -144,4 +145,6 @@ On Linux, the default location for the configuration file is `$HOME/.config/gtkw On Linux system wide syntax color-schemes (styles) are found in `/usr/share/gtksourceview-2.0/styles` and personal styles can be added in `$HOME/.local/share/gtksourceview-2.0/styles`. On win32, the system wide style directory will depend on where you installed the gtksourceview2 files, any personal styles can be placed in `%LOCALAPPDATA%\gtksourceview-2.0\styles`. +On Windows, where you install the gtkwrite.exe executable is irrelevant to the operation of the editor. However, until an installer is created, to have the GPL license and logo displayed in help-about you should install to `C:/Program Files/gtkwrite` (on 32-bit versions) or to `C:/Program Files (x86)/gtkwrite` for 64-bit versions. (include the `gpl-2.0.txt` file and the `img` directory in that the same location) + Give it a try, help make it better. Drop me a line if you have any questions. diff --git a/gtk_appdata.c b/gtk_appdata.c index 8b7d6ab..e07b1f7 100644 --- a/gtk_appdata.c +++ b/gtk_appdata.c @@ -13,35 +13,20 @@ static gboolean chk_key_ok (GError **err) return TRUE; } -/** set user data dir and system data dir */ -static void set_data_dirs (kwinst *app) -{ - gchar *usrdata = get_posix_filename (g_get_user_data_dir()); - app->usrdatadir = g_strdup_printf ("%s/%s", usrdata, CFGDIR); - g_free (usrdata); -#ifndef HAVEMSWIN - app->sysdatadir = g_strdup (NIXSHARE); -#else - /* test whether C:/Program Files (x86) exists and use the - * 8 char mangled progra~2 if it does, otherwise use progra~1 - * TODO: write routine that simply replaces check for - * "Program Files (x86)" and then "Program Files", replacing each - * with the mangled name in app->exename directly, then simply use - * the concatenation of dir from app->exename and IMGDIR and LOGONAME. - */ - if (g_file_test (WINPRG86)) - app->sysdatadir = g_strdup (WINPRG86); - else - app->sysdatadir = g_strdup (WINPRG); -#endif -} - /** set default values for application & initialize variables */ static void context_set_defaults (kwinst *app, char **argv) { app->exename = get_posix_filename (argv[0]); /* executable name */ app->user = g_get_user_name (); /* system username */ - set_data_dirs (app); +#ifndef HAVEMSWIN + app->usrdatadir = g_strdup_printf ("%s/%s", g_get_user_data_dir(), CFGDIR); + app->sysdatadir = g_strdup (NIXSHARE); +#else + gchar *usrdata = get_posix_filename (g_get_user_data_dir()); + app->usrdatadir = g_strdup_printf ("%s/%s", usrdata, CFGDIR); + app->sysdatadir = g_strdup (g_path_get_dirname(argv[0])); + g_free (usrdata); +#endif #ifdef DEBUG g_print ("app->exename : %s\n" "app->user : %s\n"