Commit 72818031 authored by Paolo Borelli's avatar Paolo Borelli

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.
parent a1332167
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment