[gimp] app: Add GimpDockContainer::get_ui_manager()



commit ab1b50ad4a27ec4e3b6ada96a926f817e52f4a2f
Author: Martin Nordholts <martinn src gnome org>
Date:   Fri May 13 18:56:03 2011 +0200

    app: Add GimpDockContainer::get_ui_manager()
    
    Add GimpDockContainer::get_ui_manager() and make GimpDockWindow
    implement it. Primary client is session restoration code.

 app/widgets/gimpdialogfactory.c    |    6 +++++-
 app/widgets/gimpdock.c             |    9 +++++++--
 app/widgets/gimpdockbook.c         |   11 ++++++++---
 app/widgets/gimpdockcontainer.c    |   26 ++++++++++++++++++++++++--
 app/widgets/gimpdockcontainer.h    |    8 +++++---
 app/widgets/gimpdockwindow.c       |   26 +++++++++++++++++---------
 app/widgets/gimpdockwindow.h       |    1 -
 app/widgets/gimpsessioninfo-dock.c |   12 +++++++-----
 app/widgets/gimpwidgets-utils.c    |   27 +++++++++++++++------------
 9 files changed, 88 insertions(+), 38 deletions(-)
---
diff --git a/app/widgets/gimpdialogfactory.c b/app/widgets/gimpdialogfactory.c
index b0a7312..1d89fb6 100644
--- a/app/widgets/gimpdialogfactory.c
+++ b/app/widgets/gimpdialogfactory.c
@@ -41,6 +41,7 @@
 #include "gimpdock.h"
 #include "gimpdockbook.h"
 #include "gimpdockable.h"
+#include "gimpdockcontainer.h"
 #include "gimpdockwindow.h"
 #include "gimpmenufactory.h"
 #include "gimpsessioninfo.h"
@@ -456,6 +457,8 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
             }
           else if (strcmp ("gimp-toolbox", entry->identifier) == 0)
             {
+              GimpDockContainer *dock_container;
+
               dock_window = gimp_dialog_factory_dialog_new (factory,
                                                             screen,
                                                             NULL /*ui_manager*/,
@@ -466,7 +469,8 @@ gimp_dialog_factory_dialog_new_internal (GimpDialogFactory *factory,
               /* When we get a dock window, we also get a UI
                * manager
                */
-              ui_manager = gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (dock_window));
+              dock_container = GIMP_DOCK_CONTAINER (dock_window);
+              ui_manager     = gimp_dock_container_get_ui_manager (dock_container);
             }
         }
 
diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c
index fd224db..ccdeac1 100644
--- a/app/widgets/gimpdock.c
+++ b/app/widgets/gimpdock.c
@@ -37,6 +37,7 @@
 #include "gimpdockable.h"
 #include "gimpdockbook.h"
 #include "gimpdockcolumns.h"
+#include "gimpdockcontainer.h"
 #include "gimpdockwindow.h"
 #include "gimppanedbox.h"
 #include "gimpuimanager.h"
@@ -564,13 +565,17 @@ gimp_dock_get_ui_manager (GimpDock *dock)
         ui_manager = gimp_dock_columns_get_ui_manager (dock_columns);
     }
 
-  /* Then GimpDockWindow */
+  /* Then GimpDockContainer */
   if (! ui_manager)
     {
       GimpDockWindow *dock_window = gimp_dock_window_from_dock (dock);
 
       if (dock_window)
-        ui_manager = gimp_dock_window_get_ui_manager (dock_window);
+        {
+          GimpDockContainer *dock_container = GIMP_DOCK_CONTAINER (dock_window);
+
+          ui_manager = gimp_dock_container_get_ui_manager (dock_container);
+        }
     }
 
   return ui_manager;
diff --git a/app/widgets/gimpdockbook.c b/app/widgets/gimpdockbook.c
index 0825be0..fb08c30 100644
--- a/app/widgets/gimpdockbook.c
+++ b/app/widgets/gimpdockbook.c
@@ -36,6 +36,7 @@
 #include "gimpdockable.h"
 #include "gimpdockbook.h"
 #include "gimpdocked.h"
+#include "gimpdockcontainer.h"
 #include "gimpdockwindow.h"
 #include "gimphelp-ids.h"
 #include "gimpmenufactory.h"
@@ -1076,7 +1077,8 @@ gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
 
   /* EEK */
   dock_window = gimp_dock_window_from_dock (dockbook->p->dock);
