[gtk+] icon helper: Avoid gratitious pixbuf use
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] icon helper: Avoid gratitious pixbuf use
- Date: Thu, 30 Nov 2017 22:32:43 +0000 (UTC)
commit a1c0b81baeb2f5b873639fbf54964ca5a876c94d
Author: Matthias Clasen <mclasen redhat com>
Date: Thu Nov 30 17:31:17 2017 -0500
icon helper: Avoid gratitious pixbuf use
We can just get the texture directly from the icontheme.
gtk/gtkiconhelper.c | 37 ++++++++-----------------------------
1 files changed, 8 insertions(+), 29 deletions(-)
---
diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c
index ab42bb9..16b7063 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -281,7 +281,6 @@ ensure_texture_for_gicon (GtkIconHelper *self,
GtkIconInfo *info;
GtkIconLookupFlags flags;
GdkTexture *texture;
- GdkPixbuf *destination;
icon_theme = gtk_css_icon_theme_value_get_icon_theme
(gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_THEME));
@@ -293,34 +292,14 @@ ensure_texture_for_gicon (GtkIconHelper *self,
gicon,
MIN (width, height),
scale, flags);
- if (info)
- {
- *symbolic = gtk_icon_info_is_symbolic (info);
-
- destination = gtk_icon_info_load_icon (info, NULL);
- }
- else
- {
- destination = NULL;
- }
-
- if (destination == NULL)
- {
- GError *error = NULL;
- destination = gtk_icon_theme_load_icon (icon_theme,
- "image-missing",
- width,
- flags | GTK_ICON_LOOKUP_USE_BUILTIN |
GTK_ICON_LOOKUP_GENERIC_FALLBACK,
- &error);
- /* We include this image as resource, so we always have it available or
- * the icontheme code is broken */
- g_assert_no_error (error);
- g_assert (destination);
- *symbolic = FALSE;
- }
-
- texture = gdk_texture_new_for_pixbuf (destination);
- g_object_unref (destination);
+ if (info == NULL)
+ info = gtk_icon_theme_lookup_icon (icon_theme,
+ "image-missing",
+ width,
+ flags | GTK_ICON_LOOKUP_USE_BUILTIN |
GTK_ICON_LOOKUP_GENERIC_FALLBACK);
+
+ *symbolic = gtk_icon_info_is_symbolic (info);
+ texture = gtk_icon_info_load_texture (info);
return texture;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]