[gimp] app: Add "dialog-factory", "ui-manager" properties to GimpDockColumns



commit 5d79f664d3d08451e456a779b03b65b72578f0ee
Author: Martin Nordholts <martinn src gnome org>
Date:   Thu Jan 7 19:18:03 2010 +0100

    app: Add "dialog-factory", "ui-manager" properties to GimpDockColumns
    
    Add "dialog-factory", "ui-manager" properties to GimpDockColumns and
    let GimpDock look for these before trying to look for a dock window
    which does not exist in single-window mode.

 app/display/gimpimagewindow.c |   10 ++++--
 app/widgets/gimpdock.c        |   48 ++++++++++++++++++++++++++-----
 app/widgets/gimpdockcolumns.c |   63 +++++++++++++++++++++++++++++++++++++----
 app/widgets/gimpdockcolumns.h |   26 ++++++++++-------
 app/widgets/gimpdockwindow.c  |   16 ++++++++++-
 5 files changed, 133 insertions(+), 30 deletions(-)
---
diff --git a/app/display/gimpimagewindow.c b/app/display/gimpimagewindow.c
index 60d721d..329e15d 100644
--- a/app/display/gimpimagewindow.c
+++ b/app/display/gimpimagewindow.c
@@ -311,9 +311,9 @@ gimp_image_window_constructor (GType                  type,
 
   /* Create the left dock columns widget */
   private->left_docks =
-    gimp_dock_columns_new (gimp_get_user_context (private->gimp));
-  gimp_dock_columns_set_context (GIMP_DOCK_COLUMNS (private->left_docks),
-                                 gimp_get_user_context (private->gimp));
+    gimp_dock_columns_new (gimp_get_user_context (private->gimp),
+                           private->dock_factory,
+                           private->menubar_manager);
   gtk_paned_pack1 (GTK_PANED (private->left_hpane), private->left_docks,
                    FALSE, FALSE);
   if (config->single_window_mode)
@@ -341,7 +341,9 @@ gimp_image_window_constructor (GType                  type,
 
   /* Create the right dock columns widget */
   private->right_docks =
-    gimp_dock_columns_new (gimp_get_user_context (private->gimp));
+    gimp_dock_columns_new (gimp_get_user_context (private->gimp),
+                           private->dock_factory,
+                           private->menubar_manager);
   gtk_paned_pack2 (GTK_PANED (private->right_hpane), private->right_docks,
                    FALSE, FALSE);
   if (config->single_window_mode)
diff --git a/app/widgets/gimpdock.c b/app/widgets/gimpdock.c
index b297fa4..3833ad0 100644
--- a/app/widgets/gimpdock.c
+++ b/app/widgets/gimpdock.c
@@ -405,7 +405,7 @@ gimp_dock_update_with_context (GimpDock    *dock,
 GimpContext *
 gimp_dock_get_context (GimpDock *dock)
 {
-  GimpContext     *context      = NULL;
+  GimpContext *context = NULL;
 
   g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
 
@@ -427,7 +427,7 @@ gimp_dock_get_context (GimpDock *dock)
         context = gimp_dock_window_get_context (dock_window);
     }
 
- return context;
+  return context;
 }
 
 /**
@@ -440,13 +440,29 @@ gimp_dock_get_context (GimpDock *dock)
 GimpDialogFactory *
 gimp_dock_get_dialog_factory (GimpDock *dock)
 {
-  GimpDockWindow *dock_window = NULL;
+  GimpDialogFactory *dialog_factory = NULL;
 
   g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
 
-  dock_window = gimp_dock_window_from_dock (dock);
+  /* First try GimpDockColumns */
+  if (! dialog_factory)
+    {
+      GimpDockColumns *dock_columns = gimp_dock_get_dock_columns (dock);
+
+      if (dock_columns)
+        dialog_factory = gimp_dock_columns_get_dialog_factory (dock_columns);
+    }
+
+  /* Then GimpDockWindow */
+  if (! dialog_factory)
+    {
+      GimpDockWindow *dock_window = gimp_dock_window_from_dock (dock);
+
+      if (dock_window)
+        dialog_factory = gimp_dock_window_get_dialog_factory (dock_window);
+    }
 
-  return gimp_dock_window_get_dialog_factory (dock_window);
+  return dialog_factory;
 }
 
 /**
@@ -459,13 +475,29 @@ gimp_dock_get_dialog_factory (GimpDock *dock)
 GimpUIManager *
 gimp_dock_get_ui_manager (GimpDock *dock)
 {
-  GimpDockWindow *dock_window = NULL;
+  GimpUIManager *ui_manager = NULL;
 
   g_return_val_if_fail (GIMP_IS_DOCK (dock), NULL);
 
-  dock_window = gimp_dock_window_from_dock (dock);
+  /* First try GimpDockColumns */
+  if (! ui_manager)
+    {
+      GimpDockColumns *dock_columns = gimp_dock_get_dock_columns (dock);
+
+      if (dock_columns)
+        ui_manager = gimp_dock_columns_get_ui_manager (dock_columns);
+    }
+
+  /* Then GimpDockWindow */
+  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);
+    }
 
