[kupfer: 6/67] Update implementation of Execute action



commit c46ff9408b2558a2acd1773828b2bbb19617179b
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Tue Mar 15 22:52:26 2011 +0100

    Update implementation of Execute action

 kupfer/obj/fileactions.py |   10 ++++++++--
 kupfer/utils.py           |    5 ++++-
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/obj/fileactions.py b/kupfer/obj/fileactions.py
index 44cf920..5bcde3f 100644
--- a/kupfer/obj/fileactions.py
+++ b/kupfer/obj/fileactions.py
@@ -102,8 +102,14 @@ class Execute (Action):
 		return (self.in_terminal, self.quoted)
 	
 	def activate(self, leaf):
-		cmd = "'%s'" % leaf.object if self.quoted else leaf.object
-		utils.launch_commandline(cmd, in_terminal=self.in_terminal)
+		if self.quoted:
+			argv = [leaf.object]
+		else:
+			argv = utils.argv_for_commandline(leaf.object)
+		if self.in_terminal:
+			utils.spawn_in_terminal(argv)
+		else:
+			utils.spawn_async(argv)
 
 	def get_description(self):
 		if self.in_terminal:
diff --git a/kupfer/utils.py b/kupfer/utils.py
index c1fd8ae..1161f57 100644
--- a/kupfer/utils.py
+++ b/kupfer/utils.py
@@ -11,6 +11,7 @@ import glib
 from kupfer import pretty
 from kupfer import kupferstring
 from kupfer import desktop_launch
+from kupfer import desktop_parse
 
 def get_dirlist(folder, depth=0, include=None, exclude=None):
 	"""
@@ -216,9 +217,11 @@ def app_info_for_commandline(cli, name=None, in_terminal=False):
 	item = gio.AppInfo(cli, name, flags)
 	return item
 
+def argv_for_commandline(cli):
+	return desktop_parse.parse_argv(cli)
+
 def launch_commandline(cli, name=None, in_terminal=False):
 	from kupfer import launch
-	from kupfer import desktop_parse
 	argv = desktop_parse.parse_argv(cli)
 	pretty.print_debug(__name__, "Launch commandline (in_terminal=", in_terminal, "):", argv, sep="")
 	if in_terminal:



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