summaryrefslogtreecommitdiff
path: root/gtk/gtkicontheme.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-06-23 07:05:29 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-06-23 08:18:42 -0400
commit12a40cf8a616924f15a8020c2af4e986012f41c9 (patch)
tree0c1deec0a5bf656ce3af75bfa91796fbb8620733 /gtk/gtkicontheme.c
parentfe92c4478e8d62b623690a07a4328b43edb1d62b (diff)
downloadgtk+-12a40cf8a616924f15a8020c2af4e986012f41c9.tar.gz
GtkIconTheme: keep misplaced symbolics working
Recent changes made it a breaking mistake to install symbolic icons of the wrong size into a theme directory, or into the legacy unthemed icon location. Since this change affects many apps, do the extra work to keep these icons working, but emit warnings, in the hope that this will lead to cleaning up the mess over time.
Diffstat (limited to 'gtk/gtkicontheme.c')
-rw-r--r--gtk/gtkicontheme.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 86b4e157ea..c3385e0f62 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -262,6 +262,8 @@ struct _GtkIconInfo
gdouble scale;
SymbolicPixbufCache *symbolic_pixbuf_cache;
+
+ gint symbolic_size;
};
typedef struct
@@ -4192,7 +4194,30 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
if (!icon_info_ensure_scale_and_pixbuf (icon_info, FALSE))
return NULL;
- size = g_strdup_printf ("%d", icon_info->dir_size * icon_info->dir_scale);
+ if (icon_info->symbolic_size == 0)
+ {
+ /* Fetch size from the original icon */
+ stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
+ pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, error);
+ g_object_unref (stream);
+
+ if (!pixbuf)
+ return NULL;
+
+ icon_info->symbolic_size = MAX (gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf));
+ g_object_unref (pixbuf);
+ }
+
+ if (icon_info->dir_type != ICON_THEME_DIR_SCALABLE)
+ g_warning ("Symbolic icon %s is not in a scalable icon theme directory",
+ icon_info->key.icon_names[0]);
+ else if (icon_info->dir_size * icon_info->dir_scale != icon_info->symbolic_size)
+ g_warning ("Symbolic icon %s of size %d is in an icon theme directory of size %d",
+ icon_info->key.icon_names[0],
+ icon_info->symbolic_size,
+ icon_info->dir_size * icon_info->dir_scale);
+
+ size = g_strdup_printf ("%d", icon_info->symbolic_size);
escaped_file_data = g_markup_escape_text (file_data, file_len);
g_free (file_data);