[nautilus-actions] Define all new data for .desktop files management



commit 17b0ecfc6f4a2b3e6b341eb12867110efb4e9210
Author: Pierre Wieser <pwieser trychlos org>
Date:   Mon Apr 19 06:42:33 2010 +0200

    Define all new data for .desktop files management

 ChangeLog                            |   10 ++
 src/api/na-ifactory-object-data.h    |   12 +++
 src/api/na-object-profile.h          |    7 ++
 src/core/na-icontext-factory.c       |  167 ++++++++++++++++++++++++++++++++++
 src/core/na-object-action-factory.c  |   19 +++--
 src/core/na-object-item-factory.c    |   25 +++++
 src/core/na-object-menu-factory.c    |    3 +-
 src/core/na-object-profile-factory.c |  155 +++++++++++++++++++++++++++++---
 8 files changed, 377 insertions(+), 21 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 67dfd5d..5803356 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -47,6 +47,16 @@
 
 2010-04-19 Pierre Wieser <pwieser trychlos org>
 
+	* src/api/na-ifactory-object-data.h:
+	* src/api/na-object-profile.h:
+	* src/core/na-icontext-factory.c:
+	* src/core/na-object-action-factory.c:
+	* src/core/na-object-item-factory.c:
+	* src/core/na-object-menu-factory.c:
+	* src/core/na-object-profile-factory.c:
+	Define all new data, new parameters, and include context informations
+	to actions and menus.
+
 	* src/api/na-core-utils.h:
 	* src/core/na-core-utils.c (na_core_utils_slist_from_array):
 	Fix leading and trailing spaces management.
diff --git a/src/api/na-ifactory-object-data.h b/src/api/na-ifactory-object-data.h
index b50e06d..305659e 100644
--- a/src/api/na-ifactory-object-data.h
+++ b/src/api/na-ifactory-object-data.h
@@ -47,6 +47,7 @@ G_BEGIN_DECLS
 #define NAFO_DATA_CONDITIONS				"na-factory-data-conditions"
 
 #define NA_FACTORY_OBJECT_ITEM_GROUP		"na-factory-group-item"
+#define NAFO_DATA_IVERSION					"na-factory-data-iversion"
 #define NAFO_DATA_TYPE						"na-factory-data-type"
 #define NAFO_DATA_LABEL						"na-factory-data-label"
 #define NAFO_DATA_TOOLTIP					"na-factory-data-tooltip"
@@ -77,6 +78,10 @@ G_BEGIN_DECLS
 #define NAFO_DATA_DESCNAME					"na-factory-data-descname"
 #define NAFO_DATA_PATH						"na-factory-data-path"
 #define NAFO_DATA_PARAMETERS				"na-factory-data-parameters"
+#define NAFO_DATA_EXECUTION_MODE			"na-factory-data-execution-mode"
+#define NAFO_DATA_STARTUP_NOTIFY			"na-factory-data-startup-notify"
+#define NAFO_DATA_STARTUP_WMCLASS			"na-factory-data-startup-wm-class"
+#define NAFO_DATA_EXECUTE_AS				"na-factory-data-execute-as"
 
 #define NA_FACTORY_OBJECT_CONDITIONS_GROUP	"na-factory-group-conditions"
 #define NAFO_DATA_BASENAMES					"na-factory-data-basenames"
@@ -88,6 +93,13 @@ G_BEGIN_DECLS
 #define NAFO_DATA_SCHEMES					"na-factory-data-schemes"
 #define NAFO_DATA_FOLDERS					"na-factory-data-folders"
 #define NAFO_DATA_SELECTION_COUNT			"na-factory-data-selection-count"
