[kupfer: 30/53] uievents: Implement ctx.environment.present_window
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 30/53] uievents: Implement ctx.environment.present_window
- Date: Thu, 24 Mar 2011 16:33:04 +0000 (UTC)
commit 9beb7f0b49088b9e922f18f344edd9c7b321252b
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Mar 24 17:22:37 2011 +0100
uievents: Implement ctx.environment.present_window
Documentation/PluginAPI.rst | 4 ++++
kupfer/kupferui.py | 5 ++++-
kupfer/plugin/quickview.py | 9 ++++++---
kupfer/ui/uievents.py | 7 +++++++
4 files changed, 21 insertions(+), 4 deletions(-)
---
diff --git a/Documentation/PluginAPI.rst b/Documentation/PluginAPI.rst
index 4b58f46..2ffc5a0 100644
--- a/Documentation/PluginAPI.rst
+++ b/Documentation/PluginAPI.rst
@@ -425,6 +425,10 @@ The object passed as ``ctx`` has the following interface:
``get_display(self)``
Return the display name (i.e ``:0.0``)
+ ``present_window(self, window)``
+ Present ``window`` (a ``gtk.Window``) on the current
+ workspace and monitor using the current event time.
+
Auxiliary Action Methods
........................
diff --git a/kupfer/kupferui.py b/kupfer/kupferui.py
index 0045c21..47df6c6 100644
--- a/kupfer/kupferui.py
+++ b/kupfer/kupferui.py
@@ -48,7 +48,10 @@ def show_about_dialog(ctx=None):
# do not delete window on close
ab.connect("delete-event", lambda *ign: True)
_about_dialog = ab
- ab.present_with_time(_get_time(ctx))
+ if ctx:
+ ctx.environment.present_window(ab)
+ else:
+ ab.present()
def _response_callback(dialog, response_id):
dialog.hide()
diff --git a/kupfer/plugin/quickview.py b/kupfer/plugin/quickview.py
index 3e72f43..8f62605 100644
--- a/kupfer/plugin/quickview.py
+++ b/kupfer/plugin/quickview.py
@@ -13,6 +13,7 @@ import gtk
from kupfer.objects import Action, FileLeaf
from kupfer.objects import OperationError
from kupfer import utils
+from kupfer.ui import uievents
def is_content_type(fileleaf, ctype):
@@ -50,7 +51,6 @@ def load_image_max_size(filename, w, h):
return pl.get_pixbuf()
class View (Action):
-
def __init__(self):
Action.__init__(self, _("View Image"))
self.open_windows = {}
@@ -61,7 +61,10 @@ class View (Action):
def valid_for_item(self, obj):
return is_content_type(obj, "image/*")
- def activate(self, obj):
+ def wants_context(self):
+ return True
+
+ def activate(self, obj, ctx):
## If the same file @obj is already open,
## then close its window.
if obj.object in self.open_windows:
@@ -77,7 +80,7 @@ class View (Action):
window.set_title(utils.get_display_path_for_bytestring(obj.object))
window.set_position(gtk.WIN_POS_CENTER)
window.add(image_widget)
- window.present()
+ ctx.environment.present_window(window)
window.connect("key-press-event", self.window_key_press, obj.object)
window.connect("delete-event", self.window_deleted, obj.object)
self.open_windows[obj.object] = window
diff --git a/kupfer/ui/uievents.py b/kupfer/ui/uievents.py
index a7ceb36..9880d56 100644
--- a/kupfer/ui/uievents.py
+++ b/kupfer/ui/uievents.py
@@ -27,7 +27,14 @@ class GUIEnvironmentContext (object):
"""
# FIXME: use Kupfer window's display
return os.getenv("DISPLAY", ":0")
+ def present_window(self, window):
+ """
+ Show and present @window on the current
+ workspace, screen & display as appropriate.
+ @window: A gtk.Window
+ """
+ window.present_with_time(self.get_timestamp())
class _internal_data (object):
seq = 0
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]