iconhelper: Refactor missing icon handling

In particular, stop using deprecated code for loading the missing image
icon.
This commit is contained in:
Benjamin Otte 2015-12-04 16:13:22 +01:00
parent 3c54a49633
commit 295f208e1c

View File

@ -419,28 +419,33 @@ ensure_surface_for_gicon (GtkIconHelper *self,
MIN (width, height), MIN (width, height),
scale, flags); scale, flags);
if (info) if (info)
destination = {
gtk_icon_info_load_symbolic_for_context (info, destination =
context, gtk_icon_info_load_symbolic_for_context (info,
&symbolic, context,
NULL); &symbolic,
NULL);
g_object_unref (info);
}
else else
destination = NULL; {
destination = NULL;
}
if (destination == NULL) if (destination == NULL)
{ {
GtkIconSet *icon_set; destination = gtk_icon_theme_load_icon (icon_theme,
"image-missing",
G_GNUC_BEGIN_IGNORE_DEPRECATIONS; width,
flags | GTK_ICON_LOOKUP_USE_BUILTIN | GTK_ICON_LOOKUP_GENERIC_FALLBACK,
icon_set = gtk_icon_factory_lookup_default (GTK_STOCK_MISSING_IMAGE); NULL);
/* We include this image as resource, so we always have it available or
destination = * the icontheme code is broken */
gtk_icon_set_render_icon_pixbuf (icon_set, context, self->priv->icon_size); g_assert (destination);
symbolic = FALSE;
G_GNUC_END_IGNORE_DEPRECATIONS;
} }
else if (!symbolic)
if (!symbolic)
{ {
GdkPixbuf *rendered; GdkPixbuf *rendered;
@ -449,16 +454,8 @@ ensure_surface_for_gicon (GtkIconHelper *self,
destination = rendered; destination = rendered;
} }
surface = NULL; surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, self->priv->window);
if (destination) g_object_unref (destination);
{
surface = gdk_cairo_surface_create_from_pixbuf (destination, scale, self->priv->window);
g_object_unref (destination);
}
if (info)
g_object_unref (info);
return surface; return surface;
} }