[nautilus-actions] Define which parameters are relevant for singular form



commit 287069c732f0f27f46874227365b8e10527524bc
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Aug 4 23:26:47 2010 +0200

    Define which parameters are relevant for singular form

 ChangeLog            |    5 +++++
 src/core/na-tokens.c |   42 ++++++++++++++++++++++++++----------------
 2 files changed, 31 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b7a06ed..46c3d9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2010-08-04 Pierre Wieser <pwieser trychlos org>
+
+	* src/core/na-tokens.c (is_singular_exec):
+	Implement DES-EMA draft v 0.13 which defines irrelevant parameters.
+
 2010-08-02 Pierre Wieser <pwieser trychlos org>
 
 	* src/nact/nact-gtk-utils.c (nact_gtk_utils_get_pixbuf):
diff --git a/src/core/na-tokens.c b/src/core/na-tokens.c
index 4789596..1add1c8 100644
--- a/src/core/na-tokens.c
+++ b/src/core/na-tokens.c
@@ -389,46 +389,56 @@ execute_action_command( const gchar *command, const NAObjectProfile *profile )
  * @tokens: the current #NATokens object.
  * @exec: the to be executed command-line before having been parsed
  *
- * Returns: %TRUE if the first parameter found in @exec command-line is
- * of singular form, %FALSE else.
- *
- * %% and %c are considered here as singular parameters. This function
- * so defaults to %TRUE as long as no plural form parameter is found.
+ * Returns: %TRUE if the first relevant parameter found in @exec
+ * command-line is of singular form, %FALSE else.
  */
 static gboolean
 is_singular_exec( const NATokens *tokens, const gchar *exec )
 {
 	gboolean singular;
-	gchar *found;
+	gboolean found;
+	gchar *iter;
+
+	singular = FALSE;
+	found = FALSE;
+	iter = ( gchar * ) exec;
 
-	singular = TRUE;
-	found = g_strstr_len( exec, -1, "%" );
+	while(( iter = g_strstr_len( iter, -1, "%" )) != NULL && !found ){
 
-	if( found ){
-		switch( found[1] ){
+		switch( iter[1] ){
 			case 'b':
-			case 'c':
 			case 'd':
 			case 'f':
-			case 'h':
-			case 'n':
-			case 'p':
-			case 's':
+			case 'm':
 			case 'u':
 			case 'w':
 			case 'x':
-			case '%':
+				found = TRUE;
+				singular = TRUE;
 				break;
 
 			case 'B':
 			case 'D':
 			case 'F':
+			case 'M':
 			case 'U':
 			case 'W':
 			case 'X':
+				found = TRUE;
 				singular = FALSE;
 				break;
+
+			/* all other parameters are irrelevant according to DES-EMA
+			 * c: selection count
+			 * h: hostname
+			 * n: username
+			 * p: port
+			 * s: scheme
+			 * %: %
+			 */
 		}
+
+		iter += 2;			/* skip the % sign and the character after */
 	}
 
 	return( singular );



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