summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2014-06-14 11:19:12 -0400
committerMatthias Clasen <mclasen@redhat.com>2014-06-14 15:10:49 -0400
commitfea939b3d75a97ded2e631235644500fcc2301cf (patch)
tree96b270aaf55b21574d11eae49a775338739cd70a
parent84cf748eae1f21e2b78b8e330a53ee12a308e32f (diff)
downloadgtk+-fea939b3d75a97ded2e631235644500fcc2301cf.tar.gz
GtkIconTheme: Don't treat svg icons specially
This changes makes svg icons go through the same scale calculation code as png icons. As a consequence, an svg that is put into the 32x32 directory will actually be loaded at size 32, even if it gets requested at a bigger size. This will let us avoid giant spinners. https://bugzilla.gnome.org/show_bug.cgi?id=731658
-rw-r--r--gtk/gtkicontheme.c63
1 files changed, 24 insertions, 39 deletions
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 8f2cc73c2b..8385d418e7 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -3895,39 +3895,6 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
}
}
- if (is_svg)
- {
- GInputStream *stream;
-
- icon_info->scale = scaled_desired_size / 1000.;
-
- if (scale_only)
- return TRUE;
-
- /* TODO: We should have a load_at_scale */
- stream = g_loadable_icon_load (icon_info->loadable,
- scaled_desired_size,
- NULL, NULL,
- &icon_info->load_error);
- if (stream)
- {
- icon_info->pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream,
- scaled_desired_size,
- scaled_desired_size,
- TRUE,
- NULL,
- &icon_info->load_error);
- g_object_unref (stream);
- }
-
- if (!icon_info->pixbuf)
- return FALSE;
-
- apply_emblems (icon_info);
-
- return TRUE;
- }
-
/* In many cases, the scale can be determined without actual access
* to the icon file. This is generally true when we have a size
* for the directory where the icon is; the image size doesn't
@@ -3951,7 +3918,7 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
icon_info->scale = (gdouble) scaled_desired_size / (icon_info->dir_size * icon_info->dir_scale);
}
- if (icon_info->scale >= 0. && scale_only)
+ if (icon_info->scale >= 0. && scale_only && !is_svg)
return TRUE;
/* At this point, we need to actually get the icon; either from the
@@ -3971,9 +3938,20 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
&icon_info->load_error);
if (stream)
{
- source_pixbuf = gdk_pixbuf_new_from_stream (stream,
- NULL,
- &icon_info->load_error);
+ if (is_svg)
+ {
+ gint size = icon_info->dir_size * icon_info->dir_scale * icon_info->scale;
+ source_pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream,
+ size,
+ size,
+ TRUE,
+ NULL,
+ &icon_info->load_error);
+ }
+ else
+ source_pixbuf = gdk_pixbuf_new_from_stream (stream,
+ NULL,
+ &icon_info->load_error);
g_object_unref (stream);
}
}
@@ -3986,7 +3964,12 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
image_width = gdk_pixbuf_get_width (source_pixbuf);
image_height = gdk_pixbuf_get_height (source_pixbuf);
- if (icon_info->scale < 0.0)
+ if (is_svg)
+ {
+ gint image_size = MAX (image_width, image_height);
+ icon_info->scale = image_size / 1000.;
+ }
+ else if (icon_info->scale < 0.0)
{
gint image_size = MAX (image_width, image_height);
if (image_size > 0)
@@ -4006,7 +3989,9 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
* extra complexity, we could keep the source pixbuf around
* but not actually scale it until needed.
*/
- if (icon_info->scale == 1.0)
+ if (is_svg)
+ icon_info->pixbuf = source_pixbuf;
+ else if (icon_info->scale == 1.0)
icon_info->pixbuf = source_pixbuf;
else
{