summaryrefslogtreecommitdiff
path: root/eel/eel-canvas.c
diff options
context:
space:
mode:
Diffstat (limited to 'eel/eel-canvas.c')
-rw-r--r--eel/eel-canvas.c91
1 files changed, 57 insertions, 34 deletions
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;