From ebdd60c63b962acaede2d699632934b1b6d6ca59 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 6 Jun 2012 18:16:05 +0200 Subject: [PATCH] icontheme: Don't assume a symbolic icon size of 16x16 If the symbolic icon has other size than 16x16, the embedder SVG that overrides colors would still force that size, resulting in clipping instead of resizing. So fetch the original pixbuf size the first time a symbolic icon is requested for a GtkIconInfo, and use that size for the embedder SVG so it can be scaled properly afterwards. https://bugzilla.gnome.org/show_bug.cgi?id=677567 --- gtk/gtkicontheme.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index fb59837016..58b643fcdb 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -232,6 +232,8 @@ struct _GtkIconInfo GdkPixbuf *pixbuf; GError *load_error; gdouble scale; + + GtkRequisition *symbolic_pixbuf_size; }; typedef struct @@ -2737,6 +2739,8 @@ gtk_icon_info_free (GtkIconInfo *icon_info) g_object_unref (icon_info->pixbuf); if (icon_info->cache_pixbuf) g_object_unref (icon_info->cache_pixbuf); + if (icon_info->symbolic_pixbuf_size) + gtk_requisition_free (icon_info->symbolic_pixbuf_size); g_slice_free (GtkIconInfo, icon_info); } @@ -3169,6 +3173,7 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, GdkPixbuf *pixbuf; gchar *data; gchar *success, *warning, *err; + gchar *width, *height; /* css_fg can't possibly have failed, otherwise * that would mean we have a broken style */ @@ -3192,13 +3197,29 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, err = gdk_color_to_css (&error_default_color); } + if (!icon_info->symbolic_pixbuf_size) + { + /* Fetch size from the original icon */ + pixbuf = gdk_pixbuf_new_from_file (icon_info->filename, error); + + if (!pixbuf) + return NULL; + + icon_info->symbolic_pixbuf_size = gtk_requisition_new (); + icon_info->symbolic_pixbuf_size->width = gdk_pixbuf_get_width (pixbuf); + icon_info->symbolic_pixbuf_size->height = gdk_pixbuf_get_height (pixbuf); + g_object_unref (pixbuf); + } + + width = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->width); + height = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->height); data = g_strconcat ("\n" "\n" + " width=\"", width, "\"\n" + " height=\"", height, "\">\n" "