[nautilus-actions] Initialize NAIFactoryObject defaults in instance_contructed



commit c530ff4124b3cd5150973f875dd9127840985e76
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sat Feb 27 23:46:49 2010 +0100

    Initialize NAIFactoryObject defaults in instance_contructed

 ChangeLog                    |    5 +++++
 src/core/na-object-action.c  |   24 +++++++++++++++++++++++-
 src/core/na-object-menu.c    |   24 +++++++++++++++++++++++-
 src/core/na-object-profile.c |   24 +++++++++++++++++++++++-
 4 files changed, 74 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a4d7519..c6107c2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2009-02-27 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-object-action.c (instance_constructed):
+	* src/core/na-object-profile.c (instance_constructed):
+	* src/core/na-object-menu.c (instance_constructed):
+	Initialize NAIFactoryObject defaults here, rather than in object_new.
+
 	* src/api/na-data-def.h: Remove fn_free() function pointer.
 
 	* src/core/na-data-boxed.c:
diff --git a/src/core/na-object-action.c b/src/core/na-object-action.c
index e619694..04d2b27 100644
--- a/src/core/na-object-action.c
+++ b/src/core/na-object-action.c
@@ -71,6 +71,7 @@ static NAObjectItemClass *st_parent_class = NULL;
 static GType        register_type( void );
 static void         class_init( NAObjectActionClass *klass );
 static void         instance_init( GTypeInstance *instance, gpointer klass );
+static void         instance_constructed( GObject *object );
 static void         instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
 static void         instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
 static void         instance_dispose( GObject *object );
@@ -156,6 +157,7 @@ class_init( NAObjectActionClass *klass )
 	st_parent_class = g_type_class_peek_parent( klass );
 
 	object_class = G_OBJECT_CLASS( klass );
+	object_class->constructed = instance_constructed;
 	object_class->set_property = instance_set_property;
 	object_class->get_property = instance_get_property;
 	object_class->dispose = instance_dispose;
@@ -189,6 +191,27 @@ instance_init( GTypeInstance *instance, gpointer klass )
 }
 
 static void
+instance_constructed( GObject *object )
+{
+	static const gchar *thisfn = "na_object_action_instance_constructed";
+	NAObjectAction *self;
+
+	g_debug( "%s: object=%p", thisfn, ( void * ) object );
+	g_return_if_fail( NA_IS_OBJECT_ACTION( object ));
+	self = NA_OBJECT_ACTION( object );
+
+	if( !self->private->dispose_has_run ){
+
+		na_factory_object_set_defaults( NA_IFACTORY_OBJECT( object ));
+
+		/* chain up to the parent class */
+		if( G_OBJECT_CLASS( st_parent_class )->constructed ){
+			G_OBJECT_CLASS( st_parent_class )->constructed( object );
+		}
+	}
+}
+
+static void
 instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
 {
 	g_return_if_fail( NA_IS_OBJECT_ACTION( object ));
@@ -470,7 +493,6 @@ na_object_action_new( void )
 	NAObjectAction *action;
 
 	action = g_object_new( NA_OBJECT_ACTION_TYPE, NULL );
-	na_factory_object_set_defaults( NA_IFACTORY_OBJECT( action ));
 
 	return( action );
 }
diff --git a/src/core/na-object-menu.c b/src/core/na-object-menu.c
index a4c35c5..3c5fd07 100644
--- a/src/core/na-object-menu.c
+++ b/src/core/na-object-menu.c
@@ -64,6 +64,7 @@ static NAObjectItemClass *st_parent_class = NULL;
 static GType        register_type( void );
 static void         class_init( NAObjectMenuClass *klass );
 static void         instance_init( GTypeInstance *instance, gpointer klass );
+static void         instance_constructed( GObject *object );
 static void         instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
 static void         instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
 static void         instance_dispose( GObject *object );
@@ -142,6 +143,7 @@ class_init( NAObjectMenuClass *klass )
 	st_parent_class = g_type_class_peek_parent( klass );
 
 	object_class = G_OBJECT_CLASS( klass );
