[kupfer: 1/51] uievents: Support ctx.environment.get_screen()
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 1/51] uievents: Support ctx.environment.get_screen()
- Date: Mon, 28 Mar 2011 15:01:10 +0000 (UTC)
commit 0d84e8dd1581bb1b606d15ed3019706576f294c5
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Mar 28 16:51:40 2011 +0200
uievents: Support ctx.environment.get_screen()
kupfer/plugin/triggers.py | 2 +-
kupfer/ui/browser.py | 3 ++-
kupfer/ui/uievents.py | 12 +++++++++++-
3 files changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/kupfer/plugin/triggers.py b/kupfer/plugin/triggers.py
index b903adb..e372737 100644
--- a/kupfer/plugin/triggers.py
+++ b/kupfer/plugin/triggers.py
@@ -75,7 +75,7 @@ class Triggers (Source):
def keybinding_callback(self, keyobj, target, event_time):
if not self.has_trigger(target):
return
- ui_ctx = uievents.GUIEnvironmentContext(event_time)
+ ui_ctx = uievents.gui_context_from_timestamp(event_time)
ctx = commandexec.DefaultActionExecutionContext()
exec_token = ctx.make_execution_token(ui_ctx)
self.perform_trigger(exec_token, target)
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 191d21b..b350157 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -1492,7 +1492,8 @@ class Interface (gobject.GObject):
def _make_gui_ctx(self):
timestamp = uievents.current_event_time()
- return uievents.GUIEnvironmentContext(timestamp)
+ return uievents.gui_context_from_toplevel(timestamp,
+ self._widget.get_toplevel())
def _activate(self, widget, current):
self.data_controller.activate(ui_ctx=self._make_gui_ctx())
diff --git a/kupfer/ui/uievents.py b/kupfer/ui/uievents.py
index 9880d56..665cfe7 100644
--- a/kupfer/ui/uievents.py
+++ b/kupfer/ui/uievents.py
@@ -6,13 +6,20 @@ import gtk
from kupfer import pretty
from kupfer.ui import keybindings
+def gui_context_from_toplevel(timestamp, toplevel):
+ return GUIEnvironmentContext(timestamp, toplevel.get_screen())
+
+def gui_context_from_timestamp(timestamp):
+ return GUIEnvironmentContext(timestamp, None)
+
class GUIEnvironmentContext (object):
"""
Context object for action execution
in the current GUI context
"""
- def __init__(self, timestamp):
+ def __init__(self, timestamp, screen=None):
self._timestamp = timestamp
+ self._screen = screen or gtk.gdk.screen_get_default()
def get_timestamp(self):
return self._timestamp
def get_startup_notification_id(self):
@@ -27,6 +34,8 @@ class GUIEnvironmentContext (object):
"""
# FIXME: use Kupfer window's display
return os.getenv("DISPLAY", ":0")
+ def get_screen(self):
+ return self._screen
def present_window(self, window):
"""
Show and present @window on the current
@@ -34,6 +43,7 @@ class GUIEnvironmentContext (object):
@window: A gtk.Window
"""
+ window.set_screen(self.get_screen())
window.present_with_time(self.get_timestamp())
class _internal_data (object):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]