[nautilus-actions] Fix the dialog title when changing level zero order



commit 94009f43126c0fb8ada89edaffb67aa6b27c10a3
Author: Pierre Wieser <pwieser trychlos org>
Date:   Thu Mar 25 00:15:40 2010 +0100

    Fix the dialog title when changing level zero order

 ChangeLog                          |   25 ++++++++++++++++++++++
 TODO                               |    2 -
 src/nact/nact-assistant-export.c   |    7 +++++-
 src/nact/nact-iaction-tab.c        |    2 +-
 src/nact/nact-iactions-list-bis.c  |   15 ++++++++-----
 src/nact/nact-iactions-list-priv.h |    2 +-
 src/nact/nact-iactions-list.c      |   33 +++++++++++++++-------------
 src/nact/nact-iactions-list.h      |    2 +-
 src/nact/nact-iadvanced-tab.c      |    2 +-
 src/nact/nact-icommand-tab.c       |    2 +-
 src/nact/nact-iconditions-tab.c    |    2 +-
 src/nact/nact-ifolders-tab.c       |    2 +-
 src/nact/nact-main-menubar.c       |   23 +++++++++++++++++--
 src/nact/nact-main-menubar.h       |    2 +-
 src/nact/nact-main-tab.h           |    1 -
 src/nact/nact-main-window.c        |   41 +++++++++++++++++++++++++++++------
 src/nact/nact-main-window.h        |    1 +
 src/nact/nact-tree-model-dnd.c     |    4 +-
 18 files changed, 123 insertions(+), 45 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c74d31a..ffebc67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,10 +1,35 @@
 2009-03-24 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-iaction-tab.c (nact_iaction_tab_runtime_init_toplevel):
+	* src/nact/nact-iadvanced-tab.c (runtime_init_connect_signals):
+	* src/nact/nact-icommand-tab.c (nact_icommand_tab_runtime_init_toplevel):
+	* src/nact/nact-iconditions-tab.c (nact_iconditions_tab_runtime_init_toplevel):
+	* src/nact/nact-ifolders-tab.c (nact_ifolders_tab_runtime_init_toplevel):
+	* src/nact/nact-main-tab.h:
+	Signal TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED is renamed as
+	MAIN_WINDOW_SIGNAL_SELECTION_CHANGED.
+
+	* src/nact/nact-main-menubar.c:
+	* src/nact/nact-main-menubar.h
+	(nact_main_menubar_is_level_zero_order_changed): New function.
+
+	* src/nact/nact-iactions-list.h:
+	* src/nact/nact-iactions-list-bis.c (nact_iactions_list_bis_delete):
+	Add an argument to select the row at end of the function.
+
+	* src/nact/nact-main-window.c:
+	Connect to MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED to update
+	dialog title.
+
 	* src/nact/nact-iactions-list.c:
 	* src/nact/nact-iactions-list.h
 	(selection_changed): Remove the not used API.
 	Remove the connection to the signal and the call to the interface.
 
+	* src/nact/nact-assistant-export.c (iactions_list_iface_init):
+	Use the IACTIONS_LIST_SIGNAL_SELECTION_CHANGED instead of the
+	interface API.
+
 	* src/nact/nact-main-window.c
 	(ipivot_consumer_on_display_order_changed):
 	Relay NAIPivotConsumer notification to nact_sort_buttons.
diff --git a/TODO b/TODO
index e78329e..733def2 100644
--- a/TODO
+++ b/TODO
@@ -137,5 +137,3 @@
             properties/
             conditions/
             command/
-
-- bug: when order changes, nact is not marked modified
diff --git a/src/nact/nact-assistant-export.c b/src/nact/nact-assistant-export.c
index bef820e..34a7d7d 100644
--- a/src/nact/nact-assistant-export.c
+++ b/src/nact/nact-assistant-export.c
@@ -222,7 +222,6 @@ iactions_list_iface_init( NactIActionsListInterface *iface )
 
 	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
 
-	iface->selection_changed = on_iactions_list_selection_changed;
 	iface->get_treeview_name = on_iactions_list_get_treeview_name;
 }
 
