mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-14 21:28:05 +02:00
* python/dbus.py: * python/examples/example-signals.py: Start implementing some notions of signals. The API is really terrible, but they sort of work (with the exception of being able to filter by service, and to transmit signals *as* a particular service). Need to figure out how to make messages come from the service we registered :-( * python/dbus_bindings.pyx.in: Removed duplicate message_handler callbacks.
27 lines
712 B
Python
27 lines
712 B
Python
import pygtk
|
|
import gtk
|
|
|
|
import dbus
|
|
|
|
class SignalFrom(dbus.Object):
|
|
def __init__(self, service):
|
|
dbus.Object.__init__(self, "/", [], service)
|
|
|
|
def signal_to(interface, signal_name, service, path):
|
|
print ("Received signal '%s.%s' from '%s%s'" % (interface, signal_name, service, path))
|
|
|
|
bus = dbus.Bus()
|
|
bus.add_signal_receiver(signal_to,
|
|
"org.designfu.SignalInterface",
|
|
"org.designfu.SignalService",
|
|
"/")
|
|
|
|
|
|
service = dbus.Service("org.designfu.SignalService", bus)
|
|
signal_from = SignalFrom(service)
|
|
|
|
signal_from.broadcast_signal("org.designfu.SignalInterface", "HelloWorld")
|
|
|
|
gtk.main()
|
|
|
|
|