[nautilus-actions] nautilus-actions-new: add last missing options



commit ea7c5459a7d8ed568447c513d25983da2bde662d
Author: Pierre Wieser <pwieser trychlos org>
Date:   Sun Feb 20 21:10:32 2011 +0100

    nautilus-actions-new: add last missing options
    
    + try-exec,
    + show-if-registered,
    + show-if-true,
    + show-if-running,
    + capability.

 ChangeLog                        |    7 +++
 src/core/na-icontext-factory.c   |   53 ++++++++++++----------
 src/utils/nautilus-actions-new.c |   90 +++++++++++++++++++++++++++++---------
 3 files changed, 104 insertions(+), 46 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ac8575c..0e3a51a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-02-20 Pierre Wieser <pwieser trychlos org>
 
+	* src/core/na-icontext-factory.c (NAFO_DATA_TRY_EXEC,
+	NAFO_DATA_SHOW_IF_REGISTERED, NAFO_DATA_SHOW_IF_TRUE,
+	NAFO_DATA_SHOW_IF_RUNNING, NAFO_DATA_CAPABILITITES): Fix options definition.
+
+	* src/utils/nautilus-actions-new.c: Add try-exec, show-if-registered,
+	show-if-true, show-if-running and capability options.
+	
 	* src/core/na-icontext-factory.c (NAFO_DATA_SCHEMES, NAFO_DATA_FOLDERS,
 	NAFO_DATA_SELECTION_COUNT, NAFO_DATA_ONLY_SHOW, NAFO_DATA_NOT_SHOW):
 	* src/core/na-object-action-factory.c (NAFO_DATA_TARGET_SELECTION,
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index 448af70..2ec45b9 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -418,12 +418,13 @@ NADataDef data_def_conditions [] = {
 				FALSE,
 				"try-exec",
 				"TryExec",
+				'X',
+				"try-exec",
 				0,
-				NULL,
-				0,
-				G_OPTION_ARG_NONE,
-				NULL,
-				NULL },
+				G_OPTION_ARG_STRING,
+				N_( "the path to a file whose executability is to be checked" ),
+				/* i18n: "<PATH>" is the path to a binary, so may be tranlatable */
+				N_( "<PATH>" ) },
 
 	{ NAFO_DATA_SHOW_IF_REGISTERED,
 				TRUE,
@@ -444,12 +445,12 @@ NADataDef data_def_conditions [] = {
 				FALSE,
 				"show-if-registered",
 				"ShowIfRegistered",
+				'g',
+				"show-if-registered",
 				0,
-				NULL,
-				0,
-				G_OPTION_ARG_NONE,
-				NULL,
-				NULL },
+				G_OPTION_ARG_STRING,
+				N_( "The name of a service which must be registered on session DBus" ),
+				N_( "<NAME>" ) },
 
 	{ NAFO_DATA_SHOW_IF_TRUE,
 				TRUE,
@@ -470,12 +471,13 @@ NADataDef data_def_conditions [] = {
 				FALSE,
 				"show-if-true",
 				"ShowIfTrue",
+				'U',
+				"show-if-true",
 				0,
-				NULL,
-				0,
-				G_OPTION_ARG_NONE,
-				NULL,
-				NULL },
+				G_OPTION_ARG_STRING,
+				/* i18n: 'true' is to be taken as a literal, must not be translated */
+				N_( "The path to a command which will display the 'true' string" ),
+				N_( "<PATH>" ) },
 
 	{ NAFO_DATA_SHOW_IF_RUNNING,
 				TRUE,
@@ -496,12 +498,12 @@ NADataDef data_def_conditions [] = {
 				FALSE,
 				"show-if-running",
 				"ShowIfRunning",
+				'R',
+				"show-if-running",
 				0,
-				NULL,
-				0,
-				G_OPTION_ARG_NONE,
-				NULL,
-				NULL },
+				G_OPTION_ARG_STRING,
+				N_( "The name of a binary which must be running" ),
+				N_( "<NAME>" ) },
 
 	{ NAFO_DATA_CAPABILITITES,
 				TRUE,
@@ -528,12 +530,13 @@ NADataDef data_def_conditions [] = {
 				FALSE,
 				"capabilities",
 				"Capabilities",
+				'P',
+				"capability",
 				0,
-				NULL,
-				0,
-				G_OPTION_ARG_NONE,
-				NULL,
-				NULL },
+				G_OPTION_ARG_STRING_ARRAY,
+				N_( "The name of a capability the selection must meet. "
+					"May be 'Owner', 'Readable', 'Writable', 'Executable' or 'Local'" ),
+				N_( "<NAME>" ) },
 
 	{ NULL },
 };
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index fd11047..e68acfc 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -84,6 +84,11 @@ static gchar    **folders_array    = NULL;
 static gchar     *selection_count  = "";
 static gchar    **onlyshow_array   = NULL;
 static gchar    **notshow_array    = NULL;
