From e114b8a882552fdfe3a1647af69870530ce8fbb0 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Fri, 7 Aug 2015 14:13:58 +0200 Subject: [PATCH] Correct categories_icon_theme_hack() function It adds an icon directory for one of the categories, which not always works, especially when a translator in the evolution-data-server uses a different category name translation, than the one from there. It is better to traverse all categories and add all icon folders into the search patch for the icon theme. --- shell/main.c | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/shell/main.c b/shell/main.c index fe97b0fcd2..eded077f42 100644 --- a/shell/main.c +++ b/shell/main.c @@ -113,7 +113,9 @@ void e_migrate_base_dirs (EShell *shell); static void categories_icon_theme_hack (void) { + GList *categories, *link; GtkIconTheme *icon_theme; + GHashTable *dirnames; const gchar *category_name; gchar *filename; gchar *dirname; @@ -121,24 +123,38 @@ categories_icon_theme_hack (void) /* XXX Allow the category icons to be referenced as named * icons, since GtkAction does not support GdkPixbufs. */ + icon_theme = gtk_icon_theme_get_default (); + dirnames = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL); + /* Get the icon file for some default category. Doesn't matter * which, so long as it has an icon. We're just interested in * the directory components. */ - category_name = _("Birthday"); - filename = e_categories_dup_icon_file_for (category_name); - g_return_if_fail (filename != NULL && *filename != '\0'); + categories = e_categories_dup_list (); - /* Extract the directory components. */ - dirname = g_path_get_dirname (filename); - g_free (filename); + for (link = categories; link; link = g_list_next (link)) { + category_name = link->data; - /* Add it to the icon theme's search path. This relies on - * GtkIconTheme's legacy feature of using image files found - * directly in the search path. */ - icon_theme = gtk_icon_theme_get_default (); - gtk_icon_theme_append_search_path (icon_theme, dirname); + filename = e_categories_dup_icon_file_for (category_name); + if (filename && *filename) { + /* Extract the directory components. */ + dirname = g_path_get_dirname (filename); - g_free (dirname); + if (dirname && !g_hash_table_contains (dirnames, dirname)) { + /* Add it to the icon theme's search path. This relies on + * GtkIconTheme's legacy feature of using image files found + * directly in the search path. */ + gtk_icon_theme_append_search_path (icon_theme, dirname); + g_hash_table_insert (dirnames, dirname, NULL); + } else { + g_free (dirname); + } + } + + g_free (filename); + } + + g_list_free_full (categories, g_free); + g_hash_table_destroy (dirnames); } #ifdef DEVELOPMENT