[kupfer: 10/51] kupferrelay: Transmit bound keys over D-Bus
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 10/51] kupferrelay: Transmit bound keys over D-Bus
- Date: Mon, 28 Mar 2011 15:01:55 +0000 (UTC)
commit 49c7ac724c756826eb88759c7c78eb0662fd8b33
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Mar 28 16:51:42 2011 +0200
kupferrelay: Transmit bound keys over D-Bus
kupfer/ui/keybindings.py | 3 +++
kupfer/ui/listen.py | 13 ++++++++++++-
kupferrelay.py | 35 ++++++-----------------------------
3 files changed, 21 insertions(+), 30 deletions(-)
---
diff --git a/kupfer/ui/keybindings.py b/kupfer/ui/keybindings.py
index f33beea..14b719c 100644
--- a/kupfer/ui/keybindings.py
+++ b/kupfer/ui/keybindings.py
@@ -44,6 +44,9 @@ gobject.signal_new("keybinding", KeyboundObject, gobject.SIGNAL_RUN_LAST,
_currently_bound = {}
+def get_all_bound_keys():
+ return list(_currently_bound.values())
+
def get_current_event_time():
"Return current event time as given by keybinder"
try:
diff --git a/kupfer/ui/listen.py b/kupfer/ui/listen.py
index f68de12..24562e4 100644
--- a/kupfer/ui/listen.py
+++ b/kupfer/ui/listen.py
@@ -97,12 +97,23 @@ class Service (ExportedGObject):
with uievents.using_startup_notify_id(notify_id):
self.emit("execute-file", filepath)
- @dbus.service.method(interface_name, in_signature="ayayay",
+ @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)
+ @dbus.service.method(interface_name, in_signature=None,
+ out_signature="as",
+ byte_arrays=True)
+ def GetBoundKeys(self):
+ from kupfer.ui import keybindings
+ return keybindings.get_all_bound_keys()
+
+ @dbus.service.signal(interface_name, signature="ay")
+ def KeyWasBound(self, keystr):
+ pass
+
@dbus.service.method(interface_name)
def Quit(self):
self.emit("quit")
diff --git a/kupferrelay.py b/kupferrelay.py
index 0e72cf9..2c740f1 100644
--- a/kupferrelay.py
+++ b/kupferrelay.py
@@ -3,37 +3,17 @@ import os
import gtk
import keybinder
import dbus
-import pickle
-
-import kupfer.puid
-import kupfer.config
-import kupfer.core.settings
-
SERV = "se.kaizer.kupfer"
OBJ = "/interface"
IFACE = "se.kaizer.kupfer.Listener"
-def get_core_keys():
- """ Get configured keys """
- sc = kupfer.core.settings.SettingsController()
- return [sc.get_keybinding(), sc.get_magic_keybinding()]
-
-def get_trigger_keys():
- """ Get configured keys """
- c = kupfer.config.get_config_file("config-kupfer.plugin.triggers-v1.pickle")
- if not c:
- print "No triggers configured"
- return
- with open(c, "rb") as f:
- data_dic = pickle.load(f)
- if not data_dic:
- print "Triggers not configured"
- return
- for target in data_dic['triggers']:
- keystr, name, puid = data_dic['triggers'][target]
- yield keystr
+def get_all_keys():
+ bus = dbus.Bus()
+ obj = bus.get_object(SERV, OBJ)
+ iface = dbus.Interface(obj, IFACE)
+ return iface.GetBoundKeys(byte_arrays=True)
def relay_key(key):
print "Relaying", key
@@ -45,12 +25,9 @@ def relay_key(key):
iface.RelayKeysFromDisplay(key, os.getenv("DISPLAY"), s_id)
def main():
- relayed_keys = []
- relayed_keys.extend(get_core_keys())
- relayed_keys.extend(get_trigger_keys())
+ relayed_keys = list(get_all_keys())
for key in relayed_keys:
keybinder.bind(key, relay_key, key)
-
gtk.main()
if __name__ == '__main__':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]