[nautilus-actions] nautilus-actions-new: add selection-count option



commit c33b6114e787dd7576f740edaccfc8fe731ec4c9
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Feb 20 15:22:49 2011 +0100

    nautilus-actions-new: add selection-count option

 ChangeLog                        |    5 +++++
 src/core/na-icontext-factory.c   |   14 +++++++-------
 src/utils/nautilus-actions-new.c |   31 ++++++++++++++++++++++++++-----
 3 files changed, 38 insertions(+), 12 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index c776ae1..3af38b7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2011-02-20 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-icontext-factory.c
+	(NAFO_DATA_SELECTION_COUNT): Fix option definition.
+
+	* src/utils/nautilus-actions-new.c: Add selection-count option.
+
 	* src/core/na-data-boxed.c (string_is_default, string_list_is_default,
 	locale_is_default): Fix default value test.
 
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index 44d1271..4534caa 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -170,7 +170,7 @@ NADataDef data_def_conditions [] = {
 				TRUE,
 				TRUE,
 				TRUE,
-				N_( "Whether the profile applies to files (deprecated option, see mimetypes)" ),
+				N_( "Whether the profile applies to files (deprecated option, see mimetype)" ),
 				/* i18n: 'true' and 'false' values are taken literally, and should not be translated */
 				N_( "Set to 'true' if the selection can have files, to 'false' otherwise.\n" \
 					"This setting is tied in with the 'isdir' setting. The valid combinations are: \n" \
@@ -201,7 +201,7 @@ NADataDef data_def_conditions [] = {
 				TRUE,
 				TRUE,
 				TRUE,
-				N_( "Whether the profile applies to folders (deprecated option, see mimetypes)" ),
+				N_( "Whether the profile applies to folders (deprecated option, see mimetype)" ),
 				/* i18n: 'true' and 'false' values are taken literally, and should not be translated */
 				N_( "Set to 'true' if the selection can have folders, to 'false' otherwise.\n" \
 					"This setting is tied in with the 'isfile' setting. The valid combinations are: \n" \
@@ -250,8 +250,8 @@ NADataDef data_def_conditions [] = {
 				FALSE,
 				"accept-multiple-files",
 				NULL,
-				0,
-				NULL,
+				'u',
+				"accept-multiple",
 				0,
 				G_OPTION_ARG_NONE,
 				NULL,
@@ -343,10 +343,10 @@ NADataDef data_def_conditions [] = {
 				FALSE,
 				"selection-count",
 				"SelectionCount",
+				'c',
+				"selection-count",
 				0,
-				NULL,
-				0,
-				G_OPTION_ARG_NONE,
+				G_OPTION_ARG_STRING,
 				NULL,
 				NULL },
 
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index d3e040c..f2c5d6e 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -80,6 +80,7 @@ static gboolean   isdir            = FALSE;
 static gboolean   accept_multiple  = FALSE;
 static gchar    **schemes_array    = NULL;
 static gchar    **folders_array    = NULL;
+static gchar     *selection_count  = "";
 /* output entries */
 static gboolean   output_stdout    = FALSE;
 static gboolean   output_desktop   = FALSE;
@@ -108,6 +109,7 @@ static const ArgFromDataDef st_arg_from_data_def[] = {
 		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MULTIPLE,         &accept_multiple },
 		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_SCHEMES,          &schemes_array },
 		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_FOLDERS,          &folders_array },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_SELECTION_COUNT,  &selection_count },
 		{ NULL }
 };
 
@@ -138,7 +140,8 @@ static GOptionEntry misc_entries[] = {
 	{ NULL }
 };
 
-#define CANNOT_BOTH		_( "Error: '%s' and '%s' options cannot both be specified.\n" )
+#define CANNOT_BOTH		_( "Error: '%s' and '%s' options cannot both be specified\n" )
+#define DEPRECATED		_( "'%s' option is deprecated, see %s\n" )
 
 static GOptionEntry   *build_option_entries( const ArgFromDataDef *defs, guint nbdefs, const GOptionEntry *adds, guint nbadds );
 static GOptionContext *init_options( void );
@@ -223,6 +226,11 @@ main( int argc, char** argv )
 		matchcase = TRUE;
 	}
 
+	if( accept_multiple && strlen( selection_count )){
+		g_printerr( CANNOT_BOTH, "--accept-multiple", "--selection-count" );
+		errors += 1;
+	}
+
 	if( output_stdout && output_desktop ){
 		g_printerr( _( "Error: only one output option may be specified.\n" ));
 		errors += 1;
@@ -367,7 +375,7 @@ get_action_from_cmdline( void )
 	GSList *schemes;
 	GSList *folders;
 	gboolean toolbar_same_label;
-	gchar *selection_count;
+	gchar *msg;
 
 	action = na_object_action_new_with_defaults();
 	profile = NA_OBJECT_PROFILE(( GList * ) na_object_get_items( action )->data );
@@ -408,6 +416,16 @@ get_action_from_cmdline( void )
 	na_object_set_matchcase( profile, matchcase );
 
 	mimetypes = NULL;
+	if( isfile ){
+		msg = g_strdup_printf( DEPRECATED, "accept-files", "mimetype" );
+		g_warning( "%s", msg );
+		g_free( msg );
+	}
+	if( isdir ){
+		msg = g_strdup_printf( DEPRECATED, "accept-dirs", "mimetype" );
+		g_warning( "%s", msg );
+		g_free( msg );
+	}
 	if( !isfile && !isdir ){
 		isfile = TRUE;
 	}
@@ -428,12 +446,15 @@ get_action_from_cmdline( void )
 		na_core_utils_slist_free( mimetypes );
 	}
 
-	selection_count = g_strdup( "=1" );
 	if( accept_multiple ){
-		g_free( selection_count );
+		msg = g_strdup_printf( DEPRECATED, "accept-multiple", "selection-count" );
+		g_warning( "%s", msg );
+		g_free( msg );
 		selection_count = g_strdup( ">0" );
 	}
-	na_object_set_selection_count( profile, selection_count );
+	if( strlen( selection_count )){
+		na_object_set_selection_count( profile, selection_count );
+	}
 
 	i = 0;
 	schemes = NULL;



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