Skip to content

Instantly share code, notes, and snippets.

@infirit
Created January 12, 2016 19:32
Show Gist options
  • Select an option

  • Save infirit/81031b2afb53fc183b24 to your computer and use it in GitHub Desktop.

Select an option

Save infirit/81031b2afb53fc183b24 to your computer and use it in GitHub Desktop.
bluez adapter base proxy class
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)
@cschramm
Copy link

Line 20 should be "property-changed", not "g-signal".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment