[gtk+] icontheme: correctly fallback to symbolic icons
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] icontheme: correctly fallback to symbolic icons
- Date: Tue, 13 Aug 2013 15:24:10 +0000 (UTC)
commit b52844031f863f669b121098b43c1064191f3a54
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Tue Aug 13 15:41:08 2013 +0200
icontheme: correctly fallback to symbolic icons
When an icon is requested as symbolic, our generic fallback algorithm
uses fullcolor icons when the specified icon name is not found, treating
the "-symbolic" suffix as another component of the icon name.
Change the algorithm to check beforehand if the icon is symbolic, remove
the suffix if so, and re-add it at the end for all the generated icon
names.
https://bugzilla.gnome.org/show_bug.cgi?id=680926
gtk/gtkicontheme.c | 40 +++++++++++++++++++++++++++++++---------
1 files changed, 31 insertions(+), 9 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 5be7dbc..5d85fe9 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -1843,25 +1843,47 @@ gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *icon_theme,
if (flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK)
{
- gchar **names;
+ gchar **names, **nonsymbolic_names;
gint dashes, i;
- gchar *p;
+ gchar *p, *nonsymbolic_icon_name;
+ gboolean is_symbolic;
+
+ is_symbolic = g_str_has_suffix (icon_name, "-symbolic");
+ if (is_symbolic)
+ nonsymbolic_icon_name = g_strndup (icon_name, strlen (icon_name) - 9);
+ else
+ nonsymbolic_icon_name = g_strdup (icon_name);
dashes = 0;
- for (p = (gchar *) icon_name; *p; p++)
+ for (p = (gchar *) nonsymbolic_icon_name; *p; p++)
if (*p == '-')
dashes++;
- names = g_new (gchar *, dashes + 2);
- names[0] = g_strdup (icon_name);
+ nonsymbolic_names = g_new (gchar *, dashes + 2);
+ nonsymbolic_names[0] = nonsymbolic_icon_name;
+
for (i = 1; i <= dashes; i++)
{
- names[i] = g_strdup (names[i - 1]);
- p = strrchr (names[i], '-');
+ nonsymbolic_names[i] = g_strdup (nonsymbolic_names[i - 1]);
+ p = strrchr (nonsymbolic_names[i], '-');
*p = '\0';
}
- names[dashes + 1] = NULL;
-
+ nonsymbolic_names[dashes + 1] = NULL;
+
+ if (is_symbolic)
+ {
+ names = g_new (gchar *, dashes + 2);
+ for (i = 0; nonsymbolic_names[i] != NULL; i++)
+ names[i] = g_strconcat (nonsymbolic_names[i], "-symbolic", NULL);
+
+ names[i] = NULL;
+ g_strfreev (nonsymbolic_names);
+ }
+ else
+ {
+ names = nonsymbolic_names;
+ }
+
info = choose_icon (icon_theme, (const gchar **) names, size, scale, flags);
g_strfreev (names);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]