+static gchar     *try_exec         = "";
+static gchar     *show_registered  = "";
+static gchar     *show_true        = "";
+static gchar     *show_running     = "";
+static gchar    **capability_array = NULL;
 /* output entries */
 static gboolean   output_stdout    = FALSE;
 static gboolean   output_desktop   = FALSE;
@@ -94,27 +99,32 @@ extern NADataGroup action_data_groups[];			/* defined in na-object-action-factor
 extern NADataGroup profile_data_groups[];			/* defined in na-object-profile-factory.c */
 
 static const ArgFromDataDef st_arg_from_data_def[] = {
-		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_LABEL,            &label },
-		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_TOOLTIP,          &tooltip },
-		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_ICON,             &icon },
-		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_ENABLED,          &enabled },
-		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TARGET_SELECTION, &target_selection },
-		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TARGET_LOCATION,  &target_location },
-		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TARGET_TOOLBAR,   &target_toolbar },
-		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TOOLBAR_LABEL,    &label_toolbar },
-		{ profile_data_groups, NA_FACTORY_OBJECT_PROFILE_GROUP,    NAFO_DATA_PATH,             &command },
-		{ profile_data_groups, NA_FACTORY_OBJECT_PROFILE_GROUP,    NAFO_DATA_PARAMETERS,       &parameters },
-		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_BASENAMES,        &basenames_array },
-		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MATCHCASE,        &matchcase },
-		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MIMETYPES,        &mimetypes_array },
-		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ISFILE,           &isfile },
-		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ISDIR,            &isdir },
-		{ 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 },
-		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ONLY_SHOW,        &onlyshow_array },
-		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_NOT_SHOW,         &notshow_array },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_LABEL,              &label },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_TOOLTIP,            &tooltip },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_ICON,               &icon },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ITEM_GROUP,       NAFO_DATA_ENABLED,            &enabled },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TARGET_SELECTION,   &target_selection },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TARGET_LOCATION,    &target_location },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TARGET_TOOLBAR,     &target_toolbar },
+		{ action_data_groups,  NA_FACTORY_OBJECT_ACTION_GROUP,     NAFO_DATA_TOOLBAR_LABEL,      &label_toolbar },
+		{ profile_data_groups, NA_FACTORY_OBJECT_PROFILE_GROUP,    NAFO_DATA_PATH,               &command },
+		{ profile_data_groups, NA_FACTORY_OBJECT_PROFILE_GROUP,    NAFO_DATA_PARAMETERS,         &parameters },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_BASENAMES,          &basenames_array },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MATCHCASE,          &matchcase },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_MIMETYPES,          &mimetypes_array },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ISFILE,             &isfile },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ISDIR,              &isdir },
+		{ 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 },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_ONLY_SHOW,          &onlyshow_array },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_NOT_SHOW,           &notshow_array },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_TRY_EXEC,           &try_exec },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_SHOW_IF_REGISTERED, &show_registered },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_SHOW_IF_TRUE,       &show_true },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_SHOW_IF_RUNNING,    &show_running },
+		{ profile_data_groups, NA_FACTORY_OBJECT_CONDITIONS_GROUP, NAFO_DATA_CAPABILITITES,      &capability_array },
 		{ NULL }
 };
 
@@ -395,6 +405,7 @@ get_action_from_cmdline( void )
 	gchar *msg;
 	GSList *only_show_in;
 	GSList *not_show_in;
+	GSList *capabilities;
 
 	action = na_object_action_new_with_defaults();
 	profile = NA_OBJECT_PROFILE(( GList * ) na_object_get_items( action )->data );
@@ -520,6 +531,43 @@ get_action_from_cmdline( void )
 		}
 	}
 
+	if( try_exec && strlen( try_exec )){
+		na_object_set_try_exec( profile, try_exec );
+	}
+
+	if( show_registered && strlen( show_registered )){
+		na_object_set_show_if_registered( profile, show_registered );
+	}
+
+	if( show_true && strlen( show_true )){
+		na_object_set_show_if_true( profile, show_true );
+	}
+
+	if( show_running && strlen( show_running )){
+		na_object_set_show_if_running( profile, show_running );
+	}
+
+	if( capability_array ){
+		capabilities = NULL;
+		for( i = 0 ; capability_array[i] && strlen( capability_array[i] ) ; ++i ){
+			const gchar *cap = ( const gchar * ) capability_array[i];
+			/* 'Owner', 'Readable', 'Writable', 'Executable' and 'Local' */
+			if( strcmp( cap, "Owner" ) &&
+				strcmp( cap, "Readable" ) &&
+				strcmp( cap, "Writable" ) &&
+				strcmp( cap, "Executable" ) &&
+				strcmp( cap, "Local" )){
+					g_warning( "%s: unknown capability", cap );
+			}  else {
+				capabilities = g_slist_append( capabilities, g_strdup( capability_array[i] ));
+			}
+		}
+		if( capabilities && g_slist_length( capabilities )){
+			na_object_set_capabilities( profile, capabilities );
+			na_core_utils_slist_free( capabilities );
+		}
+	}
+
 	return( action );
 }
 



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