summaryrefslogtreecommitdiff
path: root/gdk-pixbuf
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2004-03-15 14:10:08 +0000
committerTor Lillqvist <tml@src.gnome.org>2004-03-15 14:10:08 +0000
commit4d32d9024b384a926987b46516103d7b6b240fa2 (patch)
treea575f00f42f58e165341879a249287ef00e0625b /gdk-pixbuf
parentba7a95175bc33b37642a198dd6d7642c331f9002 (diff)
downloadgdk-pixbuf-4d32d9024b384a926987b46516103d7b6b240fa2.tar.gz
[Win32] Look up installation prefix at run-time, replace prefix in
2004-03-15 Tor Lillqvist <tml@iki.fi> * queryloaders.c (main): [Win32] Look up installation prefix at run-time, replace prefix in PIXBUF_LIBDIR with that. (#106141)
Diffstat (limited to 'gdk-pixbuf')
-rw-r--r--gdk-pixbuf/ChangeLog5
-rw-r--r--gdk-pixbuf/queryloaders.c43
2 files changed, 47 insertions, 1 deletions
diff --git a/gdk-pixbuf/ChangeLog b/gdk-pixbuf/ChangeLog
index 7d2a06bef..2a20a446f 100644
--- a/gdk-pixbuf/ChangeLog
+++ b/gdk-pixbuf/ChangeLog
@@ -1,7 +1,10 @@
2004-03-15 Tor Lillqvist <tml@iki.fi>
+ * queryloaders.c (main): [Win32] Look up installation prefix at
+ run-time, replace prefix in PIXBUF_LIBDIR with that. (#106141)
+
Merges from stable branch that had been left out. (#136282, J. Ali
- Harlow)
+ Harlow):
Changes for run-time lookup of installation location on Win32:
diff --git a/gdk-pixbuf/queryloaders.c b/gdk-pixbuf/queryloaders.c
index e2f6bfc91..21aa320eb 100644
--- a/gdk-pixbuf/queryloaders.c
+++ b/gdk-pixbuf/queryloaders.c
@@ -45,6 +45,10 @@
#endif
#define SOEXT_LEN (strlen (SOEXT))
+#ifdef G_OS_WIN32
+#include <windows.h>
+#endif
+
static void
print_escaped (const char *str)
{
@@ -203,6 +207,45 @@ int main (int argc, char **argv)
{
gint i;
+#ifdef G_OS_WIN32
+ gchar libdir[sizeof (PIXBUF_LIBDIR) + 100];
+ gchar runtime_prefix[1000];
+ gchar *slash;
+
+ strcpy (libdir, PIXBUF_LIBDIR);
+
+ if (g_ascii_strncasecmp (PIXBUF_LIBDIR, GTK_PREFIX, strlen (GTK_PREFIX)) == 0 &&
+ (PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '/' ||
+ PIXBUF_LIBDIR[strlen (GTK_PREFIX)] == '\\')) {
+ /* GTK_PREFIX is a prefix of PIXBUF_LIBDIR, as it
+ * normally is. Replace that prefix in PIXBUF_LIBDIR
+ * with the installation directory on this machine.
+ * We assume this invokation of
+ * gdk-pixbuf-query-loaders is run from either a "bin"
+ * subdirectory of the installation directory, or in
+ * the insallation directory itself.
+ */
+ GetModuleFileName (NULL, runtime_prefix, sizeof (runtime_prefix));
+
+ slash = strrchr (runtime_prefix, '\\');
+ *slash = '\0';
+ slash = strrchr (runtime_prefix, '\\');
+ if (slash != NULL && g_ascii_strcasecmp (slash + 1, "bin") == 0) {
+ *slash = '\0';
+ }
+
+ if (strlen (runtime_prefix) + 1 + strlen (PIXBUF_LIBDIR) - strlen (GTK_PREFIX) < sizeof (libdir)) {
+ strcpy (libdir, runtime_prefix);
+ strcat (libdir, "/");
+ strcat (libdir, PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1);
+ }
+ }
+
+#undef PIXBUF_LIBDIR
+#define PIXBUF_LIBDIR libdir
+
+#endif
+
g_printf ("# GdkPixbuf Image Loader Modules file\n"
"# Automatically generated file, do not edit\n"
"#\n");