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. --- docs/reference/pygobject-functions.xml | 36 +++++++--------------------------- glib/glibmodule.c | 16 +++++++++++++++ 2 files changed, 23 insertions(+), 29 deletions(-) diff --git a/docs/reference/pygobject-functions.xml b/docs/reference/pygobject-functions.xml index 8ad1e40..7ca3918 100644 --- a/docs/reference/pygobject-functions.xml +++ b/docs/reference/pygobject-functions.xml @@ -116,10 +116,13 @@ linkend="function-gobject---install-metaclass">gobject._install_metaclass module but are not directly associated with a specific class. - Many functions that previously were in this namespace got moved - to glib namespace - instead. They are still available in gobject for backward - compatibility, but not documented here. + + Many functions that previously were in this namespace got moved to glib namespace instead. They + are still available in gobject for backward compatibility, but + not documented here. If you miss documentation for some function, be sure to + check glib first. + @@ -755,31 +758,6 @@ properties. - - gobject.threads_init - - - gobject.threads_init - - - - - Returns : - - - - - This function is available in PyGTK 2.4 and above. - - - The threads_init() function initializes the - the use of Python threading in the gobject module. This function is - different than the gtk.gdk.threads_init() - function as that function also initializes the gdk threads. - - - gobject.signal_accumulator_true_handled 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