diff --git a/ChangeLog b/ChangeLog index 206b0dda4..88e7bf199 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index 206b0dda4..88e7bf199 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 206b0dda4..88e7bf199 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/ChangeLog.pre-2-12 b/ChangeLog.pre-2-12 index 206b0dda4..88e7bf199 100644 --- a/ChangeLog.pre-2-12 +++ b/ChangeLog.pre-2-12 @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index 206b0dda4..88e7bf199 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index 206b0dda4..88e7bf199 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index 206b0dda4..88e7bf199 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index 206b0dda4..88e7bf199 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,24 @@ +2001-01-17 Tor Lillqvist + + * config.h.win32.in: Define ENABLE_NLS and GETTEXT_PACKAGE. + + * makefile.mingw.in + * makefile.msc.in: Use the GNU intl library. + + * gwin32.c (g_win32_get_package_installation_directory): New + function. To be used by various GLib-using packages to get their + installation directory, which should be stored in the Registry by + some installer. + + * gwin32.h: Declare it. + + * testglib.c (main): Test it. + + * gutils.c: On Win32, define GLIB_LOCALE_DIR using + g_win32_get_package_installation_directory(). + + * glib.def: Update. + Mon Jan 15 21:39:06 2001 Owen Taylor * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@. diff --git a/config.h.win32.in b/config.h.win32.in index 6beceb866..d263cf267 100644 --- a/config.h.win32.in +++ b/config.h.win32.in @@ -145,3 +145,8 @@ /* #undef HAVE_LIBW */ #define USE_LIBICONV 1 + +#define ENABLE_NLS 1 + +/* Dunno if this will expand correctly: */ +#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@" diff --git a/glib.def b/glib.def index f3fe6b401..b56d2d3ba 100644 --- a/glib.def +++ b/glib.def @@ -585,6 +585,7 @@ EXPORTS g_win32_closedir g_win32_error_message g_win32_ftruncate + g_win32_get_package_installation_directory g_win32_getlocale g_win32_opendir g_win32_readdir diff --git a/glib/glib.def b/glib/glib.def index f3fe6b401..b56d2d3ba 100644 --- a/glib/glib.def +++ b/glib/glib.def @@ -585,6 +585,7 @@ EXPORTS g_win32_closedir g_win32_error_message g_win32_ftruncate + g_win32_get_package_installation_directory g_win32_getlocale g_win32_opendir g_win32_readdir diff --git a/glib/gutils.c b/glib/gutils.c index 9004546d8..b16e31ab0 100644 --- a/glib/gutils.c +++ b/glib/gutils.c @@ -1006,6 +1006,15 @@ g_get_codeset (void) #include +#ifdef G_OS_WIN32 + +#define GLIB_LOCALE_DIR \ + g_strconcat (g_win32_get_package_installation_directory (GETTEXT_PACKAGE), \ + G_DIR_SEPARATOR_S, \ + "locale", \ + NULL) +#endif + int _glib_gettext_initialized = 0; char *_glib_gettext_init (const char *str) diff --git a/glib/gwin32.c b/glib/gwin32.c index b45b26550..7126b5df9 100644 --- a/glib/gwin32.c +++ b/glib/gwin32.c @@ -822,3 +822,55 @@ g_win32_error_message (gint error) return retval; } + +gchar * +g_win32_get_package_installation_directory (gchar *package) +{ + static GHashTable *installation_dirs = NULL; + gchar *result; + gchar *key; + char win_dir[MAX_PATH]; + gchar *sep; + HKEY reg_key = NULL; + DWORD type; + DWORD nbytes; + + if (installation_dirs == NULL) + installation_dirs = g_hash_table_new (g_str_hash, g_str_equal); + + result = g_hash_table_lookup (installation_dirs, package); + + if (result && result[0]) + return result; + + key = g_strconcat ("Software\\", package, NULL); + + nbytes = 0; + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, key, 0, + KEY_QUERY_VALUE, ®_key) != ERROR_SUCCESS + || RegQueryValueEx (reg_key, "InstallationDirectory", 0, + &type, NULL, &nbytes) != ERROR_SUCCESS + || type != REG_SZ) + { + /* Uh oh. Use a default %WinDir%\package value */ + if (GetWindowsDirectory (win_dir, sizeof (win_dir)) == 0) + strcpy (win_dir, (GetVersion () >= 0x80000000 ? "C:\\windows" : "C:\\winnt")); + sep = (win_dir[strlen (win_dir) - 1] == '\\' ? "" : "\\"); + result = g_strconcat (win_dir, sep, package, NULL); + } + else + { + result = g_malloc (nbytes + 1); + RegQueryValueEx (reg_key, "InstallationDirectory", 0, + &type, result, &nbytes); + result[nbytes] = '\0'; + } + g_hash_table_insert (installation_dirs, package, result); + + if (reg_key != NULL) + RegCloseKey (reg_key); + + g_free (key); + + return result; +} diff --git a/glib/gwin32.h b/glib/gwin32.h index acb3050df..faa81c76a 100644 --- a/glib/gwin32.h +++ b/glib/gwin32.h @@ -110,6 +110,8 @@ gchar * g_win32_getlocale (void); */ gchar * g_win32_error_message (gint error); +gchar * g_win32_get_package_installation_directory (gchar *package); + G_END_DECLS #endif /* G_OS_WIN32 */ diff --git a/glib/makefile.mingw.in b/glib/makefile.mingw.in index 1b0f1be1b..0a4329fb7 100644 --- a/glib/makefile.mingw.in +++ b/glib/makefile.mingw.in @@ -20,7 +20,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@ INCLUDES = -I . DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DEPCFLAGS = $(LIBICONV_CFLAGS) +DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS) DLLS_TO_BUILD = \ glib-$(GLIB_VER).dll \ @@ -96,7 +96,7 @@ makefile.mingw: makefile.mingw.in ################ glib glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def - ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) $(LIBICONV_LIBS) -luser32 -lwsock32 + ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) $(INTL_LIBS) $(LIBICONV_LIBS) -luser32 -lwsock32 gspawn-win32-helper.exe : gspawn-win32-helper.c $(CC) $(CFLAGS) -mwindows -DG_LOG_DOMAIN=\"gspawn-win32-helper\" -o $@ $< -L . -lglib-$(GLIB_VER) diff --git a/glib/makefile.msc.in b/glib/makefile.msc.in index 49f92ea12..3e0677602 100644 --- a/glib/makefile.msc.in +++ b/glib/makefile.msc.in @@ -1,5 +1,5 @@ ## Makefile for building the GLib dlls with Microsoft C -## Use: nmake -f makefile.msc install +## Use: nmake -f makefile.msc # Change this to wherever you want to install the DLLs. This directory # should be in your PATH. @@ -18,7 +18,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@ INCLUDES = -I . DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DEPCFLAGS = $(LIBICONV_CFLAGS) +DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS) DLLS_TO_BUILD = \ glib-$(GLIB_VER).dll \ @@ -94,7 +94,7 @@ makefile.msc: makefile.msc.in ################ glib glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def - $(CC) $(CFLAGS) -LD -Feglib-$(GLIB_VER).dll $(glib_OBJECTS) $(LIBICONV_LIBS) user32.lib advapi32.lib wsock32.lib $(LDFLAGS) /def:glib.def + $(CC) $(CFLAGS) -LD -Feglib-$(GLIB_VER).dll $(glib_OBJECTS) $(INTL_LIBS) $(LIBICONV_LIBS) user32.lib advapi32.lib wsock32.lib $(LDFLAGS) /def:glib.def gspawn-win32-helper.exe : gspawn-win32-helper.c glib-$(GLIB_VER).dll $(CC) $(CFLAGS) -Fe$@ -DG_LOG_DOMAIN=\"gspawn-win32-helper\" gspawn-win32-helper.c glib-$(GLIB_VER).lib $(LDFLAGS) /subsystem:windows user32.lib diff --git a/gutils.c b/gutils.c index 9004546d8..b16e31ab0 100644 --- a/gutils.c +++ b/gutils.c @@ -1006,6 +1006,15 @@ g_get_codeset (void) #include +#ifdef G_OS_WIN32 + +#define GLIB_LOCALE_DIR \ + g_strconcat (g_win32_get_package_installation_directory (GETTEXT_PACKAGE), \ + G_DIR_SEPARATOR_S, \ + "locale", \ + NULL) +#endif + int _glib_gettext_initialized = 0; char *_glib_gettext_init (const char *str) diff --git a/gwin32.c b/gwin32.c index b45b26550..7126b5df9 100644 --- a/gwin32.c +++ b/gwin32.c @@ -822,3 +822,55 @@ g_win32_error_message (gint error) return retval; } + +gchar * +g_win32_get_package_installation_directory (gchar *package) +{ + static GHashTable *installation_dirs = NULL; + gchar *result; + gchar *key; + char win_dir[MAX_PATH]; + gchar *sep; + HKEY reg_key = NULL; + DWORD type; + DWORD nbytes; + + if (installation_dirs == NULL) + installation_dirs = g_hash_table_new (g_str_hash, g_str_equal); + + result = g_hash_table_lookup (installation_dirs, package); + + if (result && result[0]) + return result; + + key = g_strconcat ("Software\\", package, NULL); + + nbytes = 0; + if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, key, 0, + KEY_QUERY_VALUE, ®_key) != ERROR_SUCCESS + || RegQueryValueEx (reg_key, "InstallationDirectory", 0, + &type, NULL, &nbytes) != ERROR_SUCCESS + || type != REG_SZ) + { + /* Uh oh. Use a default %WinDir%\package value */ + if (GetWindowsDirectory (win_dir, sizeof (win_dir)) == 0) + strcpy (win_dir, (GetVersion () >= 0x80000000 ? "C:\\windows" : "C:\\winnt")); + sep = (win_dir[strlen (win_dir) - 1] == '\\' ? "" : "\\"); + result = g_strconcat (win_dir, sep, package, NULL); + } + else + { + result = g_malloc (nbytes + 1); + RegQueryValueEx (reg_key, "InstallationDirectory", 0, + &type, result, &nbytes); + result[nbytes] = '\0'; + } + g_hash_table_insert (installation_dirs, package, result); + + if (reg_key != NULL) + RegCloseKey (reg_key); + + g_free (key); + + return result; +} diff --git a/gwin32.h b/gwin32.h index acb3050df..faa81c76a 100644 --- a/gwin32.h +++ b/gwin32.h @@ -110,6 +110,8 @@ gchar * g_win32_getlocale (void); */ gchar * g_win32_error_message (gint error); +gchar * g_win32_get_package_installation_directory (gchar *package); + G_END_DECLS #endif /* G_OS_WIN32 */ diff --git a/makefile.mingw.in b/makefile.mingw.in index 1b0f1be1b..0a4329fb7 100644 --- a/makefile.mingw.in +++ b/makefile.mingw.in @@ -20,7 +20,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@ INCLUDES = -I . DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DEPCFLAGS = $(LIBICONV_CFLAGS) +DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS) DLLS_TO_BUILD = \ glib-$(GLIB_VER).dll \ @@ -96,7 +96,7 @@ makefile.mingw: makefile.mingw.in ################ glib glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def - ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) $(LIBICONV_LIBS) -luser32 -lwsock32 + ./build-dll glib $(GLIB_VER) glib.def $(glib_OBJECTS) $(INTL_LIBS) $(LIBICONV_LIBS) -luser32 -lwsock32 gspawn-win32-helper.exe : gspawn-win32-helper.c $(CC) $(CFLAGS) -mwindows -DG_LOG_DOMAIN=\"gspawn-win32-helper\" -o $@ $< -L . -lglib-$(GLIB_VER) diff --git a/makefile.msc.in b/makefile.msc.in index 49f92ea12..3e0677602 100644 --- a/makefile.msc.in +++ b/makefile.msc.in @@ -1,5 +1,5 @@ ## Makefile for building the GLib dlls with Microsoft C -## Use: nmake -f makefile.msc install +## Use: nmake -f makefile.msc # Change this to wherever you want to install the DLLs. This directory # should be in your PATH. @@ -18,7 +18,7 @@ GLIB_VER = @GLIB_MAJOR_VERSION@.@GLIB_MINOR_VERSION@ INCLUDES = -I . DEFINES = -DHAVE_CONFIG_H -DGLIB_COMPILATION -DG_LOG_DOMAIN=g_log_domain_glib -DG_ENABLE_DEBUG -DEPCFLAGS = $(LIBICONV_CFLAGS) +DEPCFLAGS = $(INTL_CFLAGS) $(LIBICONV_CFLAGS) DLLS_TO_BUILD = \ glib-$(GLIB_VER).dll \ @@ -94,7 +94,7 @@ makefile.msc: makefile.msc.in ################ glib glib-$(GLIB_VER).dll : $(glib_OBJECTS) glib.def - $(CC) $(CFLAGS) -LD -Feglib-$(GLIB_VER).dll $(glib_OBJECTS) $(LIBICONV_LIBS) user32.lib advapi32.lib wsock32.lib $(LDFLAGS) /def:glib.def + $(CC) $(CFLAGS) -LD -Feglib-$(GLIB_VER).dll $(glib_OBJECTS) $(INTL_LIBS) $(LIBICONV_LIBS) user32.lib advapi32.lib wsock32.lib $(LDFLAGS) /def:glib.def gspawn-win32-helper.exe : gspawn-win32-helper.c glib-$(GLIB_VER).dll $(CC) $(CFLAGS) -Fe$@ -DG_LOG_DOMAIN=\"gspawn-win32-helper\" gspawn-win32-helper.c glib-$(GLIB_VER).lib $(LDFLAGS) /subsystem:windows user32.lib diff --git a/testglib.c b/testglib.c index 5399a6e6b..05dd7d5ac 100644 --- a/testglib.c +++ b/testglib.c @@ -1144,6 +1144,11 @@ main (int argc, #ifdef G_OS_WIN32 g_print ("current locale: %s\n", g_win32_getlocale ()); + + g_print ("GLib installation directory (used for message catalogs): %s\n", + g_win32_get_package_installation_directory (GETTEXT_PACKAGE)); + g_print ("GTK+ 2.0 installation directory, if available: %s\n", + g_win32_get_package_installation_directory ("gtk20")); #endif g_print ("checking file functions...\n"); diff --git a/tests/testglib.c b/tests/testglib.c index 5399a6e6b..05dd7d5ac 100644 --- a/tests/testglib.c +++ b/tests/testglib.c @@ -1144,6 +1144,11 @@ main (int argc, #ifdef G_OS_WIN32 g_print ("current locale: %s\n", g_win32_getlocale ()); + + g_print ("GLib installation directory (used for message catalogs): %s\n", + g_win32_get_package_installation_directory (GETTEXT_PACKAGE)); + g_print ("GTK+ 2.0 installation directory, if available: %s\n", + g_win32_get_package_installation_directory ("gtk20")); #endif g_print ("checking file functions...\n");