+#define NAFO_DATA_ONLY_SHOW					"na-factory-data-only-show-in"
+#define NAFO_DATA_NOT_SHOW					"na-factory-data-not-show-in"
+#define NAFO_DATA_TRY_EXEC					"na-factory-data-try-exec"
+#define NAFO_DATA_SHOW_IF_REGISTERED		"na-factory-data-show-if-registered"
+#define NAFO_DATA_SHOW_IF_TRUE				"na-factory-data-show-if-true"
+#define NAFO_DATA_SHOW_IF_RUNNING			"na-factory-data-show-if-running"
+#define NAFO_DATA_CAPABILITITES				"na-factory-data-capabilitites"
 
 G_END_DECLS
 
diff --git a/src/api/na-object-profile.h b/src/api/na-object-profile.h
index 9a41c9a..a633bf3 100644
--- a/src/api/na-object-profile.h
+++ b/src/api/na-object-profile.h
@@ -67,6 +67,13 @@ typedef struct {
 }
 	NAObjectProfileClass;
 
+enum {
+	NA_EXECUTION_MODE_NORMAL = 1,
+	NA_EXECUTION_MODE_TERMINAL,
+	NA_EXECUTION_MODE_EMBEDDED,
+	NA_EXECUTION_MODE_DISPLAY_OUTPUT
+};
+
 GType            na_object_profile_get_type( void );
 
 NAObjectProfile *na_object_profile_new( void );
diff --git a/src/core/na-icontext-factory.c b/src/core/na-icontext-factory.c
index f06cf07..187a5e1 100644
--- a/src/core/na-icontext-factory.c
+++ b/src/core/na-icontext-factory.c
@@ -292,5 +292,172 @@ NADataDef data_def_conditions [] = {
 				NULL,
 				NULL },
 
+	{ NAFO_DATA_ONLY_SHOW,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Only show in environment" ),
+				N_( "Defaults to all." ),
+				NAFD_TYPE_STRING_LIST,
+				NULL,
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"only-show-in",
+				"OnlyShowIn",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_NOT_SHOW,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Not show in environment" ),
+				N_( "Defaults to none." ),
+				NAFD_TYPE_STRING_LIST,
+				NULL,
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"not-show-in",
+				"NotShowIn",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_TRY_EXEC,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Try exec" ),
+				N_( "Note that, when specified, only the presence and the executability status of " \
+					"the specified file are checked.\n" \
+					"Parameters may appear in TryExec value, and will be substituted at runtime.\n" \
+					"Defaults to successful." ),
+				NAFD_TYPE_STRING,
+				NULL,
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"try-exec",
+				"TryExec",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_SHOW_IF_REGISTERED,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Show if registered" ),
+				N_( "The well-known name of a DBus service.\n" \
+					"The item will be candidate if the named service is registered on session DBus at runtime.\n" \
+					"Parameters may appear in ShowIfRegistered value, and will be substituted at runtime.\n" \
+					"Defaults to successful." ),
+				NAFD_TYPE_STRING,
+				NULL,
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"show-if-registered",
+				"ShowIfRegistered",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_SHOW_IF_TRUE,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Show if True" ),
+				N_( "A command which, when executed, should output a string on stdout.\n" \
+					"The item will be candidate if the outputed string is equal to \"true\".\n" \
+					"Parameters may appear in ShowIfTrue value, and will be substituted at runtime.\n" \
+					"Defaults to successful." ),
+				NAFD_TYPE_STRING,
+				NULL,
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"show-if-true",
+				"ShowIfTrue",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_SHOW_IF_RUNNING,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Show if running" ),
+				N_( "The name of a process.\n" \
+					"The item will be candidate if the process name is found in memory at runtime.\n" \
+					"Parameters may appear in ShowIfRunning value, and will be substituted at runtime.\n" \
+					"Defaults to successful." ),
+				NAFD_TYPE_STRING,
+				NULL,
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"show-if-running",
+				"ShowIfRunning",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_CAPABILITITES,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Capabilities" ),
+				N_( "A list of capabilities each item of the selection must satisfy in order the item be candidate.\n" \
+					"Capabilities may be negated.\n" \
+					"Capabilities have to be choosen between following predefined ones:\n" \
+					"- Owner: current user is the owner of selected items\n" \
+					"- Readable: selected items are readable by user (probably more usefull when negated)\n" \
+					"- Writable: selected items are writable by user\n" \
+					"- Executable: selected items are executable by user\n" \
+					"- Local: selected items are local.\n" \
+					"Defaults to \"*;\"." ),
+				NAFD_TYPE_STRING_LIST,
+				"*",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"capabilities",
+				"Capabilities",
+				0,
+				NULL,
+				0,
+				G_OPTION_ARG_NONE,
+				NULL,
+				NULL },
+
 	{ NULL },
 };
