[gimp] app: implement GObject::constructed() instead of ::constructor()



commit c1b357564810fd7e300a32b9fc07821768d8a7b4
Author: Michael Natterer <mitch gimp org>
Date:   Wed Jan 12 23:06:03 2011 +0100

    app: implement GObject::constructed() instead of ::constructor()

 app/display/gimpdisplayshell.c    |   22 ++++----------
 app/paint/gimpinkundo.c           |   32 ++++++++-------------
 app/paint/gimppaintcoreundo.c     |   50 ++++++++++++++-------------------
 app/text/gimptextundo.c           |   56 ++++++++++++++++---------------------
 app/vectors/gimpvectorsmodundo.c  |   36 +++++++++--------------
 app/vectors/gimpvectorspropundo.c |   31 +++++++-------------
 app/vectors/gimpvectorsundo.c     |   52 ++++++++++++++--------------------
 7 files changed, 110 insertions(+), 169 deletions(-)
---
diff --git a/app/display/gimpdisplayshell.c b/app/display/gimpdisplayshell.c
index d2dba11..344ee86 100644
--- a/app/display/gimpdisplayshell.c
+++ b/app/display/gimpdisplayshell.c
@@ -116,9 +116,7 @@ struct _GimpDisplayShellOverlay
 
 static void      gimp_color_managed_iface_init     (GimpColorManagedInterface *iface);
 
-static GObject * gimp_display_shell_constructor    (GType             type,
-                                                    guint             n_params,
-                                                    GObjectConstructParam *params);
+static void      gimp_display_shell_constructed    (GObject          *object);
 static void      gimp_display_shell_dispose        (GObject          *object);
 static void      gimp_display_shell_finalize       (GObject          *object);
 static void      gimp_display_shell_set_property   (GObject          *object,
@@ -214,7 +212,7 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
                   gimp_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
 
-  object_class->constructor        = gimp_display_shell_constructor;
+  object_class->constructed        = gimp_display_shell_constructed;
   object_class->dispose            = gimp_display_shell_dispose;
   object_class->finalize           = gimp_display_shell_finalize;
   object_class->set_property       = gimp_display_shell_set_property;
@@ -339,13 +337,10 @@ gimp_display_shell_init (GimpDisplayShell *shell)
                      GIMP_HELP_IMAGE_WINDOW, NULL);
 }
 
