[kupfer: 30/51] Re-make the D-Bus API to use $DISPLAY and $DESKTOP_STARTUP_ID consistently
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 30/51] Re-make the D-Bus API to use $DISPLAY and $DESKTOP_STARTUP_ID consistently
- Date: Mon, 28 Mar 2011 15:03:35 +0000 (UTC)
commit 1ec8a4a4949c23daf9ec105fd96a748c1eda9fa2
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Mar 28 16:51:46 2011 +0200
Re-make the D-Bus API to use $DISPLAY and $DESKTOP_STARTUP_ID consistently
New API includes::
PresentOnDisplay(display, notify_id)
ExecuteFileOnDisplay(filepath, display, notify_id)
PutFilesOnDisplay(files, display, notify_id)
PutTextOnDisplay(text, display, notify_id)
RelayKeysFromDisplay(keystring, display, notify_id)
bin/kupfer-exec.in | 4 +-
bin/kupfer.in | 6 +++-
kupfer/plugin/triggers.py | 2 +-
kupfer/ui/browser.py | 52 +++++++++++++++++++----------------
kupfer/ui/keybindings.py | 10 +++---
kupfer/ui/listen.py | 65 +++++++++++++++++++++++++++++---------------
kupfer/ui/uievents.py | 8 +++--
7 files changed, 88 insertions(+), 59 deletions(-)
---
diff --git a/bin/kupfer-exec.in b/bin/kupfer-exec.in
index 0717996..29f59c7 100755
--- a/bin/kupfer-exec.in
+++ b/bin/kupfer-exec.in
@@ -20,8 +20,8 @@ while test $# != 0
do
FILE=$(readlink -f "$1")
dbus-send --print-reply --dest=$SERVICE $OBJ \
- $IFACE.ExecuteFileWithStartup string:"$FILE" \
- string:"$DESKTOP_STARTUP_ID" \
+ $IFACE.ExecuteFileOnDisplay string:"$FILE" \
+ string:"$DISPLAY" string:"$DESKTOP_STARTUP_ID" \
> /dev/null 2>&1
KUPFER_RUNNING=$?
diff --git a/bin/kupfer.in b/bin/kupfer.in
index ba76499..e737b25 100755
--- a/bin/kupfer.in
+++ b/bin/kupfer.in
@@ -51,7 +51,8 @@ KUPFER_RUNNING=$?
if test \( -n "$TEXT_INPUT" -a $KUPFER_HAS_OPTIONS != 0 \)
then
dbus-send --type=method_call --dest=$SERVICE $OBJ \
- $IFACE.PutText string:"$TEXT_INPUT"
+ $IFACE.PutTextOnDisplay string:"$TEXT_INPUT" \
+ string:"$DISPLAY" string:"$DESKTOP_STARTUP_ID"
fi
_realpaths () {
@@ -75,7 +76,8 @@ then
# array item separator. This is then unescaped by kupfer
ARRAY=$(_realpaths "$@" | sed -e 's/,/%%kupfercomma%%/g' | tr \\0 ,)
dbus-send --type=method_call --dest=$SERVICE $OBJ \
- $IFACE.PutFiles array:string:"$ARRAY"
+ $IFACE.PutFilesOnDisplay array:string:"$ARRAY" \
+ string:"$DISPLAY" string:"$DESKTOP_STARTUP_ID"
fi
diff --git a/kupfer/plugin/triggers.py b/kupfer/plugin/triggers.py
index 9b06f8a..54e1135 100644
--- a/kupfer/plugin/triggers.py
+++ b/kupfer/plugin/triggers.py
@@ -72,7 +72,7 @@ class Triggers (Source):
for target, (keystr, name, id_) in self.trigger_table.iteritems():
keybindings.bind_key(None, target)
- def keybinding_callback(self, keyobj, target, event_time, display):
+ def keybinding_callback(self, keyobj, target, display, event_time):
if not self.has_trigger(target):
return
ui_ctx = uievents.gui_context_from_keyevent(event_time, display)
diff --git a/kupfer/ui/browser.py b/kupfer/ui/browser.py
index 19f1845..4ae7480 100644
--- a/kupfer/ui/browser.py
+++ b/kupfer/ui/browser.py
@@ -2065,13 +2065,12 @@ class WindowController (pretty.OutputMixin):
return (screen.get_monitor_at_point(x,y) !=
screen.get_monitor_at_window(self.window.window))
- def activate(self, sender=None, time=0):
- dispname = self.window.get_screen().get_display().get_name()
- self.present_on_display(sender, dispname)
+ def activate(self, sender=None):
+ dispname = self.window.get_screen().make_display_name()
+ self.on_present(sender, dispname, gtk.get_current_event_time())
- def present_on_display(self, sender, display=None):
+ def on_present(self, sender, display, timestamp):
"""Present on @display, where None means default display"""
- time = uievents.current_event_time()
self._window_hide_timer.invalidate()
if not display:
display = gtk.gdk.display_get_default().get_name()
@@ -2079,10 +2078,11 @@ class WindowController (pretty.OutputMixin):
not self.is_current_display(display)):
self._center_window(display)
self.window.stick()
- self.window.present_with_time(time)
- self.window.window.focus(timestamp=time)
+ self.window.present_with_time(timestamp)
+ self.window.window.focus(timestamp=timestamp)
self.interface.focus()
+
def put_away(self):
self.interface.put_away()
self.window.hide()
@@ -2090,35 +2090,39 @@ class WindowController (pretty.OutputMixin):
def _cancelled(self, widget):
self.put_away()
- def show_hide(self, sender=None, time=0, display=None):
+ def on_show_hide(self, sender, display, timestamp):
"""
Toggle activate/put-away
"""
if self.window.get_property("visible"):
self.put_away()
else:
- self.present_on_display(sender, display)
+ self.on_present(sender, display, timestamp)
+
+ def show_hide(self, sender):
+ "GtkStatusIcon callback"
+ self.on_show_hide(sender, "", gtk.get_current_event_time())
- def _key_binding(self, keyobj, keybinding_number, event_time, display):
+ def _key_binding(self, keyobj, keybinding_number, display, timestamp):
"""Keybinding activation callback"""
if keybinding_number == keybindings.KEYBINDING_DEFAULT:
- self.show_hide(time=event_time, display=display)
+ self.on_show_hide(keyobj, display, timestamp)
elif keybinding_number == keybindings.KEYBINDING_MAGIC:
- self.present_on_display(keyobj, display=display)
+ self.on_present(keyobj, display, timestamp)
self.interface.select_selected_text()
self.interface.select_selected_file()
- def _put_text_received(self, sender, text):
- """We got a search query from dbus"""
- self.activate()
+ def on_put_text(self, sender, text, display, timestamp):
+ """We got a search text from dbus"""
+ self.on_present(sender, display, timestamp)
self.interface.put_text(text)
- def _put_files_received(self, sender, fileuris):
- """We got a search query from dbus"""
- self.activate()
+ def on_put_files(self, sender, fileuris, display, timestamp):
+ self.on_present(sender, display, timestamp)
self.interface.put_files(fileuris)
- def _execute_file_received(self, sender, filepath):
+ def on_execute_file(self, sender, filepath, display, timestamp):
+ # FIXME
self.interface.execute_file(filepath)
def _close_window(self, window, event):
@@ -2216,11 +2220,11 @@ class WindowController (pretty.OutputMixin):
except listen.NoConnectionError:
kserv = None
else:
- kserv.connect("present", self.present_on_display)
- kserv.connect("show-hide", self.show_hide)
- kserv.connect("put-text", self._put_text_received)
- kserv.connect("put-files", self._put_files_received)
- kserv.connect("execute-file", self._execute_file_received)
+ kserv.connect("present", self.on_present)
+ kserv.connect("show-hide", self.on_show_hide)
+ kserv.connect("put-text", self.on_put_text)
+ kserv.connect("put-files", self.on_put_files)
+ kserv.connect("execute-file", self.on_execute_file)
kserv.connect("quit", self.quit)
keyobj = keybindings.GetKeyboundObject()
keyobj.connect("bound-key-changed",
diff --git a/kupfer/ui/keybindings.py b/kupfer/ui/keybindings.py
index e8e6ee4..0c7c84b 100644
--- a/kupfer/ui/keybindings.py
+++ b/kupfer/ui/keybindings.py
@@ -31,18 +31,18 @@ class KeyboundObject (gobject.GObject):
def _keybinding(self, target):
import keybinder
time = keybinder.get_current_event_time()
- self.emit("keybinding", target, time, "")
+ self.emit("keybinding", target, "", time)
def emit_bound_key_changed(self, keystring, is_bound):
self.emit("bound-key-changed", keystring, is_bound)
- def relayed_keys(self, sender, keystring, display):
+ def relayed_keys(self, sender, keystring, display, timestamp):
for target, key in _currently_bound.iteritems():
if keystring == key:
- self.emit("keybinding", target, 0, display)
+ self.emit("keybinding", target, display, timestamp)
-# Arguments: Target, Timestamp, Display
+# Arguments: Target, Display, Timestamp
gobject.signal_new("keybinding", KeyboundObject, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_BOOLEAN,
- (gobject.TYPE_INT, gobject.TYPE_INT64, gobject.TYPE_STRING))
+ (gobject.TYPE_INT, gobject.TYPE_STRING, gobject.TYPE_UINT))
# Arguments: Keystring, Boolean
gobject.signal_new("bound-key-changed", KeyboundObject, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_BOOLEAN,
diff --git a/kupfer/ui/listen.py b/kupfer/ui/listen.py
index acc02d6..0403f1d 100644
--- a/kupfer/ui/listen.py
+++ b/kupfer/ui/listen.py
@@ -51,57 +51,66 @@ class Service (ExportedGObject):
@dbus.service.method(interface_name)
def Present(self):
- self.emit("present", "")
+ self.PresentOnDisplay("", "")
@dbus.service.method(interface_name, in_signature="ay",
byte_arrays=True)
def PresentWithStartup(self, notify_id):
- with uievents.using_startup_notify_id(notify_id):
- self.emit("present", "")
+ self.PresentOnDisplay("", notify_id)
@dbus.service.method(interface_name, in_signature="ayay",
byte_arrays=True)
def PresentOnDisplay(self, display, notify_id):
- with uievents.using_startup_notify_id(notify_id):
- self.emit("present", display)
+ with uievents.using_startup_notify_id(notify_id) as time:
+ self.emit("present", display, time)
@dbus.service.method(interface_name)
def ShowHide(self):
- self.emit("show-hide")
+ self.emit("show-hide", "", 0)
@dbus.service.method(interface_name, in_signature="s")
def PutText(self, text):
- self.emit("put-text", text)
+ self.PutTextOnDisplay(text, "", "")
+
+ @dbus.service.method(interface_name, in_signature="sayay",
+ byte_arrays=True)
+ def PutTextOnDisplay(self, text, display, notify_id):
+ with uievents.using_startup_notify_id(notify_id) as time:
+ self.emit("put-text", text, display, time)
@dbus.service.method(interface_name, in_signature="as")
def PutFiles(self, fileuris):
+ self.PutFilesOnDisplay(fileuris, "", "")
+
+ @dbus.service.method(interface_name, in_signature="asayay",
+ byte_arrays=True)
+ def PutFilesOnDisplay(self, fileuris, display, notify_id):
# files sent with dbus-send from kupfer have a custom comma
# escape that we have to unescape here
fileuris[:] = [f.replace("%%kupfercomma%%", ",") for f in fileuris]
- self.emit("put-files", fileuris)
+ with uievents.using_startup_notify_id(notify_id) as time:
+ self.emit("put-files", fileuris, display, time)
@dbus.service.method(interface_name, in_signature="s")
def ExecuteFile(self, filepath):
- self.emit("execute-file", filepath)
+ self.ExecuteFileOnDisplay(filepath, "", "")
@dbus.service.method(interface_name, in_signature="say",
byte_arrays=True)
def ExecuteFileWithStartup(self, filepath, notify_id):
- with uievents.using_startup_notify_id(notify_id):
- self.emit("execute-file", filepath)
+ self.ExecuteFileOnDisplay(filepath, "", notify_id)
@dbus.service.method(interface_name, in_signature="sayay",
byte_arrays=True)
def ExecuteFileOnDisplay(self, filepath, display, notify_id):
- raise NotImplementedError
- with uievents.using_startup_notify_id(notify_id):
- self.emit("execute-file", filepath)
+ with uievents.using_startup_notify_id(notify_id) as time:
+ self.emit("execute-file", filepath, display, time)
@dbus.service.method(interface_name, in_signature="sayay",
byte_arrays=True)
def RelayKeysFromDisplay(self, keystring, display, notify_id):
- with uievents.using_startup_notify_id(notify_id):
- self.emit("relay-keys", keystring, display)
+ with uievents.using_startup_notify_id(notify_id) as time:
+ self.emit("relay-keys", keystring, display, time)
@dbus.service.method(interface_name, in_signature=None,
out_signature="as",
@@ -118,24 +127,36 @@ class Service (ExportedGObject):
def Quit(self):
self.emit("quit")
+# Signature: displayname, timestamp
gobject.signal_new("present", Service, gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_BOOLEAN, (gobject.TYPE_STRING, ))
+ gobject.TYPE_BOOLEAN, (gobject.TYPE_STRING, gobject.TYPE_UINT))
+# Signature: displayname, timestamp
gobject.signal_new("show-hide", Service, gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_BOOLEAN, ())
+ gobject.TYPE_BOOLEAN, (gobject.TYPE_STRING, gobject.TYPE_UINT))
+# Signature: text, displayname, timestamp
gobject.signal_new("put-text", Service, gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_BOOLEAN, (gobject.TYPE_STRING, ))
+ gobject.TYPE_BOOLEAN,
+ (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT))
+# Signature: filearray, displayname, timestamp
gobject.signal_new("put-files", Service, gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_BOOLEAN, (gobject.TYPE_PYOBJECT, ))
+ gobject.TYPE_BOOLEAN,
+ (gobject.TYPE_PYOBJECT, gobject.TYPE_STRING, gobject.TYPE_UINT))
+# Signature: fileuri, displayname, timestamp
gobject.signal_new("execute-file", Service, gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_BOOLEAN, (gobject.TYPE_STRING,))
+ gobject.TYPE_BOOLEAN,
+ (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT))
+# Signature: ()
gobject.signal_new("quit", Service, gobject.SIGNAL_RUN_LAST,
gobject.TYPE_BOOLEAN, ())
+# Signature: keystring, displayname, timestamp
gobject.signal_new("relay-keys", Service, gobject.SIGNAL_RUN_LAST,
- gobject.TYPE_BOOLEAN, (gobject.TYPE_STRING, gobject.TYPE_STRING, ))
+ gobject.TYPE_BOOLEAN,
+ (gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_UINT))
+
diff --git a/kupfer/ui/uievents.py b/kupfer/ui/uievents.py
index eee9431..86426af 100644
--- a/kupfer/ui/uievents.py
+++ b/kupfer/ui/uievents.py
@@ -110,7 +110,7 @@ def _parse_notify_id(startup_notification_id):
if "_TIME" in startup_notification_id:
_ign, bstime = startup_notification_id.split("_TIME", 1)
try:
- time = int(bstime)
+ time = abs(int(bstime))
except ValueError:
pass
return time
@@ -120,8 +120,10 @@ def using_startup_notify_id(notify_id):
"""
Pass in a DESKTOP_STARTUP_ID
- with using_startup_notify_id(...):
+ with using_startup_notify_id(...) as time:
pass
+
+ The yelt object is the parsed timestamp
"""
timestamp = _parse_notify_id(notify_id)
if timestamp:
@@ -129,7 +131,7 @@ def using_startup_notify_id(notify_id):
try:
pretty.print_debug(__name__, "Using startup id", repr(notify_id))
_internal_data.current_event_time = timestamp
- yield
+ yield timestamp
finally:
_internal_data.current_event_time = gtk.gdk.CURRENT_TIME
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]