-  if (dock_window && gimp_dock_window_get_ui_manager (dock_window))
+  if (dock_window &&
+      gimp_dock_container_get_ui_manager (GIMP_DOCK_CONTAINER (dock_window)))
     {
       const gchar *dialog_id;
 
@@ -1085,10 +1087,13 @@ gimp_dockbook_create_tab_widget (GimpDockbook *dockbook,
 
       if (dialog_id)
         {
-          GimpActionGroup *group;
+          GimpDockContainer *dock_container;
+          GimpActionGroup   *group;
+
+          dock_container = GIMP_DOCK_CONTAINER (dock_window);
 
           group = gimp_ui_manager_get_action_group
-            (gimp_dock_window_get_ui_manager (dock_window), "dialogs");
+            (gimp_dock_container_get_ui_manager (dock_container), "dialogs");
 
           if (group)
             {
diff --git a/app/widgets/gimpdockcontainer.c b/app/widgets/gimpdockcontainer.c
index de63c34..c86e585 100644
--- a/app/widgets/gimpdockcontainer.c
+++ b/app/widgets/gimpdockcontainer.c
@@ -79,6 +79,28 @@ gimp_dock_container_get_docks (GimpDockContainer *container)
 
   if (iface->get_docks)
     return iface->get_docks (container);
-  else
-    return NULL;
+
+  return NULL;
 }
+
+/**
+ * gimp_dock_container_get_ui_manager:
+ * @container: A #GimpDockContainer
+ *
+ * Returns: The #GimpUIManager of the #GimpDockContainer
+ **/
+GimpUIManager *
+gimp_dock_container_get_ui_manager (GimpDockContainer *container)
+{
+  GimpDockContainerInterface *iface;
+
+  g_return_val_if_fail (GIMP_IS_DOCK_CONTAINER (container), NULL);
+
+  iface = GIMP_DOCK_CONTAINER_GET_INTERFACE (container);
+
+  if (iface->get_ui_manager)
+    return iface->get_ui_manager (container);
+
+  return NULL;
+}
+
diff --git a/app/widgets/gimpdockcontainer.h b/app/widgets/gimpdockcontainer.h
index 60c5a74..a43c1ee 100644
--- a/app/widgets/gimpdockcontainer.h
+++ b/app/widgets/gimpdockcontainer.h
@@ -35,12 +35,14 @@ struct _GimpDockContainerInterface
   GTypeInterface base_iface;
 
   /*  virtual functions  */
-  GList *   (* get_docks)        (GimpDockContainer *container);
+  GList         * (* get_docks)      (GimpDockContainer *container);
+  GimpUIManager * (* get_ui_manager) (GimpDockContainer *container);
 };
 
 
-GType     gimp_dock_container_interface_get_type  (void) G_GNUC_CONST;
-GList   * gimp_dock_container_get_docks           (GimpDockContainer *container);
+GType           gimp_dock_container_interface_get_type  (void) G_GNUC_CONST;
+GList         * gimp_dock_container_get_docks           (GimpDockContainer *container);
+GimpUIManager * gimp_dock_container_get_ui_manager      (GimpDockContainer *container);
 
 
 #endif  /*  __GIMP_DOCK_CONTAINER_H__  */
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index ebf4d7b..4a39cf1 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -130,6 +130,9 @@ static gboolean  gimp_dock_window_delete_event            (GtkWidget       *widg
                                                            GdkEventAny     *event);
 static GList *   gimp_dock_window_get_docks               (GimpDockContainer
                                                                            *dock_container);
+static GimpUIManager *
+                 gimp_dock_window_get_ui_manager          (GimpDockContainer
+                                                                           *dock_container);
 
 static gboolean  gimp_dock_window_should_add_to_recent    (GimpDockWindow  *dock_window);
 static void      gimp_dock_window_display_changed         (GimpDockWindow  *dock_window,
@@ -264,7 +267,8 @@ gimp_dock_window_init (GimpDockWindow *dock_window)
 static void
 gimp_dock_window_dock_container_iface_init (GimpDockContainerInterface *iface)
 {
-  iface->get_docks = gimp_dock_window_get_docks;
+  iface->get_docks      = gimp_dock_window_get_docks;
+  iface->get_ui_manager = gimp_dock_window_get_ui_manager;
 }
 
 static void
@@ -699,6 +703,18 @@ gimp_dock_window_get_docks (GimpDockContainer *dock_container)
   return gimp_dock_columns_get_docks (dock_window->p->dock_columns);
 }
 
+static GimpUIManager *
+gimp_dock_window_get_ui_manager (GimpDockContainer *dock_container)
+{
+  GimpDockWindow *dock_window;
+
+  g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_container), NULL);
+
+  dock_window = GIMP_DOCK_WINDOW (dock_container);
+
+  return dock_window->p->ui_manager;
+}
+
 /**
  * gimp_dock_window_should_add_to_recent:
  * @dock_window:
@@ -1014,14 +1030,6 @@ gimp_dock_window_get_id (GimpDockWindow *dock_window)
   return dock_window->p->ID;
 }
 
-GimpUIManager *
-gimp_dock_window_get_ui_manager (GimpDockWindow *dock_window)
-{
-  g_return_val_if_fail (GIMP_IS_DOCK_WINDOW (dock_window), NULL);
-
-  return dock_window->p->ui_manager;
-}
-
 GimpContext *
 gimp_dock_window_get_context (GimpDockWindow *dock_window)
 {
diff --git a/app/widgets/gimpdockwindow.h b/app/widgets/gimpdockwindow.h
index 22a918d..8946d82 100644
--- a/app/widgets/gimpdockwindow.h
+++ b/app/widgets/gimpdockwindow.h
@@ -67,7 +67,6 @@ void                gimp_dock_window_add_dock               (GimpDockWindow    *
                                                              gint               index);
 void                gimp_dock_window_remove_dock            (GimpDockWindow    *dock_window,
                                                              GimpDock          *dock);
-GimpUIManager     * gimp_dock_window_get_ui_manager         (GimpDockWindow    *dock_window);
 GimpContext       * gimp_dock_window_get_context            (GimpDockWindow    *dock);
 GimpDialogFactory * gimp_dock_window_get_dialog_factory     (GimpDockWindow    *dock);
 gboolean            gimp_dock_window_get_auto_follow_active (GimpDockWindow    *menu_dock);
diff --git a/app/widgets/gimpsessioninfo-dock.c b/app/widgets/gimpsessioninfo-dock.c
index af9d557..b12b5a8 100644
--- a/app/widgets/gimpsessioninfo-dock.c
+++ b/app/widgets/gimpsessioninfo-dock.c
@@ -29,6 +29,7 @@
 #include "gimpdialogfactory.h"
 #include "gimpdock.h"
 #include "gimpdockbook.h"
+#include "gimpdockcontainer.h"
 #include "gimpdockwindow.h"
 #include "gimpsessioninfo.h"
 #include "gimpsessioninfo-aux.h"
@@ -195,15 +196,16 @@ gimp_session_info_dock_restore (GimpSessionInfoDock *dock_info,
                                 GdkScreen           *screen,
                                 GimpDockWindow      *dock_window)
 {
-  GtkWidget     *dock       = NULL;
-  GList         *iter       = NULL;
-  GimpUIManager *ui_manager = NULL;
-  gint           n_books    = 0;
+  GimpDockContainer *dock_container = GIMP_DOCK_CONTAINER (dock_window);
+  gint               n_books        = 0;
+  GtkWidget         *dock;
+  GList             *iter;
+  GimpUIManager     *ui_manager;
 
   g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
 
-  ui_manager = gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (dock_window));
+  ui_manager = gimp_dock_container_get_ui_manager (dock_container);
   dock       = gimp_dialog_factory_dialog_new (factory,
                                                screen,
                                                ui_manager,
diff --git a/app/widgets/gimpwidgets-utils.c b/app/widgets/gimpwidgets-utils.c
index 6bf2e22..0a8a708 100644
--- a/app/widgets/gimpwidgets-utils.c
+++ b/app/widgets/gimpwidgets-utils.c
@@ -41,6 +41,7 @@
 
 #include "gimpdialogfactory.h"
 #include "gimpdock.h"
+#include "gimpdockcontainer.h"
 #include "gimpdockwindow.h"
 #include "gimperrordialog.h"
 #include "gimpwidgets-utils.h"
@@ -1106,9 +1107,10 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
                            GdkScreen         *screen,
                            gboolean           toolbox)
 {
-  GtkWidget     *dock_window = NULL;
-  GtkWidget     *dock        = NULL;
-  GimpUIManager *ui_manager  = NULL;
+  GtkWidget         *dock_window;
+  GimpDockContainer *dock_container;
+  GtkWidget         *dock;
+  GimpUIManager     *ui_manager;
 
   g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (factory), NULL);
   g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
@@ -1125,15 +1127,16 @@ gimp_dock_with_window_new (GimpDialogFactory *factory,
                                                 -1 /*view_size*/,
                                                 FALSE /*present*/);
 
-  ui_manager = gimp_dock_window_get_ui_manager (GIMP_DOCK_WINDOW (dock_window));
-  dock       = gimp_dialog_factory_dialog_new (factory,
-                                               screen,
-                                               ui_manager,
-                                               (toolbox ?
-                                                "gimp-toolbox" :
-                                                "gimp-dock"),
-                                               -1 /*view_size*/,
-                                               FALSE /*present*/);
+  dock_container = GIMP_DOCK_CONTAINER (dock_window);
+  ui_manager     = gimp_dock_container_get_ui_manager (dock_container);
+  dock           = gimp_dialog_factory_dialog_new (factory,
+                                                   screen,
+                                                   ui_manager,
+                                                   (toolbox ?
+                                                    "gimp-toolbox" :
+                                                    "gimp-dock"),
+                                                   -1 /*view_size*/,
+                                                   FALSE /*present*/);
 
   if (dock)
     gimp_dock_window_add_dock (GIMP_DOCK_WINDOW (dock_window),



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