[nautilus-actions] Restore dynamic title



commit 9aa32b3fb9a612c254b7b37c0cf674c685f147bb
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Oct 18 00:20:02 2009 +0200

    Restore dynamic title

 ChangeLog                   |    3 ++
 src/nact/nact-main-window.c |   49 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 52 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 8949be2..66a5407 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2009-10-17 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-main-window.c (setup_dialog_title):
+	Restore function which had disappeared since v 1.12.
+
 	* src/nact/nact-iactions-list.c
 	(nact_iactions_list_initial_load_toplevel):
 	Cells are only editable in edition mode.
diff --git a/src/nact/nact-main-window.c b/src/nact/nact-main-window.c
index fe1fd96..d4cdfde 100644
--- a/src/nact/nact-main-window.c
+++ b/src/nact/nact-main-window.c
@@ -151,9 +151,11 @@ static void     on_base_runtime_init_toplevel( NactMainWindow *window, gpointer
 static void     on_base_all_widgets_showed( 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 );
 static void     set_current_profile( NactMainWindow *window, gboolean set_action, GSList *selected_items );
 static gchar   *iactions_list_get_treeview_name( NactIActionsList *instance );
+static void     setup_dialog_title( NactMainWindow *window );
 
 static void     on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data, gboolean force_display );
 
@@ -949,6 +951,14 @@ on_base_runtime_init_toplevel( NactMainWindow *window, gpointer user_data )
 		/* fill the IActionsList at last so that all signals are connected
 		 */
 		nact_iactions_list_runtime_init_toplevel( NACT_IACTIONS_LIST( window ), tree );
+
+		/* this to update the title when an item is modified
+		 */
+		base_window_signal_connect(
+				BASE_WINDOW( window ),
+				G_OBJECT( window ),
+				IACTIONS_LIST_SIGNAL_STATUS_CHANGED,
+				G_CALLBACK( on_iactions_list_status_changed ));
 	}
 }
 
@@ -1026,9 +1036,17 @@ on_iactions_list_selection_changed( NactIActionsList *instance, GSList *selected
 			TAB_UPDATABLE_PROP_EDITED_PROFILE, window->private->edited_profile,
 			NULL );
 
+	setup_dialog_title( window );
+
 	g_signal_emit_by_name( window, TAB_UPDATABLE_SIGNAL_SELECTION_CHANGED, GINT_TO_POINTER( count ));
 }
 
+static void
+on_iactions_list_status_changed( NactMainWindow *window, gpointer user_data )
+{
+	setup_dialog_title( window );
+}
+
 /*
  * update the notebook when selection changes in ActionsList
  * if there is only one profile, we also setup the profile
@@ -1091,6 +1109,37 @@ iactions_list_get_treeview_name( NactIActionsList *instance )
 }
 
 static void
+setup_dialog_title( NactMainWindow *window )
+{
+	GtkWindow *toplevel;
+	NactApplication *application;
+	gchar *title;
+	gchar *label;
+	gchar *tmp;
+
+	application = NACT_APPLICATION( base_window_get_application( BASE_WINDOW( window )));
+	title = base_application_get_application_name( BASE_APPLICATION( application ));
+
+	if( window->private->edited_item ){
+		label = na_object_get_label( window->private->edited_item );
+		tmp = g_strdup_printf( "%s - %s", title, label );
+		g_free( label );
+		g_free( title );
+		title = tmp;
+	}
+
+	if( nact_main_window_has_modified_items( window )){
+		tmp = g_strdup_printf( "*%s", title );
+		g_free( title );
+		title = tmp;
+	}
+
+	toplevel = base_window_get_toplevel( BASE_WINDOW( window ));
+	gtk_window_set_title( toplevel, title );
+	g_free( title );
+}
+
+static void
 on_tab_updatable_item_updated( NactMainWindow *window, gpointer user_data, gboolean force_display )
 {
 	/*static const gchar *thisfn = "nact_main_window_on_tab_updatable_item_updated";*/



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