mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-17 23:10:22 +00:00
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
This commit is contained in:
parent
8818d8a19b
commit
b52844031f
@ -1843,25 +1843,47 @@ gtk_icon_theme_lookup_icon_for_scale (GtkIconTheme *icon_theme,
|
|||||||
|
|
||||||
if (flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK)
|
if (flags & GTK_ICON_LOOKUP_GENERIC_FALLBACK)
|
||||||
{
|
{
|
||||||
gchar **names;
|
gchar **names, **nonsymbolic_names;
|
||||||
gint dashes, i;
|
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;
|
dashes = 0;
|
||||||
for (p = (gchar *) icon_name; *p; p++)
|
for (p = (gchar *) nonsymbolic_icon_name; *p; p++)
|
||||||
if (*p == '-')
|
if (*p == '-')
|
||||||
dashes++;
|
dashes++;
|
||||||
|
|
||||||
names = g_new (gchar *, dashes + 2);
|
nonsymbolic_names = g_new (gchar *, dashes + 2);
|
||||||
names[0] = g_strdup (icon_name);
|
nonsymbolic_names[0] = nonsymbolic_icon_name;
|
||||||
|
|
||||||
for (i = 1; i <= dashes; i++)
|
for (i = 1; i <= dashes; i++)
|
||||||
{
|
{
|
||||||
names[i] = g_strdup (names[i - 1]);
|
nonsymbolic_names[i] = g_strdup (nonsymbolic_names[i - 1]);
|
||||||
p = strrchr (names[i], '-');
|
p = strrchr (nonsymbolic_names[i], '-');
|
||||||
*p = '\0';
|
*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);
|
info = choose_icon (icon_theme, (const gchar **) names, size, scale, flags);
|
||||||
|
|
||||||
g_strfreev (names);
|
g_strfreev (names);
|
||||||
|
Loading…
Reference in New Issue
Block a user