+	object_class->constructed = instance_constructed;
 	object_class->set_property = instance_set_property;
 	object_class->get_property = instance_get_property;
 	object_class->dispose = instance_dispose;
@@ -175,6 +177,27 @@ instance_init( GTypeInstance *instance, gpointer klass )
 }
 
 static void
+instance_constructed( GObject *object )
+{
+	static const gchar *thisfn = "na_object_menu_instance_constructed";
+	NAObjectMenu *self;
+
+	g_debug( "%s: object=%p", thisfn, ( void * ) object );
+	g_return_if_fail( NA_IS_OBJECT_MENU( object ));
+	self = NA_OBJECT_MENU( object );
+
+	if( !self->private->dispose_has_run ){
+
+		na_factory_object_set_defaults( NA_IFACTORY_OBJECT( object ));
+
+		/* chain up to the parent class */
+		if( G_OBJECT_CLASS( st_parent_class )->constructed ){
+			G_OBJECT_CLASS( st_parent_class )->constructed( object );
+		}
+	}
+}
+
+static void
 instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
 {
 	g_return_if_fail( NA_IS_OBJECT_MENU( object ));
@@ -384,7 +407,6 @@ na_object_menu_new( void )
 	NAObjectMenu *menu;
 
 	menu = g_object_new( NA_OBJECT_MENU_TYPE, NULL );
-	na_factory_object_set_defaults( NA_IFACTORY_OBJECT( menu ));
 
 	return( menu );
 }
diff --git a/src/core/na-object-profile.c b/src/core/na-object-profile.c
index a82963a..089d71e 100644
--- a/src/core/na-object-profile.c
+++ b/src/core/na-object-profile.c
@@ -68,6 +68,7 @@ static NAObjectIdClass *st_parent_class = NULL;
 static GType        register_type( void );
 static void         class_init( NAObjectProfileClass *klass );
 static void         instance_init( GTypeInstance *instance, gpointer klass );
+static void         instance_constructed( GObject *object );
 static void         instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec );
 static void         instance_set_property( GObject *object, guint property_id, const GValue *value, GParamSpec *spec );
 static void         instance_dispose( GObject *object );
@@ -164,6 +165,7 @@ class_init( NAObjectProfileClass *klass )
 	st_parent_class = g_type_class_peek_parent( klass );
 
 	object_class = G_OBJECT_CLASS( klass );
+	object_class->constructed = instance_constructed;
 	object_class->set_property = instance_set_property;
 	object_class->get_property = instance_get_property;
 	object_class->dispose = instance_dispose;
@@ -202,6 +204,27 @@ instance_init( GTypeInstance *instance, gpointer klass )
 }
 
 static void
+instance_constructed( GObject *object )
+{
+	static const gchar *thisfn = "na_object_profile_instance_constructed";
+	NAObjectProfile *self;
+
+	g_debug( "%s: object=%p", thisfn, ( void * ) object );
+	g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
+	self = NA_OBJECT_PROFILE( object );
+
+	if( !self->private->dispose_has_run ){
+
+		na_factory_object_set_defaults( NA_IFACTORY_OBJECT( object ));
+
+		/* chain up to the parent class */
+		if( G_OBJECT_CLASS( st_parent_class )->constructed ){
+			G_OBJECT_CLASS( st_parent_class )->constructed( object );
+		}
+	}
+}
+
+static void
 instance_get_property( GObject *object, guint property_id, GValue *value, GParamSpec *spec )
 {
 	g_return_if_fail( NA_IS_OBJECT_PROFILE( object ));
@@ -514,7 +537,6 @@ na_object_profile_new( void )
 	NAObjectProfile *profile;
 
 	profile = g_object_new( NA_OBJECT_PROFILE_TYPE, NULL );
-	na_factory_object_set_defaults( NA_IFACTORY_OBJECT( profile ));
 
 	return( profile );
 }



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