[nautilus-actions] Unconditionally accepts any target in nautilus-actions-run



commit 660c5807239b909b36e5b5413648f5c32a09252b
Author: Pierre Wieser <pwieser trychlos org>
Date:   Wed Dec 1 22:56:06 2010 +0100

    Unconditionally accepts any target in nautilus-actions-run
    
    Fix #634056 - Create 'hidden' actions.

 ChangeLog                        |    8 ++++++++
 src/api/na-object-item.h         |    7 ++++++-
 src/core/na-icontext.c           |    4 ++++
 src/utils/nautilus-actions-run.c |   10 +++-------
 4 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 2311ac1..7c329fb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2010-12-01 Pierre Wieser <pwieser trychlos org>
 
+	* src/api/na-object-item.h: Define new ITEM_TARGET_ANY target.
+
+	* src/core/na-icontext.c (is_candidate_for_target):
+	Unconditionnally accepts any target.
+
+	* src/utils/nautilus-actions-run.c (main, get_profile_for_targets):
+	Ask there is no selection on the target. Fix #634056.
+
 	* configure.ac: call new NA_SET_DEFAULT_IO_PROVIDER macro.
 
 	* m4/na-default-io-provider.m4: New file.
diff --git a/src/api/na-object-item.h b/src/api/na-object-item.h
index f18b4d5..d4e77a3 100644
--- a/src/api/na-object-item.h
+++ b/src/api/na-object-item.h
@@ -68,11 +68,16 @@ typedef struct {
 	NAObjectItemClass;
 
 /* targets
+ *
+ * ITEM_TARGET_ANY is just a wilcard target defined in order to be able
+ * to activate an action from a keyboard shortcut, while keeping this
+ * same action hidden from the UI.
  */
 enum {
 	ITEM_TARGET_SELECTION = 1,
 	ITEM_TARGET_LOCATION,
-	ITEM_TARGET_TOOLBAR
+	ITEM_TARGET_TOOLBAR,
+	ITEM_TARGET_ANY
 };
 
 GType       na_object_item_get_type( void );
diff --git a/src/core/na-icontext.c b/src/core/na-icontext.c
index cad82c9..20490c4 100644
--- a/src/core/na-icontext.c
+++ b/src/core/na-icontext.c
@@ -417,6 +417,10 @@ is_candidate_for_target( const NAIContext *object, guint target, GList *files )
 				ok = na_object_is_target_selection( object );
 				break;
 
+			case ITEM_TARGET_ANY:
+				ok = TRUE;
+				break;
+
 			default:
 				g_warning( "%s: unknonw target=%d", thisfn, target );
 				ok = FALSE;
diff --git a/src/utils/nautilus-actions-run.c b/src/utils/nautilus-actions-run.c
index 6f6e08e..87dccf5 100644
--- a/src/utils/nautilus-actions-run.c
+++ b/src/utils/nautilus-actions-run.c
@@ -152,7 +152,7 @@ main( int argc, char** argv )
 		exit( status );
 	}
 
-	if( !na_icontext_is_candidate( NA_ICONTEXT( action ), ITEM_TARGET_SELECTION, targets )){
+	if( !na_icontext_is_candidate( NA_ICONTEXT( action ), ITEM_TARGET_ANY, targets )){
 		g_printerr( _( "Action %s is not a valid candidate. Exiting.\n" ), id );
 		exit( status );
 	}
@@ -228,17 +228,13 @@ get_action( const gchar *id )
 
 	if( !action ){
 		g_printerr( _( "Error: action '%s' doesn't exist.\n" ), id );
-	}
 
-	if( action ){
+	} else {
 		if( !na_object_is_enabled( action )){
 			g_printerr( _( "Error: action '%s' is disabled.\n" ), id );
 			g_object_unref( action );
 			action = NULL;
 		}
-	}
-
-	if( action ){
 		if( !na_object_is_valid( action )){
 			g_printerr( _( "Error: action '%s' is not valid.\n" ), id );
 			g_object_unref( action );
@@ -380,7 +376,7 @@ get_profile_for_targets( NAObjectAction *action, GList *targets )
 	profiles = na_object_get_items( action );
 
 	for( ip = profiles ; ip && !candidate ; ip = ip->next ){
-		if( na_icontext_is_candidate( NA_ICONTEXT( ip->data ), ITEM_TARGET_SELECTION, targets )){
+		if( na_icontext_is_candidate( NA_ICONTEXT( ip->data ), ITEM_TARGET_ANY, targets )){
 			candidate = NA_OBJECT_PROFILE( ip->data );
 		}
 	}



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