|
 |
02512f |
From b24a8e9aa82b64de970d8137181bf8a03b6f724a Mon Sep 17 00:00:00 2001
|
|
 |
02512f |
From: Christian Kellner <christian@kellner.me>
|
|
 |
02512f |
Date: Tue, 10 Apr 2018 09:47:48 +0200
|
|
 |
02512f |
Subject: [PATCH 2/4] shell: Icon name helper returns symbolic name
|
|
 |
02512f |
|
|
 |
02512f |
The helper function to get the icon name from a GIcon directly
|
|
 |
02512f |
returns the symbolic icon now. This makes it in turn possible
|
|
 |
02512f |
to also directly check if the theme has the icon with the symbolic
|
|
 |
02512f |
name instead of checking of for the full colored one and then
|
|
 |
02512f |
deriving the symbolic name from that. The latter (old) practice
|
|
 |
02512f |
will fail if there is a symbolic icon in the theme that has no
|
|
 |
02512f |
full color icon (like e.g. thunderbolt).
|
|
 |
02512f |
---
|
|
 |
02512f |
shell/cc-window.c | 19 ++++++++++---------
|
|
 |
02512f |
1 file changed, 10 insertions(+), 9 deletions(-)
|
|
 |
02512f |
|
|
 |
02512f |
diff --git a/shell/cc-window.c b/shell/cc-window.c
|
|
 |
02512f |
index 33f1ddcad511..3af9cf0bd9fc 100644
|
|
 |
02512f |
--- a/shell/cc-window.c
|
|
 |
02512f |
+++ b/shell/cc-window.c
|
|
 |
02512f |
@@ -88,8 +88,8 @@ enum
|
|
 |
02512f |
};
|
|
 |
02512f |
|
|
 |
02512f |
/* Auxiliary methods */
|
|
 |
02512f |
-static const gchar *
|
|
 |
02512f |
-get_icon_name_from_g_icon (GIcon *gicon)
|
|
 |
02512f |
+static gchar *
|
|
 |
02512f |
+get_symbolic_icon_name_from_g_icon (GIcon *gicon)
|
|
 |
02512f |
{
|
|
 |
02512f |
const gchar * const *names;
|
|
 |
02512f |
GtkIconTheme *icon_theme;
|
|
 |
02512f |
@@ -103,8 +103,11 @@ get_icon_name_from_g_icon (GIcon *gicon)
|
|
 |
02512f |
|
|
 |
02512f |
for (i = 0; names[i] != NULL; i++)
|
|
 |
02512f |
{
|
|
 |
02512f |
- if (gtk_icon_theme_has_icon (icon_theme, names[i]))
|
|
 |
02512f |
- return names[i];
|
|
 |
02512f |
+ g_autofree gchar *name = NULL;
|
|
 |
02512f |
+ name = g_strdup_printf ("%s-symbolic", names[i]);
|
|
 |
02512f |
+
|
|
 |
02512f |
+ if (gtk_icon_theme_has_icon (icon_theme, name))
|
|
 |
02512f |
+ return g_steal_pointer (&name);
|
|
 |
02512f |
}
|
|
 |
02512f |
|
|
 |
02512f |
return NULL;
|
|
 |
02512f |
@@ -248,9 +251,8 @@ setup_model (CcWindow *shell)
|
|
 |
02512f |
g_autofree gchar *name = NULL;
|
|
 |
02512f |
g_autofree gchar *description = NULL;
|
|
 |
02512f |
g_autofree gchar *id = NULL;
|
|
 |
02512f |
- g_autofree gchar *symbolic_icon = NULL;
|
|
 |
02512f |
+ g_autofree gchar *icon_name = NULL;
|
|
 |
02512f |
g_autofree GStrv keywords = NULL;
|
|
 |
02512f |
- const gchar *icon_name;
|
|
 |
02512f |
|
|
 |
02512f |
gtk_tree_model_get (model, &iter,
|
|
 |
02512f |
COL_CATEGORY, &category,
|
|
 |
02512f |
@@ -261,8 +263,7 @@ setup_model (CcWindow *shell)
|
|
 |
02512f |
COL_KEYWORDS, &keywords,
|
|
 |
02512f |
-1);
|
|
 |
02512f |
|
|
 |
02512f |
- icon_name = get_icon_name_from_g_icon (icon);
|
|
 |
02512f |
- symbolic_icon = g_strdup_printf ("%s-symbolic", icon_name);
|
|
 |
02512f |
+ icon_name = get_symbolic_icon_name_from_g_icon (icon);
|
|
 |
02512f |
|
|
 |
02512f |
cc_panel_list_add_panel (CC_PANEL_LIST (shell->panel_list),
|
|
 |
02512f |
category,
|
|
 |
02512f |
@@ -270,7 +271,7 @@ setup_model (CcWindow *shell)
|
|
 |
02512f |
name,
|
|
 |
02512f |
description,
|
|
 |
02512f |
keywords,
|
|
 |
02512f |
- symbolic_icon);
|
|
 |
02512f |
+ icon_name);
|
|
 |
02512f |
|
|
 |
02512f |
valid = gtk_tree_model_iter_next (model, &iter);
|
|
 |
02512f |
}
|
|
 |
02512f |
--
|
|
 |
02512f |
2.17.0
|
|
 |
02512f |
|