diff options
author | Matthias Clasen <mclasen@redhat.com> | 2014-06-20 15:47:00 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2014-06-22 11:52:11 -0400 |
commit | b96058c3b70bd0f59b588bed68bea8901ace83ec (patch) | |
tree | c4108262e08b8894d45f28ceb4f7ecb97ff3e7ae /gtk/gtkicontheme.c | |
parent | 769fc520552a9efe32af2ab615135fa6f3b0e009 (diff) | |
download | gtk+-b96058c3b70bd0f59b588bed68bea8901ace83ec.tar.gz |
GtkIconTheme: Load symbolic icons at the same size
Reuse the scale information that we have from loading icons
normally, when loading a symbolic icon, so that we apply the
same size constraints.
This commit assumes that svgs have the nominal size of the
directory they are in, which will be true for all current
symbolic icons.
Diffstat (limited to 'gtk/gtkicontheme.c')
-rw-r--r-- | gtk/gtkicontheme.c | 36 |
1 files changed, 11 insertions, 25 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c index da5a8272f1..3e921e8113 100644 --- a/gtk/gtkicontheme.c +++ b/gtk/gtkicontheme.c @@ -4157,7 +4157,7 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, gchar *css_warning; gchar *css_error; gchar *data; - gchar *width, *height; + gchar *size; gchar *file_data, *escaped_file_data; gsize file_len; SymbolicPixbufCache *symbolic_cache; @@ -4171,7 +4171,8 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, } /* css_fg can't possibly have failed, otherwise - * that would mean we have a broken style */ + * that would mean we have a broken style + */ g_return_val_if_fail (fg != NULL, NULL); css_fg = gdk_rgba_to_string (fg); @@ -4196,24 +4197,10 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, if (!g_file_load_contents (icon_info->icon_file, NULL, &file_data, &file_len, NULL, error)) return NULL; - if (!icon_info->symbolic_pixbuf_size) - { - /* 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_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); - } + if (!icon_info_ensure_scale_and_pixbuf (icon_info, FALSE)) + return NULL; - width = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->width); - height = g_strdup_printf ("%d", icon_info->symbolic_pixbuf_size->height); + size = g_strdup_printf ("%d", icon_info->dir_size * icon_info->dir_scale); escaped_file_data = g_markup_escape_text (file_data, file_len); g_free (file_data); @@ -4222,8 +4209,8 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, "<svg version=\"1.1\"\n" " xmlns=\"http://www.w3.org/2000/svg\"\n" " xmlns:xi=\"http://www.w3.org/2001/XInclude\"\n" - " width=\"", width, "\"\n" - " height=\"", height, "\">\n" + " width=\"", size, "\"\n" + " height=\"", size, "\">\n" " <style type=\"text/css\">\n" " rect,path {\n" " fill: ", css_fg," !important;\n" @@ -4246,13 +4233,12 @@ gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info, g_free (css_warning); g_free (css_error); g_free (css_success); - g_free (width); - g_free (height); + g_free (size); stream = g_memory_input_stream_new_from_data (data, -1, g_free); pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, - icon_info->desired_size * icon_info->desired_scale, - icon_info->desired_size * icon_info->desired_scale, + gdk_pixbuf_get_width (icon_info->pixbuf), + gdk_pixbuf_get_height (icon_info->pixbuf), TRUE, NULL, error); |