Created
January 12, 2016 19:32
-
-
Save infirit/81031b2afb53fc183b24 to your computer and use it in GitHub Desktop.
bluez adapter base proxy class
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from gi.repository import Gio, GLib, GObject | |
| class BaseProxy(Gio.DBusProxy): | |
| __gsignals__ = { | |
| str('property-changed'): (GObject.SignalFlags.NO_HOOKS, | |
| None, | |
| (GObject.TYPE_PYOBJECT, | |
| GObject.TYPE_PYOBJECT, | |
| GObject.TYPE_PYOBJECT)) | |
| } | |
| def __init__(self, object_path, interface_name): | |
| super(BaseProxy, self).__init__( | |
| g_name='org.bluez', | |
| g_connection=Gio.bus_get_sync(Gio.BusType.SYSTEM), | |
| g_flags=Gio.DBusProxyFlags.NONE, | |
| g_object_path=object_path, | |
| g_interface_name=interface_name) | |
| self.connect("g-signal", self._on_property_changed) | |
| def _on_property_changed(self, proxy, sender, signal_name, param): | |
| interface = param[0] | |
| key, value = param[1].popitem() | |
| path = proxy.get_object_path() | |
| print(interface, path, key, value) | |
| self.emit("property-changed", key, value, path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Line 20 should be "property-changed", not "g-signal".