[gimp] app: add view-type, container and context props to GimpContainerEditor



commit bef55fbb6610379e714ef59f47189059e9459f32
Author: Michael Natterer <mitch gimp org>
Date:   Sun Oct 9 20:40:56 2011 +0200

    app: add view-type, container and context props to GimpContainerEditor
    
    and remove them from the various public construct() functions. Had to
    change construction in GimpDataFactoryView slightly because of GObject
    construct property constraints.

 app/widgets/gimpbrushfactoryview.c      |    5 +-
 app/widgets/gimpbufferview.c            |    8 +-
 app/widgets/gimpcontainereditor.c       |  180 +++++++++++++++++++++++++++---
 app/widgets/gimpcontainereditor.h       |   10 +-
 app/widgets/gimpcontainerpopup.c        |   10 +-
 app/widgets/gimpdatafactoryview.c       |   42 +++++---
 app/widgets/gimpdatafactoryview.h       |    2 -
 app/widgets/gimpdocumentview.c          |   11 ++-
 app/widgets/gimpdynamicsfactoryview.c   |   10 +-
 app/widgets/gimpfontview.c              |   11 ++-
 app/widgets/gimpimageview.c             |   11 ++-
 app/widgets/gimppatternfactoryview.c    |    8 +-
 app/widgets/gimptemplateview.c          |   11 ++-
 app/widgets/gimptoolpresetfactoryview.c |    8 +-
 14 files changed, 253 insertions(+), 74 deletions(-)
