summaryrefslogtreecommitdiffstats
path: root/glib/pyglib.c
diff options
context:
space:
mode:
authorJohan Dahlin <johan@gnome.org>2008-07-20 14:17:04 +0000
committerJohan Dahlin <johan@src.gnome.org>2008-07-20 14:17:04 +0000
commit45ccf5f6ff1a1805ed326b397c70cf55bba28124 (patch)
tree59b30668a1b28efced9f417b1e6bc2f4bc9709ec /glib/pyglib.c
parent9cd866c9066eaa933b54e77225ada672fcfacad3 (diff)
downloadpygobject-45ccf5f6ff1a1805ed326b397c70cf55bba28124.tar.gz
pygobject-45ccf5f6ff1a1805ed326b397c70cf55bba28124.tar.xz
pygobject-45ccf5f6ff1a1805ed326b397c70cf55bba28124.zip
Move maincontext and mainloop over to glib. Update the threadstate api to
2008-07-20 Johan Dahlin <johan@gnome.org> * glib/Makefile.am: * glib/glibmodule.c (pyglib_main_context_default), (init_glib): * glib/pyglib.c (pyglib_init), (pyglib_threads_enabled), (pyglib_main_context_new): * glib/pyglib.h: * glib/pygmaincontext.c (_wrap_g_main_context_iteration), (pyglib_maincontext_register_types): * glib/pygmaincontext.h: * glib/pygmainloop.c (pyg_signal_watch_prepare), (pyg_signal_watch_check), (pyg_main_loop_new), (_wrap_g_main_loop_get_context), (_wrap_g_main_loop_run), (pyglib_mainloop_register_types): * glib/pygmainloop.h: * gobject/Makefile.am: * gobject/__init__.py: * gobject/gobjectmodule.c (pyg_destroy_notify), (pyobject_free), (pyg_object_set_property), (pyg_object_get_property), (_pyg_signal_accumulator), (pygobject__g_instance_init), (pyg_handler_marshal), (pygobject_gil_state_ensure), (pygobject_gil_state_release), (marshal_emission_hook), (_log_func), (init_gobject): * gobject/pygboxed.c (pyg_boxed_dealloc), (pyg_boxed_new): * gobject/pygenum.c (pyg_enum_add): * gobject/pygflags.c (pyg_flags_add): * gobject/pygiochannel.c (pyg_iowatch_marshal): * gobject/pygmaincontext.c: * gobject/pygmainloop.c: * gobject/pygobject-private.h: * gobject/pygobject.c (pygobject_data_free), (pyg_toggle_notify), (pygobject_new_with_interfaces), (pygobject_weak_ref_notify): * gobject/pygobject.h: * gobject/pygoptiongroup.c (destroy_g_group), (arg_func): * gobject/pygpointer.c (pyg_pointer_new): * gobject/pygsource.c (pyg_source_get_context), (pyg_source_prepare), (pyg_source_check), (pyg_source_dispatch), (pyg_source_finalize): * gobject/pygtype.c (pyg_closure_invalidate), (pyg_closure_marshal), (pyg_signal_class_closure_marshal): * tests/common.py: Move maincontext and mainloop over to glib. Update the threadstate api to use the variant in glib. svn path=/trunk/; revision=843
Diffstat (limited to 'glib/pyglib.c')
-rw-r--r--glib/pyglib.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/glib/pyglib.c b/glib/pyglib.c
index 57bc095..3f7ebbd 100644
--- a/glib/pyglib.c
+++ b/glib/pyglib.c
@@ -27,10 +27,14 @@
#include <pythread.h>
#include "pyglib.h"
#include "pyglib-private.h"
+#include "pygmaincontext.h"
static struct _PyGLib_Functions *_PyGLib_API;
static int pyglib_thread_state_tls_key;
+static PyTypeObject *_PyGMainContext_Type;
+#define PyGMainContext_Type (*_PyGMainContext_Type)
+
void
pyglib_init(void)
{
@@ -63,6 +67,8 @@ pyglib_init(void)
"could not import glib (could not find _PyGLib_API object)");
Py_DECREF(glib);
}
+
+ _PyGMainContext_Type = (PyTypeObject*)PyObject_GetAttrString(glib, "MainContext");
}
void
@@ -71,6 +77,12 @@ pyglib_init_internal(PyObject *api)
_PyGLib_API = (struct _PyGLib_Functions *) PyCObject_AsVoidPtr(api);
}
+gboolean
+pyglib_threads_enabled(void)
+{
+ return _PyGLib_API->threads_enabled;
+}
+
PyGILState_STATE
pyglib_gil_state_ensure(void)
{
@@ -255,3 +267,25 @@ bad_gerror:
PyErr_Print();
return -2;
}
+
+/**
+ * pyglib_main_context_new:
+ * @context: a GMainContext.
+ *
+ * Creates a wrapper for a GMainContext.
+ *
+ * Returns: the GMainContext wrapper.
+ */
+PyObject *
+pyglib_main_context_new(GMainContext *context)
+{
+ PyGMainContext *self;
+
+ self = (PyGMainContext *)PyObject_NEW(PyGMainContext,
+ &PyGMainContext_Type);
+ if (self == NULL)
+ return NULL;
+
+ self->context = g_main_context_ref(context);
+ return (PyObject *)self;
+}