[nautilus-actions] Fix user interface on label change



commit 5b19a07170cebb9ef6f286c3a7d853b6380231d7
Author: pierre <pierre vfedora10 virtuals pwi>
Date:   Mon Mar 1 14:01:31 2010 +0100

    Fix user interface on label change

 ChangeLog                    |   10 ++++++++++
 src/nact/nact-iaction-tab.c  |   33 +++++++++++++++++++++++----------
 src/nact/nact-icommand-tab.c |   11 ++++++++---
 3 files changed, 41 insertions(+), 13 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d52100d..6d560e4 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2009-03-01 Pierre Wieser <pwieser trychlos org>
 
+	* src/nact/nact-iaction-tab.c (setup_toolbar_label):
+	Immediately update the toolbar label when it is the same that those
+	of the action.
+
+	* src/nact/nact-icommand-tab.c (parse_parameters):
+	Fix display of a single '%' char.
+
+	* src/nact/nautilus-actions-config-tool.ui:
+	ActionIconLabelLabel field renamed as ActionToolbarLabelLabel.
+
 	* src/io-gconf/nagp-reader.c (read_done_item):
 	Only action needs to setup the parent pointer.
 
diff --git a/src/nact/nact-iaction-tab.c b/src/nact/nact-iaction-tab.c
index 07dc834..418f688 100644
--- a/src/nact/nact-iaction-tab.c
+++ b/src/nact/nact-iaction-tab.c
@@ -89,6 +89,7 @@ static void          on_target_toolbar_toggled( GtkToggleButton *button, NactIAc
 static void          on_toolbar_same_label_toggled( GtkToggleButton *button, NactIActionTab *instance );
 static void          toolbar_same_label_set_sensitive( NactIActionTab *instance, NAObjectItem *item );
 
+static void          setup_toolbar_label( NactIActionTab *instance, NAObjectItem *item, const gchar *label );
 static void          on_toolbar_label_changed( GtkEntry *entry, NactIActionTab *instance );
 static void          toolbar_label_set_sensitive( NactIActionTab *instance, NAObjectItem *item );
 
@@ -286,7 +287,7 @@ nact_iaction_tab_runtime_init_toplevel( NactIActionTab *instance )
 				"toggled",
 				G_CALLBACK( on_toolbar_same_label_toggled ));
 
