entry: Refactor get_icon_pixbuf

This way it will only return a pixbuf if the icon helper has a pixbuf.
This commit is contained in:
Timm Bäder 2016-12-02 15:16:10 +01:00
parent 8a543ab23c
commit 3dac21f20b
3 changed files with 2 additions and 25 deletions

View File

@ -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));
}
/**

View File

@ -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)
{

View File

@ -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);