Define ENABLE_NLS and GETTEXT_PACKAGE.
authorTor Lillqvist <tml@iki.fi>
Tue, 16 Jan 2001 22:06:23 +0000 (22:06 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Tue, 16 Jan 2001 22:06:23 +0000 (22:06 +0000)
2001-01-17  Tor Lillqvist  <tml@iki.fi>

* 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.

23 files changed:
ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
config.h.win32.in
glib.def
glib/glib.def
glib/gutils.c
glib/gwin32.c
glib/gwin32.h
glib/makefile.mingw.in
glib/makefile.msc.in
gutils.c
gwin32.c
gwin32.h
makefile.mingw.in
makefile.msc.in
testglib.c
tests/testglib.c

index 206b0dd..88e7bf1 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 206b0dd..88e7bf1 100644 (file)
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 206b0dd..88e7bf1 100644 (file)
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 206b0dd..88e7bf1 100644 (file)
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 206b0dd..88e7bf1 100644 (file)
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 206b0dd..88e7bf1 100644 (file)
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 206b0dd..88e7bf1 100644 (file)
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 206b0dd..88e7bf1 100644 (file)
@@ -1,3 +1,24 @@
+2001-01-17  Tor Lillqvist  <tml@iki.fi>
+
+       * 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  <otaylor@redhat.com>
 
        * glib-2.0.pc.in (Libs) glib-config-2.0.in: Add @INTLLIBS@.
index 6beceb8..d263cf2 100644 (file)
 /* #undef HAVE_LIBW */
 
 #define USE_LIBICONV 1
+
+#define ENABLE_NLS 1
+
+/* Dunno if this will expand correctly: */
+#define GETTEXT_PACKAGE "@GETTEXT_PACKAGE@"
index f3fe6b4..b56d2d3 100644 (file)
--- 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
index f3fe6b4..b56d2d3 100644 (file)
@@ -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
index 9004546..b16e31a 100644 (file)
@@ -1006,6 +1006,15 @@ g_get_codeset (void)
 
 #include <libintl.h>
 
+#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)
index b45b265..7126b5d 100644 (file)
@@ -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, &reg_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;
+}
index acb3050..faa81c7 100644 (file)
@@ -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 */
index 1b0f1be..0a4329f 100644 (file)
@@ -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)
index 49f92ea..3e06776 100644 (file)
@@ -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
index 9004546..b16e31a 100644 (file)
--- a/gutils.c
+++ b/gutils.c
@@ -1006,6 +1006,15 @@ g_get_codeset (void)
 
 #include <libintl.h>
 
+#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)
index b45b265..7126b5d 100644 (file)
--- 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, &reg_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;
+}
index acb3050..faa81c7 100644 (file)
--- 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 */
index 1b0f1be..0a4329f 100644 (file)
@@ -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)
index 49f92ea..3e06776 100644 (file)
@@ -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
index 5399a6e..05dd7d5 100644 (file)
@@ -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");
index 5399a6e..05dd7d5 100644 (file)
@@ -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");