summaryrefslogtreecommitdiffstats
path: root/gobject/pygobject.c
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2005-07-09 18:25:32 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2005-07-09 18:25:32 +0000
commit83a43997b2136c6f5337219ddfe6aa6829d66fae (patch)
treee31a18b2a0f0fcc7cb55849c88c2afa12aa85d3d /gobject/pygobject.c
parent49eabd6c5ab0b3c849bd03bd2149b47e50f19aee (diff)
downloadpygobject-83a43997b2136c6f5337219ddfe6aa6829d66fae.tar.gz
pygobject-83a43997b2136c6f5337219ddfe6aa6829d66fae.tar.xz
pygobject-83a43997b2136c6f5337219ddfe6aa6829d66fae.zip
Bug 161177: Allow creation of python classes from g_object_new
Diffstat (limited to 'gobject/pygobject.c')
-rw-r--r--gobject/pygobject.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/gobject/pygobject.c b/gobject/pygobject.c
index 1263554..1fe837d 100644
--- a/gobject/pygobject.c
+++ b/gobject/pygobject.c
@@ -660,6 +660,7 @@ pygobject_lookup_class(GType gtype)
/**
* pygobject_new:
* @obj: a GObject instance.
+ * @sink: whether to sink any floating reference found on the GObject.
*
* This function gets a reference to a wrapper for the given GObject
* instance. If a wrapper has already been created, a new reference
@@ -669,7 +670,7 @@ pygobject_lookup_class(GType gtype)
* Returns: a reference to the wrapper for the GObject.
*/
PyObject *
-pygobject_new(GObject *obj)
+pygobject_new_full(GObject *obj, gboolean sink)
{
PyGObject *self;
@@ -695,7 +696,8 @@ pygobject_new(GObject *obj)
pyg_begin_allow_threads;
self->obj = g_object_ref(obj);
pyg_end_allow_threads;
- sink_object(self->obj);
+ if (sink)
+ sink_object(self->obj);
self->inst_dict = NULL;
self->weakreflist = NULL;
@@ -711,6 +713,12 @@ pygobject_new(GObject *obj)
return (PyObject *)self;
}
+PyObject *
+pygobject_new(GObject *obj)
+{
+ return pygobject_new_full(obj, TRUE);
+}
+
static void
pygobject_unwatch_closure(gpointer data, GClosure *closure)
{
@@ -943,11 +951,7 @@ pygobject_init(PyGObject *self, PyObject *args, PyObject *kwargs)
n_params++;
}
}
-
- self->obj = g_object_newv(object_type, n_params, params);
- if (self->obj)
- pygobject_register_wrapper((PyObject *)self);
- else
+ if (pygobject_constructv(self, n_params, params))
PyErr_SetString (PyExc_RuntimeError, "could not create object");
cleanup: