summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorJasmine Hassan <[email protected]>2012-10-30 23:42:48 +0200
committerJasmine Hassan <[email protected]>2012-11-16 09:45:51 +0200
commit5f7d0e33a04e69778509edb93beabbe0e62ab69b (patch)
treec9bf66086d6b74705cea4de46383da7a99d79895 /eel
parent4fe815f4dc825928008a1fc09e53ebcbbc22569d (diff)
downloadcaja-5f7d0e33a04e69778509edb93beabbe0e62ab69b.tar.bz2
caja-5f7d0e33a04e69778509edb93beabbe0e62ab69b.tar.xz
[eel-canvas] don't use GtkObject (GTK3)
the ::destroy signal of GtkObject has only been moved to GtkWidget in GTK3 (after GtkObject removal): http://developer.gnome.org/gtk3/3.0/ch25s02.html So, we conditionals in this case, to keep working with GTK2 Nautilus commit message: This implies adding a 'destroy' signal to EelCanvasItem, with similar semantics to gtk_object_destroy() http://git.gnome.org/browse/nautilus/commit/?id=1f615321613751a5dbc84d5ef7f20edd104b8dc4
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-canvas-rect-ellipse.c21
-rw-r--r--eel/eel-canvas.c91
-rw-r--r--eel/eel-canvas.h8
3 files changed, 63 insertions, 57 deletions
diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c
index 9d738243..18263ce9 100644
--- a/eel/eel-canvas-rect-ellipse.c
+++ b/eel/eel-canvas-rect-ellipse.c
@@ -68,7 +68,6 @@ enum
static void eel_canvas_re_class_init (EelCanvasREClass *klass);
static void eel_canvas_re_init (EelCanvasRE *re);
-static void eel_canvas_re_destroy (GtkObject *object);
static void eel_canvas_re_set_property (GObject *object,
guint param_id,
const GValue *value,
@@ -133,11 +132,9 @@ static void
eel_canvas_re_class_init (EelCanvasREClass *klass)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
EelCanvasItemClass *item_class;
gobject_class = (GObjectClass *) klass;
- object_class = (GtkObjectClass *) klass;
item_class = (EelCanvasItemClass *) klass;
re_parent_class = g_type_class_peek_parent (klass);
@@ -223,8 +220,6 @@ eel_canvas_re_class_init (EelCanvasREClass *klass)
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
- object_class->destroy = eel_canvas_re_destroy;
-
item_class->realize = eel_canvas_re_realize;
item_class->unrealize = eel_canvas_re_unrealize;
item_class->translate = eel_canvas_re_translate;
@@ -241,22 +236,6 @@ eel_canvas_re_init (EelCanvasRE *re)
re->width = 0.0;
}
-static void
-eel_canvas_re_destroy (GtkObject *object)
-{
- EelCanvasRE *re;
-
- g_return_if_fail (object != NULL);
- g_return_if_fail (EEL_IS_CANVAS_RE (object));
-
- re = EEL_CANVAS_RE (object);
-
- /* remember, destroy can be run multiple times! */
-
- if (GTK_OBJECT_CLASS (re_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (re_parent_class)->destroy) (object);
-}
-
static void get_bounds (EelCanvasRE *re, double *px1, double *py1, double *px2, double *py2)
{
EelCanvasItem *item;
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c
index ff38d197..647de723 100644
--- a/eel/eel-canvas.c
+++ b/eel/eel-canvas.c
@@ -101,6 +101,7 @@ enum
enum
{
+ ITEM_DESTROY,
ITEM_EVENT,
ITEM_LAST_SIGNAL
};
@@ -111,7 +112,7 @@ static int emit_event (EelCanvas *canvas, GdkEvent *event
static guint item_signals[ITEM_LAST_SIGNAL];
-static GtkObjectClass *item_parent_class;
+static GObjectClass *item_parent_class;
static gpointer accessible_item_parent_class;
static gpointer accessible_parent_class;
@@ -145,10 +146,10 @@ eel_canvas_item_get_type (void)
(GInstanceInitFunc) eel_canvas_item_init
};
- canvas_item_type = g_type_register_static (gtk_object_get_type (),
- "EelCanvasItem",
- &canvas_item_info,
- 0);
+ canvas_item_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED,
+ "EelCanvasItem",
+ &canvas_item_info,
+ 0);
}
return canvas_item_type;
@@ -359,9 +360,21 @@ eel_canvas_item_dispose (GObject *object)
item->canvas = NULL;
}
+ g_object_set_data (object, "in-destruction", GINT_TO_POINTER (1));
+ g_signal_emit (object, item_signals[ITEM_DESTROY], 0);
+
+ g_object_set_data (object, "in-destruction", NULL);
+
G_OBJECT_CLASS (item_parent_class)->dispose (object);
}
+void
+eel_canvas_item_destroy (EelCanvasItem *item)
+{
+ if (g_object_get_data (G_OBJECT (item), "in-destruction") == NULL) {
+ g_object_run_dispose (G_OBJECT (item));
+ }
+}
/* Realize handler for canvas items */
static void
@@ -1200,7 +1213,7 @@ static void eel_canvas_group_get_property(GObject *object,
GValue *value,
GParamSpec *pspec);
-static void eel_canvas_group_destroy (GtkObject *object);
+static void eel_canvas_group_destroy (EelCanvasItem *object);
static void eel_canvas_group_update (EelCanvasItem *item,
double i2w_dx,
@@ -1266,11 +1279,9 @@ static void
eel_canvas_group_class_init (EelCanvasGroupClass *klass)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
EelCanvasItemClass *item_class;
gobject_class = (GObjectClass *) klass;
- object_class = (GtkObjectClass *) klass;
item_class = (EelCanvasItemClass *) klass;
group_parent_class = g_type_class_peek_parent (klass);
@@ -1293,8 +1304,7 @@ eel_canvas_group_class_init (EelCanvasGroupClass *klass)
-G_MAXDOUBLE, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
- object_class->destroy = eel_canvas_group_destroy;
-
+ item_class->destroy = eel_canvas_group_destroy;
item_class->update = eel_canvas_group_update;
item_class->unrealize = eel_canvas_group_unrealize;
item_class->map = eel_canvas_group_map;
@@ -1391,7 +1401,7 @@ eel_canvas_group_get_property (GObject *gobject, guint param_id,
/* Destroy handler for canvas groups */
static void
-eel_canvas_group_destroy (GtkObject *object)
+eel_canvas_group_destroy (EelCanvasItem *object)
{
EelCanvasGroup *group;
EelCanvasItem *child;
@@ -1407,11 +1417,11 @@ eel_canvas_group_destroy (GtkObject *object)
child = list->data;
list = list->next;
- gtk_object_destroy (GTK_OBJECT (child));
+ eel_canvas_item_destroy (child);
}
- if (GTK_OBJECT_CLASS (group_parent_class)->destroy)
- (* GTK_OBJECT_CLASS (group_parent_class)->destroy) (object);
+ if (EEL_CANVAS_ITEM_CLASS (group_parent_class)->destroy)
+ (* EEL_CANVAS_ITEM_CLASS (group_parent_class)->destroy) (object);
}
/* Update handler for canvas groups */
@@ -1720,12 +1730,7 @@ eel_canvas_group_bounds (EelCanvasItem *item, double *x1, double *y1, double *x2
static void
group_add (EelCanvasGroup *group, EelCanvasItem *item)
{
-#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14)
g_object_ref_sink (item);
-#else
- g_object_ref (item);
- gtk_object_sink (GTK_OBJECT (item));
-#endif
if (!group->item_list)
{
@@ -1793,7 +1798,11 @@ enum
static void eel_canvas_class_init (EelCanvasClass *klass);
static void eel_canvas_init (EelCanvas *canvas);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static void eel_canvas_destroy (GtkWidget *object);
+#else
static void eel_canvas_destroy (GtkObject *object);
+#endif
static void eel_canvas_map (GtkWidget *widget);
static void eel_canvas_unmap (GtkWidget *widget);
static void eel_canvas_realize (GtkWidget *widget);
@@ -2108,11 +2117,9 @@ static void
eel_canvas_class_init (EelCanvasClass *klass)
{
GObjectClass *gobject_class;
- GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
gobject_class = (GObjectClass *)klass;
- object_class = (GtkObjectClass *) klass;
widget_class = (GtkWidgetClass *) klass;
canvas_parent_class = g_type_class_peek_parent (klass);
@@ -2120,8 +2127,11 @@ eel_canvas_class_init (EelCanvasClass *klass)
gobject_class->set_property = eel_canvas_set_property;
gobject_class->get_property = eel_canvas_get_property;
- object_class->destroy = eel_canvas_destroy;
-
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ GTK_OBJECT_CLASS (klass)->destroy = eel_canvas_destroy;
+#else
+ widget_class->destroy = eel_canvas_destroy;
+#endif
widget_class->map = eel_canvas_map;
widget_class->unmap = eel_canvas_unmap;
widget_class->realize = eel_canvas_realize;
@@ -2143,7 +2153,7 @@ eel_canvas_class_init (EelCanvasClass *klass)
canvas_signals[DRAW_BACKGROUND] =
g_signal_new ("draw_background",
- G_TYPE_FROM_CLASS (object_class),
+ G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (EelCanvasClass, draw_background),
NULL, NULL,
@@ -2160,7 +2170,7 @@ eel_canvas_class_init (EelCanvasClass *klass)
* never ever do this, so we panic if this happens.
*/
static void
-panic_root_destroyed (GtkObject *object, gpointer data)
+panic_root_destroyed (GtkWidget *object, gpointer data)
{
g_error ("Eeeek, root item %p of canvas %p was destroyed!", object, data);
}
@@ -2195,12 +2205,7 @@ eel_canvas_init (EelCanvas *canvas)
canvas->root = EEL_CANVAS_ITEM (g_object_new (eel_canvas_group_get_type (), NULL));
canvas->root->canvas = canvas;
-#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14)
g_object_ref_sink (canvas->root);
-#else
- g_object_ref (canvas->root);
- gtk_object_sink (GTK_OBJECT (canvas->root));
-#endif
canvas->root_destroy_id = g_signal_connect (G_OBJECT (canvas->root),
"destroy", G_CALLBACK (panic_root_destroyed), canvas);
@@ -2246,7 +2251,11 @@ shutdown_transients (EelCanvas *canvas)
/* Destroy handler for EelCanvas */
static void
+#if GTK_CHECK_VERSION (3, 0, 0)
+eel_canvas_destroy (GtkWidget *object)
+#else
eel_canvas_destroy (GtkObject *object)
+#endif
{
EelCanvas *canvas;
@@ -2265,14 +2274,19 @@ eel_canvas_destroy (GtkObject *object)
{
EelCanvasItem *root = canvas->root;
canvas->root = NULL;
- gtk_object_destroy (GTK_OBJECT (root));
+ eel_canvas_item_destroy (root);
g_object_unref (root);
}
shutdown_transients (canvas);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ if (GTK_WIDGET_CLASS (canvas_parent_class)->destroy)
+ (* GTK_WIDGET_CLASS (canvas_parent_class)->destroy) (object);
+#else
if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy)
(* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object);
+#endif
}
/**
@@ -2673,14 +2687,14 @@ emit_event (EelCanvas *canvas, GdkEvent *event)
while (item && !finished)
{
- g_object_ref (GTK_OBJECT (item));
+ g_object_ref (item);
g_signal_emit (
G_OBJECT (item), item_signals[ITEM_EVENT], 0,
&ev, &finished);
parent = item->parent;
- g_object_unref (GTK_OBJECT (item));
+ g_object_unref (item);
item = parent;
}
@@ -4015,7 +4029,7 @@ eel_canvas_item_accessible_get_type (void)
GTypeInfo tinfo = { 0 };
factory = atk_registry_get_factory (atk_get_default_registry(),
- GTK_TYPE_OBJECT);
+ G_TYPE_INITIALLY_UNOWNED);
if (!factory)
{
return G_TYPE_INVALID;
@@ -4148,6 +4162,15 @@ eel_canvas_item_class_init (EelCanvasItemClass *klass)
G_TYPE_BOOLEAN, 1,
GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE);
+ item_signals[ITEM_DESTROY] =
+ g_signal_new ("destroy",
+ G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ G_STRUCT_OFFSET (EelCanvasItemClass, destroy),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
klass->realize = eel_canvas_item_realize;
klass->unrealize = eel_canvas_item_unrealize;
klass->map = eel_canvas_item_map;
diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h
index 453cdaee..b288dedf 100644
--- a/eel/eel-canvas.h
+++ b/eel/eel-canvas.h
@@ -115,7 +115,7 @@ extern "C" {
struct _EelCanvasItem
{
- GtkObject object;
+ GInitiallyUnowned object;
/* Parent canvas for this item */
EelCanvas *canvas;
@@ -132,7 +132,9 @@ extern "C" {
struct _EelCanvasItemClass
{
- GtkObjectClass parent_class;
+ GInitiallyUnownedClass parent_class;
+
+ void (* destroy) (EelCanvasItem *item);
/* Tell the item to update itself. The flags are from the update flags
* defined above. The item should update its internal state from its
@@ -195,6 +197,8 @@ extern "C" {
EelCanvasItem *eel_canvas_item_new (EelCanvasGroup *parent, GType type,
const gchar *first_arg_name, ...);
+ void eel_canvas_item_destroy (EelCanvasItem *item);
+
/* Constructors for use in derived classes and language wrappers */
void eel_canvas_item_construct (EelCanvasItem *item, EelCanvasGroup *parent,
const gchar *first_arg_name, va_list args);