diff options
author | Manish Singh <yosh@gimp.org> | 2005-08-01 22:50:42 +0000 |
---|---|---|
committer | Manish Singh <yosh@src.gnome.org> | 2005-08-01 22:50:42 +0000 |
commit | 9ef8e1721cbf74cd758380ace340ca9f2f19928b (patch) | |
tree | b39ae020119bea8b57860cd79ce9d8f4fdf23da8 /gobject/pygmaincontext.c | |
parent | ca9f9bd7c784486b1f712445d0659ea3ba19099c (diff) | |
download | pygobject-9ef8e1721cbf74cd758380ace340ca9f2f19928b.tar.gz pygobject-9ef8e1721cbf74cd758380ace340ca9f2f19928b.tar.xz pygobject-9ef8e1721cbf74cd758380ace340ca9f2f19928b.zip |
gobject/pygobject-private.h Add a convenience function
2005-08-01 Manish Singh <yosh@gimp.org>
* gobject/pygobject-private.h
* gobject/pygmaincontext.c: Add a convenience function
(pyg_main_context_new) to create a PyGMainContext from a
GMainContext. Takes care of refing the supplied GMainContext
as well.
* gobject/gobjectmodule.c (pyg_main_context_default)
* gobject/pygmainloop.c (_wrap_g_main_loop_get_context)
* gobject/pygsource.c (pyg_source_get_context): use the new
convenience function here. This fixes bug #312259.
Diffstat (limited to 'gobject/pygmaincontext.c')
-rw-r--r-- | gobject/pygmaincontext.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/gobject/pygmaincontext.c b/gobject/pygmaincontext.c index 7286a86..b320eea 100644 --- a/gobject/pygmaincontext.c +++ b/gobject/pygmaincontext.c @@ -27,7 +27,7 @@ #include "pygobject-private.h" static int -pyg_main_context_new(PyGMainContext *self) +pyg_main_context_init(PyGMainContext *self) { self->context = g_main_context_new(); return 0; @@ -118,5 +118,27 @@ PyTypeObject PyGMainContext_Type = { (descrgetfunc)0, (descrsetfunc)0, 0, - (initproc)pyg_main_context_new, + (initproc)pyg_main_context_init, }; + +/** + * pyg_main_context_new: + * @context: a GMainContext. + * + * Creates a wrapper for a GMainContext. + * + * Returns: the GMainContext wrapper. + */ +PyObject * +pyg_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; +} |