--- Thunar-0.8.0-old/thunar-vfs/thunar-vfs-io-local.c 2007-01-20 12:39:09.000000000 -0800 +++ Thunar-0.8.0/thunar-vfs/thunar-vfs-io-local.c 2007-10-20 21:05:25.000000000 -0700 @@ -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 */ --- Thunar-0.8.0-old/thunar/thunar-icon-factory.c 2007-10-21 00:26:38.000000000 -0700 +++ Thunar-0.8.0/thunar/thunar-icon-factory.c 2007-10-21 00:27:51.000000000 -0700 @@ -542,6 +542,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); @@ -562,74 +563,86 @@ } 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)) - { - /* 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")) - { - /* 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)) - { - /* 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)) - { - /* 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 generate a thumbnail for the SVG icon */ - pixbuf = thunar_vfs_thumb_factory_generate_thumbnail (factory->thumbnail_factory, info); - if (G_LIKELY (pixbuf != NULL)) - { - /* 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); - - /* cleanup */ - g_free (thumbnail); - } - - /* cleanup */ - thunar_vfs_info_unref (info); - } - - /* 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); - - /* cleanup */ - gtk_icon_info_free (icon_info); - } + int i; + for (i = 0; i<2; i++) + { + if (i == 1) /* On second iteration, check without the 'extension' */ + { + 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")) + { + /* 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)) + { + /* 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)) + { + /* 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 generate a thumbnail for the SVG icon */ + pixbuf = thunar_vfs_thumb_factory_generate_thumbnail (factory->thumbnail_factory, info); + if (G_LIKELY (pixbuf != NULL)) + { + /* 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); + + /* cleanup */ + g_free (thumbnail); + } + + /* cleanup */ + thunar_vfs_info_unref (info); + } + + /* 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); + + /* cleanup */ + gtk_icon_info_free (icon_info); + } + if (pixbuf) break; + } } /* use fallback icon if no pixbuf could be loaded */