[evolution/gnome-3-16] Correct categories_icon_theme_hack() function
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution/gnome-3-16] Correct categories_icon_theme_hack() function
- Date: Fri, 7 Aug 2015 12:19:00 +0000 (UTC)
commit 87d6c435d87f36cdadfdfb8cf8e49377130d446e
Author: Milan Crha <mcrha redhat com>
Date: Fri Aug 7 14:13:58 2015 +0200
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 | 46 +++++++++++++++++++++++++++++++---------------
1 files changed, 31 insertions(+), 15 deletions(-)
---
diff --git a/shell/main.c b/shell/main.c
index fe97b0f..eded077 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');
-
- /* Extract the directory components. */
- dirname = g_path_get_dirname (filename);
- g_free (filename);
-
- /* 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);
+ categories = e_categories_dup_list ();
+
+ for (link = categories; link; link = g_list_next (link)) {
+ category_name = link->data;
+
+ filename = e_categories_dup_icon_file_for (category_name);
+ if (filename && *filename) {
+ /* Extract the directory components. */
+ dirname = g_path_get_dirname (filename);
+
+ 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_free (dirname);
+ g_list_free_full (categories, g_free);
+ g_hash_table_destroy (dirnames);
}
#ifdef DEVELOPMENT
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]