summaryrefslogtreecommitdiff
path: root/gtk/gtkcellrendererpixbuf.c
diff options
context:
space:
mode:
authorMichael Natterer <mitch@imendio.com>2005-10-27 13:16:23 +0000
committerMichael Natterer <mitch@src.gnome.org>2005-10-27 13:16:23 +0000
commit194e8daff9c8bddd1997beaa0b17db41de416a31 (patch)
treefd5b562a6395002be78d41bd5887a4115c28aeea /gtk/gtkcellrendererpixbuf.c
parent1d2f3d38d3f4253b88ce63b810b777b5fee080e9 (diff)
downloadgtk+-194e8daff9c8bddd1997beaa0b17db41de416a31.tar.gz
Fix bug #319974:
2005-10-26 Michael Natterer <mitch@imendio.com> Fix bug #319974: * gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_set_property): make sure that setting any of pixbuf/stock-id/icon-name resets the others because they are mutually exclusive, and that unsetting any of them only resets the pixbuf and nothing else. Also added some missing g_object_notify(). (gtk_cell_renderer_pixbuf_get_property): simplified calls to g_value_set_object(). (gtk_cell_renderer_pixbuf_create_stock_pixbuf) (gtk_cell_renderer_pixbuf_create_named_icon_pixbuf): added g_object_notify ("pixbuf").
Diffstat (limited to 'gtk/gtkcellrendererpixbuf.c')
-rw-r--r--gtk/gtkcellrendererpixbuf.c91
1 files changed, 60 insertions, 31 deletions
diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c
index 74b2c2f6ce..054130012d 100644
--- a/gtk/gtkcellrendererpixbuf.c
+++ b/gtk/gtkcellrendererpixbuf.c
@@ -264,16 +264,13 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object,
switch (param_id)
{
case PROP_PIXBUF:
- g_value_set_object (value,
- cellpixbuf->pixbuf ? G_OBJECT (cellpixbuf->pixbuf) : NULL);
+ g_value_set_object (value, G_OBJECT (cellpixbuf->pixbuf));
break;
case PROP_PIXBUF_EXPANDER_OPEN:
- g_value_set_object (value,
- cellpixbuf->pixbuf_expander_open ? G_OBJECT (cellpixbuf->pixbuf_expander_open) : NULL);
+ g_value_set_object (value, G_OBJECT (cellpixbuf->pixbuf_expander_open));
break;
case PROP_PIXBUF_EXPANDER_CLOSED:
- g_value_set_object (value,
- cellpixbuf->pixbuf_expander_closed ? G_OBJECT (cellpixbuf->pixbuf_expander_closed) : NULL);
+ g_value_set_object (value, G_OBJECT (cellpixbuf->pixbuf_expander_closed));
break;
case PROP_STOCK_ID:
g_value_set_string (value, priv->stock_id);
@@ -303,7 +300,6 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
- GdkPixbuf *pixbuf;
GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
GtkCellRendererPixbufPrivate *priv;
@@ -312,28 +308,34 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
switch (param_id)
{
case PROP_PIXBUF:
- pixbuf = (GdkPixbuf*) g_value_get_object (value);
- if (pixbuf)
- g_object_ref (pixbuf);
if (cellpixbuf->pixbuf)
g_object_unref (cellpixbuf->pixbuf);
- cellpixbuf->pixbuf = 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");
+ }
+ }
break;
case PROP_PIXBUF_EXPANDER_OPEN:
- pixbuf = (GdkPixbuf*) g_value_get_object (value);
- if (pixbuf)
- g_object_ref (pixbuf);
if (cellpixbuf->pixbuf_expander_open)
g_object_unref (cellpixbuf->pixbuf_expander_open);
- cellpixbuf->pixbuf_expander_open = pixbuf;
+ cellpixbuf->pixbuf_expander_open = (GdkPixbuf*) g_value_dup_object (value);
break;
case PROP_PIXBUF_EXPANDER_CLOSED:
- pixbuf = (GdkPixbuf*) g_value_get_object (value);
- if (pixbuf)
- g_object_ref (pixbuf);
if (cellpixbuf->pixbuf_expander_closed)
g_object_unref (cellpixbuf->pixbuf_expander_closed);
- cellpixbuf->pixbuf_expander_closed = pixbuf;
+ cellpixbuf->pixbuf_expander_closed = (GdkPixbuf*) g_value_dup_object (value);
break;
case PROP_STOCK_ID:
if (priv->stock_id)
@@ -342,12 +344,26 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
{
g_object_unref (cellpixbuf->pixbuf);
cellpixbuf->pixbuf = NULL;
+ g_object_notify (object, "pixbuf");
}
g_free (priv->stock_id);
- g_free (priv->icon_name);
- priv->icon_name = NULL;
}
- priv->stock_id = g_strdup (g_value_get_string (value));
+ 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");
+ }
+ }
break;
case PROP_STOCK_SIZE:
priv->stock_size = g_value_get_uint (value);
@@ -355,7 +371,7 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
case PROP_STOCK_DETAIL:
if (priv->stock_detail)
g_free (priv->stock_detail);
- priv->stock_detail = g_strdup (g_value_get_string (value));
+ priv->stock_detail = g_value_dup_string (value);
break;
case PROP_ICON_NAME:
if (priv->icon_name)
@@ -364,11 +380,26 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
{
g_object_unref (cellpixbuf->pixbuf);
cellpixbuf->pixbuf = NULL;
+ g_object_notify (object, "pixbuf");
}
- g_free (priv->stock_id);
g_free (priv->icon_name);
}
- priv->icon_name = g_strdup (g_value_get_string (value));
+ 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");
+ }
+ }
break;
case PROP_FOLLOW_STATE:
priv->follow_state = g_value_get_boolean (value);
@@ -377,12 +408,6 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
-
- if (cellpixbuf->pixbuf && priv->stock_id)
- {
- g_object_unref (cellpixbuf->pixbuf);
- cellpixbuf->pixbuf = NULL;
- }
}
/**
@@ -419,6 +444,8 @@ gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
priv->stock_id,
priv->stock_size,
priv->stock_detail);
+
+ g_object_notify (G_OBJECT (cellpixbuf), "pixbuf");
}
static void
@@ -458,6 +485,8 @@ gtk_cell_renderer_pixbuf_create_named_icon_pixbuf (GtkCellRendererPixbuf *cellpi
g_warning ("could not load image: %s\n", error->message);
g_error_free (error);
}
+
+ g_object_notify (G_OBJECT (cellpixbuf), "pixbuf");
}
static GdkPixbuf *