-		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconLabelEntry" );
+		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionToolbarLabelEntry" );
 		base_window_signal_connect(
 				BASE_WINDOW( instance ),
 				G_OBJECT( label_widget ),
@@ -481,8 +482,8 @@ on_tab_updatable_selection_changed( NactIActionTab *instance, gint count_selecte
 		toolbar_same_label_set_sensitive( instance, item );
 		nact_gtk_utils_set_editable( GTK_OBJECT( toggle ), editable );
 
-		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconLabelEntry" );
-		label = item && NA_IS_OBJECT_ACTION( item ) ? na_object_get_toolbar_label( NA_OBJECT_ACTION( item )) : g_strdup( "" );
+		label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionToolbarLabelEntry" );
+		label = item && NA_IS_OBJECT_ACTION( item ) ? na_object_get_toolbar_label( item ) : g_strdup( "" );
 		gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
 		g_free( label );
 		toolbar_label_set_sensitive( instance, item );
@@ -671,7 +672,6 @@ on_label_changed( GtkEntry *entry, NactIActionTab *instance )
 {
 	NAObjectItem *edited;
 	const gchar *label;
-	gboolean toolbar_same_label;
 
 	g_object_get(
 			G_OBJECT( instance ),
@@ -684,10 +684,7 @@ on_label_changed( GtkEntry *entry, NactIActionTab *instance )
 		check_for_label( instance, entry, label );
 
 		if( NA_IS_OBJECT_ACTION( edited )){
-			toolbar_same_label = na_object_is_toolbar_same_label( NA_OBJECT_ACTION( edited ));
-			if( toolbar_same_label ){
-				na_object_set_toolbar_label( NA_OBJECT_ACTION( edited ), label );
-			}
+			setup_toolbar_label( instance, edited, label );
 		}
 
 		g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, TRUE );
@@ -769,7 +766,7 @@ on_toolbar_same_label_toggled( GtkToggleButton *button, NactIActionTab *instance
 				na_object_set_toolbar_same_label( NA_OBJECT_ACTION( edited ), same_label );
 				if( same_label ){
 					label = na_object_get_label( edited );
-					label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconLabelEntry" );
+					label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionToolbarLabelEntry" );
 					gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
 					g_free( label );
 				}
@@ -799,6 +796,22 @@ toolbar_same_label_set_sensitive( NactIActionTab *instance, NAObjectItem *item )
 	gtk_widget_set_sensitive( GTK_WIDGET( toggle ), target_toolbar && !readonly );
 }
 
+/*
+ * setup the label of the toolbar according to the toolbar_same_label flag
+ */
+static void
+setup_toolbar_label( NactIActionTab *instance, NAObjectItem *item, const gchar *label )
+{
+	GtkWidget *label_widget;
+
+	if( item && NA_IS_OBJECT_ACTION( item )){
+		if( na_object_is_toolbar_same_label( item )){
+			label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionToolbarLabelEntry" );
+			gtk_entry_set_text( GTK_ENTRY( label_widget ), label );
+		}
+	}
+}
+
 static void
 on_toolbar_label_changed( GtkEntry *entry, NactIActionTab *instance )
 {
@@ -828,7 +841,7 @@ toolbar_label_set_sensitive( NactIActionTab *instance, NAObjectItem *item )
 
 	is_action = item && NA_IS_OBJECT_ACTION( item );
 	same_label = is_action ? na_object_is_toolbar_same_label( NA_OBJECT_ACTION( item )) : FALSE;
-	label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionIconLabelEntry" );
+	label_widget = base_window_get_widget( BASE_WINDOW( instance ), "ActionToolbarLabelEntry" );
 	gtk_widget_set_sensitive( label_widget, is_action && !same_label );
 }
 
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index d942fec..f11c557 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -542,7 +542,6 @@ on_parameters_changed( GtkEntry *entry, NactICommandTab *instance )
 				NULL );
 
 		if( edited ){
-
 			na_object_set_parameters( edited, gtk_entry_get_text( entry ));
 			g_signal_emit_by_name( G_OBJECT( instance ), TAB_UPDATABLE_SIGNAL_ITEM_UPDATED, edited, FALSE );
 			update_example_label( instance, edited );
@@ -669,6 +668,7 @@ parse_parameters( NactICommandTab *instance )
 	gboolean is_file, is_dir;
 	gboolean accept_multiple;
 	GSList *scheme_list;
+	guint iter_inc;
 
 	const gchar *command = gtk_entry_get_text( GTK_ENTRY( get_path_entry( instance )));
 	const gchar *param_template = gtk_entry_get_text( GTK_ENTRY( get_parameters_entry( instance )));
@@ -742,6 +742,7 @@ parse_parameters( NactICommandTab *instance )
 
 	while(( iter = g_strstr_len( iter, strlen( iter ), "%" ))){
 		tmp_string = g_string_append_len( tmp_string, old_iter, strlen( old_iter ) - strlen( iter ));
+		iter_inc = 1;
 		switch( iter[1] ){
 
 			case 'd': /* base dir of the (first) selected file(s)/folder(s) */
@@ -789,9 +790,13 @@ parse_parameters( NactICommandTab *instance )
 			case '%': /* a percent sign */
 				tmp_string = g_string_append_c( tmp_string, '%' );
 				break;
+
+			default:
+				iter_inc = 1;
+				break;
 		}
-		iter+=2; /* skip the % sign and the character after. */
-		old_iter = iter; /* store the new start of the string */
+		iter += iter_inc;				/* skip the % sign and the character after. */
+		old_iter = iter;				/* store the new start of the string */
 	}
 	tmp_string = g_string_append_len( tmp_string, old_iter, strlen( old_iter ));
 



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