[gimp] libgimp: implement GObject::dispose() instead of GtkWidget::destroy()



commit 1948feb686c8210f8f9a3162d9c40d0fbdc856b5
Author: Michael Natterer <mitch gimp org>
Date:   Fri Oct 15 12:17:10 2010 +0200

    libgimp: implement GObject::dispose() instead of GtkWidget::destroy()

 libgimp/gimpprogressbar.c  |   10 +++---
 libgimp/gimpselectbutton.c |   25 ++++++-------
 libgimp/gimpzoompreview.c  |   83 +++++++++++++++++++++-----------------------
 3 files changed, 56 insertions(+), 62 deletions(-)
---
diff --git a/libgimp/gimpprogressbar.c b/libgimp/gimpprogressbar.c
index ceb54f1..73ae666 100644
--- a/libgimp/gimpprogressbar.c
+++ b/libgimp/gimpprogressbar.c
@@ -48,7 +48,7 @@
  **/
 
 
-static void     gimp_progress_bar_destroy    (GtkObject   *object);
+static void     gimp_progress_bar_dispose    (GObject     *object);
 
 static void     gimp_progress_bar_start      (const gchar *message,
                                               gboolean     cancelable,
@@ -70,9 +70,9 @@ G_DEFINE_TYPE (GimpProgressBar, gimp_progress_bar, GTK_TYPE_PROGRESS_BAR)
 static void
 gimp_progress_bar_class_init (GimpProgressBarClass *klass)
 {
-  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  object_class->destroy = gimp_progress_bar_destroy;
+  object_class->dispose = gimp_progress_bar_dispose;
 }
 
 static void
@@ -94,7 +94,7 @@ gimp_progress_bar_init (GimpProgressBar *bar)
 }
 
 static void
-gimp_progress_bar_destroy (GtkObject *object)
+gimp_progress_bar_dispose (GObject *object)
 {
   GimpProgressBar *bar = GIMP_PROGRESS_BAR (object);
 
@@ -104,7 +104,7 @@ gimp_progress_bar_destroy (GtkObject *object)
       bar->progress_callback = NULL;
     }
 
-  GTK_OBJECT_CLASS (parent_class)->destroy (object);
+  G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
 static void
diff --git a/libgimp/gimpselectbutton.c b/libgimp/gimpselectbutton.c
index cd48017..0dab586 100644
--- a/libgimp/gimpselectbutton.c
+++ b/libgimp/gimpselectbutton.c
@@ -41,7 +41,7 @@
 
 /*  local function prototypes  */
 
-static void   gimp_select_button_destroy (GtkObject *object);
+static void   gimp_select_button_dispose (GObject *object);
 
 
 G_DEFINE_TYPE (GimpSelectButton, gimp_select_button, GTK_TYPE_HBOX)
@@ -49,9 +49,9 @@ G_DEFINE_TYPE (GimpSelectButton, gimp_select_button, GTK_TYPE_HBOX)
 static void
 gimp_select_button_class_init (GimpSelectButtonClass *klass)
 {
-  GtkObjectClass *object_class = GTK_OBJECT_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  object_class->destroy = gimp_select_button_destroy;
+  object_class->dispose = gimp_select_button_dispose;
 }
 
 static void
@@ -60,6 +60,14 @@ gimp_select_button_init (GimpSelectButton *select_button)
   select_button->temp_callback = NULL;
 }
 
+static void
+gimp_select_button_dispose (GObject *object)
+{
+  gimp_select_button_close_popup (GIMP_SELECT_BUTTON (object));
+
+  G_OBJECT_CLASS (gimp_select_button_parent_class)->dispose (object);
+}
+
 /**
  * gimp_select_button_close_popup:
  * @button: A #GimpSelectButton
@@ -82,14 +90,3 @@ gimp_select_button_close_popup (GimpSelectButton *button)
       button->temp_callback = NULL;
     }
 }
-
-
-/*  private functions  */
-
-static void
-gimp_select_button_destroy (GtkObject *object)
-{
-  gimp_select_button_close_popup (GIMP_SELECT_BUTTON (object));
-
-  GTK_OBJECT_CLASS (gimp_select_button_parent_class)->destroy (object);
-}
diff --git a/libgimp/gimpzoompreview.c b/libgimp/gimpzoompreview.c
index 77bd1eb..458c8be 100644
--- a/libgimp/gimpzoompreview.c
+++ b/libgimp/gimpzoompreview.c
@@ -69,7 +69,8 @@ typedef struct
 static GObject * gimp_zoom_preview_constructor (GType                  type,
                                                 guint                  n_params,
                                                 GObjectConstructParam *params);