-  return gimp_dock_window_get_ui_manager (dock_window);
+  return ui_manager;
 }
 
 GList *
diff --git a/app/widgets/gimpdockcolumns.c b/app/widgets/gimpdockcolumns.c
index f3fbb17..d7d1dde 100644
--- a/app/widgets/gimpdockcolumns.c
+++ b/app/widgets/gimpdockcolumns.c
@@ -40,6 +40,7 @@
 #include "gimpmenudock.h"
 #include "gimppanedbox.h"
 #include "gimptoolbox.h"
+#include "gimpuimanager.h"
 
 #include "gimp-log.h"
 
@@ -47,7 +48,9 @@
 enum
 {
   PROP_0,
-  PROP_CONTEXT
+  PROP_CONTEXT,
+  PROP_DIALOG_FACTORY,
+  PROP_UI_MANAGER
 };
 
 enum
@@ -60,11 +63,13 @@ enum
 
 struct _GimpDockColumnsPrivate
 {
-  GimpContext *context;
+  GimpContext       *context;
+  GimpDialogFactory *dialog_factory;
+  GimpUIManager     *ui_manager;
 
-  GList       *docks;
+  GList             *docks;
 
-  GtkWidget   *paned_hbox;
+  GtkWidget         *paned_hbox;
 };
 
 
@@ -112,6 +117,18 @@ gimp_dock_columns_class_init (GimpDockColumnsClass *klass)
                                                         GIMP_TYPE_CONTEXT,
                                                         GIMP_PARAM_WRITABLE |
                                                         G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class, PROP_DIALOG_FACTORY,
