[gimp] app: move code from GtkObject::destroy() to GObject::dispose()



commit 0e17e44ba4d9c61dd7774bb2d8043100cedfd6f3
Author: Michael Natterer <mitch gimp org>
Date:   Sun Sep 26 22:35:49 2010 +0200

    app: move code from GtkObject::destroy() to GObject::dispose()

 app/display/gimpdisplayshell.c     |  183 ++++++++++++++++++------------------
 app/display/gimpimagewindow.c      |   40 +++-----
 app/display/gimpnavigationeditor.c |   10 +-
 app/display/gimpstatusbar.c        |   39 ++++----
 4 files changed, 127 insertions(+), 145 deletions(-)
---
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index 95049a4..8b283dc 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -117,6 +117,7 @@ static void      gimp_color_managed_iface_init     (GimpColorManagedInterface *i
 static GObject * gimp_display_shell_constructor    (GType             type,
                                                     guint             n_params,
                                                     GObjectConstructParam *params);
+static void      gimp_display_shell_dispose        (GObject          *object);
 static void      gimp_display_shell_finalize       (GObject          *object);
 static void      gimp_display_shell_set_property   (GObject          *object,
                                                     guint             property_id,
@@ -127,8 +128,6 @@ static void      gimp_display_shell_get_property   (GObject          *object,
                                                     GValue           *value,
                                                     GParamSpec       *pspec);
 
-static void      gimp_display_shell_destroy        (GtkObject        *object);
-
 static void      gimp_display_shell_unrealize      (GtkWidget        *widget);
 static void      gimp_display_shell_screen_changed (GtkWidget        *widget,
                                                     GdkScreen        *previous);
@@ -183,9 +182,8 @@ static const gchar display_rc_style[] =
 static void
 gimp_display_shell_class_init (GimpDisplayShellClass *klass)
 {
-  GObjectClass   *object_class     = G_OBJECT_CLASS (klass);
-  GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
-  GtkWidgetClass *widget_class     = GTK_WIDGET_CLASS (klass);
+  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   display_shell_signals[SCALED] =
     g_signal_new ("scaled",
@@ -215,12 +213,11 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
                   G_TYPE_NONE, 0);
 
   object_class->constructor        = gimp_display_shell_constructor;
+  object_class->dispose            = gimp_display_shell_dispose;
   object_class->finalize           = gimp_display_shell_finalize;
   object_class->set_property       = gimp_display_shell_set_property;
   object_class->get_property       = gimp_display_shell_get_property;
 
-  gtk_object_class->destroy        = gimp_display_shell_destroy;
-
   widget_class->unrealize          = gimp_display_shell_unrealize;
   widget_class->screen_changed     = gimp_display_shell_screen_changed;
   widget_class->popup_menu         = gimp_display_shell_popup_menu;
@@ -746,6 +743,92 @@ gimp_display_shell_constructor (GType                  type,
 }
 
 static void
+gimp_display_shell_dispose (GObject *object)
+{
+  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
+
+  if (shell->display && gimp_display_get_shell (shell->display))
+    gimp_display_shell_disconnect (shell);
+
+  shell->popup_manager = NULL;
+
+  gimp_display_shell_selection_free (shell);
+
+  if (shell->filter_stack)
+    gimp_display_shell_filter_set (shell, NULL);
+
+  if (shell->filter_idle_id)
+    {
+      g_source_remove (shell->filter_idle_id);
+      shell->filter_idle_id = 0;
+    }
+
+  if (shell->render_surface)
+    {
+      cairo_surface_destroy (shell->render_surface);
+      shell->render_surface = NULL;
+    }
+
+  if (shell->highlight)
+    {
+      g_slice_free (GdkRectangle, shell->highlight);
+      shell->highlight = NULL;
+    }
+
+  if (shell->mask)
+    {
+      g_object_unref (shell->mask);
+      shell->mask = NULL;
+    }
+
+  if (shell->event_history)
+    {
+      g_array_free (shell->event_history, TRUE);
+      shell->event_history = NULL;
+    }
+
+  if (shell->event_queue)
+    {
+      g_array_free (shell->event_queue, TRUE);
+      shell->event_queue = NULL;
+    }
+
+  if (shell->zoom_focus_pointer_queue)
+    {
+      g_queue_free (shell->zoom_focus_pointer_queue);
+      shell->zoom_focus_pointer_queue = NULL;
+    }
+
+  if (shell->title_idle_id)
+    {
+      g_source_remove (shell->title_idle_id);
+      shell->title_idle_id = 0;
+    }
+
+  if (shell->fill_idle_id)
+    {
+      g_source_remove (shell->fill_idle_id);
+      shell->fill_idle_id = 0;
+    }
+
+  if (shell->nav_popup)
+    {
+      gtk_widget_destroy (shell->nav_popup);
+      shell->nav_popup = NULL;
+    }
+
+  if (shell->grid_dialog)
+    {
+      gtk_widget_destroy (shell->grid_dialog);
+      shell->grid_dialog = NULL;
+    }
+
+  shell->display = NULL;
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
 gimp_display_shell_finalize (GObject *object)
 {
   GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
@@ -848,92 +931,6 @@ gimp_display_shell_get_property (GObject    *object,
 }
 
 static void
-gimp_display_shell_destroy (GtkObject *object)
-{
-  GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (object);
-
-  if (shell->display && gimp_display_get_shell (shell->display))
-    gimp_display_shell_disconnect (shell);
-
-  shell->popup_manager = NULL;
-
-  gimp_display_shell_selection_free (shell);
-
-  if (shell->filter_stack)
-    gimp_display_shell_filter_set (shell, NULL);
-
-  if (shell->filter_idle_id)
-    {
-      g_source_remove (shell->filter_idle_id);
-      shell->filter_idle_id = 0;
-    }
-
-  if (shell->render_surface)
-    {
-      cairo_surface_destroy (shell->render_surface);
-      shell->render_surface = NULL;
-    }
-
-  if (shell->highlight)
-    {
-      g_slice_free (GdkRectangle, shell->highlight);
-      shell->highlight = NULL;
-    }
-
-  if (shell->mask)
-    {
-      g_object_unref (shell->mask);
-      shell->mask = NULL;
-    }
-
-  if (shell->event_history)
-    {
-      g_array_free (shell->event_history, TRUE);
-      shell->event_history = NULL;
-    }
-
-  if (shell->event_queue)
-    {
-      g_array_free (shell->event_queue, TRUE);
-      shell->event_queue = NULL;
-    }
-
-  if (shell->zoom_focus_pointer_queue)
-    {
-      g_queue_free (shell->zoom_focus_pointer_queue);
-      shell->zoom_focus_pointer_queue = NULL;
-    }
-
-  if (shell->title_idle_id)
-    {
-      g_source_remove (shell->title_idle_id);
-      shell->title_idle_id = 0;
-    }
-
-  if (shell->fill_idle_id)
-    {
-      g_source_remove (shell->fill_idle_id);
-      shell->fill_idle_id = 0;
-    }
-
-  if (shell->nav_popup)
-    {
-      gtk_widget_destroy (shell->nav_popup);
-      shell->nav_popup = NULL;
-    }
-
-  if (shell->grid_dialog)
-    {
-      gtk_widget_destroy (shell->grid_dialog);
-      shell->grid_dialog = NULL;
-    }
-
-  shell->display = NULL;
-
-  GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
 gimp_display_shell_unrealize (GtkWidget *widget)
 {
   GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (widget);
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 90c07e1..428d9d0 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -123,8 +123,6 @@ static void      gimp_image_window_get_property        (GObject             *obj
                                                         GValue              *value,
                                                         GParamSpec          *pspec);
 
-static void      gimp_image_window_real_destroy        (GtkObject           *object);
-
 static gboolean  gimp_image_window_delete_event        (GtkWidget           *widget,
                                                         GdkEventAny         *event);
 static gboolean  gimp_image_window_configure_event     (GtkWidget           *widget,
@@ -202,9 +200,8 @@ static const gchar image_window_rc_style[] =
 static void
 gimp_image_window_class_init (GimpImageWindowClass *klass)
 {
-  GObjectClass   *object_class     = G_OBJECT_CLASS (klass);
-  GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
-  GtkWidgetClass *widget_class     = GTK_WIDGET_CLASS (klass);
+  GObjectClass   *object_class = G_OBJECT_CLASS (klass);
+  GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
 
   object_class->constructor        = gimp_image_window_constructor;
   object_class->dispose            = gimp_image_window_dispose;
@@ -212,8 +209,6 @@ gimp_image_window_class_init (GimpImageWindowClass *klass)
   object_class->set_property       = gimp_image_window_set_property;
   object_class->get_property       = gimp_image_window_get_property;
 
-  gtk_object_class->destroy        = gimp_image_window_real_destroy;
-
   widget_class->delete_event       = gimp_image_window_delete_event;
   widget_class->configure_event    = gimp_image_window_configure_event;
   widget_class->window_state_event = gimp_image_window_window_state_event;
@@ -398,6 +393,12 @@ gimp_image_window_dispose (GObject *object)
       private->dialog_factory = NULL;
     }
 
+  if (private->menubar_manager)
+    {
+      g_object_unref (private->menubar_manager);
+      private->menubar_manager = NULL;
+    }
+
   G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
@@ -481,21 +482,6 @@ gimp_image_window_get_property (GObject    *object,
     }
 }
 
-static void
-gimp_image_window_real_destroy (GtkObject *object)
-{
-  GimpImageWindow        *window  = GIMP_IMAGE_WINDOW (object);
-  GimpImageWindowPrivate *private = GIMP_IMAGE_WINDOW_GET_PRIVATE (window);
-
-  if (private->menubar_manager)
-    {
-      g_object_unref (private->menubar_manager);
-      private->menubar_manager = NULL;
-    }
-
-  GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
 static gboolean
 gimp_image_window_delete_event (GtkWidget   *widget,
                                 GdkEventAny *event)
@@ -1310,9 +1296,10 @@ gimp_image_window_disconnect_from_active_shell (GimpImageWindow *window)
 
   active_display = private->active_shell->display;
 
-  g_signal_handlers_disconnect_by_func (active_display,
-                                        gimp_image_window_image_notify,
-                                        window);
+  if (active_display)
+    g_signal_handlers_disconnect_by_func (active_display,
+                                          gimp_image_window_image_notify,
+                                          window);
 
   g_signal_handlers_disconnect_by_func (private->active_shell,
                                         gimp_image_window_shell_scaled,
@@ -1324,7 +1311,8 @@ gimp_image_window_disconnect_from_active_shell (GimpImageWindow *window)
                                         gimp_image_window_shell_icon_notify,
                                         window);
 
-  gimp_image_window_hide_tooltip (private->menubar_manager, window);
+  if (private->menubar_manager)
+    gimp_image_window_hide_tooltip (private->menubar_manager, window);
 }
 
 static void
diff --git a/app/display/gimpnavigationeditor.c b/app/display/gimpnavigationeditor.c
index 314df74..8a642de 100644
--- a/app/display/gimpnavigationeditor.c
+++ b/app/display/gimpnavigationeditor.c
@@ -55,7 +55,7 @@
 
 static void        gimp_navigation_editor_docked_iface_init (GimpDockedInterface  *iface);
 
-static void        gimp_navigation_editor_destroy           (GtkObject            *object);
+static void        gimp_navigation_editor_dispose           (GObject              *object);
 
 static void        gimp_navigation_editor_set_context       (GimpDocked           *docked,
                                                              GimpContext          *context);
@@ -104,9 +104,9 @@ G_DEFINE_TYPE_WITH_CODE (GimpNavigationEditor, gimp_navigation_editor,
 static void
 gimp_navigation_editor_class_init (GimpNavigationEditorClass *klass)
 {
-  GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  gtk_object_class->destroy = gimp_navigation_editor_destroy;
+  object_class->dispose = gimp_navigation_editor_dispose;
 }
 
 static void
@@ -149,14 +149,14 @@ gimp_navigation_editor_init (GimpNavigationEditor *editor)
 }
 
 static void
-gimp_navigation_editor_destroy (GtkObject *object)
+gimp_navigation_editor_dispose (GObject *object)
 {
   GimpNavigationEditor *editor = GIMP_NAVIGATION_EDITOR (object);
 
   if (editor->shell)
     gimp_navigation_editor_set_shell (editor, NULL);
 
-  GTK_OBJECT_CLASS (parent_class)->destroy (object);
+  G_OBJECT_CLASS (parent_class)->dispose (object);
 }
 
 static void
diff --git a/app/display/gimpstatusbar.c b/app/display/gimpstatusbar.c
index ab23ecf..b756824 100644
--- a/app/display/gimpstatusbar.c
+++ b/app/display/gimpstatusbar.c
@@ -72,10 +72,9 @@ struct _GimpStatusbarMsg
 
 static void     gimp_statusbar_progress_iface_init (GimpProgressInterface *iface);
 
+static void     gimp_statusbar_dispose            (GObject           *object);
 static void     gimp_statusbar_finalize           (GObject           *object);
 
-static void     gimp_statusbar_destroy            (GtkObject         *object);
-
 static void     gimp_statusbar_hbox_size_request  (GtkWidget         *widget,
                                                    GtkRequisition    *requisition,
                                                    GimpStatusbar     *statusbar);
@@ -136,12 +135,10 @@ G_DEFINE_TYPE_WITH_CODE (GimpStatusbar, gimp_statusbar, GTK_TYPE_STATUSBAR,
 static void
 gimp_statusbar_class_init (GimpStatusbarClass *klass)
 {
-  GObjectClass   *object_class     = G_OBJECT_CLASS (klass);
-  GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
-
-  object_class->finalize    = gimp_statusbar_finalize;
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
-  gtk_object_class->destroy = gimp_statusbar_destroy;
+  object_class->dispose  = gimp_statusbar_dispose;
+  object_class->finalize = gimp_statusbar_finalize;
 }
 
 static void
@@ -263,6 +260,20 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
 }
 
 static void
+gimp_statusbar_dispose (GObject *object)
+{
+  GimpStatusbar *statusbar = GIMP_STATUSBAR (object);
+
+  if (statusbar->temp_timeout_id)
+    {
+      g_source_remove (statusbar->temp_timeout_id);
+      statusbar->temp_timeout_id = 0;
+    }
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
 gimp_statusbar_finalize (GObject *object)
 {
   GimpStatusbar *statusbar = GIMP_STATUSBAR (object);
@@ -287,20 +298,6 @@ gimp_statusbar_finalize (GObject *object)
 }
 
 static void
-gimp_statusbar_destroy (GtkObject *object)
-{
-  GimpStatusbar *statusbar = GIMP_STATUSBAR (object);
-
-  if (statusbar->temp_timeout_id)
-    {
-      g_source_remove (statusbar->temp_timeout_id);
-      statusbar->temp_timeout_id = 0;
-    }
-
-  GTK_OBJECT_CLASS (parent_class)->destroy (object);
-}
-
-static void
 gimp_statusbar_hbox_size_request (GtkWidget      *widget,
                                   GtkRequisition *requisition,
                                   GimpStatusbar  *statusbar)



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