gtkicontheme: check for GdkPixbuf first

We checked for G_IS_LOADABLE_ICON() before GDK_IS_PIXBUF().

Since we made GdkPixbuf implement GLoadableIcon, the special case for
pixbufs is never used, and the much much slower GLoadableIcon path is
taken instead.  Move the GdkPixbuf one to be first to fix that.

https://bugzilla.gnome.org/show_bug.cgi?id=705320
This commit is contained in:
Ryan Lortie 2013-08-01 23:06:00 +02:00
parent 0091b4d54a
commit 03147b0e72

View File

@ -5184,7 +5184,40 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme,
g_return_val_if_fail (GTK_IS_ICON_THEME (icon_theme), NULL);
g_return_val_if_fail (G_IS_ICON (icon), NULL);
if (G_IS_LOADABLE_ICON (icon))
if (GDK_IS_PIXBUF (icon))
{
GdkPixbuf *pixbuf;
pixbuf = GDK_PIXBUF (icon);
if ((flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0)
{
gint width, height, max;
gdouble pixbuf_scale;
GdkPixbuf *scaled;
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
max = MAX (width, height);
pixbuf_scale = (gdouble) size * scale / (gdouble) max;
scaled = gdk_pixbuf_scale_simple (pixbuf,
0.5 + width * pixbuf_scale,
0.5 + height * pixbuf_scale,
GDK_INTERP_BILINEAR);
info = gtk_icon_info_new_for_pixbuf (icon_theme, scaled);
g_object_unref (scaled);
}
else
{
info = gtk_icon_info_new_for_pixbuf (icon_theme, pixbuf);
}
return info;
}
else if (G_IS_LOADABLE_ICON (icon))
{
info = icon_info_new ();
info->loadable = G_LOADABLE_ICON (g_object_ref (icon));
@ -5248,39 +5281,6 @@ gtk_icon_theme_lookup_by_gicon_for_scale (GtkIconTheme *icon_theme,
else
return NULL;
}
else if (GDK_IS_PIXBUF (icon))
{
GdkPixbuf *pixbuf;
pixbuf = GDK_PIXBUF (icon);
if ((flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0)
{
gint width, height, max;
gdouble pixbuf_scale;
GdkPixbuf *scaled;
width = gdk_pixbuf_get_width (pixbuf);
height = gdk_pixbuf_get_height (pixbuf);
max = MAX (width, height);
pixbuf_scale = (gdouble) size * scale / (gdouble) max;
scaled = gdk_pixbuf_scale_simple (pixbuf,
0.5 + width * pixbuf_scale,
0.5 + height * pixbuf_scale,
GDK_INTERP_BILINEAR);
info = gtk_icon_info_new_for_pixbuf (icon_theme, scaled);
g_object_unref (scaled);
}
else
{
info = gtk_icon_info_new_for_pixbuf (icon_theme, pixbuf);
}
return info;
}
return NULL;
}