@@ -383,6 +382,12 @@ on_runtime_init_dialog( NactAssistantExport *dialog, gpointer user_data )
 
 	assistant = GTK_ASSISTANT( base_window_get_toplevel( BASE_WINDOW( dialog )));
 
+	base_window_signal_connect(
+			BASE_WINDOW( dialog ),
+			G_OBJECT( dialog ),
+			IACTIONS_LIST_SIGNAL_SELECTION_CHANGED,
+			G_CALLBACK( on_iactions_list_selection_changed ));
+
 	assist_runtime_init_intro( dialog, assistant );
 	assist_runtime_init_actions_list( dialog, assistant );
 	assist_runtime_init_target_folder( dialog, assistant );
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 4f6d79c..f46aba8 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -237,7 +237,7 @@ nact_iaction_tab_runtime_init_toplevel( NactIActionTab *instance )
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
 				G_OBJECT( instance ),
-				TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+				MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
 				G_CALLBACK( on_tab_updatable_selection_changed ));
 
 		base_window_signal_connect(
diff --git a/src/nact/nact-iactions-list-bis.c b/src/nact/nact-iactions-list-bis.c
index b2a237c..77945dc 100644
--- a/src/nact/nact-iactions-list-bis.c
+++ b/src/nact/nact-iactions-list-bis.c
@@ -168,7 +168,7 @@ nact_iactions_list_bis_collapse_to_parent( NactIActionsList *instance )
  * possible, and refilter the display model.
  */
 void
-nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items )
+nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items, gboolean select_at_end )
 {
 	static const gchar *thisfn = "nact_iactions_list_bis_delete";
 	GtkTreeView *treeview;
@@ -177,8 +177,8 @@ nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items )
 	GList *it;
 	IActionsListInstanceData *ialid;
 
-	g_debug( "%s: instance=%p, items=%p (count=%d)",
-			thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ));
+	g_debug( "%s: instance=%p, items=%p (count=%d), select_at_end=%s",
+			thisfn, ( void * ) instance, ( void * ) items, g_list_length( items ), select_at_end ? "True":"False" );
 	g_return_if_fail( NACT_IS_IACTIONS_LIST( instance ));
 
 	if( st_iactions_list_initialized && !st_iactions_list_finalized ){
@@ -187,7 +187,7 @@ nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items )
 		model = gtk_tree_view_get_model( treeview );
 
 		ialid = nact_iactions_list_priv_get_instance_data( instance );
-		ialid->selection_changed_send_allowed = FALSE;
+		ialid->selection_changed_allowed = FALSE;
 
 		decrement_counters( instance, ialid, items );
 
@@ -206,10 +206,12 @@ nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items )
 
 		gtk_tree_model_filter_refilter( GTK_TREE_MODEL_FILTER( model ));
 
-		ialid->selection_changed_send_allowed = TRUE;
+		ialid->selection_changed_allowed = TRUE;
 
 		if( path ){
-			nact_iactions_list_bis_select_row_at_path( instance, treeview, model, path );
+			if( select_at_end ){
+				nact_iactions_list_bis_select_row_at_path( instance, treeview, model, path );
+			}
 			gtk_tree_path_free( path );
 		}
 	}
