diff options
author | Paolo Borelli <pborelli@gnome.org> | 2015-08-12 08:12:36 +0200 |
---|---|---|
committer | Paolo Borelli <pborelli@gnome.org> | 2015-08-12 21:40:04 +0200 |
commit | 7281803169561f3932d23e9fe0c56826ccdd3b7e (patch) | |
tree | 4b24f442e33bcbaeedc76537c1ec0e48ed1b1438 /gtk/gtkcellrendererpixbuf.c | |
parent | a1332167fb277dfb54a7111b73d594f2d753c7a9 (diff) | |
download | gtk+-7281803169561f3932d23e9fe0c56826ccdd3b7e.tar.gz |
cellrendererpixbuf: do not clear the icon helper twice
Do not call _gtk_icon_helper_clear explicitely when the properties
are set, since the corresponding _gtk_icon_helper_set_* method
already calls clear internally.
While at it rename the reset function to make it clear that it
is calling notify for the previous image type and avoid the
notification if the image type is not changing.
Diffstat (limited to 'gtk/gtkcellrendererpixbuf.c')
-rw-r--r-- | gtk/gtkcellrendererpixbuf.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c index 7151fc9827..6459c0934f 100644 --- a/gtk/gtkcellrendererpixbuf.c +++ b/gtk/gtkcellrendererpixbuf.c @@ -320,12 +320,14 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object, } static void -gtk_cell_renderer_pixbuf_reset (GtkCellRendererPixbuf *cellpixbuf) +notify_old_storage_type (GtkCellRendererPixbuf *cellpixbuf, + GtkImageType new_storage_type, + GtkImageType old_storage_type) { - GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; - GtkImageType storage_type = _gtk_icon_helper_get_storage_type (priv->icon_helper); + if (new_storage_type == old_storage_type) + return; - switch (storage_type) + switch (old_storage_type) { case GTK_IMAGE_SURFACE: g_object_notify (G_OBJECT (cellpixbuf), "surface"); @@ -334,7 +336,7 @@ gtk_cell_renderer_pixbuf_reset (GtkCellRendererPixbuf *cellpixbuf) g_object_notify (G_OBJECT (cellpixbuf), "pixbuf"); break; case GTK_IMAGE_STOCK: - g_object_notify (G_OBJECT (cellpixbuf), "stock-id"); + g_object_notify (G_OBJECT (cellpixbuf), "stock-id"); break; case GTK_IMAGE_ICON_NAME: g_object_notify (G_OBJECT (cellpixbuf), "icon-name"); @@ -346,8 +348,6 @@ gtk_cell_renderer_pixbuf_reset (GtkCellRendererPixbuf *cellpixbuf) default: break; } - - _gtk_icon_helper_clear (priv->icon_helper); } static void @@ -358,11 +358,12 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object, { GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object); GtkCellRendererPixbufPrivate *priv = cellpixbuf->priv; + GtkImageType old_storage_type = _gtk_icon_helper_get_storage_type (priv->icon_helper); switch (param_id) { case PROP_PIXBUF: - gtk_cell_renderer_pixbuf_reset (cellpixbuf); + notify_old_storage_type (cellpixbuf, GTK_IMAGE_PIXBUF, old_storage_type); _gtk_icon_helper_set_pixbuf (priv->icon_helper, g_value_get_object (value)); break; case PROP_PIXBUF_EXPANDER_OPEN: @@ -376,11 +377,11 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object, priv->pixbuf_expander_closed = (GdkPixbuf*) g_value_dup_object (value); break; case PROP_SURFACE: - gtk_cell_renderer_pixbuf_reset (cellpixbuf); + notify_old_storage_type (cellpixbuf, GTK_IMAGE_SURFACE, old_storage_type); _gtk_icon_helper_set_surface (priv->icon_helper, g_value_get_boxed (value)); break; case PROP_STOCK_ID: - gtk_cell_renderer_pixbuf_reset (cellpixbuf); + notify_old_storage_type (cellpixbuf, GTK_IMAGE_STOCK, old_storage_type); _gtk_icon_helper_set_stock_id (priv->icon_helper, g_value_get_string (value), priv->icon_size); break; case PROP_STOCK_SIZE: @@ -392,14 +393,14 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object, priv->stock_detail = g_value_dup_string (value); break; case PROP_ICON_NAME: - gtk_cell_renderer_pixbuf_reset (cellpixbuf); + notify_old_storage_type (cellpixbuf, GTK_IMAGE_ICON_NAME, old_storage_type); _gtk_icon_helper_set_icon_name (priv->icon_helper, g_value_get_string (value), priv->icon_size); break; case PROP_FOLLOW_STATE: priv->follow_state = g_value_get_boolean (value); break; case PROP_GICON: - gtk_cell_renderer_pixbuf_reset (cellpixbuf); + notify_old_storage_type (cellpixbuf, GTK_IMAGE_GICON, old_storage_type); _gtk_icon_helper_set_gicon (priv->icon_helper, g_value_get_object (value), priv->icon_size); break; default: |