From 0ffa2524281e7f99cc3c2fb6a341b86fa0228735 Mon Sep 17 00:00:00 2001 From: Rodney Dawes Date: Sun, 14 Aug 2005 23:58:24 +0000 Subject: [PATCH] Get the Example icon that is specified by the icon theme, if it exists, 2005-08-14 Rodney Dawes * theme-thumbnail.c (create_image): Get the Example icon that is specified by the icon theme, if it exists, and then fall back through a better list of icons to use. Gnome uses gnome-fs-directory currently for folders, so we should prefer that over folder, but the icon naming spec lists x-directory-normal for standard folders, so we should prefer that above other folders This fixes issues with the wrong icon being drawn in the thumbnail, due to the icon theme providing the gnome folder icon, but inheriting from another theme which provides a different icon named "folder" for KDE or other desktops --- capplets/common/ChangeLog | 9 +++++++++ capplets/common/theme-thumbnail.c | 19 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/capplets/common/ChangeLog b/capplets/common/ChangeLog index cc1cce01c..d3c061ca0 100644 --- a/capplets/common/ChangeLog +++ b/capplets/common/ChangeLog @@ -1,3 +1,12 @@ +2005-08-14 Rodney Dawes + + * theme-thumbnail.c (create_image): Get the Example icon that is + specified by the icon theme, if it exists, and then fall back through + a better list of icons to use. Gnome uses gnome-fs-directory currently + for folders, so we should prefer that over folder, but the icon naming + spec lists x-directory-normal for standard folders, so we should prefer + that above other folders + 2005-07-27 Sebastien Bacher * capplet-util.c: (capplet_set_icon): set a default icon for capplets, diff --git a/capplets/common/theme-thumbnail.c b/capplets/common/theme-thumbnail.c index aa94b9671..46a892a2e 100644 --- a/capplets/common/theme-thumbnail.c +++ b/capplets/common/theme-thumbnail.c @@ -121,6 +121,7 @@ create_image (ThemeThumbnailData *theme_thumbnail_data, GdkPixbuf *folder_icon; GtkIconInfo *folder_icon_info; const gchar *filename; + gchar *example_icon_name; settings = gtk_settings_get_default (); g_object_set (G_OBJECT (settings), @@ -197,11 +198,21 @@ create_image (ThemeThumbnailData *theme_thumbnail_data, icon_theme = gtk_icon_theme_new (); gtk_icon_theme_set_custom_theme (icon_theme, (char *) theme_thumbnail_data->icon_theme_name->data); - /* Have to try both "folder" and "gnome-fs-directory" seems themes seem to use either name */ - folder_icon_info = gtk_icon_theme_lookup_icon (icon_theme, "folder", 48, GTK_ICON_LOOKUP_FORCE_SVG); - if (folder_icon_info == NULL) { + folder_icon_info = NULL; + /* Get the Example icon name in the theme if specified */ + example_icon_name = gtk_icon_theme_get_example_icon_name (icon_theme); + if (example_icon_name != NULL) + folder_icon_info = gtk_icon_theme_lookup_icon (icon_theme, example_icon_name, 48, GTK_ICON_LOOKUP_FORCE_SVG); + g_free (example_icon_name); + + /* If an Example is not specified, fall back to using the folder icons in + the order of Icon Nameing Spec, "gnome-fs-directory", and "folder" */ + if (folder_icon_info == NULL) + folder_icon_info = gtk_icon_theme_lookup_icon (icon_theme, "x-directory-normal", 48, GTK_ICON_LOOKUP_FORCE_SVG); + if (folder_icon_info == NULL) folder_icon_info = gtk_icon_theme_lookup_icon (icon_theme, "gnome-fs-directory", 48, GTK_ICON_LOOKUP_FORCE_SVG); - } + if (folder_icon_info == NULL) + folder_icon_info = gtk_icon_theme_lookup_icon (icon_theme, "folder", 48, GTK_ICON_LOOKUP_FORCE_SVG); g_object_unref (icon_theme);