[nautilus-actions] Recursively update the parents of an item



commit a3241e1b70754598fc14d0aab0a9acb0766389d4
Author: pierre <pierre vfedora10 virtuals pwi>
Date:   Tue Oct 13 09:27:29 2009 +0200

    Recursively update the parents of an item

 ChangeLog                     |   12 ++++++++++++
 src/common/na-object-api.h    |    1 +
 src/common/na-object-id-fn.h  |    5 +++--
 src/common/na-object-id.c     |   25 +++++++++++++++++++++++++
 src/nact/nact-iactions-list.c |   14 ++------------
 5 files changed, 43 insertions(+), 14 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 486bfc9..d67daf4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2009-10-13 Pierre Wieser <pwieser trychlos org>
+
+	* src/common/na-object-api.h (na_object_get_topmost_parent):
+	New function.
+
+	* src/common/na-object-id-fn.h:
+	* src/common/na-object-id.c (na_object_id_get_topmost_parent):
+	New function.
+
+	* src/nact/nact-iactions-list.c (on_tab_updatable_item_updated):
+	Recursively update the display of parents of the updated item.
+
 2009-10-12 Pierre Wieser <pwieser trychlos org>
 
 	* src/common/na-object-api.h
diff --git a/src/common/na-object-api.h b/src/common/na-object-api.h
index fb6eab0..92f8d4d 100644
--- a/src/common/na-object-api.h
+++ b/src/common/na-object-api.h
@@ -63,6 +63,7 @@ G_BEGIN_DECLS
 
 /* NAObjectId
  */
+#define na_object_get_topmost_parent( object )		na_object_id_get_topmost_parent( NA_OBJECT_ID( object ))
 #define na_object_prepare_for_paste( object, pivot, renumber, action ) \
 													na_object_id_prepare_for_paste( NA_OBJECT_ID( object ), pivot, renumber, ( NAObjectAction * ) action )
 #define na_object_set_copy_of_label( object )		na_object_id_set_copy_of_label( NA_OBJECT_ID( object ))
diff --git a/src/common/na-object-id-fn.h b/src/common/na-object-id-fn.h
index 6b7b74b..9127f74 100644
--- a/src/common/na-object-id-fn.h
+++ b/src/common/na-object-id-fn.h
@@ -48,8 +48,9 @@
 
 G_BEGIN_DECLS
 
-void na_object_id_prepare_for_paste( NAObjectId *object, NAPivot *pivot, gboolean renumber, NAObjectAction *action );
-void na_object_id_set_copy_of_label( NAObjectId *object );
+NAObjectId *na_object_id_get_topmost_parent( NAObjectId *object );
+void        na_object_id_prepare_for_paste( NAObjectId *object, NAPivot *pivot, gboolean renumber, NAObjectAction *action );
+void        na_object_id_set_copy_of_label( NAObjectId *object );
 
 G_END_DECLS
 
diff --git a/src/common/na-object-id.c b/src/common/na-object-id.c
index 48f641f..701e1ff 100644
--- a/src/common/na-object-id.c
+++ b/src/common/na-object-id.c
@@ -42,6 +42,31 @@
 #include "na-iprefs.h"
 
 /**
+ * na_object_id_get_topmost_parent:
+ * @object: the #NAObject whose parent is searched.
+ *
+ * Returns: the topmost parent, maybe @object itself.
+ */
+NAObjectId *
+na_object_id_get_topmost_parent( NAObjectId *object )
+{
+	NAObjectId *parent;
+
+	g_return_val_if_fail( NA_IS_OBJECT_ID( object ), NULL );
+
+	parent = object;
+
+	if( !object->private->dispose_has_run ){
+
+		while( parent->private->parent ){
+			parent = NA_OBJECT_ID( parent->private->parent );
+		}
+	}
+
+	return( parent );
+}
+
+/**
  * na_object_id_prepare_for_paste:
  * @object: the #NAObjectId object to be pasted.
  * @pivot; the #NAPivot instance which let us access to preferences.
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index bf3e28c..63c86a2 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -1921,7 +1921,7 @@ static void
 on_tab_updatable_item_updated( NactIActionsList *instance, NAObject *object )
 {
 	static const gchar *thisfn = "nact_iactions_list_on_tab_updatable_item_updated";
-	NAObject *item;
+	NAObjectId *item;
 	GtkTreeView *treeview;
 	GtkTreeModel *model;
 
@@ -1931,18 +1931,8 @@ on_tab_updatable_item_updated( NactIActionsList *instance, NAObject *object )
 	if( object ){
 		treeview = get_actions_list_treeview( instance );
 		model = gtk_tree_view_get_model( treeview );
-
-		item = object;
-		if( NA_IS_OBJECT_PROFILE( object )){
-			item = NA_OBJECT( na_object_get_parent( object ));
-		}
-
+		item = na_object_get_topmost_parent( object );
 		na_object_check_edition_status( item );
-
-		nact_tree_model_display( NACT_TREE_MODEL( model ), object );
-		if( NA_IS_OBJECT_PROFILE( object )){
-			nact_tree_model_display( NACT_TREE_MODEL( model ), NA_OBJECT( item ));
-		}
 	}
 }
 



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