[nautilus-actions] Update example label on selection change



commit b722fe7fc32877512065ca3ee904ab2a5b89521e
Author: Pierre Wieser <pwieser trychlos org>
Date:   Fri Sep 3 11:59:11 2010 +0200

    Update example label on selection change

 ChangeLog                    |    6 ++
 src/nact/nact-icommand-tab.c |  185 +-----------------------------------------
 2 files changed, 8 insertions(+), 183 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 809757e..d76f178 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2010-09-03 Pierre Wieser <pwieser trychlos org>
+
+	* src/nact/nact-icommand-tab.c
+	(on_tab_updatable_selection_changed): Update example label.
+	(parse_parameters): Cleanup code.
+
 2010-09-02 Pierre Wieser <pwieser trychlos org>
 
 	* src/io-desktop/nadp-reader.c (nadp_reader_iimporter_import_from_uri):
diff --git a/src/nact/nact-icommand-tab.c b/src/nact/nact-icommand-tab.c
index b4c6990..1666699 100644
--- a/src/nact/nact-icommand-tab.c
+++ b/src/nact/nact-icommand-tab.c
@@ -411,6 +411,8 @@ on_tab_updatable_selection_changed( NactICommandTab *instance, gint count_select
 		legend_button = get_legend_button( instance );
 		gtk_widget_set_sensitive( GTK_WIDGET( legend_button ), profile != NULL );
 
+		update_example_label( instance, profile );
+
 		wdir_entry = base_window_get_widget( BASE_WINDOW( instance ), "WorkingDirectoryEntry" );
 		wdir = profile ? na_object_get_working_dir( profile ) : g_strdup( "" );
 		wdir = wdir ? wdir : g_strdup( "" );
@@ -642,189 +644,6 @@ on_wdir_changed( GtkEntry *entry, NactICommandTab *instance )
 static gchar *
 parse_parameters( NactICommandTab *instance )
 {
-#if 0
-	GString *tmp_string = g_string_new( "" );
-	NAObjectItem *item;
-	NAObjectProfile *profile;
-	NAIContext *context;
-
-	/* i18n notes: example strings for the command preview */
-	gchar *ex_path = _( "/path/to" );
-	gchar *ex_files[] = { N_( "file1.txt" ), N_( "file2.txt" ), NULL };
-	gchar *ex_dirs[] = { N_(" folder1" ), N_( "folder2" ), NULL };
-	gchar *ex_mixed[] = { N_(" file1.txt" ), N_( "folder1" ), NULL };
-	gchar *ex_scheme_default = "file";
-	gchar *ex_host_default = _( "test.example.net" );
-	gchar *ex_one_file = _( "file.txt" );
-	gchar *ex_one_dir = _( "folder" );
-	gchar *ex_port_default = _( "8080" );
-	gchar *ex_one = NULL;
-	gchar *ex_list = NULL;
-	gchar *ex_path_list = NULL;
-	gchar *ex_uri_file1 = _( "file:///path/to/file1.text" );
-	gchar *ex_uri_file2 = _( "file:///path/to/file2.text" );
-	gchar *ex_uri_folder1 = _( "file:///path/to/a/dir" );
-	gchar *ex_uri_folder2 = _( "file:///path/to/another/dir" );
-	gchar *ex_uri_list = NULL;
-	gchar *ex_scheme;
-	gchar *ex_host;
-	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 )));
-
-	gchar *iter = g_strdup( param_template );
-	gchar *old_iter = iter;
-	gchar *tmp;
-	gchar *separator;
-	gchar *start;
-
-	g_string_append_printf( tmp_string, "%s ", command );
-
-	/*nact_iconditions_tab_get_isfiledir( NACT_ICONDITIONS_TAB( instance ), &is_file, &is_dir );
-	accept_multiple = nact_iconditions_tab_get_multiple( NACT_ICONDITIONS_TAB( instance ));*/
-	is_file = TRUE;
-	is_dir = TRUE;
-	accept_multiple = TRUE;
-
-	g_object_get(
-			G_OBJECT( instance ),
-			TAB_UPDATABLE_PROP_SELECTED_ITEM, &item,
-			TAB_UPDATABLE_PROP_SELECTED_PROFILE, &profile,
-			NULL );
-
-	context = ( profile ? NA_ICONTEXT( profile ) : ( NAIContext * ) item );
-
-	scheme_list = na_object_get_schemes( context );
-
-	separator = g_strdup_printf( " %s/", ex_path );
-	start = g_strdup_printf( "%s/", ex_path );
-
-	if( accept_multiple ){
-		if( is_file && is_dir ){
-			ex_one = ex_files[0];
-			ex_list = na_core_utils_gstring_joinv( NULL, " ", ex_mixed );
-			ex_path_list = na_core_utils_gstring_joinv( start, separator, ex_mixed );
-			ex_uri_list = g_strjoin( " ", ex_uri_file1, ex_uri_folder1, NULL );
-
-		} else if( is_dir ){
-			ex_one = ex_dirs[0];
-			ex_list = na_core_utils_gstring_joinv( NULL, " ", ex_dirs );
-			ex_path_list = na_core_utils_gstring_joinv( start, separator, ex_dirs );
-			ex_uri_list = g_strjoin( " ", ex_uri_folder1, ex_uri_folder2, NULL );
-
-		} else if( is_file ){
-			ex_one = ex_files[0];
-			ex_list = na_core_utils_gstring_joinv( NULL, " ", ex_files );
-			ex_path_list = na_core_utils_gstring_joinv( start, separator, ex_files );
-			ex_uri_list = g_strjoin( " ", ex_uri_file1, ex_uri_file2, NULL );
-		}
-	} else {
-		if( is_dir && !is_file ){
-			ex_one = ex_one_dir;
-			ex_uri_list = g_strdup( ex_uri_folder1 );
-
-		} else {
-			ex_one = ex_one_file;
-			ex_uri_list = g_strdup( ex_uri_file1 );
-		}
-		ex_list = g_strdup( ex_one );
-		ex_path_list = g_strjoin( "/", ex_path, ex_one, NULL );
-	}
-
-	g_free (start);
-	g_free (separator);
-
-	if( scheme_list != NULL ){
-		ex_scheme = ( gchar * ) scheme_list->data;
-		if( g_ascii_strcasecmp( ex_scheme, "file" ) == 0 ){
-			if( g_slist_length( scheme_list ) > 1 ){
-				ex_scheme = ( gchar * ) scheme_list->next->data;
-				ex_host = ex_host_default;
-			} else {
-				ex_host = "";
-			}
-		} else {
-			ex_host = ex_host_default;
-		}
-	} else {
-		ex_scheme = ex_scheme_default;
-		ex_host = "";
-	}
-
-	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) */
-				tmp_string = g_string_append( tmp_string, ex_path );
-				break;
-
-			case 'f': /* the basename of the (first) selected file/folder */
-				tmp_string = g_string_append( tmp_string, ex_one );
-				break;
-
-			case 'h': /* hostname of the (first) URI */
-				tmp_string = g_string_append( tmp_string, ex_host );
-				break;
-
-			case 'm': /* list of the basename of the selected files/directories separated by space */
-				tmp_string = g_string_append( tmp_string, ex_list );
-				break;
-
-			case 'M': /* list of the selected files/directories with their complete path separated by space. */
-				tmp_string = g_string_append( tmp_string, ex_path_list );
-				break;
-
-			case 'p': /* port number of the (first) URI */
-				tmp_string = g_string_append( tmp_string, ex_port_default );
-				break;
-
-			case 'R': /* space-separated list of selected URIs */
-				tmp_string = g_string_append( tmp_string, ex_uri_list );
-				break;
-
-			case 's': /* scheme of the (first) URI */
-				tmp_string = g_string_append( tmp_string, ex_scheme );
-				break;
-
-			case 'u': /* (first) URI */
-				tmp = g_strjoin( NULL, ex_scheme, "://", ex_path, "/", ex_one, NULL );
-				tmp_string = g_string_append( tmp_string, tmp );
-				g_free( tmp );
-				break;
-
-			case 'U': /* username of the GVfs URI */
-				tmp_string = g_string_append( tmp_string, "root" );
-				break;
-
-			case '%': /* a percent sign */
-				tmp_string = g_string_append_c( tmp_string, '%' );
-				break;
-
-			default:
-				iter_inc = 1;
-				break;
-		}
-		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 ));
-
-	na_core_utils_slist_free( scheme_list );
-
-	g_free( ex_list );
-	g_free( ex_path_list );
-	g_free( ex_uri_list );
-	g_free( iter );
-
-	return( g_string_free( tmp_string, FALSE ));
-#endif
-
 	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 )));
 	gchar *exec, *returned;



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