---
diff --git a/app/widgets/gimpbrushfactoryview.c b/app/widgets/gimpbrushfactoryview.c
index 05d58c4..352ee19 100644
--- a/app/widgets/gimpbrushfactoryview.c
+++ b/app/widgets/gimpbrushfactoryview.c
@@ -124,6 +124,7 @@ gimp_brush_factory_view_new (GimpViewType     view_type,
   GimpContainerEditor  *editor;
 
   g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
   g_return_val_if_fail (view_size > 0 &&
                         view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
   g_return_val_if_fail (view_border_width >= 0 &&
@@ -131,14 +132,14 @@ gimp_brush_factory_view_new (GimpViewType     view_type,
                         NULL);
 
   factory_view = g_object_new (GIMP_TYPE_BRUSH_FACTORY_VIEW,
+                               "view-type",    view_type,
                                "data-factory", factory,
+                               "context",      context,
                                NULL);
 
   factory_view->change_brush_spacing = change_brush_spacing;
 
   if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
-                                          view_type,
-                                          context,
                                           view_size, view_border_width,
                                           menu_factory, "<Brushes>",
                                           "/brushes-popup",
diff --git a/app/widgets/gimpbufferview.c b/app/widgets/gimpbufferview.c
index 63aa120..029094f 100644
--- a/app/widgets/gimpbufferview.c
+++ b/app/widgets/gimpbufferview.c
@@ -127,11 +127,13 @@ gimp_buffer_view_new (GimpViewType     view_type,
   GtkWidget           *frame;
   GtkWidget           *hbox;
 
-  buffer_view = g_object_new (GIMP_TYPE_BUFFER_VIEW, NULL);
+  buffer_view = g_object_new (GIMP_TYPE_BUFFER_VIEW,
+                              "view-type", view_type,
+                              "container", container,
+                              "context",   context,
+                              NULL);
 
   if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (buffer_view),
-                                         view_type,
-                                         container, context,
                                          view_size, view_border_width,
                                          menu_factory, "<Buffers>",
                                          "/buffers-popup"))
diff --git a/app/widgets/gimpcontainereditor.c b/app/widgets/gimpcontainereditor.c
index 84c31fb..b17e374 100644
--- a/app/widgets/gimpcontainereditor.c
+++ b/app/widgets/gimpcontainereditor.c
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpcontainereditor.c
- * Copyright (C) 2001 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2001-2011 Michael Natterer <mitch gimp org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -41,8 +41,36 @@
 #include "gimpuimanager.h"
 
 
+enum
+{
+  PROP_0,
+  PROP_VIEW_TYPE,
+  PROP_CONTAINER,
+  PROP_CONTEXT
+};
+
+
+struct _GimpContainerEditorPrivate
+{
+  GimpViewType   view_type;
+  GimpContainer *container;
+  GimpContext   *context;
+};
+
+
 static void  gimp_container_editor_docked_iface_init (GimpDockedInterface *iface);
 
+static void   gimp_container_editor_constructed      (GObject             *object);
+static void   gimp_container_editor_dispose          (GObject             *object);
+static void   gimp_container_editor_set_property     (GObject             *object,
+                                                      guint                property_id,
+                                                      const GValue        *value,
+                                                      GParamSpec          *pspec);
+static void   gimp_container_editor_get_property     (GObject             *object,
+                                                      guint                property_id,
+                                                      GValue              *value,
+                                                      GParamSpec          *pspec);
+
 static gboolean gimp_container_editor_select_item    (GtkWidget           *widget,
                                                       GimpViewable        *viewable,
                                                       gpointer             insert_data,
@@ -84,9 +112,40 @@ G_DEFINE_TYPE_WITH_CODE (GimpContainerEditor, gimp_container_editor,
 static void
 gimp_container_editor_class_init (GimpContainerEditorClass *klass)
 {
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->constructed   = gimp_container_editor_constructed;
+  object_class->dispose       = gimp_container_editor_dispose;
+  object_class->set_property  = gimp_container_editor_set_property;
+  object_class->get_property  = gimp_container_editor_get_property;
+
   klass->select_item     = NULL;
   klass->activate_item   = NULL;
   klass->context_item    = gimp_container_editor_real_context_item;
+
+  g_object_class_install_property (object_class, PROP_VIEW_TYPE,
+                                   g_param_spec_enum ("view-type",
+                                                      NULL, NULL,
+                                                      GIMP_TYPE_VIEW_TYPE,
+                                                      GIMP_VIEW_TYPE_LIST,
+                                                      GIMP_PARAM_READWRITE |
+                                                      G_PARAM_CONSTRUCT_ONLY));
+
+  g_object_class_install_property (object_class, PROP_CONTAINER,
+                                   g_param_spec_object ("container",
+                                                        NULL, NULL,
+                                                        GIMP_TYPE_CONTAINER,
+                                                        GIMP_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+
+  g_object_class_install_property (object_class, PROP_CONTEXT,
+                                   g_param_spec_object ("context",
+                                                        NULL, NULL,
+                                                        GIMP_TYPE_CONTEXT,
+                                                        GIMP_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
+
+  g_type_class_add_private (klass, sizeof (GimpContainerEditorPrivate));
 }
 
 static void
@@ -106,14 +165,101 @@ gimp_container_editor_init (GimpContainerEditor *editor)
   gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
                                   GTK_ORIENTATION_VERTICAL);
 
-  editor->view = NULL;
+  editor->priv = G_TYPE_INSTANCE_GET_PRIVATE (editor,
+                                              GIMP_TYPE_CONTAINER_EDITOR,
+                                              GimpContainerEditorPrivate);
+}
+
+static void
+gimp_container_editor_constructed (GObject *object)
+{
+  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (object);
+
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
+
+  g_assert (GIMP_IS_CONTAINER (editor->priv->container));
+  g_assert (GIMP_IS_CONTEXT (editor->priv->context));
+}
+
+static void
+gimp_container_editor_dispose (GObject *object)
+{
+  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (object);
+
+  if (editor->priv->container)
+    {
+      g_object_unref (editor->priv->container);
+      editor->priv->container = NULL;
+    }
+
+  if (editor->priv->context)
+    {
+      g_object_unref (editor->priv->context);
+      editor->priv->context = NULL;
+    }
+
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
+static void
+gimp_container_editor_set_property (GObject      *object,
+                                    guint         property_id,
+                                    const GValue *value,
+                                    GParamSpec   *pspec)
+{
+  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (object);
+
+  switch (property_id)
+    {
+    case PROP_VIEW_TYPE:
+      editor->priv->view_type = g_value_get_enum (value);
+      break;
+
+    case PROP_CONTAINER:
+      editor->priv->container = g_value_dup_object (value);
+      break;
+
+    case PROP_CONTEXT:
+      editor->priv->context = g_value_dup_object (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
+}
+
+static void
+gimp_container_editor_get_property (GObject    *object,
+                                    guint       property_id,
+                                    GValue     *value,
+                                    GParamSpec *pspec)
+{
+  GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (object);
+
+  switch (property_id)
+    {
+    case PROP_VIEW_TYPE:
+      g_value_set_enum (value, editor->priv->view_type);
+      break;
+
+    case PROP_CONTAINER:
+      g_value_set_object (value, editor->priv->container);
+      break;
+
+    case PROP_CONTEXT:
+      g_value_set_object (value, editor->priv->context);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+      break;
+    }
 }
 
 gboolean
 gimp_container_editor_construct (GimpContainerEditor *editor,
-                                 GimpViewType         view_type,
-                                 GimpContainer       *container,
-                                 GimpContext         *context,
                                  gint                 view_size,
                                  gint                 view_border_width,
                                  GimpMenuFactory     *menu_factory,
@@ -121,8 +267,6 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
                                  const gchar         *ui_identifier)
 {
   g_return_val_if_fail (GIMP_IS_CONTAINER_EDITOR (editor), FALSE);
-  g_return_val_if_fail (GIMP_IS_CONTAINER (container), FALSE);
-  g_return_val_if_fail (GIMP_IS_CONTEXT (context), FALSE);
   g_return_val_if_fail (view_size > 0 &&
                         view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, FALSE);
   g_return_val_if_fail (view_border_width >= 0 &&
@@ -131,19 +275,19 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
   g_return_val_if_fail (menu_factory == NULL ||
                         GIMP_IS_MENU_FACTORY (menu_factory), FALSE);
 
-  switch (view_type)
+  switch (editor->priv->view_type)
     {
     case GIMP_VIEW_TYPE_GRID:
 #if 0
       editor->view =
-        GIMP_CONTAINER_VIEW (gimp_container_icon_view_new (container,
-                                                           context,
+        GIMP_CONTAINER_VIEW (gimp_container_icon_view_new (editor->priv->container,
+                                                           editor->priv->context,
                                                            view_size,
                                                            view_border_width));
 #else
       editor->view =
-        GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (container,
-                                                           context,
+        GIMP_CONTAINER_VIEW (gimp_container_grid_view_new (editor->priv->container,
+                                                           editor->priv->context,
                                                            view_size,
                                                            view_border_width));
 #endif
@@ -151,8 +295,8 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
 
     case GIMP_VIEW_TYPE_LIST:
       editor->view =
-        GIMP_CONTAINER_VIEW (gimp_container_tree_view_new (container,
-                                                           context,
+        GIMP_CONTAINER_VIEW (gimp_container_tree_view_new (editor->priv->container,
+                                                           editor->priv->context,
                                                            view_size,
                                                            view_border_width));
       break;
@@ -162,9 +306,9 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
       return FALSE;
     }
 
-  if (GIMP_IS_LIST (container))
+  if (GIMP_IS_LIST (editor->priv->container))
     gimp_container_view_set_reorderable (GIMP_CONTAINER_VIEW (editor->view),
-                                         ! GIMP_LIST (container)->sort_func);
+                                         ! GIMP_LIST (editor->priv->container)->sort_func);
 
   if (menu_factory && menu_identifier && ui_identifier)
     gimp_editor_create_menu (GIMP_EDITOR (editor->view),
@@ -186,8 +330,8 @@ gimp_container_editor_construct (GimpContainerEditor *editor,
                            editor, 0);
 
   {
-    GimpObject *object = gimp_context_get_by_type (context,
-                                                   gimp_container_get_children_type (container));
+    GimpObject *object = gimp_context_get_by_type (editor->priv->context,
+                                                   gimp_container_get_children_type (editor->priv->container));
 
     gimp_container_editor_select_item (GTK_WIDGET (editor->view),
                                        (GimpViewable *) object, NULL,
diff --git a/app/widgets/gimpcontainereditor.h b/app/widgets/gimpcontainereditor.h
index 0cecbba..555bf1e 100644
--- a/app/widgets/gimpcontainereditor.h
+++ b/app/widgets/gimpcontainereditor.h
@@ -2,7 +2,7 @@
  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
  *
  * gimpcontainereditor.h
- * Copyright (C) 2001 Michael Natterer <mitch gimp org>
+ * Copyright (C) 2001-2011 Michael Natterer <mitch gimp org>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -30,13 +30,16 @@
 #define GIMP_CONTAINER_EDITOR_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CONTAINER_EDITOR, GimpContainerEditorClass))
 
 
-typedef struct _GimpContainerEditorClass  GimpContainerEditorClass;
+typedef struct _GimpContainerEditorPrivate GimpContainerEditorPrivate;
+typedef struct _GimpContainerEditorClass   GimpContainerEditorClass;
 
 struct _GimpContainerEditor
 {
   GtkBox             parent_instance;
 
   GimpContainerView *view;
+
+  GimpContainerEditorPrivate *priv;
 };
 
 struct _GimpContainerEditorClass
@@ -62,9 +65,6 @@ void             gimp_container_editor_set_selection_mode (GimpContainerEditor *
 /*  protected  */
 
 gboolean  gimp_container_editor_construct (GimpContainerEditor *editor,
-                                           GimpViewType         view_type,
-                                           GimpContainer       *container,
-                                           GimpContext         *context,
                                            gint                 view_size,
                                            gint                 view_border_width,
                                            GimpMenuFactory     *menu_factory,
diff --git a/app/widgets/gimpcontainerpopup.c b/app/widgets/gimpcontainerpopup.c
index fabe1a5..bb08084 100644
--- a/app/widgets/gimpcontainerpopup.c
+++ b/app/widgets/gimpcontainerpopup.c
@@ -549,11 +549,13 @@ gimp_container_popup_create_view (GimpContainerPopup *popup)
   GimpEditor *editor;
   GtkWidget  *button;
 
-  popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR, NULL);
+  popup->editor = g_object_new (GIMP_TYPE_CONTAINER_EDITOR,
+                                "view-type", popup->view_type,
+                                "container", popup->container,
+                                "context",   popup->context,
+                                NULL);
+
   gimp_container_editor_construct (popup->editor,
-                                   popup->view_type,
-                                   popup->container,
-                                   popup->context,
                                    popup->view_size,
                                    popup->view_border_width,
                                    NULL, NULL, NULL);
diff --git a/app/widgets/gimpdatafactoryview.c b/app/widgets/gimpdatafactoryview.c
index d2346ff..068348f 100644
--- a/app/widgets/gimpdatafactoryview.c
+++ b/app/widgets/gimpdatafactoryview.c
@@ -77,7 +77,10 @@ struct _GimpDataFactoryViewPriv
 };
 
 
-static void   gimp_data_factory_view_constructed    (GObject             *object);
+static GObject *
+              gimp_data_factory_view_constructor    (GType                type,
+                                                     guint                n_construct_params,
+                                                     GObjectConstructParam *construct_params);
 static void   gimp_data_factory_view_dispose        (GObject             *object);
 static void   gimp_data_factory_view_set_property   (GObject             *object,
                                                      guint                property_id,
@@ -110,7 +113,7 @@ gimp_data_factory_view_class_init (GimpDataFactoryViewClass *klass)
   GObjectClass             *object_class = G_OBJECT_CLASS (klass);
   GimpContainerEditorClass *editor_class = GIMP_CONTAINER_EDITOR_CLASS (klass);
 
-  object_class->constructed   = gimp_data_factory_view_constructed;
+  object_class->constructor   = gimp_data_factory_view_constructor;
   object_class->dispose       = gimp_data_factory_view_dispose;
   object_class->set_property  = gimp_data_factory_view_set_property;
   object_class->get_property  = gimp_data_factory_view_get_property;
@@ -146,18 +149,33 @@ gimp_data_factory_view_init (GimpDataFactoryView *view)
   view->priv->refresh_button   = NULL;
 }
 
-static void
-gimp_data_factory_view_constructed (GObject *object)
+static GObject *
+gimp_data_factory_view_constructor (GType                  type,
+                                    guint                  n_construct_params,
+                                    GObjectConstructParam *construct_params)
 {
-  GimpDataFactoryView *factory_view = GIMP_DATA_FACTORY_VIEW (object);
+  GimpDataFactoryView *factory_view;
+  GObject             *object;
 
-  if (G_OBJECT_CLASS (parent_class)->constructed)
-    G_OBJECT_CLASS (parent_class)->constructed (object);
+  object = G_OBJECT_CLASS (parent_class)->constructor (type,
+                                                       n_construct_params,
+                                                       construct_params);
+
+  factory_view = GIMP_DATA_FACTORY_VIEW (object);
 
   g_assert (GIMP_IS_DATA_FACTORY (factory_view->priv->factory));
 
   factory_view->priv->tagged_container =
     gimp_tagged_container_new (gimp_data_factory_get_container (factory_view->priv->factory));
+
+  /* this must happen in constructor(), because doing it in
+   * set_property() warns about wrong construct property usage
+   */
+  g_object_set (object,
+                "container", factory_view->priv->tagged_container,
+                NULL);
+
+  return object;
 }
 
 static void
@@ -234,14 +252,15 @@ gimp_data_factory_view_new (GimpViewType      view_type,
   GimpDataFactoryView *factory_view;
 
   g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
 
   factory_view = g_object_new (GIMP_TYPE_DATA_FACTORY_VIEW,
+                               "view-type",    view_type,
                                "data-factory", factory,
+                               "context",      context,
                                NULL);
 
   if (! gimp_data_factory_view_construct (factory_view,
-                                          view_type,
-                                          context,
                                           view_size,
                                           view_border_width,
                                           menu_factory,
@@ -308,8 +327,6 @@ gimp_data_factory_view_have (GimpDataFactoryView *factory_view,
 
 gboolean
 gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
-                                  GimpViewType         view_type,
-                                  GimpContext         *context,
                                   gint                 view_size,
                                   gint                 view_border_width,
                                   GimpMenuFactory     *menu_factory,
@@ -328,9 +345,6 @@ gimp_data_factory_view_construct (GimpDataFactoryView *factory_view,
                         FALSE);
 
   if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (factory_view),
-                                         view_type,
-                                         factory_view->priv->tagged_container,
-                                         context,
                                          view_size, view_border_width,
                                          menu_factory, menu_identifier,
                                          ui_identifier))
diff --git a/app/widgets/gimpdatafactoryview.h b/app/widgets/gimpdatafactoryview.h
index 9124a08..c870d19 100644
--- a/app/widgets/gimpdatafactoryview.h
+++ b/app/widgets/gimpdatafactoryview.h
@@ -73,8 +73,6 @@ gboolean          gimp_data_factory_view_have                 (GimpDataFactoryVi
 /*  protected  */
 
 gboolean          gimp_data_factory_view_construct            (GimpDataFactoryView *factory_view,
-                                                               GimpViewType         view_type,
-                                                               GimpContext         *context,
                                                                gint                 view_size,
                                                                gint                 view_border_width,
                                                                GimpMenuFactory     *menu_factory,
diff --git a/app/widgets/gimpdocumentview.c b/app/widgets/gimpdocumentview.c
index efa329d..3189b61 100644
--- a/app/widgets/gimpdocumentview.c
+++ b/app/widgets/gimpdocumentview.c
@@ -80,11 +80,16 @@ gimp_document_view_new (GimpViewType     view_type,
   GimpDocumentView    *document_view;
   GimpContainerEditor *editor;
 
-  document_view = g_object_new (GIMP_TYPE_DOCUMENT_VIEW, NULL);
+  g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+  document_view = g_object_new (GIMP_TYPE_DOCUMENT_VIEW,
+                                "view-type", view_type,
+                                "container", container,
+                                "context",   context,
+                                NULL);
 
   if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (document_view),
-                                         view_type,
-                                         container, context,
                                          view_size, view_border_width,
                                          menu_factory, "<Documents>",
                                          "/documents-popup"))
diff --git a/app/widgets/gimpdynamicsfactoryview.c b/app/widgets/gimpdynamicsfactoryview.c
index a15ef1d..3050fa3 100644
--- a/app/widgets/gimpdynamicsfactoryview.c
+++ b/app/widgets/gimpdynamicsfactoryview.c
@@ -26,12 +26,9 @@
 
 #include "widgets-types.h"
 
-#include "core/gimpcontainer.h"
+#include "core/gimpcontext.h"
 #include "core/gimpdatafactory.h"
-#include "core/gimpviewable.h"
 
-#include "gimpcontainerview.h"
-#include "gimpeditor.h"
 #include "gimpdynamicsfactoryview.h"
 #include "gimpviewrenderer.h"
 
@@ -61,6 +58,7 @@ gimp_dynamics_factory_view_new (GimpViewType      view_type,
   GimpDynamicsFactoryView *factory_view;
 
   g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
   g_return_val_if_fail (view_size > 0 &&
                         view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
   g_return_val_if_fail (view_border_width >= 0 &&
@@ -68,12 +66,12 @@ gimp_dynamics_factory_view_new (GimpViewType      view_type,
                         NULL);
 
   factory_view = g_object_new (GIMP_TYPE_DYNAMICS_FACTORY_VIEW,
+                               "view-type",    view_type,
                                "data-factory", factory,
+                               "context",      context,
                                NULL);
 
   if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
-                                          view_type,
-                                          context,
                                           view_size, view_border_width,
                                           menu_factory, "<Dynamics>",
                                           "/dynamics-popup",
diff --git a/app/widgets/gimpfontview.c b/app/widgets/gimpfontview.c
index 7ffe534..1a217bc 100644
--- a/app/widgets/gimpfontview.c
+++ b/app/widgets/gimpfontview.c
@@ -72,11 +72,16 @@ gimp_font_view_new (GimpViewType     view_type,
   GimpFontView        *font_view;
   GimpContainerEditor *editor;
 
-  font_view = g_object_new (GIMP_TYPE_FONT_VIEW, NULL);
+  g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+  font_view = g_object_new (GIMP_TYPE_FONT_VIEW,
+                            "view-type", view_type,
+                            "container", container,
+                            "context",   context,
+                            NULL);
 
   if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (font_view),
-                                         view_type,
-                                         container,context,
                                          view_size, view_border_width,
                                          menu_factory, "<Fonts>",
                                          "/fonts-popup"))
diff --git a/app/widgets/gimpimageview.c b/app/widgets/gimpimageview.c
index 569c8d7..b05cffe 100644
--- a/app/widgets/gimpimageview.c
+++ b/app/widgets/gimpimageview.c
@@ -76,11 +76,16 @@ gimp_image_view_new (GimpViewType     view_type,
   GimpImageView       *image_view;
   GimpContainerEditor *editor;
 
-  image_view = g_object_new (GIMP_TYPE_IMAGE_VIEW, NULL);
+  g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+  image_view = g_object_new (GIMP_TYPE_IMAGE_VIEW,
+                             "view-type", view_type,
+                             "container", container,
+                             "context",   context,
+                             NULL);
 
   if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (image_view),
-                                         view_type,
-                                         container, context,
                                          view_size, view_border_width,
                                          menu_factory, "<Images>",
                                          "/images-popup"))
diff --git a/app/widgets/gimppatternfactoryview.c b/app/widgets/gimppatternfactoryview.c
index c5a1da2..216e788 100644
--- a/app/widgets/gimppatternfactoryview.c
+++ b/app/widgets/gimppatternfactoryview.c
@@ -26,11 +26,10 @@
 
 #include "widgets-types.h"
 
-#include "core/gimpcontainer.h"
+#include "core/gimpcontext.h"
 #include "core/gimpdatafactory.h"
 #include "core/gimpviewable.h"
 
-#include "gimpcontainerview.h"
 #include "gimpeditor.h"
 #include "gimppatternfactoryview.h"
 #include "gimpviewrenderer.h"
@@ -62,6 +61,7 @@ gimp_pattern_factory_view_new (GimpViewType      view_type,
   GimpContainerEditor    *editor;
 
   g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
   g_return_val_if_fail (view_size > 0 &&
                         view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
   g_return_val_if_fail (view_border_width >= 0 &&
@@ -69,12 +69,12 @@ gimp_pattern_factory_view_new (GimpViewType      view_type,
                         NULL);
 
   factory_view = g_object_new (GIMP_TYPE_PATTERN_FACTORY_VIEW,
+                               "view-type",    view_type,
                                "data-factory", factory,
+                               "context",      context,
                                NULL);
 
   if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
-                                          view_type,
-                                          context,
                                           view_size, view_border_width,
                                           menu_factory, "<Patterns>",
                                           "/patterns-popup",
diff --git a/app/widgets/gimptemplateview.c b/app/widgets/gimptemplateview.c
index b88f96f..79ad705 100644
--- a/app/widgets/gimptemplateview.c
+++ b/app/widgets/gimptemplateview.c
@@ -91,11 +91,16 @@ gimp_template_view_new (GimpViewType     view_type,
   GimpTemplateView    *template_view;
   GimpContainerEditor *editor;
 
-  template_view = g_object_new (GIMP_TYPE_TEMPLATE_VIEW, NULL);
+  g_return_val_if_fail (GIMP_IS_CONTAINER (container), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
+
+  template_view = g_object_new (GIMP_TYPE_TEMPLATE_VIEW,
+                                "view-type", view_type,
+                                "container", container,
+                                "context",   context,
+                                NULL);
 
   if (! gimp_container_editor_construct (GIMP_CONTAINER_EDITOR (template_view),
-                                         view_type,
-                                         container, context,
                                          view_size, view_border_width,
                                          menu_factory, "<Templates>",
                                          "/templates-popup"))
diff --git a/app/widgets/gimptoolpresetfactoryview.c b/app/widgets/gimptoolpresetfactoryview.c
index e62259b..dbdf112 100644
--- a/app/widgets/gimptoolpresetfactoryview.c
+++ b/app/widgets/gimptoolpresetfactoryview.c
@@ -26,11 +26,10 @@
 
 #include "widgets-types.h"
 
-#include "core/gimpcontainer.h"
+#include "core/gimpcontext.h"
 #include "core/gimpdatafactory.h"
 #include "core/gimpviewable.h"
 
-#include "gimpcontainerview.h"
 #include "gimpeditor.h"
 #include "gimptoolpresetfactoryview.h"
 #include "gimpviewrenderer.h"
@@ -61,6 +60,7 @@ gimp_tool_preset_factory_view_new (GimpViewType      view_type,
   GimpToolPresetFactoryView *factory_view;
 
   g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
+  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
   g_return_val_if_fail (view_size > 0 &&
                         view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
   g_return_val_if_fail (view_border_width >= 0 &&
@@ -68,12 +68,12 @@ gimp_tool_preset_factory_view_new (GimpViewType      view_type,
                         NULL);
 
   factory_view = g_object_new (GIMP_TYPE_TOOL_PRESET_FACTORY_VIEW,
+                               "view-type",    view_type,
                                "data-factory", factory,
+                               "context",      context,
                                NULL);
 
   if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
-                                          view_type,
-                                          context,
                                           view_size, view_border_width,
                                           menu_factory, "<ToolPreset>",
                                           "/tool-preset-popup",



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