[nautilus-actions] Refactoring: rename src/core/na-iduplicable.h to src/api/na-iduplicable.h



commit e6109b71c43da4e255d352a2310a57c09b6dd8c3
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Feb 15 17:30:32 2010 +0100

    Refactoring: rename src/core/na-iduplicable.h to src/api/na-iduplicable.h

 ChangeLog                          |    1 +
 src/api/Makefile.am                |    1 +
 src/{core => api}/na-iduplicable.h |   51 ++---
 src/core/Makefile.am               |    1 +
 src/core/na-iduplicable.c          |  387 +++++++++++++++++++++---------------
 5 files changed, 244 insertions(+), 197 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9e80d7e..a64a30f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
 2009-02-15 Pierre Wieser <pwieser trychlos org>
 
+	Rename src/core/na-iduplicable.h to src/api/na-iduplicable.h
 	Rename src/core/na-gconf-utils.h to src/api/na-gconf-utils.h
 	Rename src/api/na-iio-provider.c to src/core/na-iio-provider.c
 
diff --git a/src/api/Makefile.am b/src/api/Makefile.am
index 1a7c7c4..361c9ed 100644
--- a/src/api/Makefile.am
+++ b/src/api/Makefile.am
@@ -37,6 +37,7 @@ api_include_HEADERS = \
 	na-core-utils.h										\
 	na-gconf-monitor.h									\
 	na-gconf-utils.h									\
+	na-iduplicable.h									\
 	na-gconf-keys.h										\
 	na-object-api.h										\
 	$(NULL)
diff --git a/src/core/na-iduplicable.h b/src/api/na-iduplicable.h
similarity index 77%
rename from src/core/na-iduplicable.h
rename to src/api/na-iduplicable.h
index ffdce15..b74ee19 100644
--- a/src/core/na-iduplicable.h
+++ b/src/api/na-iduplicable.h
@@ -28,8 +28,8 @@
  *   ... and many others (see AUTHORS)
  */
 
-#ifndef __NAUTILUS_ACTIONS_NA_PRIVATE_IDUPLICABLE_H__
-#define __NAUTILUS_ACTIONS_NA_PRIVATE_IDUPLICABLE_H__
+#ifndef __NAUTILUS_ACTIONS_API_NA_IDUPLICABLE_H__
+#define __NAUTILUS_ACTIONS_API_NA_IDUPLICABLE_H__
 
 /**
  * SECTION: na_iduplicable
@@ -69,7 +69,7 @@ G_BEGIN_DECLS
 #define NA_IS_IDUPLICABLE( instance )				( G_TYPE_CHECK_INSTANCE_TYPE( instance, NA_IDUPLICABLE_TYPE ))
 #define NA_IDUPLICABLE_GET_INTERFACE( instance )	( G_TYPE_INSTANCE_GET_INTERFACE(( instance ), NA_IDUPLICABLE_TYPE, NAIDuplicableInterface ))
 
-typedef struct NAIDuplicable NAIDuplicable;
+typedef struct NAIDuplicable                 NAIDuplicable;
 
 typedef struct NAIDuplicableInterfacePrivate NAIDuplicableInterfacePrivate;
 
@@ -78,22 +78,6 @@ typedef struct {
 	NAIDuplicableInterfacePrivate *private;
 
 	/**
-	 * new:
-	 * @object: a #NAIDuplicable instance of the class of which we
-	 * want a new instance.
-	 *
-	 * Returns: a newly allocated #NAIDuplicable object.
-	 *
-	 * The most derived class of the implementation should define this
-	 * virtual function in order to get advantage of #NAIDuplicable
-	 * interface.
-	 *
-	 * This let the target class to do some initialization on the newly
-	 * created object.
-	 */
-	NAIDuplicable * ( *new )      ( const NAIDuplicable *object );
-
-	/**
 	 * copy:
 	 * @target: the #NAIDuplicable target of the copy.
 	 * @source: the #NAIDuplicable source of the copy
@@ -106,7 +90,7 @@ typedef struct {
 	 * care itself of calling each function in the class hierarchy,
 	 * from topmost base class to most-derived one.
 	 */
