[gtk+] GtkIconTheme: keep misplaced symbolics working
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] GtkIconTheme: keep misplaced symbolics working
- Date: Mon, 23 Jun 2014 12:19:52 +0000 (UTC)
commit 12a40cf8a616924f15a8020c2af4e986012f41c9
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Jun 23 07:05:29 2014 -0400
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.
gtk/gtkicontheme.c | 27 ++++++++++++++++++++++++++-
1 files changed, 26 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 86b4e15..c3385e0 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]