Sophie

Sophie

distrib > * > 2008.0 > x86_64 > by-pkgid > 7852596252fa6d02e3e40fae8377700d > files > 1

thunar-0.9.0-6mdv2008.0.src.rpm

diff -Naur Thunar-0.9.0/thunar/thunar-icon-factory.c Thunar-0.9.0.tpg/thunar/thunar-icon-factory.c
--- Thunar-0.9.0/thunar/thunar-icon-factory.c	2007-12-02 13:46:33.000000000 +0000
+++ Thunar-0.9.0.tpg/thunar/thunar-icon-factory.c	2008-03-21 16:45:58.000000000 +0000
@@ -547,6 +547,7 @@
   GdkPixbuf     *scaled;
   GError        *err = NULL;
   gchar         *thumbnail;
+  gchar         *p;
 
   _thunar_return_val_if_fail (THUNAR_IS_ICON_FACTORY (factory), NULL);
   _thunar_return_val_if_fail (name != NULL && *name != '\0', NULL);
@@ -567,77 +568,88 @@
         }
       else
         {
-          /* check if the icon theme contains an icon of that name */
-          icon_info = gtk_icon_theme_lookup_icon (factory->icon_theme, name, size, 0);
-          if (G_LIKELY (icon_info != NULL))
+          int i;
+          for (i = 0; i<2; i)
             {
-              /* check if we have an SVG icon here */
-              filename = gtk_icon_info_get_filename (icon_info);
-              if (filename != NULL && g_str_has_suffix (filename, ".svg"))
+              if (i == 1) /* On second iteration, check without the 'extension' */
                 {
-                  /* We try to load SVG icons via the thumbnail database, because otherwise it's quite
-                   * slow to load the SVG icon each time, and also requires somewhat more memory than
-                   * simply loading and scaling PNG icons from the thumbnail database.
-                   *
-                   * Therefore first determine the path for the SVG icon.
-                   */
-                  path = thunar_vfs_path_new (filename, NULL);
-                  if (G_LIKELY (path != NULL))
+                  p = strrchr ((gchar *)name, '.');
+                  if (G_UNLIKELY (p != NULL))
+                    *p = '\0';
+                  else break;
+                }
+              /* check if the icon theme contains an icon of that name */
+              icon_info = gtk_icon_theme_lookup_icon (factory->icon_theme, name, size, 0);
+              if (G_LIKELY (icon_info != NULL))
+                {
+                  /* check if we have an SVG icon here */
+                  filename = gtk_icon_info_get_filename (icon_info);
+                  if (filename != NULL && g_str_has_suffix (filename, ".svg"))
                     {
-                      /* determine the info for the SVG icon, required for the thumbnail lookup */
-                      info = thunar_vfs_info_new_for_path (path, NULL);
-                      if (G_LIKELY (info != NULL))
+                      /* We try to load SVG icons via the thumbnail database, because otherwise it's quite
+                       * slow to load the SVG icon each time, and also requires somewhat more memory than
+                       * simply loading and scaling PNG icons from the thumbnail database.
+                       *
+                       * Therefore first determine the path for the SVG icon.
+                       */
+                      path = thunar_vfs_path_new (filename, NULL);
+                      if (G_LIKELY (path != NULL))
                         {
-                          /* check if we have a valid thumbnail for the SVG icon */
-                          thumbnail = thunar_vfs_thumb_factory_lookup_thumbnail (factory->thumbnail_factory, info);
-                          if (thumbnail == NULL)
+                          /* determine the info for the SVG icon, required for the thumbnail lookup */
+                          info = thunar_vfs_info_new_for_path (path, NULL);
+                          if (G_LIKELY (info != NULL))
                             {
-                              /* try to generate a thumbnail for the SVG icon */
-                              pixbuf = thunar_vfs_thumb_factory_generate_thumbnail (factory->thumbnail_factory, info);
-                              if (G_LIKELY (pixbuf != NULL))
+                              /* check if we have a valid thumbnail for the SVG icon */
+                              thumbnail = thunar_vfs_thumb_factory_lookup_thumbnail (factory->thumbnail_factory, info);
+                              if (thumbnail == NULL)
                                 {
-                                  /* try to store the generated thumbnail in the database */
-                                  if (!thunar_vfs_thumb_factory_store_thumbnail (factory->thumbnail_factory, pixbuf, info, &err))
+                                  /* try to generate a thumbnail for the SVG icon */
+                                  pixbuf = thunar_vfs_thumb_factory_generate_thumbnail (factory->thumbnail_factory, info);
+                                  if (G_LIKELY (pixbuf != NULL))
                                     {
-                                      /* not critical, but atleast let the user know whats going on */
-                                      g_warning ("Failed to store thumbnail for \"%s\" (%s), disabling thumbnailing", filename, err->message);
-                                      g_object_set (G_OBJECT (factory->preferences), "misc-show-thumbnails", FALSE, NULL);
-                                      g_error_free (err);
+                                      /* try to store the generated thumbnail in the database */
+                                      if (!thunar_vfs_thumb_factory_store_thumbnail (factory->thumbnail_factory, pixbuf, info, &err))
+                                        {
+                                          /* not critical, but atleast let the user know whats going on */
+                                          g_warning ("Failed to store thumbnail for \"%s\": %s", filename, err->message);
+                                          g_error_free (err);
+                                        }
+
+                                      /* scale down the generated thumbnail */
+                                      scaled = exo_gdk_pixbuf_scale_down (pixbuf, TRUE, size, size);
+                                      g_object_unref (G_OBJECT (pixbuf));
+                                      pixbuf = scaled;
                                     }
+                                }
+                              else
+                                {
+                                  /* load icon from the thumbnail */
+                                  pixbuf = exo_gdk_pixbuf_new_from_file_at_max_size (thumbnail, size, size, TRUE, NULL);
 
-                                  /* scale down the generated thumbnail */
-                                  scaled = exo_gdk_pixbuf_scale_down (pixbuf, TRUE, size, size);
-                                  g_object_unref (G_OBJECT (pixbuf));
-                                  pixbuf = scaled;
+                                  /* cleanup */
+                                  g_free (thumbnail);
                                 }
-                            }
-                          else
-                            {
-                              /* load icon from the thumbnail */
-                              pixbuf = exo_gdk_pixbuf_new_from_file_at_max_size (thumbnail, size, size, TRUE, NULL);
 
                               /* cleanup */
-                              g_free (thumbnail);
+                              thunar_vfs_info_unref (info);
                             }
 
                           /* cleanup */
-                          thunar_vfs_info_unref (info);
+                          thunar_vfs_path_unref (path);
                         }
-
-                      /* cleanup */
-                      thunar_vfs_path_unref (path);
                     }
-                }
 
-              /* fallback to loading via the GtkIconTheme methods */
-              if (G_LIKELY (pixbuf == NULL))
-                pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
+                  /* fallback to loading via the GtkIconTheme methods */
+                  if (G_LIKELY (pixbuf == NULL))
+                    pixbuf = gtk_icon_info_load_icon (icon_info, NULL);
 
-              /* cleanup */
-              gtk_icon_info_free (icon_info);
+                  /* cleanup */
+                  gtk_icon_info_free (icon_info);
+                }
+              if (pixbuf) break;
             }
-        }
-
+         }
+ 
       /* use fallback icon if no pixbuf could be loaded */
       if (G_UNLIKELY (pixbuf == NULL))
         {
diff -Naur Thunar-0.9.0/thunar-vfs/thunar-vfs-io-local.c Thunar-0.9.0.tpg/thunar-vfs/thunar-vfs-io-local.c
--- Thunar-0.9.0/thunar-vfs/thunar-vfs-io-local.c	2007-12-02 13:46:33.000000000 +0000
+++ Thunar-0.9.0.tpg/thunar-vfs/thunar-vfs-io-local.c	2008-03-21 14:13:46.000000000 +0000
@@ -456,13 +456,14 @@
                   /* setup the custom icon */
                   info->custom_icon = g_strdup (str);
 
+                  /* DISABLED; this should be handled in the icon factory */
                   /* drop any suffix (e.g. '.png') from themed icons */
-                  if (!g_path_is_absolute (info->custom_icon))
+                  /*if (!g_path_is_absolute (info->custom_icon))
                     {
                       p = strrchr (info->custom_icon, '.');
                       if (G_UNLIKELY (p != NULL))
                         *p = '\0';
-                    }
+                    }*/
                 }
 
               /* determine the type of the .desktop file */