-	void            ( *copy )     ( NAIDuplicable *target, const NAIDuplicable *source );
+	void     ( *copy )     ( NAIDuplicable *target, const NAIDuplicable *source );
 
 	/**
 	 * are_equal:
@@ -123,7 +107,7 @@ typedef struct {
 	 * care itself of calling each function in the class hierarchy,
 	 * from topmost base class to most-derived one.
 	 */
-	gboolean        ( *are_equal )( const NAIDuplicable *a, const NAIDuplicable *b );
+	gboolean ( *are_equal )( const NAIDuplicable *a, const NAIDuplicable *b );
 
 	/**
 	 * is_valid:
@@ -138,30 +122,33 @@ typedef struct {
 	 * care itself of calling each function in the class hierarchy,
 	 * from topmost base class to most-derived one.
 	 */
-	gboolean        ( *is_valid )   ( const NAIDuplicable *object );
+	gboolean ( *is_valid )   ( const NAIDuplicable *object );
 }
 	NAIDuplicableInterface;
 
-#define NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED		"na-iduplicable-status-changed"
-
-#define NA_IDUPLICABLE_EDITION_STATUS_DEBUG			0
+#define NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED	"na-iduplicable-status-changed"
 
 GType          na_iduplicable_get_type( void );
 
-void           na_iduplicable_init( NAIDuplicable *object );
-void           na_iduplicable_dispose( NAIDuplicable *object );
-void           na_iduplicable_dump( const NAIDuplicable *object );
+void           na_iduplicable_dispose     ( const NAIDuplicable *object );
+void           na_iduplicable_dump        ( const NAIDuplicable *object );
+NAIDuplicable *na_iduplicable_duplicate   ( const NAIDuplicable *object );
 void           na_iduplicable_check_status( const NAIDuplicable *object );
-NAIDuplicable *na_iduplicable_duplicate( const NAIDuplicable *object );
+
+NAIDuplicable *na_iduplicable_get_origin  ( const NAIDuplicable *object );
+gboolean       na_iduplicable_is_valid    ( const NAIDuplicable *object );
+
+#if 0
+void           na_iduplicable_init        ( NAIDuplicable *object );
+
 void           na_iduplicable_reset_status( NAIDuplicable *object );
 
 gboolean       na_iduplicable_is_modified( const NAIDuplicable *object );
-gboolean       na_iduplicable_is_valid( const NAIDuplicable *object );
-NAIDuplicable *na_iduplicable_get_origin( const NAIDuplicable *object );
 void           na_iduplicable_set_origin( NAIDuplicable *object, const NAIDuplicable *origin );
 
 void           na_iduplicable_register_consumer( GObject *consumer );
+#endif
 
 G_END_DECLS
 
-#endif /* __NAUTILUS_ACTIONS_NA_PRIVATE_IDUPLICABLE_H__ */
+#endif /* __NAUTILUS_ACTIONS_API_NA_IDUPLICABLE_H__ */
diff --git a/src/core/Makefile.am b/src/core/Makefile.am
index 4bcd66b..568633d 100644
--- a/src/core/Makefile.am
+++ b/src/core/Makefile.am
@@ -40,6 +40,7 @@ libna_core_la_SOURCES = \
 	na-core-utils.c										\
 	na-gconf-monitor.c									\
 	na-gconf-utils.c									\
+	na-iduplicable.c									\
 	na-iio-provider.c									\
 	\
 	na-iabout.c											\
diff --git a/src/core/na-iduplicable.c b/src/core/na-iduplicable.c
index 56cb295..c80d95a 100644
--- a/src/core/na-iduplicable.c
+++ b/src/core/na-iduplicable.c
@@ -32,7 +32,7 @@
 #include <config.h>
 #endif
 
-#include "na-iduplicable.h"
+#include <api/na-iduplicable.h>
 
 /* private interface data
  */
@@ -40,19 +40,17 @@ struct NAIDuplicableInterfacePrivate {
 	GList *consumers;
 };
 