diff --git a/src/core/na-object-action-factory.c b/src/core/na-object-action-factory.c
index 5f89da8..d271206 100644
--- a/src/core/na-object-action-factory.c
+++ b/src/core/na-object-action-factory.c
@@ -38,18 +38,23 @@
 #include <api/na-data-def.h>
 #include <api/na-data-types.h>
 
-extern NADataDef data_def_id[];			/* defined in na-object-id-factory.c */
-extern NADataDef data_def_item [];		/* defined in na-object-item-factory.c */
+extern NADataDef data_def_id[];				/* defined in na-object-id-factory.c */
+extern NADataDef data_def_item [];			/* defined in na-object-item-factory.c */
+extern NADataDef data_def_conditions [];	/* defined in na-icontext-factory.c */
 
 static NADataDef data_def_action [] = {
 
+	/* this version number, expressed as a string, is obsoleted starting with .desktop
+	 * files introduction ; it is replaced by an integer version number, at the item level
+	 * the new integer version number starts at 1. It will so be consistant with future
+	 * versions of .desktop files
+	 */
 	{ NAFO_DATA_VERSION,
 				TRUE,
+				FALSE,
 				TRUE,
-				TRUE,
-				N_( "Version of the format" ),
-				N_( "The version of the configuration format that will be used to manage " \
-					"backward compatibility." ),
+				"Version of the format",
+				"The version of the configuration format that will be used to manage backward compatibility.",
 				NAFD_TYPE_STRING,
 				"2.0",
 				TRUE,
@@ -418,6 +423,6 @@ NADataGroup action_data_groups [] = {
 	{ NA_FACTORY_OBJECT_ITEM_GROUP,       data_def_item },
 	{ NA_FACTORY_OBJECT_ACTION_GROUP,     data_def_action },
 	{ NA_FACTORY_ACTION_V1_GROUP,         data_def_action_v1 },
-	{ NA_FACTORY_OBJECT_CONDITIONS_GROUP, NULL },
+	{ NA_FACTORY_OBJECT_CONDITIONS_GROUP, data_def_conditions },
 	{ NULL }
 };
diff --git a/src/core/na-object-item-factory.c b/src/core/na-object-item-factory.c
index a9ed2d6..7f06fee 100644
--- a/src/core/na-object-item-factory.c
+++ b/src/core/na-object-item-factory.c
@@ -346,5 +346,30 @@ NADataDef data_def_item [] = {
 				NULL,
 				NULL },
 
+	/* this integer version number is introduced with .desktop files and obsoletes
+	 * the previous string version number which was only set on actions
+	 * we so have: "1.0" < "1.1" < "2.0" < 1
+	 */
+	{ NAFO_DATA_IVERSION,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Version of the format" ),
+				N_( "The version of the configuration format that will be used to manage backward compatibility." ),
+				NAFD_TYPE_UINT,
+				"1",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"iversion",
+				NULL,
+				0,
+				NULL,
+				0,
+				0,
+				NULL,
+				NULL },
+
 	{ NULL },
 };
diff --git a/src/core/na-object-menu-factory.c b/src/core/na-object-menu-factory.c
index 64345ac..02fafce 100644
--- a/src/core/na-object-menu-factory.c
+++ b/src/core/na-object-menu-factory.c
@@ -38,6 +38,7 @@
 
 extern NADataDef data_def_id [];			/* defined in na-object-id-factory.c */
 extern NADataDef data_def_item [];			/* defined in na-object-item-factory.c */
+extern NADataDef data_def_conditions [];	/* defined in na-icontext-factory.c */
 
 static NADataDef data_def_menu [] = {
 	{ NULL },
@@ -47,6 +48,6 @@ NADataGroup menu_data_groups [] = {
 	{ NA_FACTORY_OBJECT_ID_GROUP,         data_def_id },
 	{ NA_FACTORY_OBJECT_ITEM_GROUP,       data_def_item },
 	{ NA_FACTORY_OBJECT_MENU_GROUP,       data_def_menu },
-	{ NA_FACTORY_OBJECT_CONDITIONS_GROUP, NULL },
+	{ NA_FACTORY_OBJECT_CONDITIONS_GROUP, data_def_conditions },
 	{ NULL }
 };
diff --git a/src/core/na-object-profile-factory.c b/src/core/na-object-profile-factory.c
index 76a1ceb..d7e0075 100644
--- a/src/core/na-object-profile-factory.c
+++ b/src/core/na-object-profile-factory.c
@@ -39,7 +39,7 @@
 #include <api/na-data-types.h>
 
 extern NADataDef data_def_id [];			/* defined in na-object-id-factory.c */
-extern NADataDef data_def_conditions [];	/* defined in na-iconditions-factory.c */
+extern NADataDef data_def_conditions [];	/* defined in na-icontext-factory.c */
 
 static NADataDef data_def_profile [] = {
 
@@ -65,6 +65,10 @@ static NADataDef data_def_profile [] = {
 				NULL,
 				NULL },
 
+	/* Path and Parameters are two separate data both in GConf, in GConf-derived
+	 * export files and in NACT. Only in desktop files, they are merged as only
+	 * one 'Exec' data.
+	 */
 	{ NAFO_DATA_PATH,
 				TRUE,
 				TRUE,
@@ -87,27 +91,51 @@ static NADataDef data_def_profile [] = {
 				NULL,
 				N_( "<PATH>" ) },
 
+	/* Desktop files not only introduced new properties conditions to item and profiles,
+	 * but also slightly changed the meaning of some parameters. This is synchronized
+	 * with the change of version data (from "2.0" string to '1' integer)
+	 */
 	{ NAFO_DATA_PARAMETERS,
 				TRUE,
 				TRUE,
 				TRUE,
 				N_( "Parameters of the command" ),
-										/* too long string for iso c: 665 (max=509) */
+										/* too long string for iso c: (max=509) */
 				N_( "The parameters of the command to be executed when the user selects the menu " \
 					"item in the file manager context menu or in the toolbar.\n" \
 					"The parameters may contain some special tokens which are replaced by the " \
 					"informations provided by the file manager before starting the command:\n" \
-					"%d: base folder of the selected file(s)\n" \
-					"%f: the name of the selected file or the first one if several are selected\n" \
-					"%h: hostname of the URI\n" \
-					"%m: space-separated list of the basenames of the selected file(s)/folder(s)\n" \
-					"%M: space-separated list of the selected file(s)/folder(s), with their full paths\n" \
-					"%p: port number of the first URI\n" \
-					"%R: space-separated list of selected URIs\n" \
-					"%s: scheme of the URI\n" \
-					"%u: URI\n" \
-					"%U: username of the URI\n" \
-					"%%: a percent sign." ),
+					"- up to version \"2.0\":\n" \
+					"  %d: base folder of the selected file(s)\n" \
+					"  %f: the name of the selected file or the first one if several are selected\n" \
+					"  %h: hostname of the URI\n" \
+					"  %m: space-separated list of the basenames of the selected file(s)/folder(s)\n" \
+					"  %M: space-separated list of the selected file(s)/folder(s), with their full paths\n" \
+					"  %p: port number of the first URI\n" \
+					"  %R: space-separated list of selected URIs\n" \
+					"  %s: scheme of the URI\n" \
+					"  %u: URI\n" \
+					"  %U: username of the URI\n" \
+					"  %%: a percent sign." \
+					"- starting from version '1':\n" \
+					"  %b: (first) basename of the selected file(s)/folder(s)\n" \
+					"  %B: space-separated list of the basenames of the selected file(s)/folder(s)\n" \
+					"  %c: count the selected file(s)/folder(s)\n" \
+					"  %d: (first) base directory of the selected file(s)/folder(s)\n" \
+					"  %D: space-separated list of base directories of the selected file(s)/folder(s)\n" \
+					"  %f: (first) filename of the selected file(s)/folder(s)\n" \
+					"  %F: space-separated list of the filenames of the selected file(s)/folder(s)\n" \
+					"  %h: hostname of the (first) URI\n" \
+					"  %n: username of the (first) URI\n" \
+					"  %p: port number of the (first) URI\n" \
+					"  %s: scheme of the (first) URI\n" \
+					"  %u: (first) URI\n" \
+					"  %U: space-separated list of selected URIs\n" \
+					"  %w: (first) basename without the extension\n" \
+					"  %W: space-separated list of basenames without the extension\n" \
+					"  %x: (first) extension\n" \
+					"  %X: space-separated list of the extensions\n" \
+					"  %%: a percent sign." ),
 				NAFD_TYPE_STRING,
 				"",
 				TRUE,
@@ -123,6 +151,107 @@ static NADataDef data_def_profile [] = {
 				NULL,
 				N_( "<STRING>" ) },
 
+	{ NAFO_DATA_EXECUTION_MODE,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Execution mode" ),
+				N_( "Execution mode of the program.\n" \
+					"This may be choosen between following values:\n" \
+					"- Normal: starts as a standard graphical user interface\n" \
+					"- Terminal: starts the preferred terminal of the graphical environment, " \
+						"and runs the command in it\n" \
+					"- Embedded: makes use of a special feature of the file manager which allows " \
+						"a terminal to be ran inside of it; an acceptable fallback is Terminal\n" \
+					"- DisplayOutput: the ran terminal may be closed at end of the command, but " \
+						"standard streams (stdout, stderr) should be collected and displayed; " \
+						"an acceptable fallback is Terminal.\n" \
+					"Defaults to \"Normal\"." ),
+				NAFD_TYPE_UINT,
+				"1",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"execution-mode",
+				"ExecutionMode",
+				0,
+				NULL,
+				0,
+				0,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_STARTUP_NOTIFY,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Startup notify" ),
+				N_( "Only relevant when ExecutionMode=Normal.\n" \
+					"Defaults to FALSE." ),
+				NAFD_TYPE_BOOLEAN,
+				"false",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"startup-notify",
+				"StartupNotify",
+				0,
+				NULL,
+				0,
+				0,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_STARTUP_WMCLASS,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Startup WM Class" ),
+				N_( "Only relevant when ExecutionMode=Normal.\n" \
+					"Defaults to empty." ),
+				NAFD_TYPE_STRING,
+				"",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"startup-wmclass",
+				"StartupWMClass",
+				0,
+				NULL,
+				0,
+				0,
+				NULL,
+				NULL },
+
+	{ NAFO_DATA_EXECUTE_AS,
+				TRUE,
+				TRUE,
+				TRUE,
+				N_( "Execute as user" ),
+				N_( "The user the command must be ran as. " \
+					"The user may be identified by its numeric UID or by its login.\n" \
+					"The implementation should ignore a profile defining a non-existing UID " \
+					"or login as a value for the ExecuteAs key.\n" \
+					"The implementation might require the presence of a well-configured subsystem (e.g. sudo).\n" \
+					"Defaults to empty: the command will be executed as the current user." ),
+				NAFD_TYPE_STRING,
+				"",
+				TRUE,
+				TRUE,
+				FALSE,
+				FALSE,
+				"execute-as",
+				"ExecuteAs",
+				0,
+				NULL,
+				0,
+				0,
+				NULL,
+				NULL },
+
 	{ NULL },
 };
 



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