]> Pileus Git - ~andy/gtk/blobdiff - gdk-pixbuf/queryloaders.c
Make 3.0 parallel-installable to 2.x
[~andy/gtk] / gdk-pixbuf / queryloaders.c
index 6a3a7c5694fac29abe90ed64e1394b411fa55cd0..e9b5fc4b47651758530b779d41489f2e639e631b 100644 (file)
@@ -22,7 +22,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
-#include <config.h>
+#include "config.h"
 
 #include <glib.h>
 #include <glib/gprintf.h>
@@ -119,17 +119,20 @@ loader_sanity_check (const char *path, GdkPixbufFormat *info, GdkPixbufModule *v
        return 0;
 }
 
-static void 
+static void
 write_loader_info (const char *path, GdkPixbufFormat *info)
 {
        const GdkPixbufModulePattern *pattern;
-       char **mime; 
-       char **ext; 
+       char **mime;
+       char **ext;
 
        g_printf("\"%s\"\n", path);
-       g_printf ("\"%s\" %u \"%s\" \"%s\"\n", 
-                 info->name, info->flags, 
-                 info->domain ? info->domain : GETTEXT_PACKAGE, info->description);
+       g_printf ("\"%s\" %u \"%s\" \"%s\" \"%s\"\n",
+                 info->name,
+                  info->flags,
+                 info->domain ? info->domain : GETTEXT_PACKAGE,
+                  info->description,
+                  info->license ? info->license : "");
        for (mime = info->mime_types; *mime; mime++) {
                g_printf ("\"%s\" ", *mime);
        }
@@ -153,6 +156,8 @@ query_module (const char *dir, const char *file)
        GModule *module;
        void                    (*fill_info)     (GdkPixbufFormat *info);
        void                    (*fill_vtable)   (GdkPixbufModule *module);
+       gpointer fill_info_ptr;
+       gpointer fill_vtable_ptr;
 
        if (g_path_is_absolute (file)) 
                path = g_strdup (file);
@@ -161,8 +166,8 @@ query_module (const char *dir, const char *file)
 
        module = g_module_open (path, 0);
        if (module &&
-           g_module_symbol (module, "fill_info", (gpointer *) &fill_info) &&
-           g_module_symbol (module, "fill_vtable", (gpointer *) &fill_vtable)) {
+           g_module_symbol (module, "fill_info", &fill_info_ptr) &&
+           g_module_symbol (module, "fill_vtable", &fill_vtable_ptr)) {
                GdkPixbufFormat *info;
                GdkPixbufModule *vtable;
                
@@ -184,6 +189,9 @@ query_module (const char *dir, const char *file)
 
                vtable->module = module;
 
+               fill_info = fill_info_ptr;
+               fill_vtable = fill_vtable_ptr;
+
                (*fill_info) (info);
                (*fill_vtable) (vtable);
                
@@ -225,27 +233,33 @@ int main (int argc, char **argv)
                 * subdirectory of the installation directory, or in
                 * the installation directory itself.
                 */
-               if (G_WIN32_HAVE_WIDECHAR_API ()) {
-                       wchar_t fn[1000];
-                       GetModuleFileNameW (NULL, fn, G_N_ELEMENTS (fn));
-                       runtime_prefix = g_utf16_to_utf8 (fn, -1, NULL, NULL, NULL);
-               }
-               else {
-                       char fn[1000];
-                       GetModuleFileNameA (NULL, fn, G_N_ELEMENTS (fn));
-                       runtime_prefix = g_locale_to_utf8 (fn, -1, NULL, NULL, NULL);
-               }
+               wchar_t fn[1000];
+               GetModuleFileNameW (NULL, fn, G_N_ELEMENTS (fn));
+               runtime_prefix = g_utf16_to_utf8 (fn, -1, NULL, NULL, NULL);
                slash = strrchr (runtime_prefix, '\\');
                *slash = '\0';
                slash = strrchr (runtime_prefix, '\\');
-               if (slash != NULL && g_ascii_strcasecmp (slash + 1, "bin") == 0) {
-                       *slash = '\0';
+               /* If running from some weird location, or from the
+                * build directory (either in the .libs folder where
+                * libtool places the real executable when using a
+                * wrapper, or directly from the gdk-pixbuf folder),
+                * use the compile-time libdir.
+                */
+               if (slash == NULL ||
+                   g_ascii_strcasecmp (slash + 1, ".libs") == 0 ||
+                   g_ascii_strcasecmp (slash + 1, "gdk-pixbuf") == 0) {
+                       libdir = PIXBUF_LIBDIR;
                }
+               else {
+                       if (slash != NULL && g_ascii_strcasecmp (slash + 1, "bin") == 0) {
+                               *slash = '\0';
+                       }
                
-               libdir = g_strconcat (runtime_prefix,
-                                     "/",
-                                     PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1,
-                                     NULL);
+                       libdir = g_strconcat (runtime_prefix,
+                                             "/",
+                                             PIXBUF_LIBDIR + strlen (GTK_PREFIX) + 1,
+                                             NULL);
+               }
        }
        else {
                libdir = PIXBUF_LIBDIR;
@@ -260,7 +274,7 @@ int main (int argc, char **argv)
                  "# Automatically generated file, do not edit\n"
                  "# Created by %s from gtk+-%s\n"
                  "#\n",
-                 (prgname ? prgname : "gdk-pixbuf-query-loaders"),
+                 (prgname ? prgname : "gdk-pixbuf-query-loaders-3.0"),
                  GDK_PIXBUF_VERSION);
   
        if (argc == 1) {