-/* signal handlers set on an object
+/* the data sructure set on each NAIDuplicable object
  */
 typedef struct {
-	gulong status_changed_handler_id;
+	NAIDuplicable *origin;
+	gboolean       modified;
+	gboolean       valid;
+	gulong         status_changed_handler_id;
 }
-	HandlersStruct;
+	DuplicableStr;
 
-/* data set against NAIDuplicable-implementated instance
- */
-#define NA_IDUPLICABLE_PROP_ORIGIN				"na-iduplicable-origin"
-#define NA_IDUPLICABLE_PROP_IS_MODIFIED			"na-iduplicable-is-modified"
-#define NA_IDUPLICABLE_PROP_IS_VALID			"na-iduplicable-is-valid"
-#define NA_IDUPLICABLE_PROP_SIGNAL_HANDLERS		"na-iduplicable-signal-handlers"
+#define NA_IDUPLICABLE_DATA_DUPLICABLE			"na-iduplicable-data-duplicable"
 
 /* signals emitted on NAIDuplicable when a status changes
  */
@@ -70,11 +68,15 @@ static GType          register_type( void );
 static void           interface_base_init( NAIDuplicableInterface *klass );
 static void           interface_base_finalize( NAIDuplicableInterface *klass );
 
-static NAIDuplicable *v_new( const NAIDuplicable *object );
 static void           v_copy( NAIDuplicable *target, const NAIDuplicable *source );
 static gboolean       v_are_equal( const NAIDuplicable *a, const NAIDuplicable *b );
 static gboolean       v_is_valid( const NAIDuplicable *object );
 
+static DuplicableStr *get_duplicable_str( const NAIDuplicable *object );
+
+#if 0
+static NAIDuplicable *v_new( const NAIDuplicable *object );
+
 static gboolean       get_modified( const NAIDuplicable *object );
 static NAIDuplicable *get_origin( const NAIDuplicable *object );
 static gboolean       get_valid( const NAIDuplicable *object );