@@ -597,6 +599,7 @@ nact_iactions_list_bis_remove_modified( NactIActionsList *instance, const NAObje
 
 		ialid = nact_iactions_list_priv_get_instance_data( instance );
 		ialid->modified_items = g_list_remove( ialid->modified_items, item );
+
 		if( g_list_length( ialid->modified_items ) == 0 ){
 			g_list_free( ialid->modified_items );
 			ialid->modified_items = NULL;
diff --git a/src/nact/nact-iactions-list-priv.h b/src/nact/nact-iactions-list-priv.h
index 67157b9..58f69b2 100644
--- a/src/nact/nact-iactions-list-priv.h
+++ b/src/nact/nact-iactions-list-priv.h
@@ -54,8 +54,8 @@ typedef struct {
 
 	/* signal management
 	 */
+	gboolean selection_changed_allowed;
 	gulong   tab_updated_handler;
-	gboolean selection_changed_send_allowed;
 
 	/* maintains a flat list of modified objects
 	 * should be faster than iterating each time this is needed
diff --git a/src/nact/nact-iactions-list.c b/src/nact/nact-iactions-list.c
index 5b30b5c..dcd069c 100644
--- a/src/nact/nact-iactions-list.c
+++ b/src/nact/nact-iactions-list.c
@@ -191,7 +191,7 @@ interface_base_init( NactIActionsListInterface *klass )
 		 * The main window is typically the only interested. It will
 		 * setup current item and profiles, before emitting another
 		 * signal targeting the notebook tabs
-		 * (see. TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED signal).
+		 * (see. MAIN_WINDOW_SIGNAL_SELECTION_CHANGED signal).
 		 */
 		st_signals[ SELECTION_CHANGED ] = g_signal_new_class_handler(
 				IACTIONS_LIST_SIGNAL_SELECTION_CHANGED,
@@ -350,16 +350,14 @@ nact_iactions_list_initial_load_toplevel( NactIActionsList *instance )
 	if( st_iactions_list_initialized && !st_iactions_list_finalized ){
 
 		treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
-
 		ialid = nact_iactions_list_priv_get_instance_data( instance );
-		ialid->selection_changed_send_allowed = FALSE;
+		ialid->selection_changed_allowed = FALSE;
 
 		/* associates the ActionsList to the label */
 		label = base_window_get_widget( BASE_WINDOW( instance ), "ActionsListLabel" );
 		gtk_label_set_mnemonic_widget( GTK_LABEL( label ), GTK_WIDGET( treeview ));
 
 		nact_tree_model_initial_load( BASE_WINDOW( instance ), treeview );
-
 		gtk_tree_view_set_enable_tree_lines( treeview, TRUE );
 
 		/* create visible columns on the tree view
@@ -416,6 +414,7 @@ nact_iactions_list_runtime_init_toplevel( NactIActionsList *instance, GList *ite
 		model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
 
 		ialid = nact_iactions_list_priv_get_instance_data( instance );
+		ialid->selection_changed_allowed = FALSE;
 		have_dnd = have_dnd_mode( instance, ialid );
 		have_filter_selection = have_filter_selection_mode( instance, ialid );
 
@@ -538,10 +537,12 @@ nact_iactions_list_dispose( NactIActionsList *instance )
 
 		treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
 		model = NACT_TREE_MODEL( gtk_tree_view_get_model( treeview ));
+
 		ialid = nact_iactions_list_priv_get_instance_data( instance );
-		ialid->selection_changed_send_allowed = FALSE;
 		g_list_free( ialid->modified_items );
+		ialid->modified_items = NULL;
 
+		ialid->selection_changed_allowed = FALSE;
 		nact_tree_model_dispose( model );
 
 		g_free( ialid );
@@ -668,15 +669,13 @@ nact_iactions_list_fill( NactIActionsList *instance, GList *items )
 		ialid = nact_iactions_list_priv_get_instance_data( instance );
 		profiles_are_displayed = are_profiles_displayed( instance, ialid );
 
-		ialid->selection_changed_send_allowed = FALSE;
-
+		ialid->selection_changed_allowed = FALSE;
 		nact_tree_model_fill( model, items, profiles_are_displayed );
+		ialid->selection_changed_allowed = TRUE;
 
 		g_list_free( ialid->modified_items );
 		ialid->modified_items = NULL;
 
-		ialid->selection_changed_send_allowed = TRUE;
-
 		g_signal_emit_by_name(
 				instance,
 				MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED,
@@ -761,8 +760,9 @@ nact_iactions_list_on_treeview_selection_changed( GtkTreeSelection *selection, N
 	IActionsListInstanceData *ialid;
 
 	ialid = nact_iactions_list_priv_get_instance_data( instance );
-	if( ialid->selection_changed_send_allowed ){
+	if( ialid->selection_changed_allowed ){
 
+		g_debug( "nact_iactions_list_on_treeview_selection_changed" );
 		g_signal_handler_block( instance, ialid->tab_updated_handler );
 
 		selected_items = nact_iactions_list_bis_get_selected_items( instance );
@@ -770,9 +770,9 @@ nact_iactions_list_on_treeview_selection_changed( GtkTreeSelection *selection, N
 		g_signal_emit_by_name( instance, IACTIONS_LIST_SIGNAL_SELECTION_CHANGED, selected_items );
 
 		g_signal_handler_unblock( instance, ialid->tab_updated_handler );
-	}
 
-	/* selection list is freed in cleanup handler for the signal */
+		/* selection list is freed in cleanup handler for the signal */
+	}
 }
 
 /**
@@ -1070,6 +1070,9 @@ inline_edition( NactIActionsList *instance )
 
 	ialid = nact_iactions_list_priv_get_instance_data( instance );
 	if( ialid->management_mode == IACTIONS_LIST_MANAGEMENT_MODE_EDITION ){
+
+		ialid->selection_changed_allowed = FALSE;
+
 		treeview = nact_iactions_list_priv_get_actions_list_treeview( instance );
 		selection = gtk_tree_view_get_selection( treeview );
 		listrows = gtk_tree_selection_get_selected_rows( selection, NULL );
@@ -1077,13 +1080,13 @@ inline_edition( NactIActionsList *instance )
 		if( g_list_length( listrows ) == 1 ){
 			path = ( GtkTreePath * ) listrows->data;
 			column = gtk_tree_view_get_column( treeview, IACTIONS_LIST_LABEL_COLUMN );
-			ialid->selection_changed_send_allowed = FALSE;
 			gtk_tree_view_set_cursor( treeview, path, column, TRUE );
-			ialid->selection_changed_send_allowed = TRUE;
 		}
 
 		g_list_foreach( listrows, ( GFunc ) gtk_tree_path_free, NULL );
 		g_list_free( listrows );
+
+		ialid->selection_changed_allowed = TRUE;
 	}
 }
 
@@ -1150,7 +1153,7 @@ on_edition_status_changed( NactIActionsList *instance, NAIDuplicable *object )
 
 	/* do not send status-changed signal while filling the tree
 	 */
-	if( ialid->selection_changed_send_allowed ){
+	if( ialid->selection_changed_allowed ){
 		g_signal_emit_by_name( instance, IACTIONS_LIST_SIGNAL_STATUS_CHANGED, NULL );
 	}
 }
diff --git a/src/nact/nact-iactions-list.h b/src/nact/nact-iactions-list.h
index 0926ea8..33c77f8 100644
--- a/src/nact/nact-iactions-list.h
+++ b/src/nact/nact-iactions-list.h
@@ -122,7 +122,7 @@ void      nact_iactions_list_set_management_mode( NactIActionsList *instance, gi
 
 void      nact_iactions_list_bis_clear_selection( NactIActionsList *instance, GtkTreeView *treeview );
 void      nact_iactions_list_bis_collapse_to_parent( NactIActionsList *instance );
-void      nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items );
+void      nact_iactions_list_bis_delete( NactIActionsList *instance, GList *items, gboolean select_at_end );
 void      nact_iactions_list_bis_expand_to_first_child( NactIActionsList *instance );
 NAObject *nact_iactions_list_bis_get_item( NactIActionsList *instance, const gchar *uuid );
 GList    *nact_iactions_list_bis_get_items( NactIActionsList *instance );
diff --git a/src/nact/nact-iadvanced-tab.c b/src/nact/nact-iadvanced-tab.c
index afe1f96..06b8a84 100644
--- a/src/nact/nact-iadvanced-tab.c
+++ b/src/nact/nact-iadvanced-tab.c
@@ -171,7 +171,7 @@ runtime_init_connect_signals( NactIAdvancedTab *instance, GtkTreeView *listview
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
 				G_OBJECT( instance ),
-				TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+				MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
 				G_CALLBACK( on_tab_updatable_selection_changed ));
 
 		base_window_signal_connect(
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index f11c557..d952b06 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -251,7 +251,7 @@ nact_icommand_tab_runtime_init_toplevel( NactICommandTab *instance )
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
 				G_OBJECT( instance ),
-				TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+				MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
 				G_CALLBACK( on_tab_updatable_selection_changed ));
 
 		base_window_signal_connect(
diff --git a/src/nact/nact-iconditions-tab.c b/src/nact/nact-iconditions-tab.c
index c8c0936..d12bb80 100644
--- a/src/nact/nact-iconditions-tab.c
+++ b/src/nact/nact-iconditions-tab.c
@@ -223,7 +223,7 @@ nact_iconditions_tab_runtime_init_toplevel( NactIConditionsTab *instance )
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
 				G_OBJECT( instance ),
-				TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+				MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
 				G_CALLBACK( on_tab_updatable_selection_changed ));
 
 		base_window_signal_connect(
diff --git a/src/nact/nact-ifolders-tab.c b/src/nact/nact-ifolders-tab.c
index 7304667..03cf6f2 100644
--- a/src/nact/nact-ifolders-tab.c
+++ b/src/nact/nact-ifolders-tab.c
@@ -216,7 +216,7 @@ nact_ifolders_tab_runtime_init_toplevel( NactIFoldersTab *instance )
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
 				G_OBJECT( instance ),
-				TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+				MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
 				G_CALLBACK( on_tab_updatable_selection_changed ));
 
 		base_window_signal_connect(
diff --git a/src/nact/nact-main-menubar.c b/src/nact/nact-main-menubar.c
index d813d94..341a023 100644
--- a/src/nact/nact-main-menubar.c
+++ b/src/nact/nact-main-menubar.c
@@ -416,6 +416,22 @@ nact_main_menubar_dispose( NactMainWindow *window )
 }
 
 /**
+ * nact_main_menubar_is_level_zero_order_changed:
+ * @window: the #NactMainWindow main window.
+ *
+ * Returns: %TRUE if the level zero has changed, %FALSE else.
+ */
+gboolean
+nact_main_menubar_is_level_zero_order_changed( const NactMainWindow *window )
+{
+	MenubarIndicatorsStruct *mis;
+
+	mis = ( MenubarIndicatorsStruct * ) g_object_get_data( G_OBJECT( window ), MENUBAR_PROP_INDICATORS );
+
+	return( mis->level_zero_order_changed );
+}
+
+/**
  * Whether the specified object should be relabeled when pasted ?
  * @object: the considered #NAObject-derived object.
  * @pivot: the #NAPivot instance.
@@ -557,9 +573,10 @@ on_level_zero_order_changed( NactMainWindow *window, gpointer user_data )
 {
 	MenubarIndicatorsStruct *mis;
 
-	g_debug( "nact_main_menubar_on_level_zero_order_changed" );
 	g_return_if_fail( NACT_IS_MAIN_WINDOW( window ));
 
+	g_debug( "nact_main_menubar_on_level_zero_order_changed: change=%s", user_data ? "True":"False" );
+
 	mis = ( MenubarIndicatorsStruct * ) g_object_get_data( G_OBJECT( window ), MENUBAR_PROP_INDICATORS );
 	mis->level_zero_order_changed = GPOINTER_TO_INT( user_data );
 	g_signal_emit_by_name( window, MAIN_WINDOW_SIGNAL_UPDATE_ACTION_SENSITIVITIES, NULL );
@@ -1075,7 +1092,7 @@ on_cut_activated( GtkAction *gtk_action, NactMainWindow *window )
 		clipboard = nact_main_window_get_clipboard( window );
 		nact_clipboard_primary_set( clipboard, to_delete, CLIPBOARD_MODE_CUT );
 		update_clipboard_counters( window );
-		nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete );
+		nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete, TRUE );
 	}
 
 	na_object_unref_selected_items( items );
@@ -1302,7 +1319,7 @@ on_delete_activated( GtkAction *gtk_action, NactMainWindow *window )
 
 	if( to_delete ){
 		nact_main_window_move_to_deleted( window, to_delete );
-		nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete );
+		nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( window ), to_delete, TRUE );
 	}
 
 	na_object_unref_selected_items( items );
diff --git a/src/nact/nact-main-menubar.h b/src/nact/nact-main-menubar.h
index 11e5064..417685f 100644
--- a/src/nact/nact-main-menubar.h
+++ b/src/nact/nact-main-menubar.h
@@ -70,10 +70,10 @@ typedef struct {
 
 void     nact_main_menubar_runtime_init( NactMainWindow *window );
 void     nact_main_menubar_dispose( NactMainWindow *window );
+gboolean nact_main_menubar_is_level_zero_order_changed( const NactMainWindow *window );
 gboolean nact_main_menubar_is_pasted_object_relabeled( NAObject *object, NAPivot *pivot );
 void     nact_main_menubar_open_popup( NactMainWindow *window, GdkEventButton *event );
 void     nact_main_menubar_save_items( NactMainWindow *window );
-
 void     nact_main_menubar_enable_item( NactMainWindow *window, const gchar *name, gboolean enabled );
 
 G_END_DECLS
diff --git a/src/nact/nact-main-tab.h b/src/nact/nact-main-tab.h
index 69f8415..54b85e6 100644
--- a/src/nact/nact-main-tab.h
+++ b/src/nact/nact-main-tab.h
@@ -51,7 +51,6 @@
 
 /* signals
  */
-#define TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED			"nact-tab-updatable-selection-changed"
 #define TAB_UPDATABLE_SIGNAL_ITEM_UPDATED				"nact-tab-updatable-item-updated"
 #define TAB_UPDATABLE_SIGNAL_ENABLE_TAB					"nact-tab-updatable-enable-tab"
 #define TAB_UPDATABLE_SIGNAL_PROVIDER_CHANGED			"nact-tab-updatable-provider-changed"
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index 0931a59..05c1d7c 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -166,6 +166,7 @@ static void     on_base_initial_load_toplevel( NactMainWindow *window, gpointer
 static void     on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data );
 static void     on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data );
 
+static void     on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_data );
 static void     on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected_items );
 static void     on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data );
 static void     set_current_object_item( NactMainWindow *window, GSList *selected_items );
