[nautilus-actions] nautilus-actions-new: add only-show-in and not-show-in options
- From: Pierre Wieser <pwieser src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus-actions] nautilus-actions-new: add only-show-in and not-show-in options
- Date: Sun, 20 Feb 2011 20:13:14 +0000 (UTC)
commit b6bc2d80a98e1ea081a63ab0c1f8839be65534a4
Author: Pierre Wieser <pwieser trychlos org>
Date: Sun Feb 20 17:50:18 2011 +0100
nautilus-actions-new: add only-show-in and not-show-in options
ChangeLog | 9 ++++++
src/core/na-icontext-factory.c | 33 ++++++++++++++----------
src/core/na-object-action-factory.c | 8 +++---
src/core/na-object-item-factory.c | 4 +-
src/utils/nautilus-actions-new.c | 48 ++++++++++++++++++++++++++++++++--
5 files changed, 79 insertions(+), 23 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 3af38b7..ac8575c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2011-02-20 Pierre Wieser <pwieser trychlos org>
+ * 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,
+ NAFO_DATA_TARGET_LOCATION, NAFO_DATA_TARGET_TOOLBAR):
+ * src/core/na-object-item-factory.c (NAFO_DATA_ENABLED):
+ Fix options definition.
+
+ * src/utils/nautilus-actions-new.c: Add only-show-in and not-show-in options.
+
* src/core/na-icontext-factory.c
(NAFO_DATA_SELECTION_COUNT): Fix option definition.
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index 4534caa..448af70 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -293,7 +293,7 @@ NADataDef data_def_conditions [] = {
's',
"scheme",
0,
- G_OPTION_ARG_STRING,
+ G_OPTION_ARG_STRING_ARRAY,
N_( "A valid GIO scheme where the selected file(s)/folder(s) should be located. " \
"You must set one option for each scheme you need" ),
/* i18n: "<STRING>" is just an abbreviation for "a string", so is tranlatable */
@@ -319,7 +319,7 @@ NADataDef data_def_conditions [] = {
'r',
"folder",
0,
- G_OPTION_ARG_STRING,
+ G_OPTION_ARG_STRING_ARRAY,
N_( "The path of a (parent) directory for which the item will be displayed. " \
"You must set one option for each folder you need" ),
/* i18n: "<PATH>" is just an abbreviation for "a folder path", so is tranlatable */
@@ -347,8 +347,9 @@ NADataDef data_def_conditions [] = {
"selection-count",
0,
G_OPTION_ARG_STRING,
- NULL,
- NULL },
+ N_( "Selection count relation [>0]" ),
+ /* i18n: "<EXPR>" is just an abbreviation for "an expression", so is tranlatable */
+ N_( "<EXPR>" ) },
{ NAFO_DATA_ONLY_SHOW,
TRUE,
@@ -365,12 +366,14 @@ NADataDef data_def_conditions [] = {
FALSE,
"only-show-in",
"OnlyShowIn",
+ 'y',
+ "only-show-in",
0,
- NULL,
- 0,
- G_OPTION_ARG_NONE,
- NULL,
- NULL },
+ G_OPTION_ARG_STRING_ARRAY,
+ N_( "The name of an only desktop environment where the item must be displayed. " \
+ "You must set one option for each environment you want" ),
+ /* i18n: "<DESKTOP>" is just a placeholder for "a desktop name", so is tranlatable */
+ N_( "<DESKTOP>" ) },
{ NAFO_DATA_NOT_SHOW,
TRUE,
@@ -387,12 +390,14 @@ NADataDef data_def_conditions [] = {
FALSE,
"not-show-in",
"NotShowIn",
+ 'Y',
+ "not-show-in",
0,
- NULL,
- 0,
- G_OPTION_ARG_NONE,
- NULL,
- NULL },
+ G_OPTION_ARG_STRING_ARRAY,
+ N_( "The name of a desktop environment where the item must not be displayed. " \
+ "You must set one option for each environment you want" ),
+ /* i18n: "<DESKTOP>" is just a placeholder for "a desktop name", so is tranlatable */
+ N_( "<DESKTOP>" ) },
{ NAFO_DATA_TRY_EXEC,
TRUE,
diff --git a/src/core/na-object-action-factory.c b/src/core/na-object-action-factory.c
index 80a3821..d27723e 100644
--- a/src/core/na-object-action-factory.c
+++ b/src/core/na-object-action-factory.c
@@ -73,7 +73,7 @@ static NADataDef data_def_action [] = {
TRUE,
TRUE,
TRUE,
- N_( "Targets the selection context menu (default)" ),
+ N_( "Targets the selection context menu" ),
N_( "Whether the action targets the selection file manager context menus.\n" \
"This used to be the historical behavior.\n" \
"Note that menus are always potential candidate to the display in " \
@@ -92,7 +92,7 @@ static NADataDef data_def_action [] = {
"selection",
0,
G_OPTION_ARG_NONE,
- NULL,
+ N_( "Targets the selection context menu [true]" ),
NULL },
{ NAFO_DATA_TARGET_LOCATION,
@@ -118,7 +118,7 @@ static NADataDef data_def_action [] = {
"location",
0,
G_OPTION_ARG_NONE,
- NULL,
+ N_( "Targets the location context menu [false]" ),
NULL },
{ NAFO_DATA_TARGET_TOOLBAR,
@@ -143,7 +143,7 @@ static NADataDef data_def_action [] = {
"toolbar",
0,
G_OPTION_ARG_NONE,
- NULL,
+ N_( "Targets the toolbar [false]" ),
NULL },
{ NAFO_DATA_TOOLBAR_LABEL,
diff --git a/src/core/na-object-item-factory.c b/src/core/na-object-item-factory.c
index 1716cf1..323eb9c 100644
--- a/src/core/na-object-item-factory.c
+++ b/src/core/na-object-item-factory.c
@@ -283,7 +283,7 @@ NADataDef data_def_item [] = {
TRUE,
TRUE,
TRUE,
- N_( "Whether the action or the menu is enabled (default)" ),
+ N_( "Whether the action or the menu is enabled" ),
N_( "If the or the menu action is disabled, it will never appear in the " \
"file manager context menu.\n" \
"Defaults to TRUE." ),
@@ -300,7 +300,7 @@ NADataDef data_def_item [] = {
"enabled",
0,
G_OPTION_ARG_NONE,
- NULL,
+ N_( "Whether the action or the menu is enabled [enabled]" ),
NULL },
/* dynamic data, so non readable / non writable
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index f2c5d6e..fd11047 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -66,6 +66,7 @@ static gboolean disabled = FALSE;
static gboolean target_selection = FALSE;
static gboolean target_location = FALSE;
static gboolean nocontext = FALSE;
+static gboolean nolocation = FALSE;
static gboolean target_toolbar = FALSE;
static gboolean notoolbar = FALSE;
static gchar *label_toolbar = "";
@@ -81,6 +82,8 @@ static gboolean accept_multiple = FALSE;
static gchar **schemes_array = NULL;
static gchar **folders_array = NULL;
static gchar *selection_count = "";
+static gchar **onlyshow_array = NULL;
+static gchar **notshow_array = NULL;
/* output entries */
static gboolean output_stdout = FALSE;
static gboolean output_desktop = FALSE;
@@ -110,6 +113,8 @@ static const ArgFromDataDef st_arg_from_data_def[] = {
{ 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, ¬show_array },
{ NULL }
};
@@ -118,7 +123,9 @@ static GOptionEntry st_added_entries[] = {
{ "disabled" , 'E', 0, G_OPTION_ARG_NONE , &disabled,
N_( "Set it if the item should be disabled at creation" ), NULL },
{ "nocontext" , 'C', 0, G_OPTION_ARG_NONE , &nocontext,
- N_( "Set it if the item doesn't target the context menu" ), NULL },
+ N_( "Set it if the item doesn't target the selection context menu" ), NULL },
+ { "nolocation" , 'T', 0, G_OPTION_ARG_NONE , &nolocation,
+ N_( "Set it if the item doesn't target the location context menu" ), NULL },
{ "notoolbar" , 'O', 0, G_OPTION_ARG_NONE , ¬oolbar,
N_( "Set it if the item doesn't target the toolbar" ), NULL },
{ "nocase" , 'A', 0, G_OPTION_ARG_NONE , &nocase,
@@ -214,6 +221,11 @@ main( int argc, char** argv )
target_selection = TRUE;
}
+ if( target_location && nolocation ){
+ g_printerr( CANNOT_BOTH, "--location", "--nolocation" );
+ errors += 1;
+ }
+
if( target_toolbar && notoolbar ){
g_printerr( CANNOT_BOTH, "--toolbar", "--notoolbar" );
errors += 1;
@@ -231,6 +243,11 @@ main( int argc, char** argv )
errors += 1;
}
+ if( onlyshow_array && notshow_array ){
+ g_printerr( CANNOT_BOTH, "--only-show-in", "--not-show-in" );
+ errors += 1;
+ }
+
if( output_stdout && output_desktop ){
g_printerr( _( "Error: only one output option may be specified.\n" ));
errors += 1;
@@ -320,10 +337,10 @@ init_options( void )
context = g_option_context_new( _( "Define a new action." ));
- /*g_option_context_set_summary( context, _(
+ g_option_context_set_summary( context, _(
"The created action defaults to be written to stdout.\n"
"It can also be written to an output folder, in a file later suitable for an import in NACT.\n"
- "Or you may choose to directly write the action into your GConf configuration." ));*/
+ "Or you may choose to directly write the action into your Nautilus-Actions configuration." ));
g_option_context_set_translation_domain( context, GETTEXT_PACKAGE );
@@ -376,6 +393,8 @@ get_action_from_cmdline( void )
GSList *folders;
gboolean toolbar_same_label;
gchar *msg;
+ GSList *only_show_in;
+ GSList *not_show_in;
action = na_object_action_new_with_defaults();
profile = NA_OBJECT_PROFILE(( GList * ) na_object_get_items( action )->data );
@@ -389,6 +408,7 @@ get_action_from_cmdline( void )
}
na_object_set_enabled( action, enabled );
na_object_set_target_selection( action, target_selection );
+ na_object_set_target_location( action, target_location );
na_object_set_target_toolbar( action, target_toolbar );
toolbar_same_label = FALSE;
@@ -478,6 +498,28 @@ get_action_from_cmdline( void )
na_core_utils_slist_free( folders );
}
+ if( onlyshow_array ){
+ only_show_in = NULL;
+ for( i = 0 ; onlyshow_array[i] && strlen( onlyshow_array[i] ) ; ++i ){
+ only_show_in = g_slist_append( only_show_in, g_strdup( onlyshow_array[i] ));
+ }
+ if( only_show_in && g_slist_length( only_show_in )){
+ na_object_set_only_show_in( profile, only_show_in );
+ na_core_utils_slist_free( only_show_in );
+ }
+ }
+
+ if( notshow_array ){
+ not_show_in = NULL;
+ for( i = 0 ; notshow_array[i] && strlen( notshow_array[i] ) ; ++i ){
+ not_show_in = g_slist_append( not_show_in, g_strdup( notshow_array[i] ));
+ }
+ if( not_show_in && g_slist_length( not_show_in )){
+ na_object_set_not_show_in( profile, not_show_in );
+ na_core_utils_slist_free( not_show_in );
+ }
+ }
+
return( action );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]