[kupfer: 35/51] core: Use ui_ctx when delivering command results



commit 582a34c5bbbc8e96696f79193177c1644b9f43dd
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Mon Mar 28 16:51:47 2011 +0200

    core: Use ui_ctx when delivering command results

 kupfer/core/commandexec.py |   23 +++++++++++++----------
 kupfer/core/data.py        |   12 ++++++------
 kupfer/ui/browser.py       |    4 ++--
 3 files changed, 21 insertions(+), 18 deletions(-)
---
diff --git a/kupfer/core/commandexec.py b/kupfer/core/commandexec.py
index d492f65..f181dad 100644
--- a/kupfer/core/commandexec.py
+++ b/kupfer/core/commandexec.py
@@ -270,7 +270,8 @@ class ActionExecutionContext (gobject.GObject, pretty.OutputMixin):
 		# If only registration was requsted, remove the command id info
 		if not show:
 			command_id = -1
-		self.emit("late-command-result", command_id, RESULT_OBJECT, result)
+		self.emit("late-command-result", command_id, RESULT_OBJECT, result,
+		                                 token.environment)
 		self._append_result(RESULT_OBJECT, result)
 
 	def _append_result(self, res_type, result):
@@ -308,7 +309,7 @@ class ActionExecutionContext (gobject.GObject, pretty.OutputMixin):
 		# the result of the nested execution context
 		if self._delegate:
 			res, ret = ret
-			return self._return_result(res, ret)
+			return self._return_result(res, ret, ui_ctx)
 
 		res = parse_action_result(action, ret)
 		if res == RESULT_ASYNC:
@@ -322,12 +323,12 @@ class ActionExecutionContext (gobject.GObject, pretty.OutputMixin):
 		if delegate and self._is_nested():
 			self._delegate = True
 
-		return self._return_result(res, ret)
+		return self._return_result(res, ret, ui_ctx)
 
-	def _return_result(self, res, ret):
+	def _return_result(self, res, ret, ui_ctx):
 		if not self._is_nested():
 			self._append_result(res, ret)
-			self.emit("command-result", res, ret)
+			self.emit("command-result", res, ret, ui_ctx)
 		return res, ret
 
 
@@ -386,13 +387,15 @@ class ActionExecutionContext (gobject.GObject, pretty.OutputMixin):
 			return RESULT_NONE, None
 
 
-# Action result type, action result
+# Signature: Action result type, action result, gui_context
 gobject.signal_new("command-result", ActionExecutionContext,
 		gobject.SIGNAL_RUN_LAST,
-		gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, gobject.TYPE_PYOBJECT))
+		gobject.TYPE_BOOLEAN,
+		(gobject.TYPE_INT, gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT))
 
-# Command ID, Action result type, action result
+# Signature: Command ID, Action result type, action result, gui_context
 gobject.signal_new("late-command-result", ActionExecutionContext,
 		gobject.SIGNAL_RUN_LAST,
-		gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, gobject.gobject.TYPE_INT,
-			gobject.TYPE_PYOBJECT))
+		gobject.TYPE_BOOLEAN,
+		(gobject.TYPE_INT, gobject.gobject.TYPE_INT,
+			gobject.TYPE_PYOBJECT, gobject.TYPE_PYOBJECT))
diff --git a/kupfer/core/data.py b/kupfer/core/data.py
index 0b9c124..2841b7a 100644
--- a/kupfer/core/data.py
+++ b/kupfer/core/data.py
@@ -834,7 +834,7 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 		self._set_object_stack(pane, objects[:-1])
 		self._insert_object(pane, objects[-1])
 
-	def _command_execution_result(self, ctx, result_type, ret):
+	def _command_execution_result(self, ctx, result_type, ret, uictx):
 		if result_type == commandexec.RESULT_SOURCE:
 			self.object_stack_clear_all()
 			self.source_pane.push_source(ret)
@@ -843,12 +843,12 @@ class DataController (gobject.GObject, pretty.OutputMixin):
 			self._insert_object(SourcePane, ret)
 		else:
 			return
-		self.emit("command-result", result_type)
+		self.emit("command-result", result_type, uictx)
 
-	def _late_command_execution_result(self, ctx, id_, result_type, ret):
+	def _late_command_execution_result(self, ctx, id_, result_type, ret, uictx):
 		"Receive late command result"
 		if self._latest_interaction < id_:
-			self._command_execution_result(ctx, result_type, ret)
+			self._command_execution_result(ctx, result_type, ret, uictx)
 
 	def find_object(self, url):
 		"""Find object with URI @url and select it in the first pane"""
@@ -998,9 +998,9 @@ gobject.signal_new("mode-changed", DataController, gobject.SIGNAL_RUN_LAST,
 gobject.signal_new("object-stack-changed", DataController, gobject.SIGNAL_RUN_LAST,
 		gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, ))
 # when an command returned a result
-# arguments: result type
+# arguments: result type, gui_context
 gobject.signal_new("command-result", DataController, gobject.SIGNAL_RUN_LAST,
-		gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, ))
+		gobject.TYPE_BOOLEAN, (gobject.TYPE_INT, gobject.TYPE_PYOBJECT))
 
 # when an action was launched
 # arguments: none
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 2ea0401..52dcad3 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -1940,8 +1940,8 @@ class WindowController (pretty.OutputMixin):
 		self.interface.did_launch()
 		self._window_hide_timer.set_ms(100, self.put_away)
 
-	def result_callback(self, sender, result_type):
-		self.activate()
+	def result_callback(self, sender, result_type, ui_ctx):
+		self.on_present(sender, ui_ctx.get_display(), ui_ctx.get_timestamp())
 
 	def _lost_focus(self, window, event):
 		# Close at unfocus.



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