@@ -373,12 +374,13 @@ class_init( NactMainWindowClass *klass )
 			G_TYPE_POINTER );
 
 	/**
-	 * nact-tab-updatable-selection-changed:
+	 * main-window-selection-changed:
 	 *
 	 * This signal is emitted by this main window, in response of a
-	 * change of the selection in IActionsList.
+	 * change of the selection in IActionsList, after having updated
+	 * its properties.
 	 * Notebook tabs should connect to this signal and update their
-	 * display to reflect the content of the new selection.
+	 * display to reflect the content of the new selection (if applyable).
 	 *
 	 * Note also that, where this main window will receive from
 	 * IActionsList the full list of currently selected items, this
@@ -387,7 +389,7 @@ class_init( NactMainWindowClass *klass )
 	 * See #iactions_list_selection_changed().
 	 */
 	st_signals[ SELECTION_CHANGED ] = g_signal_new(
-			TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED,
+			MAIN_WINDOW_SIGNAL_SELECTION_CHANGED,
 			G_TYPE_OBJECT,
 			G_SIGNAL_RUN_LAST,
 			0,					/* no default handler */
@@ -484,7 +486,6 @@ iactions_list_iface_init( NactIActionsListInterface *iface )
 
 	g_debug( "%s: iface=%p", thisfn, ( void * ) iface );
 
-	iface->selection_changed = NULL;
 	iface->get_treeview_name = iactions_list_get_treeview_name;
 }
 