@@ -85,6 +87,7 @@ static gboolean       set_valid( const NAIDuplicable *object, gboolean is_valid
 static void           status_changed_handler( NAIDuplicable *instance, gpointer user_data );
 static void           propagate_signal_to_consumers( const gchar *signal, NAIDuplicable *instance, gpointer user_data );
 static void           release_signal_consumers( GList *consumers );
+#endif
 
 GType
 na_iduplicable_get_type( void )
@@ -135,8 +138,13 @@ interface_base_init( NAIDuplicableInterface *klass )
 		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
 		klass->private = g_new0( NAIDuplicableInterfacePrivate, 1 );
+
 		klass->private->consumers = NULL;
 
+		klass->copy = NULL;
+		klass->are_equal = NULL;
+		klass->is_valid = NULL;
+
 		/**
 		 * na-iduplicable-status-changed:
 		 *
@@ -156,6 +164,7 @@ interface_base_init( NAIDuplicableInterface *klass )
 				G_TYPE_POINTER );
 
 		st_interface = klass;
+
 		st_initialized = TRUE;
 	}
 }
@@ -167,16 +176,19 @@ interface_base_finalize( NAIDuplicableInterface *klass )
 
 	if( !st_finalized ){
 
-		st_finalized = TRUE;
-
 		g_debug( "%s: klass=%p", thisfn, ( void * ) klass );
 
+		st_finalized = TRUE;
+
+#if 0
 		release_signal_consumers( klass->private->consumers );
+#endif
 
 		g_free( klass->private );
 	}
 }
 
+#if 0
 /**
  * na_iduplicable_init:
  * @object: the #NAIDuplicable object to be initialized.
@@ -189,25 +201,22 @@ interface_base_finalize( NAIDuplicableInterface *klass )
 void
 na_iduplicable_init( NAIDuplicable *object )
 {
-	HandlersStruct *str;
+	DuplicableStr *str;
 
-	g_return_if_fail( st_initialized && !st_finalized );
 	g_return_if_fail( NA_IS_IDUPLICABLE( object ));
 
-	set_origin( object, NULL );
-	set_modified( object, FALSE );
-	set_valid( object, TRUE );
+	if( st_initialized && !st_finalized ){
 
-	str = g_new0( HandlersStruct, 1 );
+		str = g_new0( DuplicableStr, 1 );
 
-	str->status_changed_handler_id = g_signal_connect(
-			G_OBJECT( object ),
-			NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED,
-			G_CALLBACK( status_changed_handler ),
-			object );
+		str->origin = NULL;
+		str->modified = FALSE;
+		str->valid = TRUE;
 
-	g_object_set_data( G_OBJECT( object ), NA_IDUPLICABLE_PROP_SIGNAL_HANDLERS, str );
+		g_object_set_data( G_OBJECT( object ), NA_IDUPLICABLE_DATA_DUPLICABLE, str );
+	}
 }
+#endif
 
 /**
  * na_iduplicable_dispose:
@@ -216,18 +225,20 @@ na_iduplicable_init( NAIDuplicable *object )
  * Releases resources.
  */
 void
-na_iduplicable_dispose( NAIDuplicable *object )
+na_iduplicable_dispose( const NAIDuplicable *object )
 {
-	HandlersStruct *str;
+	DuplicableStr *str;
 
-	g_return_if_fail( st_initialized && !st_finalized );
 	g_return_if_fail( NA_IS_IDUPLICABLE( object ));
 
-	str = g_object_get_data( G_OBJECT( object ), NA_IDUPLICABLE_PROP_SIGNAL_HANDLERS );
+	if( st_initialized && !st_finalized ){
+
+		str = get_duplicable_str( object );
 
-	g_signal_handler_disconnect( object, str->status_changed_handler_id );
+		g_signal_handler_disconnect(( gpointer ) object, str->status_changed_handler_id );
 
-	g_free( str );
+		g_free( str );
+	}
 }
 
 /**
@@ -246,20 +257,61 @@ void
 na_iduplicable_dump( const NAIDuplicable *object )
 {
 	static const gchar *thisfn = "na_iduplicable_dump";
-	NAIDuplicable *origin;
-	gboolean modified;
-	gboolean valid;
+	DuplicableStr *str;
 
-	g_return_if_fail( st_initialized && !st_finalized );
 	g_return_if_fail( NA_IS_IDUPLICABLE( object ));
 
-	origin = get_origin( object );
-	modified = get_modified( object );
-	valid = get_valid( object );
+	if( st_initialized && !st_finalized ){
+
+		str = get_duplicable_str( object );
+
+		g_debug( "%s:   origin=%p", thisfn, ( void * ) str->origin );
+		g_debug( "%s: modified=%s", thisfn, str->modified ? "True" : "False" );
+		g_debug( "%s:    valid=%s", thisfn, str->valid ? "True" : "False" );
+	}
+}
+
+/**
+ * na_iduplicable_duplicate:
+ * @object: the #NAIDuplicable object to be duplicated.
+ *
+ * Exactly duplicates a #NAIDuplicable-implemented object.
+ * Properties %NA_IDUPLICABLE_PROP_ORIGIN, %PROP_IDUPLICABLE_ISMODIFIED
+ * and %PROP_IDUPLICABLE_ISVALID are initialized to their default
+ * values.
+ *
+ * As %PROP_IDUPLICABLE_ISVALID property is set to %TRUE without any
+ * further check, this suppose that only valid objects are duplicated.
+ *
+ * Returns: a new #NAIDuplicable.
+ */
+NAIDuplicable *
+na_iduplicable_duplicate( const NAIDuplicable *object )
+{
+	static const gchar *thisfn = "na_iduplicable_duplicate";
+	NAIDuplicable *dup;
+	DuplicableStr *str;
+
+	g_debug( "%s: object=%p (%s)",
+			thisfn,
+			( void * ) object, G_OBJECT_TYPE_NAME( object ));
+
+	g_return_val_if_fail( NA_IS_IDUPLICABLE( object ), NULL );
+
+	dup = NULL;
+
+	if( st_initialized && !st_finalized ){
+
+		dup = g_object_new( G_OBJECT_TYPE( object ), NULL );
+
+		v_copy( dup, object );
+
+		str = get_duplicable_str( dup );
+		str->origin = ( NAIDuplicable * ) object;
+		g_object_set_data( G_OBJECT( object ), NA_IDUPLICABLE_DATA_DUPLICABLE, str );
+	}
 
-	g_debug( "%s:   origin=%p", thisfn, ( void * ) origin );
-	g_debug( "%s: modified=%s", thisfn, modified ? "True" : "False" );
-	g_debug( "%s:    valid=%s", thisfn, valid ? "True" : "False" );
+	return( dup );
 }
 
 /**
@@ -267,95 +319,146 @@ na_iduplicable_dump( const NAIDuplicable *object )
  * @object: the #NAIDuplicable object to be checked.
  *
  * Checks the edition status of the #NAIDuplicable object, and set up
- * the corresponding %PROP_IDUPLICABLE_ISMODIFIED and
- * %PROP_IDUPLICABLE_ISVALID properties.
+ * the corresponding properties.
  *
  * This function is supposed to be called each time the object may have
  * been modified in order to set the corresponding properties. Helper
  * functions na_iduplicable_is_modified() and na_iduplicable_is_valid()
  * will then only return the current value of the properties.
  *
- * na_iduplicable_check_status() is not, as itself, recursive.
+ * #na_iduplicable_check_status() is not, as itself, recursive.
  * That is, the modification and validity status are only set on the
  * specified object.
- * Nonetheless, a derived class may perfectly implement a recursive
- * check on childs, if any. See, e.g. #NAObject implementation.
+ * #NAObject implementation has choosen to handle itself the recursivity:
+ * #na_object_check_status() so first check status for childs, before
+ * calling this function.
  */
 void
 na_iduplicable_check_status( const NAIDuplicable *object )
 {
 	static const gchar *thisfn = "na_iduplicable_check_status";
-	gboolean modified = TRUE;
-	NAIDuplicable *origin;
-	gboolean valid;
+	DuplicableStr *str;
 	gboolean was_modified, was_valid;
 
 	g_debug( "%s: object=%p (%s)", thisfn, ( void * ) object, G_OBJECT_TYPE_NAME( object ));
-	g_return_if_fail( st_initialized && !st_finalized );
 	g_return_if_fail( NA_IS_IDUPLICABLE( object ));
 
-	origin = get_origin( object );
-	if( origin ){
+	if( st_initialized && !st_finalized ){
 
-		/* order is important, as derived class may rely on having
-		 * origin first, and then checked object itself
-		 */
-		modified = !v_are_equal( origin, object );
-	}
-	was_modified = set_modified( object, modified );
+		str = get_duplicable_str( object );
 
-	valid = v_is_valid( object );
-	was_valid = set_valid( object, valid );
+		was_modified = str->modified;
+		was_valid = str->valid;
 
-	if(( was_valid && !valid ) || ( !was_valid && valid ) || ( was_modified && !modified ) || ( !was_modified && modified )){
-		g_signal_emit_by_name( G_OBJECT( object ), NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED, object );
-	}
+		if( str->origin ){
+			str->modified = !v_are_equal( str->origin, object );
+		}
+
+		str->valid = v_is_valid( object );
+
+		if(( was_valid && !str->valid ) ||
+			( !was_valid && str->valid ) ||
+			( was_modified && !str->modified ) ||
+			( !was_modified && str->modified )){
+
+				g_signal_emit_by_name( G_OBJECT( object ), NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED, object );
+		}
 
-	#if NA_IDUPLICABLE_EDITION_STATUS_DEBUG
-	g_debug( "%s: object=%p (%s), modified=%s, valid=%s", thisfn,
-			( void * ) object, G_OBJECT_TYPE_NAME( object ),
-			modified ? "True":"False", valid ? "True":"False" );
+#if 0
+		g_debug( "%s: object=%p (%s), modified=%s, valid=%s", thisfn,
+				( void * ) object, G_OBJECT_TYPE_NAME( object ),
+				modified ? "True":"False", valid ? "True":"False" );
 #endif
+	}
 }
 
 /**
- * na_iduplicable_duplicate:
- * @object: the #NAIDuplicable object to be duplicated.
- *
- * Exactly duplicates a #NAIDuplicable-implemented object.
- * Properties %NA_IDUPLICABLE_PROP_ORIGIN, %PROP_IDUPLICABLE_ISMODIFIED
- * and %PROP_IDUPLICABLE_ISVALID are initialized to their default
- * values.
+ * na_iduplicable_get_origin:
+ * @object: the #NAIDuplicable object whose origin is to be returned.
  *
- * As %PROP_IDUPLICABLE_ISVALID property is set to %TRUE without any
- * further check, this suppose that only valid objects are duplicated.
+ * Returns the origin of a duplicated #NAIDuplicable.
  *
- * Returns: a new #NAIDuplicable.
+ * Returns: the original #NAIDuplicable, or NULL.
  */
 NAIDuplicable *
-na_iduplicable_duplicate( const NAIDuplicable *object )
+na_iduplicable_get_origin( const NAIDuplicable *object )
 {
-	/*static const gchar *thisfn = "na_iduplicable_duplicate";*/
-	NAIDuplicable *dup = NULL;
-
-	/*g_debug( "%s: object=%p", thisfn, ( void * ) object );*/
+	NAIDuplicable *origin;
+	DuplicableStr *str;
 
-	g_return_val_if_fail( st_initialized && !st_finalized, NULL );
 	g_return_val_if_fail( NA_IS_IDUPLICABLE( object ), NULL );
 
-	dup = v_new( object );
+	origin = NULL;
 
-	if( dup ){
-		v_copy( dup, object );
-		set_origin( dup, object );
-		set_modified( dup, get_modified( object ));
-		set_valid( dup, get_valid( object ));
+	if( st_initialized && !st_finalized ){
+
+		str = get_duplicable_str( object );
+		origin = str->origin;
 	}
 
-	return( dup );
+	return( origin );
 }
 
 /**
+ * na_iduplicable_is_valid:
+ * @object: the #NAIDuplicable object whose status is to be returned.
+ *
+ * Returns the current value of the relevant property
+ * without rechecking the edition status itself.
+ *
+ * Returns: %TRUE is the provided object is valid.
+ */
+gboolean
+na_iduplicable_is_valid( const NAIDuplicable *object )
+{
+	/*static const gchar *thisfn = "na_iduplicable_is_valid";
+	g_debug( "%s: object=%p", thisfn, object );*/
+	gboolean is_valid;
+	DuplicableStr *str;
+
+	g_return_val_if_fail( NA_IS_IDUPLICABLE( object ), FALSE );
+
+	is_valid = FALSE;
+
+	if( st_initialized && !st_finalized ){
+
+		str = get_duplicable_str( object );
+		is_valid = str->valid;
+	}
+
+	return( is_valid );
+}
+
+static void
+v_copy( NAIDuplicable *target, const NAIDuplicable *source )
+{
+	if( NA_IDUPLICABLE_GET_INTERFACE( target )->copy ){
+		NA_IDUPLICABLE_GET_INTERFACE( target )->copy( target, source );
+	}
+}
+
+static gboolean
+v_are_equal( const NAIDuplicable *a, const NAIDuplicable *b )
+{
+	if( NA_IDUPLICABLE_GET_INTERFACE( a )->are_equal ){
+		return( NA_IDUPLICABLE_GET_INTERFACE( a )->are_equal( a, b ));
+	}
+
+	return( FALSE );
+}
+
+static gboolean
+v_is_valid( const NAIDuplicable *object )
+{
+	if( NA_IDUPLICABLE_GET_INTERFACE( object )->is_valid ){
+		return( NA_IDUPLICABLE_GET_INTERFACE( object )->is_valid( object ));
+	}
+
+	return( FALSE );
+}
+
+#if 0
+/**
  * na_iduplicable_reset_status:
  * @object: the #NAIDuplicable object whose status is to be reset.
  *
@@ -397,53 +500,6 @@ na_iduplicable_is_modified( const NAIDuplicable *object )
 }
 
 /**
- * na_iduplicable_is_valid:
- * @object: the #NAIDuplicable object whose status is to be returned.
- *
- * Returns the current value of the %PROP_IDUPLICABLE_ISVALID property
- * without rechecking the edition status itself.
- *
- * Returns: %TRUE is the provided object is valid.
- */
-gboolean
-na_iduplicable_is_valid( const NAIDuplicable *object )
-{
-	/*static const gchar *thisfn = "na_iduplicable_is_valid";
-	g_debug( "%s: object=%p", thisfn, object );*/
-	gboolean is_valid = FALSE;
-
-	g_return_val_if_fail( st_initialized && !st_finalized, FALSE );
-	g_return_val_if_fail( NA_IS_IDUPLICABLE( object ), FALSE );
-
-	is_valid = get_valid( object );
-
-	return( is_valid );
-}
-
-/**
- * na_iduplicable_get_origin:
- * @object: the #NAIDuplicable object whose origin is to be returned.
- *
- * Returns the origin of a duplicated #NAIDuplicable.
- *
- * Returns: the original #NAIDuplicable, or NULL.
- */
-NAIDuplicable *
-na_iduplicable_get_origin( const NAIDuplicable *object )
-{
-	/*static const gchar *thisfn = "na_iduplicable_is_valid";
-	g_debug( "%s: object=%p", thisfn, object );*/
-	NAIDuplicable *origin = NULL;
-
-	g_return_val_if_fail( st_initialized && !st_finalized, NULL );
-	g_return_val_if_fail( NA_IS_IDUPLICABLE( object ), NULL );
-
-	origin = get_origin( object );
-
-	return( origin );
-}
-
-/**
  * na_iduplicable_set_origin:
  * @object: the #NAIDuplicable object whose origin is to be set.
  * @origin: the new original #NAIDuplicable.
@@ -490,34 +546,6 @@ v_new( const NAIDuplicable *object )
 	return( NULL );
 }
 
-static void
-v_copy( NAIDuplicable *target, const NAIDuplicable *source )
-{
-	if( NA_IDUPLICABLE_GET_INTERFACE( target )->copy ){
-		NA_IDUPLICABLE_GET_INTERFACE( target )->copy( target, source );
-	}
-}
-
-static gboolean
-v_are_equal( const NAIDuplicable *a, const NAIDuplicable *b )
-{
-	if( NA_IDUPLICABLE_GET_INTERFACE( a )->are_equal ){
-		return( NA_IDUPLICABLE_GET_INTERFACE( a )->are_equal( a, b ));
-	}
-
-	return( FALSE );
-}
-
-static gboolean
-v_is_valid( const NAIDuplicable *object )
-{
-	if( NA_IDUPLICABLE_GET_INTERFACE( object )->is_valid ){
-		return( NA_IDUPLICABLE_GET_INTERFACE( object )->is_valid( object ));
-	}
-
-	return( FALSE );
-}
-
 static gboolean
 get_modified( const NAIDuplicable *object )
 {
@@ -621,3 +649,32 @@ release_signal_consumers( GList *consumers )
 {
 	g_list_free( consumers );
 }
+#endif
+
+static DuplicableStr *
+get_duplicable_str( const NAIDuplicable *object )
+{
+	DuplicableStr *str;
+
+	str = ( DuplicableStr * ) g_object_get_data( G_OBJECT( object ), NA_IDUPLICABLE_DATA_DUPLICABLE );
+
+	if( !str ){
+		str = g_new0( DuplicableStr, 1 );
+
+		str->origin = NULL;
+		str->modified = FALSE;
+		str->valid = TRUE;
+
+#if 0
+		str->status_changed_handler_id = g_signal_connect(
+				G_OBJECT( object ),
+				NA_IDUPLICABLE_SIGNAL_STATUS_CHANGED,
+				G_CALLBACK( status_changed_handler ),
+				object );
+#endif
+
+		g_object_set_data( G_OBJECT( object ), NA_IDUPLICABLE_DATA_DUPLICABLE, str );
+	}
+
+	return( str );
+}



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