Commit a5fd296c authored by Cosimo Cecchi's avatar Cosimo Cecchi

themedicon: 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
parent aa4b9429
......@@ -155,8 +155,17 @@ g_themed_icon_constructed (GObject *object)
const char *p;
char *dashp;
char *last;
gboolean is_symbolic;
char *name;
char **names;
is_symbolic = g_str_has_suffix (themed->names[0], "-symbolic");
if (is_symbolic)
name = g_strndup (themed->names[0], strlen (themed->names[0]) - 9);
else
name = g_strdup (themed->names[0]);
p = themed->names[0];
p = name;
while (*p)
{
if (*p == '-')
......@@ -164,17 +173,31 @@ g_themed_icon_constructed (GObject *object)
p++;
}
last = g_strdup (themed->names[0]);
last = name;
g_strfreev (themed->names);
themed->names = g_new (char *, dashes + 1 + 1);
themed->names[i++] = last;
names = g_new (char *, dashes + 1 + 1);
names[i++] = last;
while ((dashp = strrchr (last, '-')) != NULL)
themed->names[i++] = last = g_strndup (last, dashp - last);
names[i++] = last = g_strndup (last, dashp - last);
names[i++] = NULL;
if (is_symbolic)
{
themed->names = g_new (char *, dashes + 1 + 1);
for (i = 0; names[i] != NULL; i++)
themed->names[i] = g_strconcat (names[i], "-symbolic", NULL);
themed->names[i++] = NULL;
themed->names[i] = NULL;
g_strfreev (names);
}
else
{
themed->names = names;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment