[gimp] app: Move title invalidation from GimpMenuDock to GimpDock base class



commit 33dbcf210e1cf71ef932f5fd68e9a5a20773a588
Author: Martin Nordholts <martinn src gnome org>
Date:   Sun Mar 7 10:25:24 2010 +0100

    app: Move title invalidation from GimpMenuDock to GimpDock base class
    
    Move title invalidation from GimpMenuDock to GimpDock base class so
    that title invalidation works properly also for the GimpToolbox.

 app/widgets/gimpdock.c     |   35 ++++++++++++++++++++------
 app/widgets/gimpdock.h     |    1 -
 app/widgets/gimpmenudock.c |   57 +-------------------------------------------
 3 files changed, 28 insertions(+), 65 deletions(-)
---
diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c
index bfe45af..66d4993 100644
--- a/app/widgets/gimpdock.c
+++ b/app/widgets/gimpdock.c
@@ -77,6 +77,7 @@ static void              gimp_dock_real_book_added   (GimpDock     *dock,
                                                       GimpDockbook *dockbook);
 static void              gimp_dock_real_book_removed (GimpDock     *dock,
                                                       GimpDockbook *dockbook);
+static void              gimp_dock_invalidate_title  (GimpDock     *dock);
 static gboolean          gimp_dock_dropped_cb        (GtkWidget    *source,
                                                       gint          insert_index,
                                                       gpointer      data);
