diff options
author | Matthias Clasen <mclasen@redhat.com> | 2009-06-15 21:10:34 +0200 |
---|---|---|
committer | Michael Natterer <mitch@gimp.org> | 2009-06-15 21:10:34 +0200 |
commit | ed33a20b29649eb728404808ed56a2bbbb38a925 (patch) | |
tree | 163479dc228a9bc5788858c66ffe0de9f8c351e9 /gtk/gtkcellrendererpixbuf.c | |
parent | 2b3de3dd75384a0af99f92656cdd70d72319ca6c (diff) | |
download | gtk+-ed33a20b29649eb728404808ed56a2bbbb38a925.tar.gz |
Bug 565317 - Resulting image of GtkCellRendererPixbuf depends on order of set properties
(gtk_cell_renderer_pixbuf_set_property): add back evil code that makes
sure that the current image is only unset if the new image was created
from the same property or the new property is not NULL.
Diffstat (limited to 'gtk/gtkcellrendererpixbuf.c')
-rw-r--r-- | gtk/gtkcellrendererpixbuf.c | 155 |
1 files changed, 117 insertions, 38 deletions
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c index 0431295e41..c0ec609688 100644 --- a/gtk/gtkcellrendererpixbuf.c +++ b/gtk/gtkcellrendererpixbuf.c @@ -284,39 +284,6 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object, } static void -unset_image_properties (GtkCellRendererPixbuf *cell) -{ - GtkCellRendererPixbufPrivate *priv; - - priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell); - - if (priv->stock_id) - { - g_free (priv->stock_id); - priv->stock_id = NULL; - g_object_notify (G_OBJECT (cell), "stock-id"); - } - if (priv->icon_name) - { - g_free (priv->icon_name); - priv->icon_name = NULL; - g_object_notify (G_OBJECT (cell), "icon-name"); - } - if (cell->pixbuf) - { - g_object_unref (cell->pixbuf); - cell->pixbuf = NULL; - g_object_notify (G_OBJECT (cell), "pixbuf"); - } - if (priv->gicon) - { - g_object_unref (priv->gicon); - priv->gicon = NULL; - g_object_notify (G_OBJECT (cell), "gicon"); - } -} - -static void gtk_cell_renderer_pixbuf_set_property (GObject *object, guint param_id, const GValue *value, @@ -330,8 +297,30 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object, switch (param_id) { case PROP_PIXBUF: - unset_image_properties (cellpixbuf); - cellpixbuf->pixbuf = (GdkPixbuf *) g_value_dup_object (value); + if (cellpixbuf->pixbuf) + g_object_unref (cellpixbuf->pixbuf); + cellpixbuf->pixbuf = (GdkPixbuf*) g_value_dup_object (value); + if (cellpixbuf->pixbuf) + { + if (priv->stock_id) + { + g_free (priv->stock_id); + priv->stock_id = NULL; + g_object_notify (object, "stock-id"); + } + if (priv->icon_name) + { + g_free (priv->icon_name); + priv->icon_name = NULL; + g_object_notify (object, "icon-name"); + } + if (priv->gicon) + { + g_object_unref (priv->gicon); + priv->gicon = NULL; + g_object_notify (object, "gicon"); + } + } break; case PROP_PIXBUF_EXPANDER_OPEN: if (cellpixbuf->pixbuf_expander_open) @@ -344,8 +333,38 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object, cellpixbuf->pixbuf_expander_closed = (GdkPixbuf*) g_value_dup_object (value); break; case PROP_STOCK_ID: - unset_image_properties (cellpixbuf); + if (priv->stock_id) + { + if (cellpixbuf->pixbuf) + { + g_object_unref (cellpixbuf->pixbuf); + cellpixbuf->pixbuf = NULL; + g_object_notify (object, "pixbuf"); + } + g_free (priv->stock_id); + } priv->stock_id = g_value_dup_string (value); + if (priv->stock_id) + { + if (cellpixbuf->pixbuf) + { + g_object_unref (cellpixbuf->pixbuf); + cellpixbuf->pixbuf = NULL; + g_object_notify (object, "pixbuf"); + } + if (priv->icon_name) + { + g_free (priv->icon_name); + priv->icon_name = NULL; + g_object_notify (object, "icon-name"); + } + if (priv->gicon) + { + g_object_unref (priv->gicon); + priv->gicon = NULL; + g_object_notify (object, "gicon"); + } + } break; case PROP_STOCK_SIZE: priv->stock_size = g_value_get_uint (value); @@ -355,15 +374,75 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object, priv->stock_detail = g_value_dup_string (value); break; case PROP_ICON_NAME: - unset_image_properties (cellpixbuf); + if (priv->icon_name) + { + if (cellpixbuf->pixbuf) + { + g_object_unref (cellpixbuf->pixbuf); + cellpixbuf->pixbuf = NULL; + g_object_notify (object, "pixbuf"); + } + g_free (priv->icon_name); + } priv->icon_name = g_value_dup_string (value); + if (priv->icon_name) + { + if (cellpixbuf->pixbuf) + { + g_object_unref (cellpixbuf->pixbuf); + cellpixbuf->pixbuf = NULL; + g_object_notify (object, "pixbuf"); + } + if (priv->stock_id) + { + g_free (priv->stock_id); + priv->stock_id = NULL; + g_object_notify (object, "stock-id"); + } + if (priv->gicon) + { + g_object_unref (priv->gicon); + priv->gicon = NULL; + g_object_notify (object, "gicon"); + } + } break; case PROP_FOLLOW_STATE: priv->follow_state = g_value_get_boolean (value); break; case PROP_GICON: - unset_image_properties (cellpixbuf); + if (priv->gicon) + { + if (cellpixbuf->pixbuf) + { + g_object_unref (cellpixbuf->pixbuf); + cellpixbuf->pixbuf = NULL; + g_object_notify (object, "pixbuf"); + } + g_object_unref (priv->gicon); + } priv->gicon = (GIcon *) g_value_dup_object (value); + if (priv->gicon) + { + if (cellpixbuf->pixbuf) + { + g_object_unref (cellpixbuf->pixbuf); + cellpixbuf->pixbuf = NULL; + g_object_notify (object, "pixbuf"); + } + if (priv->stock_id) + { + g_free (priv->stock_id); + priv->stock_id = NULL; + g_object_notify (object, "stock-id"); + } + if (priv->icon_name) + { + g_free (priv->icon_name); + priv->icon_name = NULL; + g_object_notify (object, "icon-name"); + } + } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); |