Commit ebdd60c6 authored by Carlos Garnacho's avatar Carlos Garnacho Committed by Carlos Garnacho

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
parent db569cbe
......@@ -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 ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"
"<svg version=\"1.1\"\n"
" xmlns=\"\"\n"
" xmlns:xi=\"\"\n"
" width=\"16\"\n"
" height=\"16\">\n"
" width=\"", width, "\"\n"
" height=\"", height, "\">\n"
" <style type=\"text/css\">\n"
" rect,path {\n"
" fill: ", css_fg," !important;\n"
......@@ -3219,6 +3240,8 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
g_free (warning);
g_free (err);
g_free (success);
g_free (width);
g_free (height);
stream = g_memory_input_stream_new_from_data (data, -1, g_free);
pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream,
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