[kupfer: 20/53] kupferui: Update for wants_context



commit ce859ba63ee67146970954a3731e65c30887cd32
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date:   Thu Mar 24 17:22:35 2011 +0100

    kupferui: Update for wants_context

 kupfer/kupferui.py              |   18 +++++++++++-------
 kupfer/obj/special.py           |    7 +++++--
 kupfer/plugin/core/contents.py  |   18 ++++++++++++------
 kupfer/plugin/kupfer_plugins.py |    8 ++++++--
 kupfer/ui/preferences.py        |    8 ++++----
 5 files changed, 38 insertions(+), 21 deletions(-)
---
diff --git a/kupfer/kupferui.py b/kupfer/kupferui.py
index 84eb392..0045c21 100644
--- a/kupfer/kupferui.py
+++ b/kupfer/kupferui.py
@@ -5,7 +5,11 @@ import gtk
 
 from kupfer import utils, version
 
-def show_help():
+def _get_time(ctx):
+	return ctx.environment.get_timestamp() if ctx else \
+			gtk.get_current_event_time()
+
+def show_help(ctx=None):
 	"""
 	Show Kupfer help pages, if possible
 	"""
@@ -14,7 +18,7 @@ def show_help():
 
 _about_dialog = None
 
-def show_about_dialog(*ignored, **kwds):
+def show_about_dialog(ctx=None):
 	"""
 	create an about dialog and show it
 	"""
@@ -44,18 +48,18 @@ def show_about_dialog(*ignored, **kwds):
 		# do not delete window on close
 		ab.connect("delete-event", lambda *ign: True)
 		_about_dialog = ab
-	ab.present()
+	ab.present_with_time(_get_time(ctx))
 
 def _response_callback(dialog, response_id):
 	dialog.hide()
 
 
-def show_preferences():
+def show_preferences(ctx=None):
 	from kupfer.ui import preferences
 	win = preferences.GetPreferencesWindowController()
-	win.show()
+	win.show(_get_time(ctx))
 
-def show_plugin_info(plugin_id):
+def show_plugin_info(plugin_id, ctx=None):
 	from kupfer.ui import preferences
 	prefs = preferences.GetPreferencesWindowController()
-	prefs.show_focus_plugin(plugin_id)
+	prefs.show_focus_plugin(plugin_id, _get_time(ctx))
diff --git a/kupfer/obj/special.py b/kupfer/obj/special.py
index 94ea7d1..3216dee 100644
--- a/kupfer/obj/special.py
+++ b/kupfer/obj/special.py
@@ -15,8 +15,11 @@ class PleaseConfigureLeaf(RunnableLeaf):
 		RunnableLeaf.__init__(self, plugin_id, self.message)
 		self.plugin_name = plugin_name
 
-	def run(self):
-		kupferui.show_plugin_info(self.object)
+	def wants_context(self):
+		return True
+
+	def run(self, ctx):
+		kupferui.show_plugin_info(self.object, ctx)
 
 	def get_icon_name(self):
 		return "preferences-desktop"
diff --git a/kupfer/plugin/core/contents.py b/kupfer/plugin/core/contents.py
index 5460d68..e185f60 100644
--- a/kupfer/plugin/core/contents.py
+++ b/kupfer/plugin/core/contents.py
@@ -51,8 +51,10 @@ class About (RunnableLeaf):
 	def __init__(self, name=None):
 		if not name: name = _("About Kupfer")
 		super(About, self).__init__(name=name)
-	def run(self):
-		kupferui.show_about_dialog()
+	def wants_context(self):
+		return True
+	def run(self, ctx):
+		kupferui.show_about_dialog(ctx)
 	def get_description(self):
 		return _("Show information about Kupfer authors and license")
 	def get_icon_name(self):
@@ -62,8 +64,10 @@ class Help (RunnableLeaf):
 	def __init__(self, name=None):
 		if not name: name = _("Kupfer Help")
 		super(Help, self).__init__(name=name)
-	def run(self):
-		kupferui.show_help()
+	def wants_context(self):
+		return True
+	def run(self, ctx):
+		kupferui.show_help(ctx)
 	def get_description(self):
 		return _("Get help with Kupfer")
 	def get_icon_name(self):
@@ -73,8 +77,10 @@ class Preferences (RunnableLeaf):
 	def __init__(self, name=None):
 		if not name: name = _("Kupfer Preferences")
 		super(Preferences, self).__init__(name=name)
-	def run(self):
-		kupferui.show_preferences()
+	def wants_context(self):
+		return True
+	def run(self, ctx):
+		kupferui.show_preferences(ctx)
 	def get_description(self):
 		return _("Show preferences window for Kupfer")
 	def get_icon_name(self):
diff --git a/kupfer/plugin/kupfer_plugins.py b/kupfer/plugin/kupfer_plugins.py
index 9e6dcfe..15e103b 100644
--- a/kupfer/plugin/kupfer_plugins.py
+++ b/kupfer/plugin/kupfer_plugins.py
@@ -18,9 +18,13 @@ from kupfer.core import plugins, settings
 class ShowInfo (Action):
 	def __init__(self):
 		Action.__init__(self, _("Show Information"))
-	def activate(self, leaf):
+
+	def wants_context(self):
+		return True
+
+	def activate(self, leaf, ctx):
 		plugin_id = leaf.object["name"]
-		kupferui.show_plugin_info(plugin_id)
+		kupferui.show_plugin_info(plugin_id, ctx)
 
 	def get_description(self):
 		pass
diff --git a/kupfer/ui/preferences.py b/kupfer/ui/preferences.py
index 31d3f6c..865031e 100644
--- a/kupfer/ui/preferences.py
+++ b/kupfer/ui/preferences.py
@@ -816,10 +816,10 @@ class PreferencesWindowController (pretty.OutputMixin):
 			self._update_alternative_combobox(category_key,
 					self.icons_combobox)
 
-	def show(self):
-		self.window.present_with_time(uievents.current_event_time())
+	def show(self, timestamp):
+		self.window.present_with_time(timestamp)
 
-	def show_focus_plugin(self, plugin_id):
+	def show_focus_plugin(self, plugin_id, timestamp):
 		"""
 		Open and show information about plugin @plugin_id
 		"""
@@ -832,7 +832,7 @@ class PreferencesWindowController (pretty.OutputMixin):
 		self.table.set_cursor(table_path)
 		self.table.scroll_to_cell(table_path)
 		self.preferences_notebook.set_current_page(PLUGIN_LIST_PAGE)
-		self.window.present()
+		self.window.present_with_time(timestamp)
 
 	def hide(self):
 		self.window.hide()



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