[kupfer: 12/51] kupferrelay: Keep up with changing global keybindings
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer: 12/51] kupferrelay: Keep up with changing global keybindings
- Date: Mon, 28 Mar 2011 15:02:05 +0000 (UTC)
commit af07b333e4bcb5b4cb29cfd089e786119f96a934
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Mon Mar 28 16:51:42 2011 +0200
kupferrelay: Keep up with changing global keybindings
kupferrelay.py | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
---
diff --git a/kupferrelay.py b/kupferrelay.py
index 2c740f1..5f4c1bf 100644
--- a/kupferrelay.py
+++ b/kupferrelay.py
@@ -4,6 +4,8 @@ import gtk
import keybinder
import dbus
+from dbus.mainloop.glib import DBusGMainLoop
+
SERV = "se.kaizer.kupfer"
OBJ = "/interface"
IFACE = "se.kaizer.kupfer.Listener"
@@ -15,6 +17,14 @@ def get_all_keys():
iface = dbus.Interface(obj, IFACE)
return iface.GetBoundKeys(byte_arrays=True)
+def rebind_key(keystring, is_bound):
+ if is_bound:
+ print "binding", keystring
+ keybinder.bind(keystring, relay_key, keystring)
+ else:
+ print "unbinding", keystring
+ keybinder.unbind(keystring)
+
def relay_key(key):
print "Relaying", key
time = keybinder.get_current_event_time()
@@ -25,9 +35,15 @@ def relay_key(key):
iface.RelayKeysFromDisplay(key, os.getenv("DISPLAY"), s_id)
def main():
+ DBusGMainLoop(set_as_default=True)
+
+ bus = dbus.Bus()
relayed_keys = list(get_all_keys())
+
for key in relayed_keys:
keybinder.bind(key, relay_key, key)
+ bus.add_signal_receiver(rebind_key, 'BoundKeyChanged',
+ dbus_interface=IFACE)
gtk.main()
if __name__ == '__main__':
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]