+                                   g_param_spec_object ("dialog-factory",
+                                                        NULL, NULL,
+                                                        GIMP_TYPE_DIALOG_FACTORY,
+                                                        GIMP_PARAM_WRITABLE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+  g_object_class_install_property (object_class, PROP_UI_MANAGER,
+                                   g_param_spec_object ("ui-manager",
+                                                        NULL, NULL,
+                                                        GIMP_TYPE_UI_MANAGER,
+                                                        GIMP_PARAM_WRITABLE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
 
   dock_columns_signals[DOCK_ADDED] =
     g_signal_new ("dock-added",
@@ -165,6 +182,12 @@ gimp_dock_columns_set_property (GObject      *object,
     case PROP_CONTEXT:
       dock_columns->p->context = g_value_get_object (value);
       break;
+    case PROP_DIALOG_FACTORY:
+      dock_columns->p->dialog_factory = g_value_get_object (value);
+      break;
+    case PROP_UI_MANAGER:
+      dock_columns->p->ui_manager = g_value_get_object (value);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -185,6 +208,12 @@ gimp_dock_columns_get_property (GObject    *object,
     case PROP_CONTEXT:
       g_value_set_object (value, dock_columns->p->context);
       break;
+    case PROP_DIALOG_FACTORY:
+      g_value_set_object (value, dock_columns->p->dialog_factory);
+      break;
+    case PROP_UI_MANAGER:
+      g_value_set_object (value, dock_columns->p->ui_manager);
+      break;
 
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
@@ -259,12 +288,18 @@ gimp_dock_columns_dock_book_removed (GimpDockColumns *dock_columns,
  * Returns: A new #GimpDockColumns.
  **/
 GtkWidget *
-gimp_dock_columns_new (GimpContext *context)
+gimp_dock_columns_new (GimpContext       *context,
+                       GimpDialogFactory *dialog_factory,
+                       GimpUIManager     *ui_manager)
 {
   g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+  g_return_val_if_fail (GIMP_IS_DIALOG_FACTORY (dialog_factory), NULL);
+  g_return_val_if_fail (GIMP_IS_UI_MANAGER (ui_manager), NULL);
 
   return g_object_new (GIMP_TYPE_DOCK_COLUMNS,
-                       "context", context,
+                       "context",        context,
+                       "dialog-factory", dialog_factory,
+                       "ui-manager",     ui_manager,
                        NULL);
 }
 
@@ -351,3 +386,19 @@ gimp_dock_columns_set_context (GimpDockColumns *dock_columns,
 
   dock_columns->p->context = context;
 }
+
+GimpDialogFactory *
+gimp_dock_columns_get_dialog_factory (GimpDockColumns *dock_columns)
+{
+  g_return_val_if_fail (GIMP_IS_DOCK_COLUMNS (dock_columns), NULL);
+
+  return dock_columns->p->dialog_factory;
+}
+
+GimpUIManager *
+gimp_dock_columns_get_ui_manager (GimpDockColumns *dock_columns)
+{
+  g_return_val_if_fail (GIMP_IS_DOCK_COLUMNS (dock_columns), NULL);
+
+  return dock_columns->p->ui_manager;
+}
diff --git a/app/widgets/gimpdockcolumns.h b/app/widgets/gimpdockcolumns.h
index 15ad465..3555a64 100644
--- a/app/widgets/gimpdockcolumns.h
+++ b/app/widgets/gimpdockcolumns.h
@@ -57,17 +57,21 @@ struct _GimpDockColumnsClass
 };
 
 
-GType               gimp_dock_columns_get_type       (void) G_GNUC_CONST;
-GtkWidget         * gimp_dock_columns_new            (GimpContext     *context);
-void                gimp_dock_columns_add_dock       (GimpDockColumns *dock_columns,
-                                                      GimpDock        *dock,
-                                                      gint             index);
-void                gimp_dock_columns_remove_dock    (GimpDockColumns *dock_columns,
-                                                      GimpDock        *dock);
-GList             * gimp_dock_columns_get_docks      (GimpDockColumns *dock_columns);
-GimpContext       * gimp_dock_columns_get_context    (GimpDockColumns *dock_columns);
-void                gimp_dock_columns_set_context    (GimpDockColumns *dock_columns,
-                                                      GimpContext     *context);
+GType               gimp_dock_columns_get_type           (void) G_GNUC_CONST;
+GtkWidget         * gimp_dock_columns_new                (GimpContext       *context,
+                                                          GimpDialogFactory *dialog_factory,
+                                                          GimpUIManager     *ui_manager);
+void                gimp_dock_columns_add_dock           (GimpDockColumns   *dock_columns,
+                                                          GimpDock          *dock,
+                                                          gint               index);
+void                gimp_dock_columns_remove_dock        (GimpDockColumns   *dock_columns,
+                                                          GimpDock          *dock);
+GList             * gimp_dock_columns_get_docks          (GimpDockColumns   *dock_columns);
+GimpContext       * gimp_dock_columns_get_context        (GimpDockColumns   *dock_columns);
+void                gimp_dock_columns_set_context        (GimpDockColumns   *dock_columns,
+                                                          GimpContext       *context);
+GimpDialogFactory * gimp_dock_columns_get_dialog_factory (GimpDockColumns   *dock_columns);
+GimpUIManager     * gimp_dock_columns_get_ui_manager     (GimpDockColumns   *dock_columns);
 
 
 #endif /* __GIMP_DOCK_COLUMNS_H__ */
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index 13d316b..a1982cd 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -366,7 +366,9 @@ gimp_dock_window_constructor (GType                  type,
      * GimpImageWindow so docks can get the GimpContext there as well
      */
     dock_window->p->dock_columns =
-      GIMP_DOCK_COLUMNS (gimp_dock_columns_new (dock_window->p->context));
+      GIMP_DOCK_COLUMNS (gimp_dock_columns_new (dock_window->p->context,
+                                                dock_window->p->dialog_factory,
+                                                dock_window->p->ui_manager));
     gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (dock_window->p->dock_columns),
                         TRUE, TRUE, 0);
     gtk_widget_show (GTK_WIDGET (dock_window->p->dock_columns));
@@ -376,6 +378,18 @@ gimp_dock_window_constructor (GType                  type,
                              G_CONNECT_SWAPPED);
   }
 
+  if (dock_window->p->auto_follow_active)
+    {
+      if (gimp_context_get_display (gimp_dialog_factory_get_context (dock_window->p->dialog_factory)))
+        gimp_context_copy_property (gimp_dialog_factory_get_context (dock_window->p->dialog_factory),
+                                    dock_window->p->context,
+                                    GIMP_CONTEXT_PROP_DISPLAY);
+      else
+        gimp_context_copy_property (gimp_dialog_factory_get_context (dock_window->p->dialog_factory),
+                                    dock_window->p->context,
+                                    GIMP_CONTEXT_PROP_IMAGE);
+    }
+
   g_signal_connect_object (gimp_dialog_factory_get_context (dock_window->p->dialog_factory), "display-changed",
                            G_CALLBACK (gimp_dock_window_factory_display_changed),
                            dock_window,



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