[nautilus-actions] NAObject: deprecate na_object_get_hierarchy()



commit da82f4681f02bfc88084ea5e66d2b29a773103c8
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Feb 21 23:33:35 2011 +0100

    NAObject: deprecate na_object_get_hierarchy()

 ChangeLog               |    6 ++++++
 src/api/na-object.h     |   29 +++++++++++------------------
 src/core/na-object-id.c |   24 ++++--------------------
 src/core/na-object.c    |    5 ++++-
 4 files changed, 25 insertions(+), 39 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 334e8ae..1005231 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2011-02-21 Pierre Wieser <pwieser trychlos org>
 
+	* src/api/na-object.h:
+	* src/core/na-object.c (na_object_get_hierarchy, na_object_free_hierarchy):
+	Deprecated functions.
+
+	* src/core/na-object-id.c (v_new_id): No more call na_object_get_hierarchy().
+
 	Rewrite copy stack to get ride of iteration on class hierarchy
 
 	* src/api/na-object-api.h
diff --git a/src/api/na-object.h b/src/api/na-object.h
index 1e3a919..2454106 100644
--- a/src/api/na-object.h
+++ b/src/api/na-object.h
@@ -103,11 +103,8 @@ typedef struct {
 	 *
 	 * Copies data and properties from @source to @target.
 	 *
-	 * Each derived class should take care of implementing this function
-	 * when relevant. NAObject class will take care of calling this
-	 * function for each class of the hierarchy, starting from topmost
-	 * base class up to the most-derived one. Each class has so only to
-	 * take care of dumping its own data.
+	 * The derived class should call its parent class at the end of the
+	 * copy of its own datas.
 	 *
 	 * Since: 2.30
 	 */
@@ -123,12 +120,9 @@ typedef struct {
 	 * When testing for the modification status of an object, @a stands for
 	 * the original object, while @b stands for the duplicated one.
 	 *
-	 * Each derived class should take care of implementing this function
-	 * when relevant. NAObject class will take care of calling this
-	 * function for each class of the hierarchy, starting from topmost
-	 * base class up to the most-derived one, at least while result
-	 * stays at TRUE.
-	 * As soon as a difference is detected, the calling sequence will
+	 * As long as no difference is detected, the derived class should call
+	 * its parent class at the end of its comparison.
+	 * As soon as a difference is detected, the calling sequence should
 	 * be stopped, and the result returned.
 	 *
 	 * Returns: TRUE if @a and @b are identical, FALSE else.
@@ -145,13 +139,10 @@ typedef struct {
 	 *
 	 * A NAObject is valid if its internal identifier is set.
 	 *
-	 * Each derived class should take care of implementing this function
-	 * when relevant. NAObject class will take care of calling this
-	 * function for each class of the hierarchy, starting from topmost
-	 * base class up to the most-derived one, at least while result
-	 * stays at TRUE.
-	 * As soon as a difference is detected, the calling sequence will
-	 * be stopped, and the result returned.
+	 * As long as the item is valid, the derived class should call its parent
+	 * at the end of its checks.
+	 * As soon as an error is detected, the calling sequence should be stopped,
+	 * and the result returned.
 	 *
 	 * Returns: TRUE if @object is valid, FALSE else.
 	 *
@@ -174,8 +165,10 @@ void      na_object_object_dump      ( const NAObject *object );
 void      na_object_object_dump_norec( const NAObject *object );
 void      na_object_object_dump_tree ( GList *tree );
 
+#ifndef NA_DISABLE_DEPRECATED
 GList    *na_object_get_hierarchy( const NAObject *object );
 void      na_object_free_hierarchy( GList *hierarchy );
+#endif
 
 void      na_object_object_debug_invalid( const NAObject *object, const gchar *reason );
 
diff --git a/src/core/na-object-id.c b/src/core/na-object-id.c
index 4712ef9..cb94c1b 100644
--- a/src/core/na-object-id.c
+++ b/src/core/na-object-id.c
@@ -380,27 +380,11 @@ na_object_id_set_new_id( NAObjectId *object, const NAObjectId *new_parent )
 static gchar *
 v_new_id( const NAObjectId *object, const NAObjectId *new_parent )
 {
-	gchar *new_id;
-	GList *hierarchy, *ih;
-	gboolean found;
-
-	found = FALSE;
-	new_id = NULL;
-	hierarchy = g_list_reverse( na_object_get_hierarchy( NA_OBJECT( object )));
-	/*g_debug( "na_object_id_most_derived_id: object=%p (%s)",
-					( void * ) object, G_OBJECT_TYPE_NAME( object ));*/
-
-	for( ih = hierarchy ; ih && !found ; ih = ih->next ){
-		if( NA_OBJECT_ID_CLASS( ih->data )->new_id ){
-			new_id = NA_OBJECT_ID_CLASS( ih->data )->new_id( object, new_parent );
-			found = TRUE;
-		}
-		if( G_OBJECT_CLASS_TYPE( ih->data ) == NA_OBJECT_ID_TYPE ){
-			break;
-		}
-	}
+	gchar *new_id = NULL;
 
-	na_object_free_hierarchy( hierarchy );
+	if( NA_OBJECT_ID_GET_CLASS( object )->new_id ){
+		new_id = NA_OBJECT_ID_GET_CLASS( object )->new_id( object, new_parent );
+	}
 
 	return( new_id );
 }
diff --git a/src/core/na-object.c b/src/core/na-object.c
index 13e44ce..74b8126 100644
--- a/src/core/na-object.c
+++ b/src/core/na-object.c
@@ -69,7 +69,6 @@ static void     v_copy( NAObject *target, const NAObject *source, gboolean recur
 static gboolean v_are_equal( const NAObject *a, const NAObject *b );
 static gboolean v_is_valid( const NAObject *a );
 static void     dump_tree( GList *tree, gint level );
-static GList   *build_class_hierarchy( const NAObject *object );
 
 GType
 na_object_object_get_type( void )
@@ -647,6 +646,7 @@ na_object_object_unref( NAObject *object )
 	}
 }
 
+#ifndef NA_DISABLE_DEPRECATED
 /*
  * build the class hierarchy
  * returns a list of GObjectClass, which starts with NAObject,
@@ -680,6 +680,7 @@ build_class_hierarchy( const NAObject *object )
  * from the topmost base class, to the most-derived one.
  *
  * Since: 2.30
+ * Deprecated: 3.1.0
  */
 GList *
 na_object_get_hierarchy( const NAObject *object )
@@ -706,12 +707,14 @@ na_object_get_hierarchy( const NAObject *object )
  * Releases the #NAObject hierarchy.
  *
  * Since: 2.30
+ * Deprecated: 3.1.0
  */
 void
 na_object_free_hierarchy( GList *hierarchy )
 {
 	g_list_free( hierarchy );
 }
+#endif /* NA_DISABLE_DEPRECATED */
 
 /**
  * na_object_object_debug_invalid:



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