@@ -292,6 +293,14 @@ gimp_dock_real_book_removed (GimpDock     *dock,
 {
 }
 
+static void
+gimp_dock_invalidate_title (GimpDock *dock)
+{
+  g_return_if_fail (GIMP_IS_DOCK (dock));
+
+  g_signal_emit (dock, dock_signals[TITLE_INVALIDATED], 0);
+}
+
 static gboolean
 gimp_dock_dropped_cb (GtkWidget *source,
                       gint       insert_index,
@@ -369,14 +378,6 @@ gimp_dock_get_title (GimpDock *dock)
   return NULL;
 }
 
-void
-gimp_dock_invalidate_title (GimpDock *dock)
-{
-  g_return_if_fail (GIMP_IS_DOCK (dock));
-
-  g_signal_emit (dock, dock_signals[TITLE_INVALIDATED], 0);
-}
-
 /**
  * gimp_dock_set_host_geometry_hints:
  * @dock:   The dock
@@ -617,12 +618,24 @@ gimp_dock_add_book (GimpDock     *dock,
 
   gimp_dockbook_set_dock (dockbook, dock);
 
+  g_signal_connect_object (dockbook, "dockable-added",
+                           G_CALLBACK (gimp_dock_invalidate_title),
+                           dock, G_CONNECT_SWAPPED);
+  g_signal_connect_object (dockbook, "dockable-removed",
+                           G_CALLBACK (gimp_dock_invalidate_title),
+                           dock, G_CONNECT_SWAPPED);
+  g_signal_connect_object (dockbook, "dockable-reordered",
+                           G_CALLBACK (gimp_dock_invalidate_title),
+                           dock, G_CONNECT_SWAPPED);
+
   dock->p->dockbooks = g_list_insert (dock->p->dockbooks, dockbook, index);
   gimp_paned_box_add_widget (GIMP_PANED_BOX (dock->p->paned_vbox),
                              GTK_WIDGET (dockbook),
                              index);
   gtk_widget_show (GTK_WIDGET (dockbook));
 
+  gimp_dock_invalidate_title (dock);
+
   g_signal_emit (dock, dock_signals[BOOK_ADDED], 0, dockbook);
 }
 
@@ -636,6 +649,10 @@ gimp_dock_remove_book (GimpDock     *dock,
 
   gimp_dockbook_set_dock (dockbook, NULL);
 
+  g_signal_handlers_disconnect_by_func (dockbook,
+                                        gimp_dock_invalidate_title,
+                                        dock);
+
   /* Ref the dockbook so we can emit the "book-removed" signal and
    * pass it as a parameter before it's destroyed
    */
@@ -645,6 +662,8 @@ gimp_dock_remove_book (GimpDock     *dock,
   gimp_paned_box_remove_widget (GIMP_PANED_BOX (dock->p->paned_vbox),
                                 GTK_WIDGET (dockbook));
 
+  gimp_dock_invalidate_title (dock);
+
   g_signal_emit (dock, dock_signals[BOOK_REMOVED], 0, dockbook);
 
   g_object_unref (dockbook);
diff --git a/app/widgets/gimpdock.h b/app/widgets/gimpdock.h
index 1aa5795..eac2752 100644
--- a/app/widgets/gimpdock.h
+++ b/app/widgets/gimpdock.h
@@ -67,7 +67,6 @@ struct _GimpDockClass
 GType               gimp_dock_get_type                (void) G_GNUC_CONST;
 
 gchar             * gimp_dock_get_title               (GimpDock       *dock);
-void                gimp_dock_invalidate_title        (GimpDock       *dock);
 void                gimp_dock_set_host_geometry_hints (GimpDock       *dock,
                                                        GtkWindow      *window);
 void                gimp_dock_invalidate_geometry     (GimpDock       *dock);
diff --git a/app/widgets/gimpmenudock.c b/app/widgets/gimpmenudock.c
index c6bcf06..7303e7b 100644
--- a/app/widgets/gimpmenudock.c
+++ b/app/widgets/gimpmenudock.c
@@ -54,16 +54,6 @@ struct _GimpMenuDockPrivate
 static void   gimp_menu_dock_style_set               (GtkWidget      *widget,
                                                       GtkStyle       *prev_style);
 
-static void   gimp_menu_dock_book_added              (GimpDock       *dock,
-                                                      GimpDockbook   *dockbook);
-static void   gimp_menu_dock_book_removed            (GimpDock       *dock,
-                                                      GimpDockbook   *dockbook);
-
-static void   gimp_menu_dock_dockbook_changed        (GimpDockbook   *dockbook,
-                                                      GimpDockable   *dockable,
-                                                      GimpMenuDock   *dock);
-
-
 
 G_DEFINE_TYPE (GimpMenuDock, gimp_menu_dock, GIMP_TYPE_DOCK)
 
@@ -74,12 +64,8 @@ static void
 gimp_menu_dock_class_init (GimpMenuDockClass *klass)
 {
   GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
-  GimpDockClass  *dock_class   = GIMP_DOCK_CLASS (klass);
 
-  widget_class->style_set   = gimp_menu_dock_style_set;
-
-  dock_class->book_added    = gimp_menu_dock_book_added;
-  dock_class->book_removed  = gimp_menu_dock_book_removed;
+  widget_class->style_set = gimp_menu_dock_style_set;
 
   gtk_widget_class_install_style_property (widget_class,
                                            g_param_spec_int ("minimal-width",
@@ -112,49 +98,8 @@ gimp_menu_dock_style_set (GtkWidget *widget,
   gtk_widget_set_size_request (widget, minimal_width, -1);
 }
 
-static void
-gimp_menu_dock_book_added (GimpDock     *dock,
-                           GimpDockbook *dockbook)
-{
-  g_signal_connect (dockbook, "dockable-added",
-                    G_CALLBACK (gimp_menu_dock_dockbook_changed),
-                    dock);
-  g_signal_connect (dockbook, "dockable-removed",
-                    G_CALLBACK (gimp_menu_dock_dockbook_changed),
-                    dock);
-  g_signal_connect (dockbook, "dockable-reordered",
-                    G_CALLBACK (gimp_menu_dock_dockbook_changed),
-                    dock);
-
-  gimp_dock_invalidate_title (GIMP_DOCK (dock));
-
-  GIMP_DOCK_CLASS (parent_class)->book_added (dock, dockbook);
-}
-
-static void
-gimp_menu_dock_book_removed (GimpDock     *dock,
-                             GimpDockbook *dockbook)
-{
-  g_signal_handlers_disconnect_by_func (dockbook,
-                                        gimp_menu_dock_dockbook_changed,
-                                        dock);
-
-  gimp_dock_invalidate_title (GIMP_DOCK (dock));
-
-  GIMP_DOCK_CLASS (parent_class)->book_removed (dock, dockbook);
-}
-
 GtkWidget *
 gimp_menu_dock_new (void)
 {
   return g_object_new (GIMP_TYPE_MENU_DOCK, NULL);
 }
-
-static void
-gimp_menu_dock_dockbook_changed (GimpDockbook *dockbook,
-                                 GimpDockable *dockable,
-                                 GimpMenuDock *dock)
-{
-  gimp_dock_invalidate_title (GIMP_DOCK (dock));
-}
-



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