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



commit 00c2d15a3aaddc4460dafeebd86c57ef68e9c26e
Author: Martin Nordholts <martinn src gnome org>
Date:   Fri May 13 19:32:16 2011 +0200

    app: Add GimpDockContainer::add_dock()
    
    Add GimpDockContainer::add_dock() and use it in
    gimp_session_info_dock_restore().

 app/widgets/gimpdockcontainer.c    |   24 ++++++++
 app/widgets/gimpdockcontainer.h    |   16 ++++--
 app/widgets/gimpdockwindow.c       |  113 ++++++++++++++++++++----------------
 app/widgets/gimpsessioninfo-dock.c |    6 +-
 4 files changed, 101 insertions(+), 58 deletions(-)
---
diff --git a/app/widgets/gimpdockcontainer.c b/app/widgets/gimpdockcontainer.c
index c86e585..54b9a27 100644
--- a/app/widgets/gimpdockcontainer.c
+++ b/app/widgets/gimpdockcontainer.c
@@ -104,3 +104,27 @@ gimp_dock_container_get_ui_manager (GimpDockContainer *container)
   return NULL;
 }
 
+/**
+ * gimp_dock_container_add_dock:
+ * @container: A #GimpDockContainer
+ * @dock:      The newly created #GimpDock to add to the container.
+ * @dock_info: The #GimpSessionInfoDock the @dock was created from.
+ *
+ * Add @dock that was created from @dock_info to @container.
+ **/
+void
+gimp_dock_container_add_dock (GimpDockContainer   *container,
+                              GimpDock            *dock,
+                              GimpSessionInfoDock *dock_info)
+{
+  GimpDockContainerInterface *iface;
+
+  g_return_if_fail (GIMP_IS_DOCK_CONTAINER (container));
+
+  iface = GIMP_DOCK_CONTAINER_GET_INTERFACE (container);
+
+  if (iface->add_dock)
+    iface->add_dock (container,
+                     dock,
+                     dock_info);
+}
diff --git a/app/widgets/gimpdockcontainer.h b/app/widgets/gimpdockcontainer.h
index a43c1ee..86ffa6e 100644
--- a/app/widgets/gimpdockcontainer.h
+++ b/app/widgets/gimpdockcontainer.h
@@ -35,14 +35,20 @@ struct _GimpDockContainerInterface
   GTypeInterface base_iface;
 
   /*  virtual functions  */
-  GList         * (* get_docks)      (GimpDockContainer *container);
-  GimpUIManager * (* get_ui_manager) (GimpDockContainer *container);
+  GList         * (* get_docks)         (GimpDockContainer   *container);
+  GimpUIManager * (* get_ui_manager)    (GimpDockContainer   *container);
+  void            (* add_dock)          (GimpDockContainer   *container,
+                                         GimpDock            *dock,
+                                         GimpSessionInfoDock *dock_info);
 };
 
 
-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);
+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);
+void            gimp_dock_container_add_dock                   (GimpDockContainer   *container,
+                                                                GimpDock            *dock,
+                                                                GimpSessionInfoDock *dock_info);
 
 
 #endif  /*  __GIMP_DOCK_CONTAINER_H__  */
diff --git a/app/widgets/gimpdockwindow.c b/app/widgets/gimpdockwindow.c
index 4a39cf1..0c3efcb 100644
--- a/app/widgets/gimpdockwindow.c
+++ b/app/widgets/gimpdockwindow.c
@@ -109,56 +109,52 @@ struct _GimpDockWindowPrivate
 };
 
 
