[gdl] Use dispose instead of destroy



commit 6e28911255593007a3b772d78695bd9b120930d9
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Tue May 3 12:40:40 2011 +0200

    Use dispose instead of destroy

 gdl/gdl-dock-item-grip.c |   32 ++++++++++++------------------
 gdl/gdl-dock-item.c      |   48 +++++++++++++++++++++------------------------
 gdl/gdl-dock.c           |   38 ++++++++++++++----------------------
 3 files changed, 50 insertions(+), 68 deletions(-)
---
diff --git a/gdl/gdl-dock-item-grip.c b/gdl/gdl-dock-item-grip.c
index bcff1bf..c275cdd 100644
--- a/gdl/gdl-dock-item-grip.c
+++ b/gdl/gdl-dock-item-grip.c
@@ -190,29 +190,24 @@ gdl_dock_item_grip_item_notify (GObject    *master,
 }
 
 static void
-gdl_dock_item_grip_destroy (GtkWidget *object)
+gdl_dock_item_grip_dispose (GObject *object)
 {
     GdlDockItemGrip *grip = GDL_DOCK_ITEM_GRIP (object);
-        
-    if (grip->priv) {
-        GdlDockItemGripPrivate *priv = grip->priv;
+    GdlDockItemGripPrivate *priv = grip->priv;
 
-        if (priv->label) {
-            gtk_widget_unparent(grip->priv->label);
-            priv->label = NULL;
-        }
+    if (priv->label) {
+        gtk_widget_unparent(priv->label);
+        priv->label = NULL;
+    }
 
-        if (grip->item)
-            g_signal_handlers_disconnect_by_func (grip->item,
-                                                  gdl_dock_item_grip_item_notify,
-                                                  grip);
+    if (grip->item) {
+        g_signal_handlers_disconnect_by_func (grip->item,
+                                              gdl_dock_item_grip_item_notify,
+                                              grip);
         grip->item = NULL;
-
-        grip->priv = NULL;
-        g_free (priv);
     }
-    
-    GTK_WIDGET_CLASS (gdl_dock_item_grip_parent_class)->destroy (object);
+
+    G_OBJECT_CLASS (gdl_dock_item_grip_parent_class)->dispose (object);
 }
 
 static void
@@ -709,8 +704,7 @@ gdl_dock_item_grip_class_init (GdlDockItemGripClass *klass)
     container_class = GTK_CONTAINER_CLASS (klass);
 
     object_class->set_property = gdl_dock_item_grip_set_property;
-
-    widget_class->destroy = gdl_dock_item_grip_destroy;
+    object_class->dispose = gdl_dock_item_grip_dispose;
 
     widget_class->draw = gdl_dock_item_grip_draw;
     widget_class->realize = gdl_dock_item_grip_realize;
diff --git a/gdl/gdl-dock-item.c b/gdl/gdl-dock-item.c
index 4365d0f..7c3473c 100644
--- a/gdl/gdl-dock-item.c
+++ b/gdl/gdl-dock-item.c
@@ -67,7 +67,7 @@ static void  gdl_dock_item_get_property  (GObject      *object,
                                           GValue       *value,
                                           GParamSpec   *pspec);
 
-static void  gdl_dock_item_destroy       (GtkWidget    *object);
+static void  gdl_dock_item_dispose       (GObject      *object);
 
 static void  gdl_dock_item_add           (GtkContainer *container,
                                           GtkWidget    *widget);
@@ -214,8 +214,7 @@ gdl_dock_item_class_init (GdlDockItemClass *klass)
     object_class->constructor = gdl_dock_item_constructor;
     object_class->set_property = gdl_dock_item_set_property;
     object_class->get_property = gdl_dock_item_get_property;
-
-    widget_class->destroy = gdl_dock_item_destroy;
+    object_class->dispose = gdl_dock_item_dispose;
 
     widget_class->realize = gdl_dock_item_realize;
     widget_class->map = gdl_dock_item_map;
@@ -608,34 +607,31 @@ gdl_dock_item_get_property  (GObject      *g_object,
 }
 
 static void
-gdl_dock_item_destroy (GtkWidget *object)
+gdl_dock_item_dispose (GObject *object)
 {
     GdlDockItem *item = GDL_DOCK_ITEM (object);
+    GdlDockItemPrivate *priv = item->priv;
 
-    if (item->priv) {
-        GdlDockItemPrivate *priv = item->priv;
-        
-        if (priv->tab_label) {
-            gdl_dock_item_set_tablabel (item, NULL);
-        };
-        if (priv->menu) {
-            gtk_menu_detach (GTK_MENU (priv->menu));
-            priv->menu = NULL;
-        };
-        if (priv->grip) {
-            gtk_container_remove (GTK_CONTAINER (item), priv->grip);
-            priv->grip = NULL;
-        }
-        if (priv->ph) {
-            g_object_unref (priv->ph);
-            priv->ph = NULL;
-        }
-        
-        item->priv = NULL;
-        g_free (priv);
+    if (priv->tab_label) {
+        gdl_dock_item_set_tablabel (item, NULL);
+    }
+
+    if (priv->menu) {
+        gtk_menu_detach (GTK_MENU (priv->menu));
+        priv->menu = NULL;
+    }
+
+    if (priv->grip) {
+        gtk_container_remove (GTK_CONTAINER (item), priv->grip);
+        priv->grip = NULL;
+    }
+
+    if (priv->ph) {
+        g_object_unref (priv->ph);
+        priv->ph = NULL;
     }
 
-    GTK_WIDGET_CLASS (gdl_dock_item_parent_class)->destroy (object);
+    G_OBJECT_CLASS (gdl_dock_item_parent_class)->dispose (object);
 }
 
 static void 
diff --git a/gdl/gdl-dock.c b/gdl/gdl-dock.c
index 17d1dca..4ef1004 100644
--- a/gdl/gdl-dock.c
+++ b/gdl/gdl-dock.c
@@ -62,7 +62,7 @@ static void  gdl_dock_notify_cb       (GObject      *object,
 
 static void  gdl_dock_set_title       (GdlDock      *dock);
 
-static void  gdl_dock_destroy         (GtkWidget    *object);
+static void  gdl_dock_dispose         (GObject      *object);
 
 static void  gdl_dock_get_preferred_width  (GtkWidget *widget,
                                             gint      *minimum,
@@ -171,6 +171,7 @@ gdl_dock_class_init (GdlDockClass *klass)
     g_object_class->constructor = gdl_dock_constructor;
     g_object_class->set_property = gdl_dock_set_property;
     g_object_class->get_property = gdl_dock_get_property;
+    g_object_class->dispose = gdl_dock_dispose;
     
     /* properties */
 
@@ -220,8 +221,6 @@ gdl_dock_class_init (GdlDockClass *klass)
                           G_MININT, G_MAXINT, 0,
                           G_PARAM_READWRITE | G_PARAM_CONSTRUCT |
                           GDL_DOCK_PARAM_EXPORT));
-    
-    widget_class->destroy = gdl_dock_destroy;
 
     widget_class->get_preferred_width = gdl_dock_get_preferred_width;
     widget_class->get_preferred_height = gdl_dock_get_preferred_height;
@@ -509,30 +508,23 @@ gdl_dock_notify_cb (GObject    *object,
 }
 
 static void
-gdl_dock_destroy (GtkWidget *object)
+gdl_dock_dispose (GObject *object)
 {
-    GdlDock *dock = GDL_DOCK (object);
-
-    if (dock->priv) {
-        GdlDockPrivate *priv = dock->priv;
-        dock->priv = NULL;
+    GdlDockPrivate *priv = GDL_DOCK (object)->priv;
 
-        if (priv->window) {
-            gtk_widget_destroy (priv->window);
-            priv->floating = FALSE;
-            priv->window = NULL;
-        }
+    if (priv->window) {
+        gtk_widget_destroy (priv->window);
+        priv->floating = FALSE;
+        priv->window = NULL;
+    }
 
-        if (priv->area_window)
-        {
-            gtk_widget_destroy (priv->area_window);
-            priv->area_window = NULL;
-        }
-        
-        g_free (priv);
+    if (priv->area_window)
+    {
+        gtk_widget_destroy (priv->area_window);
+        priv->area_window = NULL;
     }
-    
-   GTK_WIDGET_CLASS (gdl_dock_parent_class)->destroy (object);
+
+    G_OBJECT_CLASS (gdl_dock_parent_class)->dispose (object);
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]