[gtk+/wip/baedert/children: 24/30] entry: Refactor get_icon_pixbuf



commit 7a626e4b99cb2a31d3e74358a95de66b96009579
Author: Timm Bäder <mail baedert org>
Date:   Fri Dec 2 15:16:10 2016 +0100

    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 5616e51..dafb25e 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 fee8bd6..4a89da6 100644
--- a/gtk/gtkiconhelper.c
+++ b/gtk/gtkiconhelper.c
@@ -493,7 +493,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 acfdd20..63aa826 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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]