-static GObject *
-gimp_display_shell_constructor (GType                  type,
-                                guint                  n_params,
-                                GObjectConstructParam *params)
+static void
+gimp_display_shell_constructed (GObject *object)
 {
-  GObject               *object;
-  GimpDisplayShell      *shell;
+  GimpDisplayShell      *shell = GIMP_DISPLAY_SHELL (object);
   GimpDisplayConfig     *config;
   GimpImage             *image;
   GimpColorDisplayStack *filter;
@@ -361,9 +356,8 @@ gimp_display_shell_constructor (GType                  type,
   gint                   shell_width;
   gint                   shell_height;
 
-  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
-
-  shell = GIMP_DISPLAY_SHELL (object);
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
 
   g_assert (GIMP_IS_UI_MANAGER (shell->popup_manager));
   g_assert (GIMP_IS_DISPLAY (shell->display));
@@ -742,8 +736,6 @@ gimp_display_shell_constructor (GType                  type,
 
   /* make sure the information is up-to-date */
   gimp_display_shell_scale_changed (shell);
-
-  return object;
 }
 
 static void
diff --git a/app/paint/gimpinkundo.c b/app/paint/gimpinkundo.c
index aeccbd6..1fc7981 100644
--- a/app/paint/gimpinkundo.c
+++ b/app/paint/gimpinkundo.c
@@ -28,15 +28,13 @@
 #include "gimpinkundo.h"
 
 
-static GObject * gimp_ink_undo_constructor  (GType                  type,
-                                             guint                  n_params,
-                                             GObjectConstructParam *params);
+static void   gimp_ink_undo_constructed (GObject             *object);
 
-static void      gimp_ink_undo_pop          (GimpUndo              *undo,
-                                             GimpUndoMode           undo_mode,
-                                             GimpUndoAccumulator   *accum);
-static void      gimp_ink_undo_free         (GimpUndo              *undo,
-                                             GimpUndoMode           undo_mode);
+static void   gimp_ink_undo_pop         (GimpUndo            *undo,
+                                         GimpUndoMode         undo_mode,
+                                         GimpUndoAccumulator *accum);
+static void   gimp_ink_undo_free        (GimpUndo            *undo,
+                                         GimpUndoMode         undo_mode);
 
 
 G_DEFINE_TYPE (GimpInkUndo, gimp_ink_undo, GIMP_TYPE_PAINT_CORE_UNDO)
@@ -50,7 +48,7 @@ gimp_ink_undo_class_init (GimpInkUndoClass *klass)
   GObjectClass  *object_class = G_OBJECT_CLASS (klass);
   GimpUndoClass *undo_class   = GIMP_UNDO_CLASS (klass);
 
-  object_class->constructor = gimp_ink_undo_constructor;
+  object_class->constructed = gimp_ink_undo_constructed;
 
   undo_class->pop           = gimp_ink_undo_pop;
   undo_class->free          = gimp_ink_undo_free;
@@ -61,18 +59,14 @@ gimp_ink_undo_init (GimpInkUndo *undo)
 {
 }
 
-static GObject *
-gimp_ink_undo_constructor (GType                  type,
-                           guint                  n_params,
-                           GObjectConstructParam *params)
+static void
+gimp_ink_undo_constructed (GObject *object)
 {
-  GObject     *object;
-  GimpInkUndo *ink_undo;
+  GimpInkUndo *ink_undo = GIMP_INK_UNDO (object);
   GimpInk     *ink;
 
-  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
-
-  ink_undo = GIMP_INK_UNDO (object);
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
 
   g_assert (GIMP_IS_INK (GIMP_PAINT_CORE_UNDO (ink_undo)->paint_core));
 
@@ -80,8 +74,6 @@ gimp_ink_undo_constructor (GType                  type,
 
   if (ink->start_blob)
     ink_undo->last_blob = gimp_blob_duplicate (ink->start_blob);
-
-  return object;
 }
 
 static void
diff --git a/app/paint/gimppaintcoreundo.c b/app/paint/gimppaintcoreundo.c
index 89d4d5a..dd9011f 100644
--- a/app/paint/gimppaintcoreundo.c
+++ b/app/paint/gimppaintcoreundo.c
@@ -32,23 +32,21 @@ enum
 };
 
 
-static GObject * gimp_paint_core_undo_constructor  (GType                  type,
-                                                    guint                  n_params,
-                                                    GObjectConstructParam *params);
-static void      gimp_paint_core_undo_set_property (GObject               *object,
-                                                    guint                  property_id,
-                                                    const GValue          *value,
-                                                    GParamSpec            *pspec);
-static void      gimp_paint_core_undo_get_property (GObject               *object,
-                                                    guint                  property_id,
-                                                    GValue                *value,
-                                                    GParamSpec            *pspec);
-
-static void      gimp_paint_core_undo_pop          (GimpUndo              *undo,
-                                                    GimpUndoMode           undo_mode,
-                                                    GimpUndoAccumulator   *accum);
-static void      gimp_paint_core_undo_free         (GimpUndo              *undo,
-                                                    GimpUndoMode           undo_mode);
+static void   gimp_paint_core_undo_constructed  (GObject             *object);
+static void   gimp_paint_core_undo_set_property (GObject             *object,
+                                                 guint                property_id,
+                                                 const GValue        *value,
+                                                 GParamSpec          *pspec);
+static void   gimp_paint_core_undo_get_property (GObject             *object,
+                                                 guint                property_id,
+                                                 GValue              *value,
+                                                 GParamSpec          *pspec);
+
+static void   gimp_paint_core_undo_pop          (GimpUndo            *undo,
+                                                 GimpUndoMode         undo_mode,
+                                                 GimpUndoAccumulator *accum);
+static void   gimp_paint_core_undo_free         (GimpUndo            *undo,
+                                                 GimpUndoMode         undo_mode);
 
 
 G_DEFINE_TYPE (GimpPaintCoreUndo, gimp_paint_core_undo, GIMP_TYPE_UNDO)
@@ -62,7 +60,7 @@ gimp_paint_core_undo_class_init (GimpPaintCoreUndoClass *klass)
   GObjectClass  *object_class = G_OBJECT_CLASS (klass);
   GimpUndoClass *undo_class   = GIMP_UNDO_CLASS (klass);
 
-  object_class->constructor  = gimp_paint_core_undo_constructor;
+  object_class->constructed  = gimp_paint_core_undo_constructed;
   object_class->set_property = gimp_paint_core_undo_set_property;
   object_class->get_property = gimp_paint_core_undo_get_property;
 
@@ -81,17 +79,13 @@ gimp_paint_core_undo_init (GimpPaintCoreUndo *undo)
 {
 }
 
-static GObject *
-gimp_paint_core_undo_constructor (GType                  type,
-                                  guint                  n_params,
-                                  GObjectConstructParam *params)
+static void
+gimp_paint_core_undo_constructed (GObject *object)
 {
-  GObject           *object;
-  GimpPaintCoreUndo *paint_core_undo;
-
-  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+  GimpPaintCoreUndo *paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
 
-  paint_core_undo = GIMP_PAINT_CORE_UNDO (object);
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
 
   g_assert (GIMP_IS_PAINT_CORE (paint_core_undo->paint_core));
 
@@ -99,8 +93,6 @@ gimp_paint_core_undo_constructor (GType                  type,
 
   g_object_add_weak_pointer (G_OBJECT (paint_core_undo->paint_core),
                              (gpointer) &paint_core_undo->paint_core);
-
-  return object;
 }
 
 static void
diff --git a/app/text/gimptextundo.c b/app/text/gimptextundo.c
index 20f2ba5..934860b 100644
--- a/app/text/gimptextundo.c
+++ b/app/text/gimptextundo.c
@@ -39,26 +39,24 @@ enum
 };
 
 
-static GObject * gimp_text_undo_constructor  (GType                  type,
-                                              guint                  n_params,
-                                              GObjectConstructParam *params);
-static void      gimp_text_undo_set_property (GObject               *object,
-                                              guint                  property_id,
-                                              const GValue          *value,
-                                              GParamSpec            *pspec);
-static void      gimp_text_undo_get_property (GObject               *object,
-                                              guint                  property_id,
-                                              GValue                *value,
-                                              GParamSpec            *pspec);
-
-static gint64    gimp_text_undo_get_memsize  (GimpObject            *object,
-                                              gint64                *gui_size);
-
-static void      gimp_text_undo_pop          (GimpUndo              *undo,
-                                              GimpUndoMode           undo_mode,
-                                              GimpUndoAccumulator   *accum);
-static void      gimp_text_undo_free         (GimpUndo              *undo,
-                                              GimpUndoMode           undo_mode);
+static void     gimp_text_undo_constructed  (GObject             *object);
+static void     gimp_text_undo_set_property (GObject             *object,
+                                             guint                property_id,
+                                             const GValue        *value,
+                                             GParamSpec          *pspec);
+static void     gimp_text_undo_get_property (GObject             *object,
+                                             guint                property_id,
+                                             GValue              *value,
+                                             GParamSpec          *pspec);
+
+static gint64   gimp_text_undo_get_memsize  (GimpObject          *object,
+                                             gint64              *gui_size);
+
+static void     gimp_text_undo_pop          (GimpUndo            *undo,
+                                             GimpUndoMode         undo_mode,
+                                             GimpUndoAccumulator *accum);
+static void     gimp_text_undo_free         (GimpUndo            *undo,
+                                             GimpUndoMode         undo_mode);
 
 
 G_DEFINE_TYPE (GimpTextUndo, gimp_text_undo, GIMP_TYPE_ITEM_UNDO)
@@ -73,7 +71,7 @@ gimp_text_undo_class_init (GimpTextUndoClass *klass)
   GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
   GimpUndoClass   *undo_class        = GIMP_UNDO_CLASS (klass);
 
-  object_class->constructor      = gimp_text_undo_constructor;
+  object_class->constructed      = gimp_text_undo_constructed;
   object_class->set_property     = gimp_text_undo_set_property;
   object_class->get_property     = gimp_text_undo_get_property;
 
@@ -94,18 +92,14 @@ gimp_text_undo_init (GimpTextUndo *undo)
 {
 }
 
-static GObject *
-gimp_text_undo_constructor (GType                  type,
-                            guint                  n_params,
-                            GObjectConstructParam *params)
+static void
+gimp_text_undo_constructed (GObject *object)
 {
-  GObject       *object;
-  GimpTextUndo  *text_undo;
+  GimpTextUndo  *text_undo = GIMP_TEXT_UNDO (object);
   GimpTextLayer *layer;
 
-  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
-
-  text_undo = GIMP_TEXT_UNDO (object);
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
 
   g_assert (GIMP_IS_TEXT_LAYER (GIMP_ITEM_UNDO (text_undo)->item));
 
@@ -137,8 +131,6 @@ gimp_text_undo_constructor (GType                  type,
     default:
       g_assert_not_reached ();
     }
-
-  return object;
 }
 
 static void
diff --git a/app/vectors/gimpvectorsmodundo.c b/app/vectors/gimpvectorsmodundo.c
index 63cc23c..1957a2d 100644
--- a/app/vectors/gimpvectorsmodundo.c
+++ b/app/vectors/gimpvectorsmodundo.c
@@ -25,18 +25,16 @@
 #include "gimpvectorsmodundo.h"
 
 
-static GObject * gimp_vectors_mod_undo_constructor (GType                  type,
-                                                    guint                  n_params,
-                                                    GObjectConstructParam *params);
+static void     gimp_vectors_mod_undo_constructed (GObject             *object);
 
-static gint64    gimp_vectors_mod_undo_get_memsize (GimpObject            *object,
-                                                    gint64                *gui_size);
+static gint64   gimp_vectors_mod_undo_get_memsize (GimpObject          *object,
+                                                   gint64              *gui_size);
 
-static void      gimp_vectors_mod_undo_pop         (GimpUndo              *undo,
-                                                    GimpUndoMode           undo_mode,
-                                                    GimpUndoAccumulator   *accum);
-static void      gimp_vectors_mod_undo_free        (GimpUndo              *undo,
-                                                    GimpUndoMode           undo_mode);
+static void     gimp_vectors_mod_undo_pop         (GimpUndo            *undo,
+                                                   GimpUndoMode         undo_mode,
+                                                   GimpUndoAccumulator *accum);
+static void     gimp_vectors_mod_undo_free        (GimpUndo            *undo,
+                                                   GimpUndoMode         undo_mode);
 
 
 G_DEFINE_TYPE (GimpVectorsModUndo, gimp_vectors_mod_undo, GIMP_TYPE_ITEM_UNDO)
@@ -51,7 +49,7 @@ gimp_vectors_mod_undo_class_init (GimpVectorsModUndoClass *klass)
   GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
   GimpUndoClass   *undo_class        = GIMP_UNDO_CLASS (klass);
 
-  object_class->constructor      = gimp_vectors_mod_undo_constructor;
+  object_class->constructed      = gimp_vectors_mod_undo_constructed;
 
   gimp_object_class->get_memsize = gimp_vectors_mod_undo_get_memsize;
 
@@ -64,18 +62,14 @@ gimp_vectors_mod_undo_init (GimpVectorsModUndo *undo)
 {
 }
 
-static GObject *
-gimp_vectors_mod_undo_constructor (GType                  type,
-                                   guint                  n_params,
-                                   GObjectConstructParam *params)
+static void
+gimp_vectors_mod_undo_constructed (GObject *object)
 {
-  GObject            *object;
-  GimpVectorsModUndo *vectors_mod_undo;
+  GimpVectorsModUndo *vectors_mod_undo = GIMP_VECTORS_MOD_UNDO (object);
   GimpVectors        *vectors;
 
-  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
-
-  vectors_mod_undo = GIMP_VECTORS_MOD_UNDO (object);
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
 
   g_assert (GIMP_IS_VECTORS (GIMP_ITEM_UNDO (object)->item));
 
@@ -84,8 +78,6 @@ gimp_vectors_mod_undo_constructor (GType                  type,
   vectors_mod_undo->vectors =
     GIMP_VECTORS (gimp_item_duplicate (GIMP_ITEM (vectors),
                                        G_TYPE_FROM_INSTANCE (vectors)));
-
-  return object;
 }
 
 static gint64
diff --git a/app/vectors/gimpvectorspropundo.c b/app/vectors/gimpvectorspropundo.c
index 1e9e1b3..a2c9fc4 100644
--- a/app/vectors/gimpvectorspropundo.c
+++ b/app/vectors/gimpvectorspropundo.c
@@ -27,13 +27,11 @@
 #include "gimpvectorspropundo.h"
 
 
-static GObject * gimp_vectors_prop_undo_constructor (GType                  type,
-                                                     guint                  n_params,
-                                                     GObjectConstructParam *params);
+static void   gimp_vectors_prop_undo_constructed (GObject             *object);
 
-static void      gimp_vectors_prop_undo_pop         (GimpUndo              *undo,
-                                                     GimpUndoMode           undo_mode,
-                                                     GimpUndoAccumulator   *accum);
+static void   gimp_vectors_prop_undo_pop         (GimpUndo            *undo,
+                                                  GimpUndoMode         undo_mode,
+                                                  GimpUndoAccumulator *accum);
 
 
 G_DEFINE_TYPE (GimpVectorsPropUndo, gimp_vectors_prop_undo, GIMP_TYPE_ITEM_UNDO)
@@ -47,7 +45,7 @@ gimp_vectors_prop_undo_class_init (GimpVectorsPropUndoClass *klass)
   GObjectClass  *object_class = G_OBJECT_CLASS (klass);
   GimpUndoClass *undo_class   = GIMP_UNDO_CLASS (klass);
 
-  object_class->constructor = gimp_vectors_prop_undo_constructor;
+  object_class->constructed = gimp_vectors_prop_undo_constructed;
 
   undo_class->pop           = gimp_vectors_prop_undo_pop;
 }
@@ -57,19 +55,14 @@ gimp_vectors_prop_undo_init (GimpVectorsPropUndo *undo)
 {
 }
 
-static GObject *
-gimp_vectors_prop_undo_constructor (GType                  type,
-                                    guint                  n_params,
-                                    GObjectConstructParam *params)
+static void
+gimp_vectors_prop_undo_constructed (GObject *object)
 {
-  GObject             *object;
-  GimpVectorsPropUndo *vectors_prop_undo;
-  GimpImage           *image;
-  GimpVectors         *vectors;
-
-  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
+  GimpImage   *image;
+  GimpVectors *vectors;
 
-  vectors_prop_undo = GIMP_VECTORS_PROP_UNDO (object);
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
 
   g_assert (GIMP_IS_VECTORS (GIMP_ITEM_UNDO (object)->item));
 
@@ -81,8 +74,6 @@ gimp_vectors_prop_undo_constructor (GType                  type,
     default:
       g_assert_not_reached ();
     }
-
-  return object;
 }
 
 static void
diff --git a/app/vectors/gimpvectorsundo.c b/app/vectors/gimpvectorsundo.c
index a78ae60..7294721 100644
--- a/app/vectors/gimpvectorsundo.c
+++ b/app/vectors/gimpvectorsundo.c
@@ -36,24 +36,22 @@ enum
 };
 
 
-static GObject * gimp_vectors_undo_constructor  (GType                  type,
-                                                 guint                  n_params,
-                                                 GObjectConstructParam *params);
-static void      gimp_vectors_undo_set_property (GObject               *object,
-                                                 guint                  property_id,
-                                                 const GValue          *value,
-                                                 GParamSpec            *pspec);
-static void      gimp_vectors_undo_get_property (GObject               *object,
-                                                 guint                  property_id,
-                                                 GValue                *value,
-                                                 GParamSpec            *pspec);
-
-static gint64    gimp_vectors_undo_get_memsize  (GimpObject            *object,
-                                                 gint64                *gui_size);
-
-static void      gimp_vectors_undo_pop          (GimpUndo              *undo,
-                                                 GimpUndoMode           undo_mode,
-                                                 GimpUndoAccumulator   *accum);
+static void     gimp_vectors_undo_constructed  (GObject             *object);
+static void     gimp_vectors_undo_set_property (GObject             *object,
+                                                guint                property_id,
+                                                const GValue        *value,
+                                                GParamSpec          *pspec);
+static void     gimp_vectors_undo_get_property (GObject             *object,
+                                                guint                property_id,
+                                                GValue              *value,
+                                                GParamSpec          *pspec);
+
+static gint64   gimp_vectors_undo_get_memsize  (GimpObject          *object,
+                                                gint64              *gui_size);
+
+static void     gimp_vectors_undo_pop          (GimpUndo            *undo,
+                                                GimpUndoMode         undo_mode,
+                                                GimpUndoAccumulator *accum);
 
 
 G_DEFINE_TYPE (GimpVectorsUndo, gimp_vectors_undo, GIMP_TYPE_ITEM_UNDO)
@@ -68,7 +66,7 @@ gimp_vectors_undo_class_init (GimpVectorsUndoClass *klass)
   GimpObjectClass *gimp_object_class = GIMP_OBJECT_CLASS (klass);
   GimpUndoClass   *undo_class        = GIMP_UNDO_CLASS (klass);
 
-  object_class->constructor      = gimp_vectors_undo_constructor;
+  object_class->constructed      = gimp_vectors_undo_constructed;
   object_class->set_property     = gimp_vectors_undo_set_property;
   object_class->get_property     = gimp_vectors_undo_get_property;
 
@@ -101,21 +99,13 @@ gimp_vectors_undo_init (GimpVectorsUndo *undo)
 {
 }
 
-static GObject *
-gimp_vectors_undo_constructor (GType                  type,
-                               guint                  n_params,
-                               GObjectConstructParam *params)
+static void
+gimp_vectors_undo_constructed (GObject *object)
 {
-  GObject       *object;
-  GimpVectorsUndo *vectors_undo;
-
-  object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
-
-  vectors_undo = GIMP_VECTORS_UNDO (object);
+  if (G_OBJECT_CLASS (parent_class)->constructed)
+    G_OBJECT_CLASS (parent_class)->constructed (object);
 
   g_assert (GIMP_IS_VECTORS (GIMP_ITEM_UNDO (object)->item));
-
-  return object;
 }
 
 static void



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