[gimp] app: make sure GimpToolPreset got the "gimp" construct property passed



commit 4c4c861aa1a08520a6941db8dd68d42d3341bca8
Author: Michael Natterer <mitch gimp org>
Date:   Sun Apr 11 16:18:21 2010 +0200

    app: make sure GimpToolPreset got the "gimp" construct property passed
    
    and pass a Gimp when creating the preset editor's local model.

 app/core/gimptoolpreset.c          |   21 +++++++++++++++++++++
 app/widgets/gimptoolpreseteditor.c |   12 ++++++++++--
 2 files changed, 31 insertions(+), 2 deletions(-)
---
diff --git a/app/core/gimptoolpreset.c b/app/core/gimptoolpreset.c
index 01fd93e..dcd0522 100644
--- a/app/core/gimptoolpreset.c
+++ b/app/core/gimptoolpreset.c
@@ -45,6 +45,9 @@ enum
 
 static void        gimp_tool_preset_config_iface_init (GimpConfigInterface *iface);
 
+static GObject       * gimp_tool_preset_constructor   (GType         type,
+                                                       guint         n_params,
+                                                       GObjectConstructParam *params);
 static void            gimp_tool_preset_finalize      (GObject      *object);
 static void            gimp_tool_preset_set_property  (GObject      *object,
                                                        guint         property_id,
@@ -82,6 +85,7 @@ gimp_tool_preset_class_init (GimpToolPresetClass *klass)
   GObjectClass  *object_class = G_OBJECT_CLASS (klass);
   GimpDataClass *data_class   = GIMP_DATA_CLASS (klass);
 
+  object_class->constructor                 = gimp_tool_preset_constructor;
   object_class->finalize                    = gimp_tool_preset_finalize;
   object_class->set_property                = gimp_tool_preset_set_property;
   object_class->get_property                = gimp_tool_preset_get_property;
@@ -120,6 +124,23 @@ gimp_tool_preset_init (GimpToolPreset *tool_preset)
   tool_preset->tool_options = NULL;
 }
 
+static GObject *
+gimp_tool_preset_constructor (GType                  type,
+                              guint                  n_params,
+                              GObjectConstructParam *params)
+{
+  GObject        *object;
+  GimpToolPreset *preset;
+
+  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+
+  preset = GIMP_TOOL_PRESET (object);
+
+  g_assert (GIMP_IS_GIMP (preset->gimp));
+
+  return object;
+}
+
 static void
 gimp_tool_preset_finalize (GObject *object)
 {
diff --git a/app/widgets/gimptoolpreseteditor.c b/app/widgets/gimptoolpreseteditor.c
index 84fc437..cdb6916 100644
--- a/app/widgets/gimptoolpreseteditor.c
+++ b/app/widgets/gimptoolpreseteditor.c
@@ -78,7 +78,6 @@ gimp_tool_preset_editor_class_init (GimpToolPresetEditorClass *klass)
 static void
 gimp_tool_preset_editor_init (GimpToolPresetEditor *editor)
 {
-  editor->tool_preset_model = g_object_new (GIMP_TYPE_TOOL_PRESET, NULL);
 }
 
 static GObject *
@@ -86,10 +85,19 @@ gimp_tool_preset_editor_constructor (GType                  type,
                                      guint                  n_params,
                                      GObjectConstructParam *params)
 {
-  GObject *object;
+  GObject              *object;
+  GimpToolPresetEditor *editor;
+  GimpDataEditor       *data_editor;
 
   object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
 
+  editor      = GIMP_TOOL_PRESET_EDITOR (object);
+  data_editor = GIMP_DATA_EDITOR (editor);
+
+  editor->tool_preset_model = g_object_new (GIMP_TYPE_TOOL_PRESET,
+                                            "gimp", data_editor->context->gimp,
+                                            NULL);
+
   gimp_docked_set_show_button_bar (GIMP_DOCKED (object), FALSE);
 
   return object;



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