-static void      gimp_dock_window_dock_container_iface_init
-                                                          (GimpDockContainerInterface
-                                                                           *iface);
-static void      gimp_dock_window_constructed             (GObject         *object);
-static void      gimp_dock_window_dispose                 (GObject         *object);
-static void      gimp_dock_window_finalize                (GObject         *object);
-static void      gimp_dock_window_set_property            (GObject         *object,
-                                                           guint            property_id,
-                                                           const GValue    *value,
-                                                           GParamSpec      *pspec);
-static void      gimp_dock_window_get_property            (GObject         *object,
-                                                           guint            property_id,
-                                                           GValue          *value,
-                                                           GParamSpec      *pspec);
-
-static void      gimp_dock_window_style_set               (GtkWidget       *widget,
-                                                           GtkStyle        *prev_style);
-static gboolean  gimp_dock_window_delete_event            (GtkWidget       *widget,
-                                                           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,
-                                                           GimpObject      *display,
-                                                           GimpContext     *context);
-static void      gimp_dock_window_image_changed           (GimpDockWindow  *dock_window,
-                                                           GimpImage       *image,
-                                                           GimpContext     *context);
-static void      gimp_dock_window_image_flush             (GimpImage       *image,
-                                                           gboolean         invalidate_preview,
-                                                           GimpDockWindow  *dock_window);
-static void      gimp_dock_window_update_title            (GimpDockWindow  *dock_window);
-static gboolean  gimp_dock_window_update_title_idle       (GimpDockWindow  *dock_window);
-static gchar *   gimp_dock_window_get_description         (GimpDockWindow  *dock_window,
-                                                           gboolean         complete);
-static void      gimp_dock_window_dock_removed            (GimpDockWindow  *dock_window,
-                                                           GimpDock        *dock,
-                                                           GimpDockColumns *dock_columns);
-static void      gimp_dock_window_factory_display_changed (GimpContext     *context,
-                                                           GimpObject      *display,
-                                                           GimpDock        *dock);
-static void      gimp_dock_window_factory_image_changed   (GimpContext     *context,
-                                                           GimpImage       *image,
-                                                           GimpDock        *dock);
-static void      gimp_dock_window_auto_clicked            (GtkWidget       *widget,
-                                                           GimpDock        *dock);
+static void            gimp_dock_window_dock_container_iface_init (GimpDockContainerInterface *iface);
+static void            gimp_dock_window_constructed               (GObject                    *object);
+static void            gimp_dock_window_dispose                   (GObject                    *object);
+static void            gimp_dock_window_finalize                  (GObject                    *object);
+static void            gimp_dock_window_set_property              (GObject                    *object,
+                                                                   guint                       property_id,
+                                                                   const GValue               *value,
+                                                                   GParamSpec                 *pspec);
+static void            gimp_dock_window_get_property              (GObject                    *object,
+                                                                   guint                       property_id,
+                                                                   GValue                     *value,
+                                                                   GParamSpec                 *pspec);
+static void            gimp_dock_window_style_set                 (GtkWidget                  *widget,
+                                                                   GtkStyle                   *prev_style);
+static gboolean        gimp_dock_window_delete_event              (GtkWidget                  *widget,
+                                                                   GdkEventAny                *event);
+static GList         * gimp_dock_window_get_docks                 (GimpDockContainer          *dock_container);
+static GimpUIManager * gimp_dock_window_get_ui_manager            (GimpDockContainer          *dock_container);
+static void            gimp_dock_window_add_dock_from_session     (GimpDockContainer          *dock_container,
+                                                                   GimpDock                   *dock,
+                                                                   GimpSessionInfoDock        *dock_info);
+static gboolean        gimp_dock_window_should_add_to_recent      (GimpDockWindow             *dock_window);
+static void            gimp_dock_window_display_changed           (GimpDockWindow             *dock_window,
+                                                                   GimpObject                 *display,
+                                                                   GimpContext                *context);
+static void            gimp_dock_window_image_changed             (GimpDockWindow             *dock_window,
+                                                                   GimpImage                  *image,
+                                                                   GimpContext                *context);
+static void            gimp_dock_window_image_flush               (GimpImage                  *image,
+                                                                   gboolean                    invalidate_preview,
+                                                                   GimpDockWindow             *dock_window);
+static void            gimp_dock_window_update_title              (GimpDockWindow             *dock_window);
+static gboolean        gimp_dock_window_update_title_idle         (GimpDockWindow             *dock_window);
+static gchar         * gimp_dock_window_get_description           (GimpDockWindow             *dock_window,
+                                                                   gboolean                    complete);
+static void            gimp_dock_window_dock_removed              (GimpDockWindow             *dock_window,
+                                                                   GimpDock                   *dock,
+                                                                   GimpDockColumns            *dock_columns);
+static void            gimp_dock_window_factory_display_changed   (GimpContext                *context,
+                                                                   GimpObject                 *display,
+                                                                   GimpDock                   *dock);
+static void            gimp_dock_window_factory_image_changed     (GimpContext                *context,
+                                                                   GimpImage                  *image,
+                                                                   GimpDock                   *dock);
+static void            gimp_dock_window_auto_clicked              (GtkWidget                  *widget,
+                                                                   GimpDock                   *dock);
 
 
 G_DEFINE_TYPE_WITH_CODE (GimpDockWindow, gimp_dock_window, GIMP_TYPE_WINDOW,
@@ -269,6 +265,7 @@ gimp_dock_window_dock_container_iface_init (GimpDockContainerInterface *iface)
 {
   iface->get_docks      = gimp_dock_window_get_docks;
   iface->get_ui_manager = gimp_dock_window_get_ui_manager;
+  iface->add_dock       = gimp_dock_window_add_dock_from_session;
 }
 
 static void
@@ -715,6 +712,22 @@ gimp_dock_window_get_ui_manager (GimpDockContainer *dock_container)
   return dock_window->p->ui_manager;
 }
 
+static void
+gimp_dock_window_add_dock_from_session (GimpDockContainer   *dock_container,
+                                        GimpDock            *dock,
+                                        GimpSessionInfoDock *dock_info)
+{
+  GimpDockWindow *dock_window;
+
+  g_return_if_fail (GIMP_IS_DOCK_WINDOW (dock_container));
+
+  dock_window = GIMP_DOCK_WINDOW (dock_container);
+
+  gimp_dock_window_add_dock (dock_window,
+                             dock,
+                             -1 /*index*/);
+}
+
 /**
  * gimp_dock_window_should_add_to_recent:
  * @dock_window:
diff --git a/app/widgets/gimpsessioninfo-dock.c b/app/widgets/gimpsessioninfo-dock.c
index b12b5a8..05126f5 100644
--- a/app/widgets/gimpsessioninfo-dock.c
+++ b/app/widgets/gimpsessioninfo-dock.c
@@ -218,9 +218,9 @@ gimp_session_info_dock_restore (GimpSessionInfoDock *dock_info,
   /* Add the dock to the dock window immediately so the stuff in the
    * dock has access to e.g. a dialog factory
    */
-  gimp_dock_window_add_dock (GIMP_DOCK_WINDOW (dock_window),
-                             GIMP_DOCK (dock),
-                             -1);
+  gimp_dock_container_add_dock (dock_container,
+                                GIMP_DOCK (dock),
+                                dock_info);
 
   /* Note that if it is a toolbox, we will get here even though we
    * don't have any books



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