diff options
author | Cosimo Cecchi <cosimoc@gnome.org> | 2010-09-29 12:58:15 +0200 |
---|---|---|
committer | Cosimo Cecchi <cosimoc@gnome.org> | 2010-09-30 18:48:41 +0200 |
commit | 1f615321613751a5dbc84d5ef7f20edd104b8dc4 (patch) | |
tree | 12ff5602acd3396225719b70f731b59abf697ab3 /eel/eel-canvas.c | |
parent | 5edcd42e503623c11bf55c6afba437b3013c7f45 (diff) | |
download | nautilus-1f615321613751a5dbc84d5ef7f20edd104b8dc4.tar.gz |
canvas: don't use GtkObject
This implies adding a 'destroy' signal to EelCanvasItem, with similar
semantics to gtk_object_destroy()
Diffstat (limited to 'eel/eel-canvas.c')
-rw-r--r-- | eel/eel-canvas.c | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 87def9933..d90d90903 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -93,6 +93,7 @@ enum { }; enum { + ITEM_DESTROY, ITEM_EVENT, ITEM_LAST_SIGNAL }; @@ -103,7 +104,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; @@ -135,7 +136,7 @@ eel_canvas_item_get_type (void) (GInstanceInitFunc) eel_canvas_item_init }; - canvas_item_type = g_type_register_static (gtk_object_get_type (), + canvas_item_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, "EelCanvasItem", &canvas_item_info, 0); @@ -336,9 +337,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 @@ -1146,7 +1159,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, @@ -1210,11 +1223,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); @@ -1237,8 +1248,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; @@ -1332,7 +1342,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; @@ -1347,11 +1357,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 */ @@ -1709,7 +1719,7 @@ enum { static void eel_canvas_class_init (EelCanvasClass *klass); static void eel_canvas_init (EelCanvas *canvas); -static void eel_canvas_destroy (GtkObject *object); +static void eel_canvas_destroy (GtkWidget *object); static void eel_canvas_map (GtkWidget *widget); static void eel_canvas_unmap (GtkWidget *widget); static void eel_canvas_realize (GtkWidget *widget); @@ -2011,11 +2021,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); @@ -2023,8 +2031,7 @@ 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; - + widget_class->destroy = eel_canvas_destroy; widget_class->map = eel_canvas_map; widget_class->unmap = eel_canvas_unmap; widget_class->realize = eel_canvas_realize; @@ -2046,7 +2053,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, @@ -2063,7 +2070,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); } @@ -2098,12 +2105,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); @@ -2147,7 +2149,7 @@ shutdown_transients (EelCanvas *canvas) /* Destroy handler for EelCanvas */ static void -eel_canvas_destroy (GtkObject *object) +eel_canvas_destroy (GtkWidget *object) { EelCanvas *canvas; @@ -2164,14 +2166,14 @@ eel_canvas_destroy (GtkObject *object) if (canvas->root) { 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_OBJECT_CLASS (canvas_parent_class)->destroy) - (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); + if (GTK_WIDGET_CLASS (canvas_parent_class)->destroy) + (* GTK_WIDGET_CLASS (canvas_parent_class)->destroy) (object); } /** @@ -2544,14 +2546,14 @@ emit_event (EelCanvas *canvas, GdkEvent *event) finished = FALSE; 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; } @@ -3833,7 +3835,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; } @@ -3961,6 +3963,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; |