-
+static void     gimp_zoom_preview_finalize        (GObject         *object);
+static void     gimp_zoom_preview_dispose         (GObject         *object);
 static void     gimp_zoom_preview_get_property    (GObject         *object,
                                                    guint            property_id,
                                                    GValue          *value,
@@ -78,8 +79,6 @@ static void     gimp_zoom_preview_set_property    (GObject         *object,
                                                    guint            property_id,
                                                    const GValue    *value,
                                                    GParamSpec      *pspec);
-static void     gimp_zoom_preview_finalize        (GObject         *object);
-static void     gimp_zoom_preview_destroy         (GtkObject       *object);
 
 static void     gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview,
                                                    gdouble          old_factor,
@@ -134,17 +133,15 @@ static gint gimp_zoom_preview_counter = 0;
 static void
 gimp_zoom_preview_class_init (GimpZoomPreviewClass *klass)
 {
-  GObjectClass     *object_class     = G_OBJECT_CLASS (klass);
-  GtkObjectClass   *gtk_object_class = GTK_OBJECT_CLASS (klass);
-  GtkWidgetClass   *widget_class     = GTK_WIDGET_CLASS (klass);
-  GimpPreviewClass *preview_class    = GIMP_PREVIEW_CLASS (klass);
+  GObjectClass     *object_class  = G_OBJECT_CLASS (klass);
+  GtkWidgetClass   *widget_class  = GTK_WIDGET_CLASS (klass);
+  GimpPreviewClass *preview_class = GIMP_PREVIEW_CLASS (klass);
 
   object_class->constructor  = gimp_zoom_preview_constructor;
+  object_class->finalize     = gimp_zoom_preview_finalize;
+  object_class->dispose      = gimp_zoom_preview_dispose;
   object_class->get_property = gimp_zoom_preview_get_property;
   object_class->set_property = gimp_zoom_preview_set_property;
-  object_class->finalize     = gimp_zoom_preview_finalize;
-
-  gtk_object_class->destroy  = gimp_zoom_preview_destroy;
 
   widget_class->style_set    = gimp_zoom_preview_style_set;
 
@@ -248,6 +245,39 @@ gimp_zoom_preview_constructor (GType                  type,
 }
 
 static void
+gimp_zoom_preview_finalize (GObject *object)
+{
+  GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (object);
+
+  if (priv->model)
+    {
+      g_object_unref (priv->model);
+      priv->model = NULL;
+    }
+
+  G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+static void
+gimp_zoom_preview_dispose (GObject *object)
+{
+  const gchar *data_name = g_object_get_data (G_OBJECT (object),
+                                               "gimp-zoom-preview-data-name");
+
+  if (data_name)
+    {
+      GimpPreview     *preview = GIMP_PREVIEW (object);
+      PreviewSettings  settings;
+
+      settings.update = gimp_preview_get_update (preview);
+
+      gimp_set_data (data_name, &settings, sizeof (PreviewSettings));
+    }
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
 gimp_zoom_preview_get_property (GObject    *object,
                                 guint       property_id,
                                 GValue     *value,
@@ -296,39 +326,6 @@ gimp_zoom_preview_set_property (GObject      *object,
 }
 
 static void
-gimp_zoom_preview_finalize (GObject *object)
-{
-  GimpZoomPreviewPrivate *priv = GIMP_ZOOM_PREVIEW_GET_PRIVATE (object);
-
-  if (priv->model)
-    {
-      g_object_unref (priv->model);
-      priv->model = NULL;
-    }
-
-  G_OBJECT_CLASS (parent_class)->finalize (object);
-}
-
-static void
-gimp_zoom_preview_destroy (GtkObject *object)
-{
-  const gchar *data_name = g_object_get_data (G_OBJECT (object),
-                                               "gimp-zoom-preview-data-name");
-
-  if (data_name)
-    {
-      GimpPreview     *preview = GIMP_PREVIEW (object);
-      PreviewSettings  settings;
-
-      settings.update = gimp_preview_get_update (preview);
-
-      gimp_set_data (data_name, &settings, sizeof (PreviewSettings));
-    }
-
-  GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
 gimp_zoom_preview_set_adjustments (GimpZoomPreview *preview,
                                    gdouble          old_factor,
                                    gdouble          new_factor)



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