From 0a1a2915d0da823bc2cf988d498ad31844346dd4 Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Fri, 14 Jan 2011 09:37:31 +0100 Subject: [PATCH] plug-ins: implement GObject::constructed() instead of ::constructor() --- plug-ins/metadata/gimpxmpmodelentry.c | 43 +++++++++++++-------------- plug-ins/metadata/gimpxmpmodeltext.c | 41 ++++++++++++------------- 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/plug-ins/metadata/gimpxmpmodelentry.c b/plug-ins/metadata/gimpxmpmodelentry.c index 0a62c0c7d1..9b194e299b 100644 --- a/plug-ins/metadata/gimpxmpmodelentry.c +++ b/plug-ins/metadata/gimpxmpmodelentry.c @@ -29,12 +29,14 @@ #include "gimpxmpmodelentry.h" -static void gimp_xmp_model_entry_iface_init (GimpXmpModelWidgetInterface *iface); +static void gimp_xmp_model_entry_iface_init (GimpXmpModelWidgetInterface *iface); -static void gimp_xmp_model_entry_set_text (GimpXmpModelWidget *widget, - const gchar *tree_value); +static void gimp_xmp_model_entry_constructed (GObject *object); -static void gimp_xmp_model_entry_changed (GimpXmpModelEntry *entry); +static void gimp_xmp_model_entry_set_text (GimpXmpModelWidget *widget, + const gchar *tree_value); + +static void gimp_xmp_model_entry_changed (GimpXmpModelEntry *entry); G_DEFINE_TYPE_WITH_CODE (GimpXmpModelEntry, gimp_xmp_model_entry, @@ -46,32 +48,24 @@ G_DEFINE_TYPE_WITH_CODE (GimpXmpModelEntry, gimp_xmp_model_entry, #define parent_class gimp_xmp_model_entry_parent_class -static GObject * -gimp_xmp_model_entry_constructor (GType type, - guint n_params, - GObjectConstructParam *params) -{ - GObject *obj; - - obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); - - gimp_xmp_model_widget_constructor (obj); - - return obj; -} - static void gimp_xmp_model_entry_class_init (GimpXmpModelEntryClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->constructor = gimp_xmp_model_entry_constructor; + object_class->constructed = gimp_xmp_model_entry_constructed; object_class->set_property = gimp_xmp_model_widget_set_property; object_class->get_property = gimp_xmp_model_widget_get_property; gimp_xmp_model_widget_install_properties (object_class); } +static void +gimp_xmp_model_entry_iface_init (GimpXmpModelWidgetInterface *iface) +{ + iface->widget_set_text = gimp_xmp_model_entry_set_text; +} + static void gimp_xmp_model_entry_init (GimpXmpModelEntry *entry) { @@ -81,9 +75,12 @@ gimp_xmp_model_entry_init (GimpXmpModelEntry *entry) } static void -gimp_xmp_model_entry_iface_init (GimpXmpModelWidgetInterface *iface) +gimp_xmp_model_entry_constructed (GObject *object) { - iface->widget_set_text = gimp_xmp_model_entry_set_text; + if (G_OBJECT_CLASS (parent_class)->constructed) + G_OBJECT_CLASS (parent_class)->constructed (object); + + gimp_xmp_model_widget_constructor (object); } static void @@ -97,6 +94,6 @@ static void gimp_xmp_model_entry_changed (GimpXmpModelEntry *entry) { const gchar *value = gtk_entry_get_text (GTK_ENTRY (entry)); - gimp_xmp_model_widget_changed (GIMP_XMP_MODEL_WIDGET (entry), - value); + + gimp_xmp_model_widget_changed (GIMP_XMP_MODEL_WIDGET (entry), value); } diff --git a/plug-ins/metadata/gimpxmpmodeltext.c b/plug-ins/metadata/gimpxmpmodeltext.c index 8f683ec141..818df510a7 100644 --- a/plug-ins/metadata/gimpxmpmodeltext.c +++ b/plug-ins/metadata/gimpxmpmodeltext.c @@ -31,6 +31,8 @@ static void gimp_xmp_model_text_iface_init (GimpXmpModelWidgetInterface *iface); +static void gimp_xmp_model_text_constructed (GObject *object); + static void gimp_xmp_model_text_changed (GtkTextBuffer *text_buffer, gpointer *user_data); @@ -46,32 +48,24 @@ G_DEFINE_TYPE_WITH_CODE (GimpXmpModelText, gimp_xmp_model_text, #define parent_class gimp_xmp_model_text_parent_class -static GObject * -gimp_xmp_model_text_constructor (GType type, - guint n_params, - GObjectConstructParam *params) -{ - GObject *obj; - - obj = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params); - - gimp_xmp_model_widget_constructor (obj); - - return obj; -} - static void gimp_xmp_model_text_class_init (GimpXmpModelTextClass *klass) { GObjectClass *object_class = G_OBJECT_CLASS (klass); - object_class->constructor = gimp_xmp_model_text_constructor; + object_class->constructed = gimp_xmp_model_text_constructed; object_class->set_property = gimp_xmp_model_widget_set_property; object_class->get_property = gimp_xmp_model_widget_get_property; gimp_xmp_model_widget_install_properties (object_class); } +static void +gimp_xmp_model_text_iface_init (GimpXmpModelWidgetInterface *iface) +{ + iface->widget_set_text = gimp_xmp_model_text_set_text; +} + static void gimp_xmp_model_text_init (GimpXmpModelText *text) { @@ -84,9 +78,12 @@ gimp_xmp_model_text_init (GimpXmpModelText *text) } static void -gimp_xmp_model_text_iface_init (GimpXmpModelWidgetInterface *iface) +gimp_xmp_model_text_constructed (GObject *object) { - iface->widget_set_text = gimp_xmp_model_text_set_text; + if (G_OBJECT_CLASS (parent_class)->constructed) + G_OBJECT_CLASS (parent_class)->constructed (object); + + gimp_xmp_model_widget_constructor (object); } static void @@ -94,14 +91,14 @@ gimp_xmp_model_text_changed (GtkTextBuffer *text_buffer, gpointer *user_data) { GimpXmpModelText *text = GIMP_XMP_MODEL_TEXT (user_data); - GtkTextIter start; - GtkTextIter end; - const gchar *value; + GtkTextIter start; + GtkTextIter end; + const gchar *value; gtk_text_buffer_get_bounds (text_buffer, &start, &end); value = gtk_text_buffer_get_text (text_buffer, &start, &end, FALSE); - gimp_xmp_model_widget_changed (GIMP_XMP_MODEL_WIDGET (text), - value); + + gimp_xmp_model_widget_changed (GIMP_XMP_MODEL_WIDGET (text), value); } void