[nautilus-actions] Initialize the order mode at runtime init



commit 8d2eea2a25a80b306b5301be354bbf9709053576
Author: Pierre Wieser <pwieser trychlos org>
Date:   Tue Oct 13 22:06:32 2009 +0200

    Initialize the order mode at runtime init

 ChangeLog                     |    3 +++
 src/nact/nact-iactions-list.c |    7 +++++--
 src/nact/nact-main-window.c   |    4 ++++
 src/nact/nact-tree-model.c    |   20 +++++++++++++-------
 src/nact/nact-tree-model.h    |    2 +-
 5 files changed, 26 insertions(+), 10 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index cefd9d6..fc26044 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,15 +9,18 @@
 
 	* src/nact/nact-iactions-list.c (on_tab_updatable_item_updated):
 	Recursively update the display of parents of the updated item.
+	(do_insert_items): Insert childs into the actual insertion path.
 
 	* src/nact/nact-main-menubar.c (on_update_sensitivities):
 	Only enable new menu and new action when on an action or a menu.
 
 	* src/nact/nact-main-tab.h:
 	* src/nact/nact-main-window.c: New SELECTED_ROW property.
+	(on_base_runtime_init_toplevel): Setup the order mode at init time.
 
 	* src/nact/nact-tree-model.c (sort_actions_list):
 	Do not sort profiles.
+	(nact_tree_model_insert): Returns the actual insertion path.
 
 	* src/runtime/na-gconf-provider-keys.h:
 	OBJECT_ITEM_TYPE_ENTRY: new key which defines the type of the entry.
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 63c86a2..57b29dd 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -1189,6 +1189,7 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
 	GList *subitems;
 	NAObject *obj_parent;
 	gpointer updatable;
+	GtkTreePath *inserted_path;
 
 	obj_parent = NULL;
 	if( list_parents ){
@@ -1199,7 +1200,7 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
 
 	for( it = reversed ; it ; it = it->next ){
 
-		nact_tree_model_insert( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ), insert_path, &obj_parent );
+		inserted_path = nact_tree_model_insert( NACT_TREE_MODEL( model ), NA_OBJECT( it->data ), insert_path, &obj_parent );
 
 		g_debug( "%s: object=%p (%s, ref_count=%d)", thisfn,
 				( void * ) it->data, G_OBJECT_TYPE_NAME( it->data ), G_OBJECT( it->data )->ref_count );
@@ -1216,8 +1217,10 @@ do_insert_items( GtkTreeView *treeview, GtkTreeModel *model, GList *items, GtkTr
 		if( NA_IS_OBJECT_ITEM( it->data ) && na_object_get_items_count( it->data )){
 
 			subitems = na_object_get_items_list( it->data );
-			do_insert_into_first( treeview, model, subitems, insert_path, NULL );
+			do_insert_into_first( treeview, model, subitems, inserted_path, NULL );
 		}
+
+		gtk_tree_path_free( inserted_path );
 	}
 
 	/*g_list_free( reversed );*/
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index de9384c..698865c 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -922,6 +922,7 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
 	NactApplication *application;
 	NAPivot *pivot;
 	GList *tree;
+	gint order_mode;
 
 	g_debug( "%s: window=%p, user_data=%p", thisfn, ( void * ) window, ( void * ) user_data );
 	g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
@@ -945,6 +946,9 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
 		nact_iadvanced_tab_runtime_init_toplevel( NACT_IADVANCED_TAB( window ));
 		nact_main_menubar_runtime_init( window );
 
+		order_mode = na_iprefs_get_order_mode( NA_IPREFS( pivot ));
+		ipivot_consumer_on_display_order_changed( NA_IPIVOT_CONSUMER( window ), order_mode );
+
 		/* fill the IActionsList at last so that all signals are connected
 		 */
 		nact_iactions_list_runtime_init_toplevel( NACT_IACTIONS_LIST( window ), tree );
diff --git a/src/nact/nact-tree-model.c b/src/nact/nact-tree-model.c
index 10407b2..1d8b6de 100644
--- a/src/nact/nact-tree-model.c
+++ b/src/nact/nact-tree-model.c
@@ -442,7 +442,7 @@ nact_tree_model_initial_load( BaseWindow *window, GtkTreeView *treeview )
 }
 
 /**
- * nact_tree_model_runtime_init_dnd:
+ * nact_tree_model_runtime_init:
  * @model: this #NactTreeModel instance.
  * @have_dnd: whether the tree model must implement drag and drop
  * interfaces.
@@ -739,11 +739,10 @@ fill_tree_store( GtkTreeStore *model, GtkTreeView *treeview,
  * profile in an action, we may have store_iter_path="0:1" (good), but
  * iter_path="0:0" (bad) - so we'd rather return a string path.
  *
- * Note that we do not return anything here as the insertion path at
- * the beginning of the function is always valid when the function
- * returns; it points now to the newly inserted row.
+ * Returns: the actual insertion path, which may be different from the
+ * asked insertion path if tree is sorted.
  */
-void
+GtkTreePath *
 nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent )
 {
 	static const gchar *thisfn = "nact_tree_model_insert";
@@ -752,6 +751,7 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
 	GtkTreeIter iter;
 	GtkTreeIter parent_iter;
 	GtkTreePath *parent_path;
+	GtkTreePath *inserted_path;
 	NAObject *parent_obj;
 	gboolean has_parent;
 	GtkTreeIter sibling_iter;
@@ -765,8 +765,10 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
 			( void * ) object, G_OBJECT_TYPE_NAME( object ), G_OBJECT( object )->ref_count,
 			( void * ) path, path_str, ( void * ) parent );
 	g_free( path_str );
-	g_return_if_fail( NACT_IS_TREE_MODEL( model ));
-	g_return_if_fail( NA_IS_OBJECT( object ));
+	g_return_val_if_fail( NACT_IS_TREE_MODEL( model ), NULL );
+	g_return_val_if_fail( NA_IS_OBJECT( object ), NULL );
+
+	inserted_path = NULL;
 
 	if( !model->private->dispose_has_run ){
 
@@ -816,7 +818,11 @@ nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePat
 				has_sibling ? &sibling_iter : NULL );
 		gtk_tree_store_set( GTK_TREE_STORE( store ), &iter, IACTIONS_LIST_NAOBJECT_COLUMN, object, -1 );
 		display_item( GTK_TREE_STORE( store ), model->private->treeview, &iter, object );
+
+		inserted_path = gtk_tree_model_get_path( store, &iter );
 	}
+
+	return( inserted_path );
 }
 
 GtkTreePath *
diff --git a/src/nact/nact-tree-model.h b/src/nact/nact-tree-model.h
index 9ea00ed..5cc9eb4 100644
--- a/src/nact/nact-tree-model.h
+++ b/src/nact/nact-tree-model.h
@@ -97,7 +97,7 @@ void         nact_tree_model_display( NactTreeModel *model, NAObject *object );
 void         nact_tree_model_display_order_change( NactTreeModel *model, gint order_mode );
 void         nact_tree_model_dump( NactTreeModel *model );
 void         nact_tree_model_fill( NactTreeModel *model, GList *items, gboolean only_actions);
-void         nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent );
+GtkTreePath *nact_tree_model_insert( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent );
 GtkTreePath *nact_tree_model_insert_into( NactTreeModel *model, const NAObject *object, GtkTreePath *path, NAObject **parent );
 void         nact_tree_model_iter( NactTreeModel *model, FnIterOnStore fn, gpointer user_data );
 NAObject    *nact_tree_model_object_at_path( NactTreeModel *model, GtkTreePath *path );



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