From 3dac21f20bd6e85549f1613ae720ebbc36c98313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timm=20B=C3=A4der?= Date: Fri, 2 Dec 2016 15:16:10 +0100 Subject: [PATCH] entry: Refactor get_icon_pixbuf This way it will only return a pixbuf if the icon helper has a pixbuf. --- gtk/gtkentry.c | 23 +---------------------- gtk/gtkiconhelper.c | 2 +- gtk/gtkiconhelperprivate.h | 2 -- 3 files changed, 2 insertions(+), 25 deletions(-) diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 5616e513e1..dafb25e337 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -8177,9 +8177,6 @@ gtk_entry_get_icon_pixbuf (GtkEntry *entry, { GtkEntryPrivate *priv; EntryIconInfo *icon_info; - cairo_surface_t *surface; - GdkPixbuf *pixbuf; - int width, height; g_return_val_if_fail (GTK_IS_ENTRY (entry), NULL); g_return_val_if_fail (IS_VALID_ICON_POSITION (icon_pos), NULL); @@ -8191,25 +8188,7 @@ gtk_entry_get_icon_pixbuf (GtkEntry *entry, if (!icon_info) return NULL; - _gtk_icon_helper_get_size (GTK_ICON_HELPER (icon_info->gadget), &width, &height); - surface = gtk_icon_helper_load_surface (GTK_ICON_HELPER (icon_info->gadget), 1); - - pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height); - - cairo_surface_destroy (surface); - - /* HACK: unfortunately this is transfer none, so we attach it somehwere - * convenient. - */ - if (pixbuf) - { - g_object_set_data_full (G_OBJECT (icon_info->gadget), - "gtk-entry-pixbuf", - pixbuf, - g_object_unref); - } - - return pixbuf; + return _gtk_icon_helper_peek_pixbuf (GTK_ICON_HELPER (icon_info->gadget)); } /** diff --git a/gtk/gtkiconhelper.c b/gtk/gtkiconhelper.c index fcf3bbed72..8ed26c536e 100644 --- a/gtk/gtkiconhelper.c +++ b/gtk/gtkiconhelper.c @@ -483,7 +483,7 @@ ensure_surface_for_gicon (GtkIconHelper *self, return surface; } -cairo_surface_t * +static cairo_surface_t * gtk_icon_helper_load_surface (GtkIconHelper *self, int scale) { diff --git a/gtk/gtkiconhelperprivate.h b/gtk/gtkiconhelperprivate.h index acfdd20fde..63aa826c84 100644 --- a/gtk/gtkiconhelperprivate.h +++ b/gtk/gtkiconhelperprivate.h @@ -115,8 +115,6 @@ cairo_surface_t *_gtk_icon_helper_peek_surface (GtkIconHelper *self); GtkImageDefinition *gtk_icon_helper_get_definition (GtkIconHelper *self); const gchar *_gtk_icon_helper_get_icon_name (GtkIconHelper *self); -cairo_surface_t *gtk_icon_helper_load_surface (GtkIconHelper *self, - int scale); void _gtk_icon_helper_get_size (GtkIconHelper *self, gint *width_out, gint *height_out);