diff options
| author | James Henstridge <james@daa.com.au> | 2000-06-28 14:27:05 +0000 |
|---|---|---|
| committer | James Henstridge <jamesh@src.gnome.org> | 2000-06-28 14:27:05 +0000 |
| commit | 623aea81b4d3624e7bc30af05402bf0c127948f1 (patch) | |
| tree | c0fdbf8fcffa09fdacd1b2df44eb013d3888bde7 /gobject | |
| parent | b63063176b2ab5e871826b5566586613c7c84e5a (diff) | |
| download | pygobject-623aea81b4d3624e7bc30af05402bf0c127948f1.tar.gz pygobject-623aea81b4d3624e7bc30af05402bf0c127948f1.tar.xz pygobject-623aea81b4d3624e7bc30af05402bf0c127948f1.zip | |
add get_data / set_data methods. Add get_param / set_param methods.
2000-06-28 James Henstridge <james@daa.com.au>
* gobjectmodule.c: add get_data / set_data methods.
Add get_param / set_param methods.
(pygobject__init__): simple init function for GObjects. Doesn't
handle params yet.
(pygobject_register_wrapper): don't ref the GObject -- it isn't like
GtkObjects where we ref/sink them.
Diffstat (limited to 'gobject')
| -rw-r--r-- | gobject/gobjectmodule.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index 5697628..a61a60b 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -70,7 +70,7 @@ pygobject_register_wrapper(PyObject *self) { GObject *obj = ((PyGObject *)self)->obj; - g_object_ref(obj); + /* g_object_ref(obj); -- not needed because no floating reference */ g_object_set_qdata(obj, pygobject_wrapper_key, self); } @@ -468,6 +468,23 @@ pygobject__class_init__(PyObject *something, PyObject *args) } static PyObject * +pygobject__init__(PyGObject *self, PyObject *args) +{ + GType object_type = G_TYPE_OBJECT; + + if (!PyArg_ParseTuple(args, "|i:GObject.__init__", &object_type)) + return NULL; + self->obj = g_object_new(object_type, NULL); + if (!self->obj) { + PyErr_SetString(PyExc_RuntimeError, "could not create object"); + return NULL; + } + pygobject_register_wrapper((PyObject *)self); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * pygobject_get_param(PyGObject *self, PyObject *args) { gchar *param_name; @@ -550,6 +567,7 @@ pygobject_set_data(PyGObject *self, PyObject *args) static PyMethodDef pygobject_methods[] = { { "__class_init__", (PyCFunction)pygobject__class_init__, METH_VARARGS|METH_CLASS_METHOD }, + { "__init__", (PyCFunction)pygobject__init__, METH_VARARGS }, { "get_param", (PyCFunction)pygobject_get_param, METH_VARARGS }, { "set_param", (PyCFunction)pygobject_set_param, METH_VARARGS }, { "get_data", (PyCFunction)pygobject_get_data, METH_VARARGS }, |
