From b72fe8c67d724d0f4637714a72e4e91c9487349f Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Wed, 28 Jul 2004 18:14:55 +0000 Subject: [PATCH] 2004-07-28 Anders Carlsson * python/dbus.py: * python/dbus_bindings.pyx.in: Add dbus.init_gthreads (), allow emit_signal to pass arguments to the signal. --- ChangeLog | 7 +++++++ python/dbus.py | 13 ++++++++++++- python/dbus_bindings.pyx.in | 4 ++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 85e70a2..cab484f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2004-07-28 Anders Carlsson + + * python/dbus.py: + * python/dbus_bindings.pyx.in: + Add dbus.init_gthreads (), allow emit_signal to pass + arguments to the signal. + 2004-07-24 Havoc Pennington * AUTHORS: add some people, not really comprehensively, let me diff --git a/python/dbus.py b/python/dbus.py index de42d74..4b53897 100644 --- a/python/dbus.py +++ b/python/dbus.py @@ -43,6 +43,13 @@ print(dbus_object.ListServices()) import dbus_bindings +_threads_initialized = 0 +def init_gthreads (): + global _threads_initialized + if not _threads_initialized: + dbus_bindings.init_gthreads () + _threads_initialized = 1 + class Bus: """A connection to a DBus daemon. @@ -285,8 +292,12 @@ class Object: self._connection.register_object_path(object_path, self._unregister_cb, self._message_cb) - def emit_signal(self, interface, signal_name): + def emit_signal(self, interface, signal_name, *args): message = dbus_bindings.Signal(self._object_path, interface, signal_name) + iter = message.get_iter() + for arg in args: + iter.append(arg) + self._connection.send(message) def _unregister_cb(self, connection): diff --git a/python/dbus_bindings.pyx.in b/python/dbus_bindings.pyx.in index 498076d..6e73c85 100644 --- a/python/dbus_bindings.pyx.in +++ b/python/dbus_bindings.pyx.in @@ -18,6 +18,7 @@ cdef extern from "dbus-glib.h": GMainContext *context) cdef void dbus_server_setup_with_g_main (DBusServer *server, GMainContext *context) + cdef void dbus_g_thread_init () cdef extern from "Python.h": void Py_XINCREF (object) @@ -1136,3 +1137,6 @@ def bus_remove_match(Connection connection, rule): if dbus_error_is_set(&error): raise DBusException, error.message + +def init_gthreads (): + dbus_g_thread_init () -- 2.7.4