]> Pileus Git - ~andy/gtk/blobdiff - gdk-pixbuf/gdk-pixbuf-io.c
Speed up printer listing in the print dialog
[~andy/gtk] / gdk-pixbuf / gdk-pixbuf-io.c
index b26fb5d00188476cd6eb405c16f03d4a9269c5c3..646b0f1eaa89305f9f11198a36adf7583a7d4a2a 100644 (file)
@@ -228,8 +228,23 @@ skip_space (const char **pos)
   
 #ifdef G_OS_WIN32
 
-/* DllMain function needed to tuck away the gdk-pixbuf DLL name */
-G_WIN32_DLLMAIN_FOR_DLL_NAME (static, dll_name)
+/* DllMain function needed to tuck away the gdk-pixbuf DLL handle */
+
+static HMODULE gdk_pixbuf_dll;
+
+BOOL WINAPI
+DllMain (HINSTANCE hinstDLL,
+        DWORD     fdwReason,
+        LPVOID    lpvReserved)
+{
+       switch (fdwReason) {
+       case DLL_PROCESS_ATTACH:
+               gdk_pixbuf_dll = (HMODULE) hinstDLL;
+               break;
+       }
+
+  return TRUE;
+}
 
 static char *
 get_toplevel (void)
@@ -237,8 +252,7 @@ get_toplevel (void)
   static char *toplevel = NULL;
 
   if (toplevel == NULL)
-    toplevel = g_win32_get_package_installation_subdirectory
-      (GETTEXT_PACKAGE, dll_name, "");
+         toplevel = g_win32_get_package_installation_directory_of_module (gdk_pixbuf_dll);
 
   return toplevel;
 }
@@ -249,8 +263,7 @@ get_sysconfdir (void)
   static char *sysconfdir = NULL;
 
   if (sysconfdir == NULL)
-    sysconfdir = g_win32_get_package_installation_subdirectory
-      (GETTEXT_PACKAGE, dll_name, "etc");
+         sysconfdir = g_build_filename (get_toplevel (), "etc", NULL);
 
   return sysconfdir;
 }
@@ -264,6 +277,13 @@ correct_prefix (gchar **path)
   if (strncmp (*path, GTK_PREFIX "/", strlen (GTK_PREFIX "/")) == 0 ||
       strncmp (*path, GTK_PREFIX "\\", strlen (GTK_PREFIX "\\")) == 0)
     {
+         gchar *tem = NULL;
+      if (strlen(*path) > 5 && strncmp (*path - 5, ".libs", 5) == 0)
+        {
+          /* We are being run from inside the build tree, and shouldn't mess about. */
+          return;
+       }
+
       /* 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
@@ -271,7 +291,7 @@ correct_prefix (gchar **path)
        * builder's machine. Replace the build-time prefix with the
        * installation prefix on this machine.
        */
-      gchar *tem = *path;
+      tem = *path;
       *path = g_strconcat (get_toplevel (), tem + strlen (GTK_PREFIX), NULL);
       g_free (tem);
     }
@@ -402,6 +422,8 @@ gdk_pixbuf_io_init (void)
                if (file_formats == NULL)
                        g_warning ("Cannot open pixbuf loader module file '%s': %s",
                                   filename, error->message);
+               g_string_free (tmp_buf, TRUE);
+               g_free (filename);
                return;
        }
        
@@ -663,9 +685,10 @@ gdk_pixbuf_load_module_unlocked (GdkPixbufModule *image_module,
         if (fill_vtable) {
                image_module->module = (void *) 1;
                 (* fill_vtable) (image_module);
-               image_module->info = g_new0 (GdkPixbufFormat, 1);
-               (* fill_info) (image_module->info);
-
+               if (image_module->info == NULL) {
+                       image_module->info = g_new0 (GdkPixbufFormat, 1);
+                       (* fill_info) (image_module->info);
+               }
                 return TRUE;
        }
        else 
@@ -777,8 +800,11 @@ _gdk_pixbuf_get_module (guchar *buffer, guint size,
        gchar **mimes;
        gchar *type;
        gint j;
+       gboolean uncertain;
 
-       mime_type = g_content_type_guess (filename, buffer, size, NULL);
+       mime_type = g_content_type_guess (NULL, buffer, size, &uncertain);
+       if (uncertain)
+               mime_type = g_content_type_guess (filename, buffer, size, NULL);
 
        for (modules = get_file_formats (); modules; modules = g_slist_next (modules)) {
                GdkPixbufModule *module = (GdkPixbufModule *)modules->data;
@@ -2390,13 +2416,10 @@ gdk_pixbuf_save_to_stream (GdkPixbuf      *pixbuf,
        data.stream = stream;
        data.cancellable = cancellable;
 
-       if (!gdk_pixbuf_save_to_callbackv (pixbuf, save_to_stream, 
-                                          &data, type, 
-                                          keys, values, 
-                                          error)) {
-               error = NULL; /* Ignore further errors */
-               res = FALSE;
-       }
+       res = gdk_pixbuf_save_to_callbackv (pixbuf, save_to_stream, 
+                                           &data, type, 
+                                           keys, values, 
+                                           error);
 
        g_strfreev (keys);
        g_strfreev (values);
@@ -2436,14 +2459,14 @@ gchar *
 gdk_pixbuf_format_get_description (GdkPixbufFormat *format)
 {
        gchar *domain;
-       gchar *description;
+       const gchar *description;
        g_return_val_if_fail (format != NULL, NULL);
 
        if (format->domain != NULL) 
                domain = format->domain;
        else 
                domain = GETTEXT_PACKAGE;
-       description = dgettext (domain, format->description);
+       description = g_dgettext (domain, format->description);
 
        return g_strdup (description);
 }