Commit c43efa51 authored by Kristian Rietveld's avatar Kristian Rietveld Committed by Kristian Rietveld

Migrating all cell renderers to use the new instance private data

Thu Dec 18 00:57:18 2003  Kristian Rietveld  <kris@gtk.org>

	Migrating all cell renderers to use the new instance private data
	construction.

	* gtk/gtktreeprivate.h: remove GtkCellRendererInfo, as it is no
	longer being used.

	* gtk/gtkcellrenderer.c (gtk_cell_renderer_init),
	(gtk_cell_renderer_class_init), (gtk_cell_renderer_get_property),
	(set_cell_bg_color), (gtk_cell_renderer_render): remove old
	GtkCellRendererInfo handling, migrate to instance private data.

	* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done),
	(gtk_cell_renderer_text_start_editing): moved focus_out_id
	from GtkCellRendererInfo to text renderer private data.

	* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_init),
	(gtk_cell_renderer_pixbuf_class_init),
	(gtk_cell_renderer_pixbuf_finalize),
	(gtk_cell_renderer_pixbuf_get_property),
	(gtk_cell_renderer_pixbuf_set_property),
	(gtk_cell_renderer_pixbuf_create_stock_pixbuf),
	(gtk_cell_renderer_pixbuf_get_size), (gtk_cell_renderer_pixbuf_render):
	migrate to instance private data.

	* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_class_init),
	(gtk_cell_renderer_toggle_get_property),
	(gtk_cell_renderer_toggle_set_property),
	(gtk_cell_renderer_toggle_render): migrate to instance private data.
