[nautilus-actions] Define new action data as arguments for nautilus-actions-new
- From: Pierre Wieser <pwieser src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [nautilus-actions] Define new action data as arguments for nautilus-actions-new
- Date: Tue, 27 Oct 2009 23:11:34 +0000 (UTC)
commit a6b2e703f1da013ad7f36c2926be8b1fd5aa98fa
Author: Pierre Wieser <pwieser trychlos org>
Date: Tue Oct 27 22:27:21 2009 +0100
Define new action data as arguments for nautilus-actions-new
ChangeLog | 4 +
src/utils/nautilus-actions-new.c | 127 +++++++++++++++++++++++++++----------
2 files changed, 96 insertions(+), 35 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index ab931ae..8b22e97 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2009-10-27 Pierre Wieser <pwieser trychlos org>
+ * src/utils/nautilus-actions-new.c:
+ Add new action data as arguments (target-selection, target-folders,
+ target-toolbar, toolbar-label, folders).
+
* src/common/na-utils.c:
* src/common/na-utils.c (na_utils_print_version):
New function.
diff --git a/src/utils/nautilus-actions-new.c b/src/utils/nautilus-actions-new.c
index ed6f4b2..78b2e8a 100644
--- a/src/utils/nautilus-actions-new.c
+++ b/src/utils/nautilus-actions-new.c
@@ -45,67 +45,85 @@
#include <common/na-xml-writer.h>
#include <common/na-utils.h>
-static gchar *label = "";
-static gchar *tooltip = "";
-static gchar *icon = "";
-static gboolean enabled = TRUE;
-static gchar *command = "";
-static gchar *parameters = "";
-static gchar **basenames_array = NULL;
-static gboolean matchcase = FALSE;
-static gchar **mimetypes_array = NULL;
-static gboolean isfile = FALSE;
-static gboolean isdir = FALSE;
-static gboolean accept_multiple = FALSE;
-static gchar **schemes_array = NULL;
-static gchar *output_dir = NULL;
-static gboolean output_gconf = FALSE;
-static gboolean version = FALSE;
+static gchar *label = "";
+static gchar *tooltip = "";
+static gchar *icon = "";
+static gboolean enabled = FALSE;
+static gboolean disabled = FALSE;
+static gboolean target_selection = FALSE;
+static gboolean target_folders = FALSE;
+static gboolean target_toolbar = FALSE;
+static gchar *label_toolbar = "";
+static gchar *command = "";
+static gchar *parameters = "";
+static gchar **basenames_array = NULL;
+static gboolean matchcase = FALSE;
+static gchar **mimetypes_array = NULL;
+static gboolean isfile = FALSE;
+static gboolean isdir = FALSE;
+static gboolean accept_multiple = FALSE;
+static gchar **schemes_array = NULL;
+static gchar **folders_array = NULL;
+static gchar *output_dir = NULL;
+static gboolean output_gconf = FALSE;
+static gboolean version = FALSE;
static GOptionEntry entries[] = {
{ "label" , 'l', 0, G_OPTION_ARG_STRING , &label,
- N_("The label of the menu item (mandatory)"), N_("<STRING>") },
+ N_( "The label of the menu item (mandatory)" ), N_( "<STRING>" ) },
{ "tooltip" , 't', 0, G_OPTION_ARG_STRING , &tooltip,
- N_("The tooltip of the menu item"), N_("<STRING>") },
+ N_( "The tooltip of the menu item" ), N_( "<STRING>" ) },
{ "icon" , 'i', 0, G_OPTION_ARG_STRING , &icon,
- N_("The icon of the menu item (filename or GTK stock ID)"), N_("<PATH|NAME>") },
+ N_( "The icon of the menu item (filename or themed icon)" ), N_( "<PATH|NAME>" ) },
{ "enabled" , 'e', 0, G_OPTION_ARG_NONE , &enabled,
- N_("Whether the action is enabled"), NULL },
+ N_( "Set it if the action should be enabled [default]" ), NULL },
+ { "disabled" , 'a', 0, G_OPTION_ARG_NONE , &disabled,
+ N_( "Set it if the action should be disabled at creation" ), NULL },
+ { "target-selection" , 'S', 0, G_OPTION_ARG_NONE , &target_selection,
+ N_( "Set it if the action should be displayed in selection menus" ), NULL },
+ { "target-folders" , 'F', 0, G_OPTION_ARG_NONE , &target_folders,
+ N_( "Set it if the action should be displayed in folders menus" ), NULL },
+ { "target-toolbar" , 'O', 0, G_OPTION_ARG_NONE , &target_toolbar,
+ N_( "Set it if the action should be displayed in toolbar" ), NULL },
+ { "label-toolbar" , 'L', 0, G_OPTION_ARG_STRING , &label_toolbar,
+ N_( "The label of the action item in the toolbar" ), N_( "<STRING>" ) },
{ "command" , 'c', 0, G_OPTION_ARG_FILENAME , &command,
- N_("The path of the command"), N_("<PATH>") },
+ N_( "The path of the command" ), N_( "<PATH>" ) },
{ "parameters" , 'p', 0, G_OPTION_ARG_STRING , ¶meters,
- N_("The parameters of the command"), N_("<PARAMETERS>") },
+ N_( "The parameters of the command" ), N_( "<PARAMETERS>" ) },
{ "match" , 'm', 0, G_OPTION_ARG_STRING_ARRAY, &basenames_array,
- N_("A pattern to match selected files against. May include wildcards (* or ?) (you must set one option for each pattern you need)"), N_("EXPR") },
+ N_( "A pattern to match selected items against. May include wildcards (* or ?). You must set one option for each pattern you need" ), N_( "<EXPR>" ) },
{ "match-case" , 'C', 0, G_OPTION_ARG_NONE , &matchcase,
- N_("Set it if the previous patterns are case sensitive"), NULL },
+ N_( "Set it if the previous patterns are case sensitive" ), NULL },
{ "mimetypes" , 'T', 0, G_OPTION_ARG_STRING_ARRAY, &mimetypes_array,
- N_("A pattern to match selected files' mimetype against. May include wildcards (* or ?) (you must set one option for each pattern you need)"), N_("EXPR") },
+ N_( "A pattern to match selected items mimetype against. May include wildcards (* or ?). You must set one option for each pattern you need" ), N_( "<EXPR>" ) },
{ "accept-files" , 'f', 0, G_OPTION_ARG_NONE , &isfile,
- N_("Set it if the selection must only contain files"), NULL },
+ N_( "Set it if the selection must only contain files" ), NULL },
{ "accept-dirs" , 'd', 0, G_OPTION_ARG_NONE , &isdir,
- N_("Set it if the selection must only contain folders. Specify both '--isfile' and '--isdir' options is selection can contain both types of items"), NULL },
+ N_( "Set it if the selection must only contain folders. Specify both '--accept-files' and '--accept-dirs' options if selection can contain both types of items" ), NULL },
{ "accept-multiple-files", 'M', 0, G_OPTION_ARG_NONE , &accept_multiple,
- N_("Set it if the selection can have several items"), NULL },
+ N_( "Set it if the selection can have several items" ), NULL },
{ "scheme" , 's', 0, G_OPTION_ARG_STRING_ARRAY, &schemes_array,
- N_("A valid GIO scheme where the selected files should be located (you must set one option for each scheme you need)"), N_("SCHEME") },
+ N_( "A valid GIO scheme where the selected files should be located. You must set one option for each scheme you need" ), N_( "<SCHEME>" ) },
+ { "folder" , 'U', 0, G_OPTION_ARG_STRING_ARRAY, &folders_array,
+ N_( "The URI of a directory for which folders or toolbar action will be displayed. You must set one option for each folder you need" ), N_( "<URI>" ) },
{ NULL }
};
static GOptionEntry output_entries[] = {
{ "output-gconf" , 'g', 0, G_OPTION_ARG_NONE , &output_gconf,
- N_("Directly import the newly created action in GConf configuration"), NULL },
+ N_( "Store the newly created action as a GConf configuration" ), NULL },
{ "output-dir" , 'o', 0, G_OPTION_ARG_FILENAME , &output_dir,
- N_("The folder where to write the new action as a GConf dump output [default: stdout]"), N_("DIR") },
+ N_( "The folder where to write the new action as a GConf dump output [default: stdout]" ), N_( "DIR" ) },
{ NULL }
};
static GOptionEntry misc_entries[] = {
{ "version" , 'v', 0, G_OPTION_ARG_NONE , &version,
- N_("Output the version number"), NULL },
+ N_( "Output the version number" ), NULL },
{ NULL }
};
@@ -124,6 +142,7 @@ main( int argc, char** argv )
GSList *msg = NULL;
GSList *im;
gchar *help;
+ gint errors;
g_type_init();
@@ -138,7 +157,7 @@ main( int argc, char** argv )
}
if( !g_option_context_parse( context, &argc, &argv, &error )){
- g_printerr( _("Syntax error: %s\n" ), error->message );
+ g_printerr( _( "Syntax error: %s\n" ), error->message );
g_error_free (error);
exit_with_usage();
}
@@ -148,13 +167,26 @@ main( int argc, char** argv )
exit( status );
}
+ errors = 0;
+
if( !label || !g_utf8_strlen( label, -1 )){
g_printerr( _( "Error: an action label is mandatory.\n" ));
- exit_with_usage();
+ errors += 1;
+ }
+
+ if( enabled && disabled ){
+ g_printerr( _( "Error: '--enabled' and '--disabled' options cannot both be specified.\n" ));
+ errors += 1;
+ } else if( !disabled ){
+ enabled = TRUE;
}
if( output_gconf && output_dir ){
g_printerr( _( "Error: only one output option may be specified.\n" ));
+ errors += 1;
+ }
+
+ if( errors ){
exit_with_usage();
}
@@ -250,6 +282,7 @@ get_action_from_cmdline( void )
GSList *basenames = NULL;
GSList *mimetypes = NULL;
GSList *schemes = NULL;
+ GSList *folders = NULL;
profiles = na_object_get_items_list( action );
profile = NA_OBJECT_PROFILE( profiles->data );
@@ -258,6 +291,21 @@ get_action_from_cmdline( void )
na_object_set_tooltip( action, tooltip );
na_object_set_icon( action, icon );
na_object_set_enabled( NA_OBJECT_ITEM( action ), enabled );
+ na_object_action_set_target_selection( action, target_selection );
+ na_object_action_set_target_background( action, target_folders );
+ na_object_action_set_target_toolbar( action, target_toolbar );
+
+ if( target_toolbar ){
+ if( label_toolbar && g_utf8_strlen( label_toolbar, -1 )){
+ na_object_action_toolbar_set_same_label( action, FALSE );
+ na_object_action_toolbar_set_label( action, label_toolbar );
+ } else {
+ na_object_action_toolbar_set_same_label( action, TRUE );
+ na_object_action_toolbar_set_label( action, label );
+ }
+ } else {
+ na_object_action_toolbar_set_label( action, "" );
+ }
na_object_profile_set_path( profile, command );
na_object_profile_set_parameters( profile, parameters );
@@ -297,6 +345,15 @@ get_action_from_cmdline( void )
g_slist_foreach( schemes, ( GFunc ) g_free, NULL );
g_slist_free( schemes );
+ i = 0;
+ while( folders_array != NULL && folders_array[i] != NULL ){
+ folders = g_slist_append( folders, g_strdup( folders_array[i] ));
+ i++;
+ }
+ na_object_profile_set_folders( profile, folders );
+ g_slist_foreach( folders, ( GFunc ) g_free, NULL );
+ g_slist_free( folders );
+
return( action );
}
@@ -331,6 +388,6 @@ write_to_gconf( NAObjectAction *action, GSList **msg )
static void
exit_with_usage( void )
{
- g_printerr( _("Try %s --help for usage.\n"), g_get_prgname());
+ g_printerr( _( "Try %s --help for usage.\n" ), g_get_prgname());
exit( EXIT_FAILURE );
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]