summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdk-pixbuf/ChangeLog15
-rw-r--r--gdk-pixbuf/Makefile.am1
-rw-r--r--gdk-pixbuf/gdk-pixbuf-io.c79
3 files changed, 72 insertions, 23 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index ad3da1c93..5eba8e1f8 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,3 +1,18 @@
+2003-01-09 Tor Lillqvist <tml@iki.fi>
+
+ Changes for run-time lookup of installation location on Win32:
+
+ * Makefile.am (INCLUDES): Define PREFIX as $(prefix).
+
+ * gdk-pixbuf-io.c (get_sysconfdir): New function, look up
+ installation location at runtime and deduce GTK_SYSCONFDIR
+ from it.
+ (get_toplevel): Similar, for the top-level installation directory.
+ (correct_prefix): Replace compile-time prefix with run-time
+ prefix.
+ (get_libdir): Remove, not used any longer.
+ (gdk_pixbuf_io_init): Call correct_prefix().
+
2003-01-05 Tor Lillqvist <tml@iki.fi>
* queryloaders.c (query_module): [Win32] Change backslahses into
diff --git a/gdk-pixbuf/Makefile.am b/gdk-pixbuf/Makefile.am
index 466c95871..d4f780bfe 100644
--- a/gdk-pixbuf/Makefile.am
+++ b/gdk-pixbuf/Makefile.am
@@ -248,6 +248,7 @@ INCLUDES = @STRIP_BEGIN@ \
-DGTK_BINARY_VERSION=\"@GTK_BINARY_VERSION@\" \
-DG_DISABLE_DEPRECATED \
-DGDK_PIXBUF_DISABLE_DEPRECATED \
+ -DPREFIX=\"$(prefix)\" \
@INCLUDED_LOADER_DEFINE@ \
@GTK_DEBUG_FLAGS@ \
@GDK_PIXBUF_DEP_CFLAGS@ \
diff --git a/gdk-pixbuf/gdk-pixbuf-io.c b/gdk-pixbuf/gdk-pixbuf-io.c
index cf3e8377b..3c677632f 100644
--- a/gdk-pixbuf/gdk-pixbuf-io.c
+++ b/gdk-pixbuf/gdk-pixbuf-io.c
@@ -165,6 +165,59 @@ skip_space (const char **pos)
return !(*p == '\0');
}
+#ifdef G_OS_WIN32
+
+/* DllMain function needed to tuck away the gdk-pixbuf DLL name */
+G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
+
+static char *
+get_toplevel (void)
+{
+ static char *toplevel = NULL;
+
+ if (toplevel == NULL)
+ toplevel = g_win32_get_package_installation_subdirectory
+ (GETTEXT_PACKAGE, dll_name, "");
+
+ return toplevel;
+}
+
+static char *
+get_sysconfdir (void)
+{
+ static char *sysconfdir = NULL;
+
+ if (sysconfdir == NULL)
+ sysconfdir = g_win32_get_package_installation_subdirectory
+ (GETTEXT_PACKAGE, dll_name, "etc");
+
+ return sysconfdir;
+}
+
+#undef GTK_SYSCONFDIR
+#define GTK_SYSCONFDIR get_sysconfdir()
+
+static void
+correct_prefix (gchar **path)
+{
+ if (strncmp (*path, PREFIX "/", strlen (PREFIX "/")) == 0 ||
+ strncmp (*path, PREFIX "\\", strlen (PREFIX "\\")) == 0)
+ {
+ /* This is an entry put there by gdk-pixbuf-query-loaders on the
+ * packager's system. On Windows a prebuilt GTK+ package can be
+ * installed in a random location. The gdk-pixbuf.loaders file
+ * distributed in such a package contains paths from the package
+ * builder's machine. Replace the build-time prefix with the
+ * installation prefix on this machine.
+ */
+ gchar *tem = *path;
+ *path = g_strconcat (get_toplevel (), tem + strlen (PREFIX), NULL);
+ g_free (tem);
+ }
+}
+
+#endif
+
static gchar *
gdk_pixbuf_get_module_file (void)
{
@@ -209,6 +262,9 @@ gdk_pixbuf_io_init ()
/* Blank line marking the end of a module
*/
if (module && *p != '#') {
+#ifdef G_OS_WIN32
+ correct_prefix (&module->module_path);
+#endif
file_formats = g_slist_prepend (file_formats, module);
module = NULL;
}
@@ -331,29 +387,6 @@ gdk_pixbuf_io_init ()
g_free (filename);
}
-#ifdef G_OS_WIN32
-
-/* DllMain function needed to tuck away the gdk-pixbuf DLL name */
-
-G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
-
-static char *
-get_libdir (void)
-{
- static char *libdir = NULL;
-
- if (libdir == NULL)
- libdir = g_win32_get_package_installation_subdirectory
- (GETTEXT_PACKAGE, dll_name, "lib\\gtk-2.0\\" GTK_BINARY_VERSION "\\loaders");
-
- return libdir;
-}
-
-#undef PIXBUF_LIBDIR
-#define PIXBUF_LIBDIR get_libdir ()
-
-#endif
-
/* actually load the image handler - gdk_pixbuf_get_module only get a */
/* reference to the module to load, it doesn't actually load it */
/* perhaps these actions should be combined in one function */