parent 62a15f2a
Thu Dec 18 00:57:18 2003 Kristian Rietveld <kris@gtk.org>
Migrating all cell renderers to use the new instance private data
construction.
* gtk/gtktreeprivate.h: remove GtkCellRendererInfo, as it is no
longer being used.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_init),
(gtk_cell_renderer_class_init), (gtk_cell_renderer_get_property),
(set_cell_bg_color), (gtk_cell_renderer_render): remove old
GtkCellRendererInfo handling, migrate to instance private data.
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done),
(gtk_cell_renderer_text_start_editing): moved focus_out_id
from GtkCellRendererInfo to text renderer private data.
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_init),
(gtk_cell_renderer_pixbuf_class_init),
(gtk_cell_renderer_pixbuf_finalize),
(gtk_cell_renderer_pixbuf_get_property),
(gtk_cell_renderer_pixbuf_set_property),
(gtk_cell_renderer_pixbuf_create_stock_pixbuf),
(gtk_cell_renderer_pixbuf_get_size), (gtk_cell_renderer_pixbuf_render):
migrate to instance private data.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_class_init),
(gtk_cell_renderer_toggle_get_property),
(gtk_cell_renderer_toggle_set_property),
(gtk_cell_renderer_toggle_render): migrate to instance private data.
Thu Dec 18 00:24:32 2003 Kristian Rietveld <kris@gtk.org>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_class_init),
......
Thu Dec 18 00:57:18 2003 Kristian Rietveld <kris@gtk.org>
Migrating all cell renderers to use the new instance private data
construction.
* gtk/gtktreeprivate.h: remove GtkCellRendererInfo, as it is no
longer being used.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_init),
(gtk_cell_renderer_class_init), (gtk_cell_renderer_get_property),
(set_cell_bg_color), (gtk_cell_renderer_render): remove old
GtkCellRendererInfo handling, migrate to instance private data.
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done),
(gtk_cell_renderer_text_start_editing): moved focus_out_id
from GtkCellRendererInfo to text renderer private data.
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_init),
(gtk_cell_renderer_pixbuf_class_init),
(gtk_cell_renderer_pixbuf_finalize),
(gtk_cell_renderer_pixbuf_get_property),
(gtk_cell_renderer_pixbuf_set_property),
(gtk_cell_renderer_pixbuf_create_stock_pixbuf),
(gtk_cell_renderer_pixbuf_get_size), (gtk_cell_renderer_pixbuf_render):
migrate to instance private data.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_class_init),
(gtk_cell_renderer_toggle_get_property),
(gtk_cell_renderer_toggle_set_property),
(gtk_cell_renderer_toggle_render): migrate to instance private data.
Thu Dec 18 00:24:32 2003 Kristian Rietveld <kris@gtk.org>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_class_init),
......
Thu Dec 18 00:57:18 2003 Kristian Rietveld <kris@gtk.org>
Migrating all cell renderers to use the new instance private data
construction.
* gtk/gtktreeprivate.h: remove GtkCellRendererInfo, as it is no
longer being used.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_init),
(gtk_cell_renderer_class_init), (gtk_cell_renderer_get_property),
(set_cell_bg_color), (gtk_cell_renderer_render): remove old
GtkCellRendererInfo handling, migrate to instance private data.
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done),
(gtk_cell_renderer_text_start_editing): moved focus_out_id
from GtkCellRendererInfo to text renderer private data.
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_init),
(gtk_cell_renderer_pixbuf_class_init),
(gtk_cell_renderer_pixbuf_finalize),
(gtk_cell_renderer_pixbuf_get_property),
(gtk_cell_renderer_pixbuf_set_property),
(gtk_cell_renderer_pixbuf_create_stock_pixbuf),
(gtk_cell_renderer_pixbuf_get_size), (gtk_cell_renderer_pixbuf_render):
migrate to instance private data.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_class_init),
(gtk_cell_renderer_toggle_get_property),
(gtk_cell_renderer_toggle_set_property),
(gtk_cell_renderer_toggle_render): migrate to instance private data.
Thu Dec 18 00:24:32 2003 Kristian Rietveld <kris@gtk.org>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_class_init),
......
Thu Dec 18 00:57:18 2003 Kristian Rietveld <kris@gtk.org>
Migrating all cell renderers to use the new instance private data
construction.
* gtk/gtktreeprivate.h: remove GtkCellRendererInfo, as it is no
longer being used.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_init),
(gtk_cell_renderer_class_init), (gtk_cell_renderer_get_property),
(set_cell_bg_color), (gtk_cell_renderer_render): remove old
GtkCellRendererInfo handling, migrate to instance private data.
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done),
(gtk_cell_renderer_text_start_editing): moved focus_out_id
from GtkCellRendererInfo to text renderer private data.
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_init),
(gtk_cell_renderer_pixbuf_class_init),
(gtk_cell_renderer_pixbuf_finalize),
(gtk_cell_renderer_pixbuf_get_property),
(gtk_cell_renderer_pixbuf_set_property),
(gtk_cell_renderer_pixbuf_create_stock_pixbuf),
(gtk_cell_renderer_pixbuf_get_size), (gtk_cell_renderer_pixbuf_render):
migrate to instance private data.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_class_init),
(gtk_cell_renderer_toggle_get_property),
(gtk_cell_renderer_toggle_set_property),
(gtk_cell_renderer_toggle_render): migrate to instance private data.
Thu Dec 18 00:24:32 2003 Kristian Rietveld <kris@gtk.org>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_class_init),
......
Thu Dec 18 00:57:18 2003 Kristian Rietveld <kris@gtk.org>
Migrating all cell renderers to use the new instance private data
construction.
* gtk/gtktreeprivate.h: remove GtkCellRendererInfo, as it is no
longer being used.
* gtk/gtkcellrenderer.c (gtk_cell_renderer_init),
(gtk_cell_renderer_class_init), (gtk_cell_renderer_get_property),
(set_cell_bg_color), (gtk_cell_renderer_render): remove old
GtkCellRendererInfo handling, migrate to instance private data.
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_editing_done),
(gtk_cell_renderer_text_start_editing): moved focus_out_id
from GtkCellRendererInfo to text renderer private data.
* gtk/gtkcellrendererpixbuf.c (gtk_cell_renderer_pixbuf_init),
(gtk_cell_renderer_pixbuf_class_init),
(gtk_cell_renderer_pixbuf_finalize),
(gtk_cell_renderer_pixbuf_get_property),
(gtk_cell_renderer_pixbuf_set_property),
(gtk_cell_renderer_pixbuf_create_stock_pixbuf),
(gtk_cell_renderer_pixbuf_get_size), (gtk_cell_renderer_pixbuf_render):
migrate to instance private data.
* gtk/gtkcellrenderertoggle.c (gtk_cell_renderer_toggle_class_init),
(gtk_cell_renderer_toggle_get_property),
(gtk_cell_renderer_toggle_set_property),
(gtk_cell_renderer_toggle_render): migrate to instance private data.
Thu Dec 18 00:24:32 2003 Kristian Rietveld <kris@gtk.org>
* gtk/gtkcellrenderertext.c (gtk_cell_renderer_text_class_init),
......
......@@ -35,6 +35,15 @@ static void set_cell_bg_color (GtkCellRenderer *cell,
GdkColor *color);
#define GTK_CELL_RENDERER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER, GtkCellRendererPrivate))
typedef struct _GtkCellRendererPrivate GtkCellRendererPrivate;
struct _GtkCellRendererPrivate
{
GdkColor cell_background;
};
enum {
PROP_ZERO,
PROP_MODE,
......@@ -83,8 +92,6 @@ gtk_cell_renderer_get_type (void)
static void
gtk_cell_renderer_init (GtkCellRenderer *cell)
{
GtkCellRendererInfo *cellinfo;
cell->mode = GTK_CELL_RENDERER_MODE_INERT;
cell->visible = TRUE;
cell->width = -1;
......@@ -93,10 +100,6 @@ gtk_cell_renderer_init (GtkCellRenderer *cell)
cell->yalign = 0.5;
cell->xpad = 0;
cell->ypad = 0;
cellinfo = g_new0 (GtkCellRendererInfo, 1);
g_object_set_data_full (G_OBJECT (cell),
GTK_CELL_RENDERER_INFO_KEY, cellinfo, g_free);
}
static void
......@@ -236,6 +239,8 @@ gtk_cell_renderer_class_init (GtkCellRendererClass *class)
ADD_SET_PROP ("cell_background_set", PROP_CELL_BACKGROUND_SET,
_("Cell background set"),
_("Whether this tag affects the cell background color"));
g_type_class_add_private (object_class, sizeof (GtkCellRendererPrivate));
}
static void
......@@ -245,10 +250,7 @@ gtk_cell_renderer_get_property (GObject *object,
GParamSpec *pspec)
{
GtkCellRenderer *cell = GTK_CELL_RENDERER (object);
GtkCellRendererInfo *cellinfo;
cellinfo = g_object_get_data (object,
GTK_CELL_RENDERER_INFO_KEY);
GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (object);
switch (param_id)
{
......@@ -286,9 +288,9 @@ gtk_cell_renderer_get_property (GObject *object,
{
GdkColor color;
color.red = cellinfo->cell_background.red;
color.green = cellinfo->cell_background.green;
color.blue = cellinfo->cell_background.blue;
color.red = priv->cell_background.red;
color.green = priv->cell_background.green;
color.blue = priv->cell_background.blue;
g_value_set_boxed (value, &color);
}
......@@ -374,10 +376,7 @@ static void
set_cell_bg_color (GtkCellRenderer *cell,
GdkColor *color)
{
GtkCellRendererInfo *cellinfo;
cellinfo = g_object_get_data (G_OBJECT (cell),
GTK_CELL_RENDERER_INFO_KEY);
GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (cell);
if (color)
{
......@@ -387,9 +386,9 @@ set_cell_bg_color (GtkCellRenderer *cell,
g_object_notify (G_OBJECT (cell), "cell_background_set");
}
cellinfo->cell_background.red = color->red;
cellinfo->cell_background.green = color->green;
cellinfo->cell_background.blue = color->blue;
priv->cell_background.red = color->red;
priv->cell_background.green = color->green;
priv->cell_background.blue = color->blue;
}
else
{
......@@ -482,10 +481,7 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
GtkCellRendererState flags)
{
gboolean selected = FALSE;
GtkCellRendererInfo *cellinfo;
cellinfo = g_object_get_data (G_OBJECT (cell),
GTK_CELL_RENDERER_INFO_KEY);
GtkCellRendererPrivate *priv = GTK_CELL_RENDERER_GET_PRIVATE (cell);
g_return_if_fail (GTK_IS_CELL_RENDERER (cell));
g_return_if_fail (GTK_CELL_RENDERER_GET_CLASS (cell)->render != NULL);
......@@ -497,9 +493,9 @@ gtk_cell_renderer_render (GtkCellRenderer *cell,
GdkColor color;
GdkGC *gc;
color.red = cellinfo->cell_background.red;
color.green = cellinfo->cell_background.green;
color.blue = cellinfo->cell_background.blue;
color.red = priv->cell_background.red;
color.green = priv->cell_background.green;
color.blue = priv->cell_background.blue;
gc = gdk_gc_new (window);
gdk_gc_set_rgb_fg_color (gc, &color);
......
......@@ -62,16 +62,18 @@ enum {
static gpointer parent_class;
#define CELLINFO_KEY "gtk-cell-renderer-pixbuf-info"
typedef struct _GtkCellRendererPixbufInfo GtkCellRendererPixbufInfo;
struct _GtkCellRendererPixbufInfo
#define GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER_PIXBUF, GtkCellRendererPixbufPrivate))
typedef struct _GtkCellRendererPixbufPrivate GtkCellRendererPixbufPrivate;
struct _GtkCellRendererPixbufPrivate
{
gchar *stock_id;
GtkIconSize stock_size;
gchar *stock_detail;
};
GType
gtk_cell_renderer_pixbuf_get_type (void)
{
......@@ -103,11 +105,10 @@ gtk_cell_renderer_pixbuf_get_type (void)
static void
gtk_cell_renderer_pixbuf_init (GtkCellRendererPixbuf *cellpixbuf)
{
GtkCellRendererPixbufInfo *cellinfo;
GtkCellRendererPixbufPrivate *priv;
cellinfo = g_new0 (GtkCellRendererPixbufInfo, 1);
cellinfo->stock_size = GTK_ICON_SIZE_MENU;
g_object_set_data (G_OBJECT (cellpixbuf), CELLINFO_KEY, cellinfo);
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cellpixbuf);
priv->stock_size = GTK_ICON_SIZE_MENU;
}
static void
......@@ -177,25 +178,26 @@ gtk_cell_renderer_pixbuf_class_init (GtkCellRendererPixbufClass *class)
_("Render detail to pass to the theme engine"),
NULL,
G_PARAM_READWRITE));
g_type_class_add_private (object_class, sizeof (GtkCellRendererPixbufPrivate));
}
static void
gtk_cell_renderer_pixbuf_finalize (GObject *object)
{
GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
GtkCellRendererPixbufInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY);
GtkCellRendererPixbufPrivate *priv;
if (cellpixbuf->pixbuf && cellinfo->stock_id)
g_object_unref (cellpixbuf->pixbuf);
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (object);
if (cellinfo->stock_id)
g_free (cellinfo->stock_id);
if (cellpixbuf->pixbuf && priv->stock_id)
g_object_unref (cellpixbuf->pixbuf);
if (cellinfo->stock_detail)
g_free (cellinfo->stock_detail);
if (priv->stock_id)
g_free (priv->stock_id);
g_free (cellinfo);
g_object_set_data (object, CELLINFO_KEY, NULL);
if (priv->stock_detail)
g_free (priv->stock_detail);
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
}
......@@ -207,7 +209,9 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object,
GParamSpec *pspec)
{
GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
GtkCellRendererPixbufInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY);
GtkCellRendererPixbufPrivate *priv;
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (object);
switch (param_id)
{
......@@ -224,13 +228,13 @@ gtk_cell_renderer_pixbuf_get_property (GObject *object,
cellpixbuf->pixbuf_expander_closed ? G_OBJECT (cellpixbuf->pixbuf_expander_closed) : NULL);
break;
case PROP_STOCK_ID:
g_value_set_string (value, cellinfo->stock_id);
g_value_set_string (value, priv->stock_id);
break;
case PROP_STOCK_SIZE:
g_value_set_enum (value, cellinfo->stock_size);
g_value_set_enum (value, priv->stock_size);
break;
case PROP_STOCK_DETAIL:
g_value_set_string (value, cellinfo->stock_detail);
g_value_set_string (value, priv->stock_detail);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
......@@ -247,7 +251,9 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
{
GdkPixbuf *pixbuf;
GtkCellRendererPixbuf *cellpixbuf = GTK_CELL_RENDERER_PIXBUF (object);
GtkCellRendererPixbufInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY);
GtkCellRendererPixbufPrivate *priv;
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (object);
switch (param_id)
{
......@@ -276,31 +282,31 @@ gtk_cell_renderer_pixbuf_set_property (GObject *object,
cellpixbuf->pixbuf_expander_closed = pixbuf;
break;
case PROP_STOCK_ID:
if (cellinfo->stock_id)
if (priv->stock_id)
{
if (cellpixbuf->pixbuf)
{
g_object_unref (cellpixbuf->pixbuf);
cellpixbuf->pixbuf = NULL;
}
g_free (cellinfo->stock_id);
g_free (priv->stock_id);
}
cellinfo->stock_id = g_strdup (g_value_get_string (value));
priv->stock_id = g_strdup (g_value_get_string (value));
break;
case PROP_STOCK_SIZE:
cellinfo->stock_size = g_value_get_enum (value);
priv->stock_size = g_value_get_enum (value);
break;
case PROP_STOCK_DETAIL:
if (cellinfo->stock_detail)
g_free (cellinfo->stock_detail);
cellinfo->stock_detail = g_strdup (g_value_get_string (value));
if (priv->stock_detail)
g_free (priv->stock_detail);
priv->stock_detail = g_strdup (g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
}
if (cellpixbuf->pixbuf && cellinfo->stock_id)
if (cellpixbuf->pixbuf && priv->stock_id)
{
g_object_unref (cellpixbuf->pixbuf);
cellpixbuf->pixbuf = NULL;
......@@ -328,17 +334,19 @@ gtk_cell_renderer_pixbuf_new (void)
static void
gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf,
GtkWidget *widget)
GtkWidget *widget)
{
GtkCellRendererPixbufInfo *cellinfo = g_object_get_data (G_OBJECT (cellpixbuf), CELLINFO_KEY);
GtkCellRendererPixbufPrivate *priv;
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cellpixbuf);
if (cellpixbuf->pixbuf)
g_object_unref (cellpixbuf->pixbuf);
cellpixbuf->pixbuf = gtk_widget_render_icon (widget,
cellinfo->stock_id,
cellinfo->stock_size,
cellinfo->stock_detail);
priv->stock_id,
priv->stock_size,
priv->stock_detail);
}
static void
......@@ -351,13 +359,15 @@ gtk_cell_renderer_pixbuf_get_size (GtkCellRenderer *cell,
gint *height)
{
GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
GtkCellRendererPixbufInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY);
GtkCellRendererPixbufPrivate *priv;
gint pixbuf_width = 0;
gint pixbuf_height = 0;
gint calc_width;
gint calc_height;
if (!cellpixbuf->pixbuf && cellinfo->stock_id)
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell);
if (!cellpixbuf->pixbuf && priv->stock_id)
gtk_cell_renderer_pixbuf_create_stock_pixbuf (cellpixbuf, widget);
if (cellpixbuf->pixbuf)
......@@ -417,12 +427,14 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
{
GtkCellRendererPixbuf *cellpixbuf = (GtkCellRendererPixbuf *) cell;
GtkCellRendererPixbufInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY);
GtkCellRendererPixbufPrivate *priv;
GdkPixbuf *pixbuf;
GdkRectangle pix_rect;
GdkRectangle draw_rect;
gboolean stock_pixbuf = FALSE;
priv = GTK_CELL_RENDERER_PIXBUF_GET_PRIVATE (cell);
pixbuf = cellpixbuf->pixbuf;
if (cell->is_expander)
{
......@@ -434,9 +446,9 @@ gtk_cell_renderer_pixbuf_render (GtkCellRenderer *cell,
pixbuf = cellpixbuf->pixbuf_expander_closed;
}
if (!pixbuf && !cellinfo->stock_id)
if (!pixbuf && !priv->stock_id)
return;
else if (!pixbuf && cellinfo->stock_id)
else if (!pixbuf && priv->stock_id)
stock_pixbuf = TRUE;
gtk_cell_renderer_pixbuf_get_size (cell, widget, cell_area,
......
......@@ -120,6 +120,7 @@ typedef struct _GtkCellRendererTextPrivate GtkCellRendererTextPrivate;
struct _GtkCellRendererTextPrivate
{
guint single_paragraph : 1;
gulong focus_out_id;
};
......@@ -1369,15 +1370,14 @@ gtk_cell_renderer_text_editing_done (GtkCellEditable *entry,
{
const gchar *path;
const gchar *new_text;
GtkCellRendererInfo *info;
GtkCellRendererTextPrivate *priv;
info = g_object_get_data (G_OBJECT (data),
GTK_CELL_RENDERER_INFO_KEY);
priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (data);
if (info->focus_out_id > 0)
if (priv->focus_out_id > 0)
{
g_signal_handler_disconnect (entry, info->focus_out_id);
info->focus_out_id = 0;
g_signal_handler_disconnect (entry, priv->focus_out_id);
priv->focus_out_id = 0;
}
if (GTK_ENTRY (entry)->editing_canceled)
......@@ -1409,11 +1409,12 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell,
GdkRectangle *cell_area,
GtkCellRendererState flags)
{
GtkCellRendererText *celltext;
GtkWidget *entry;
GtkCellRendererInfo *info;
GtkCellRendererText *celltext;
GtkCellRendererTextPrivate *priv;
celltext = GTK_CELL_RENDERER_TEXT (cell);
priv = GTK_CELL_RENDERER_TEXT_GET_PRIVATE (cell);
/* If the cell isn't editable we return NULL. */
if (celltext->editable == FALSE)
......@@ -1429,15 +1430,12 @@ gtk_cell_renderer_text_start_editing (GtkCellRenderer *cell,
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
info = g_object_get_data (G_OBJECT (cell),
GTK_CELL_RENDERER_INFO_KEY);
gtk_widget_show (entry);
g_signal_connect (entry,
"editing_done",
G_CALLBACK (gtk_cell_renderer_text_editing_done),
celltext);
info->focus_out_id = g_signal_connect (entry, "focus_out_event",
priv->focus_out_id = g_signal_connect (entry, "focus_out_event",
G_CALLBACK (gtk_cell_renderer_text_focus_out_event),
celltext);
......
......@@ -73,6 +73,14 @@ enum {
static guint toggle_cell_signals[LAST_SIGNAL] = { 0 };
#define GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), GTK_TYPE_CELL_RENDERER_TOGGLE, GtkCellRendererTogglePrivate))
typedef struct _GtkCellRendererTogglePrivate GtkCellRendererTogglePrivate;
struct _GtkCellRendererTogglePrivate
{
guint inconsistent : 1;
};
GType
gtk_cell_renderer_toggle_get_type (void)
......@@ -172,6 +180,8 @@ gtk_cell_renderer_toggle_class_init (GtkCellRendererToggleClass *class)
_gtk_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
g_type_class_add_private (object_class, sizeof (GtkCellRendererTogglePrivate));
}
static void
......@@ -181,6 +191,9 @@ gtk_cell_renderer_toggle_get_property (GObject *object,
GParamSpec *pspec)
{
GtkCellRendererToggle *celltoggle = GTK_CELL_RENDERER_TOGGLE (object);
GtkCellRendererTogglePrivate *priv;
priv = GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE (object);
switch (param_id)
{
......@@ -188,16 +201,7 @@ gtk_cell_renderer_toggle_get_property (GObject *object,
g_value_set_boolean (value, celltoggle->active);
break;
case PROP_INCONSISTENT:
{
/* Move out of here when more properties start to use the info
* thing. I put it here to not affect performance, this property
* is not going to be used much.
*/
GtkCellRendererInfo *cellinfo;
cellinfo = g_object_get_data (object, GTK_CELL_RENDERER_INFO_KEY);
g_value_set_boolean (value, cellinfo->inconsistent);
}
g_value_set_boolean (value, priv->inconsistent);
break;
case PROP_ACTIVATABLE:
g_value_set_boolean (value, celltoggle->activatable);
......@@ -219,6 +223,9 @@ gtk_cell_renderer_toggle_set_property (GObject *object,
GParamSpec *pspec)
{
GtkCellRendererToggle *celltoggle = GTK_CELL_RENDERER_TOGGLE (object);
GtkCellRendererTogglePrivate *priv;
priv = GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE (object);
switch (param_id)
{
......@@ -227,14 +234,8 @@ gtk_cell_renderer_toggle_set_property (GObject *object,
g_object_notify (G_OBJECT(object), "active");
break;
case PROP_INCONSISTENT:
{
/* read comment in _get_property */
GtkCellRendererInfo *cellinfo;
cellinfo = g_object_get_data (object, GTK_CELL_RENDERER_INFO_KEY);
cellinfo->inconsistent = g_value_get_boolean (value);
g_object_notify (G_OBJECT (object), "inconsistent");
}
priv->inconsistent = g_value_get_boolean (value);
g_object_notify (G_OBJECT (object), "inconsistent");
break;
case PROP_ACTIVATABLE:
celltoggle->activatable = g_value_get_boolean (value);
......@@ -316,12 +317,14 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
GtkCellRendererState flags)
{
GtkCellRendererToggle *celltoggle = (GtkCellRendererToggle *) cell;
GtkCellRendererInfo *cellinfo;
GtkCellRendererTogglePrivate *priv;
gint width, height;
gint x_offset, y_offset;
GtkShadowType shadow;
GtkStateType state = 0;
priv = GTK_CELL_RENDERER_TOGGLE_GET_PRIVATE (cell);
gtk_cell_renderer_toggle_get_size (cell, widget, cell_area,
&x_offset, &y_offset,
&width, &height);
......@@ -331,9 +334,7 @@ gtk_cell_renderer_toggle_render (GtkCellRenderer *cell,
if (width <= 0 || height <= 0)
return;
cellinfo = g_object_get_data (G_OBJECT (cell), GTK_CELL_RENDERER_INFO_KEY);
if (cellinfo->inconsistent)
if (priv->inconsistent)
shadow = GTK_SHADOW_ETCHED_IN;
else
shadow = celltoggle->active ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
......
......@@ -212,21 +212,6 @@ struct _GtkTreeViewPrivate
GtkDestroyNotify search_destroy;
};
/* cool ABI compat hack */
#define GTK_CELL_RENDERER_INFO_KEY "gtk-cell-renderer-info"
typedef struct _GtkCellRendererInfo GtkCellRendererInfo;
struct _GtkCellRendererInfo
{
GdkColor cell_background;
/* text renderer */
gulong focus_out_id;
/* toggle renderer */
guint inconsistent :1;
};
#ifdef __GNUC__
#define TREE_VIEW_INTERNAL_ASSERT(expr, ret) G_STMT_START{ \
......
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