From 602afea88c338a38327cd84e08703c5daa384ec6 Mon Sep 17 00:00:00 2001 From: Paul Pogonyshev Date: Tue, 10 Nov 2009 22:32:33 +0200 Subject: Move threads_init() function from 'gobject' to 'glib' Retain in original place for backward compatibility, but remove it from the docs. --- glib/glibmodule.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'glib/glibmodule.c') diff --git a/glib/glibmodule.c b/glib/glibmodule.c index 58206eb..74a09db 100644 --- a/glib/glibmodule.c +++ b/glib/glibmodule.c @@ -89,6 +89,16 @@ get_handler_priority(gint *priority, PyObject *kwargs) return 0; } +static PyObject * +pyglib_threads_init(PyObject *unused, PyObject *args, PyObject *kwargs) +{ + if (!pyglib_enable_threads()) + return NULL; + + Py_INCREF(Py_None); + return Py_None; +} + static PyObject * pyglib_idle_add(PyObject *self, PyObject *args, PyObject *kwargs) { @@ -586,6 +596,12 @@ pyglib_set_prgname(PyObject *self, PyObject *arg) } static PyMethodDef _glib_functions[] = { + { "threads_init", + (PyCFunction) pyglib_threads_init, METH_NOARGS, + "threads_init()\n" + "Initialize GLib for use from multiple threads. If you also use GTK+\n" + "itself (i.e. GUI, not just PyGObject), use gtk.gdk.threads_init()\n" + "instead." }, { "idle_add", (PyCFunction)pyglib_idle_add, METH_VARARGS|METH_KEYWORDS, "idle_add(callable, user_data=None, priority=None) -> source id\n" -- cgit