@@ -847,7 +848,7 @@ nact_main_window_has_modified_items( const NactMainWindow *window )
 		g_debug( "%s: has_modified=%s", thisfn, has_modified ? "True":"False" );
 	}
 
-	return( count_deleted > 0 || has_modified );
+	return( count_deleted > 0 || has_modified || nact_main_menubar_is_level_zero_order_changed( window ));
 }
 
 /**
@@ -1087,6 +1088,12 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
 				G_OBJECT( window ),
 				IACTIONS_LIST_SIGNAL_STATUS_CHANGED,
 				G_CALLBACK( on_iactions_list_status_changed ));
+
+		base_window_signal_connect(
+				BASE_WINDOW( window ),
+				G_OBJECT( window ),
+				MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED,
+				G_CALLBACK( on_main_window_level_zero_order_changed ));
 	}
 }
 
@@ -1117,6 +1124,14 @@ on_base_all_widgets_showed( NactMainWindow *window, gpointer user_data )
 	}
 }
 
+static void
+on_main_window_level_zero_order_changed( NactMainWindow *window, gpointer user_data )
+{
+	g_debug( "nact_main_window_on_main_window_level_zero_order_changed" );
+
+	setup_dialog_title( window );
+}
+
 /*
  * iactions_list_selection_changed:
  * @window: this #NactMainWindow instance.
@@ -1175,12 +1190,14 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
 
 	setup_dialog_title( window );
 
-	g_signal_emit_by_name( window, TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED, GINT_TO_POINTER( count ));
+	g_signal_emit_by_name( window, MAIN_WINDOW_SIGNAL_SELECTION_CHANGED, GINT_TO_POINTER( count ));
 }
 
 static void
 on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data )
 {
+	g_debug( "nact_main_window_on_iactions_list_status_changed" );
+
 	setup_dialog_title( window );
 }
 
@@ -1251,6 +1268,12 @@ iactions_list_get_treeview_name( NactIActionsList *instance )
 	return( name );
 }
 
+/*
+ * the title bar of the main window brings up three informations:
+ * - the name of the application
+ * - the name of the currently selected item if there is only one
+ * - an asterisk if anything has been modified
+ */
 static void
 setup_dialog_title( NactMainWindow *window )
 {
@@ -1260,6 +1283,7 @@ setup_dialog_title( NactMainWindow *window )
 	gchar *label;
 	gchar *tmp;
 
+	g_debug( "setup_dialog_title" );
 	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
 	title = base_application_get_application_name( BASE_APPLICATION( application ));
 
@@ -1429,6 +1453,9 @@ ipivot_consumer_on_display_order_changed( NAIPivotConsumer *instance, gint order
 
 	nact_iactions_list_display_order_change( NACT_IACTIONS_LIST( instance ), order_mode );
 	nact_sort_buttons_display_order_change( NACT_MAIN_WINDOW( instance ), order_mode );
+
+	g_signal_emit_by_name(
+			NACT_MAIN_WINDOW( instance ), MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED, GINT_TO_POINTER( TRUE ));
 }
 
 static gchar *
diff --git a/src/nact/nact-main-window.h b/src/nact/nact-main-window.h
index b8d1a6e..ae3403d 100644
--- a/src/nact/nact-main-window.h
+++ b/src/nact/nact-main-window.h
@@ -69,6 +69,7 @@ typedef struct {
 }
 	NactMainWindowClass;
 
+#define MAIN_WINDOW_SIGNAL_SELECTION_CHANGED			"main-window-selection-changed"
 #define MAIN_WINDOW_SIGNAL_UPDATE_ACTION_SENSITIVITIES	"main-window-update-sensitivities"
 #define MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED		"main-window-level-zero-order-changed"
 
diff --git a/src/nact/nact-tree-model-dnd.c b/src/nact/nact-tree-model-dnd.c
index 1b2cc30..10574f3 100644
--- a/src/nact/nact-tree-model-dnd.c
+++ b/src/nact/nact-tree-model-dnd.c
@@ -559,7 +559,7 @@ drop_inside( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData  *selecti
 				} else {
 					inserted = na_object_ref( current );
 					deletable = g_list_prepend( NULL, inserted );
-					nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( main_window ), deletable );
+					nact_iactions_list_bis_delete( NACT_IACTIONS_LIST( main_window ), deletable, FALSE );
 					g_list_free( deletable );
 				}
 
@@ -575,7 +575,7 @@ drop_inside( NactTreeModel *model, GtkTreePath *dest, GtkSelectionData  *selecti
 
 	nact_iactions_list_bis_insert_at_path( NACT_IACTIONS_LIST( main_window ), object_list, new_dest );
 
-	if( !copy_data && gtk_tree_path_get_depth( new_dest ) == 1 ){
+	if( gtk_tree_path_get_depth( new_dest ) == 1 ){
 		g_signal_emit_by_name( main_window, MAIN_WINDOW_SIGNAL_LEVEL_ZERO_ORDER_CHANGED, GINT_TO_POINTER( TRUE ));
 	}
 



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