diff options
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/Makefile.am | 3 | ||||
-rw-r--r-- | bindings/python/Makefile.am | 29 | ||||
-rw-r--r-- | bindings/python/glade-python-gwa.c | 1676 | ||||
-rw-r--r-- | bindings/python/glade-python-gwa.defs | 161 | ||||
-rw-r--r-- | bindings/python/glade-python-gwa.override | 879 | ||||
-rw-r--r-- | bindings/python/glade-python.c | 626 |
6 files changed, 3374 insertions, 0 deletions
diff --git a/bindings/Makefile.am b/bindings/Makefile.am new file mode 100644 index 00000000..0cda9810 --- /dev/null +++ b/bindings/Makefile.am @@ -0,0 +1,3 @@ +## Process this file with automake to produce Makefile.in + +SUBDIRS = python diff --git a/bindings/python/Makefile.am b/bindings/python/Makefile.am new file mode 100644 index 00000000..9be73cdc --- /dev/null +++ b/bindings/python/Makefile.am @@ -0,0 +1,29 @@ +## Process this file with automake to produce Makefile.in + +libgladeui = $(top_builddir)/gladeui/libgladeui-1.la + + +# libgladepython + +gladepython_LTLIBRARIES = libgladepython.la +gladepythondir = $(pkglibdir)/bindings + +libgladepython_la_SOURCES = glade-python.c glade-python-gwa.c +libgladepython_la_CPPFLAGS = \ + -I$(top_srcdir) \ + -I$(top_builddir) \ + $(AM_CPPFLAGS) +libgladepython_la_CFLAGS = \ + -g -Wall \ + $(top_srcdir) \ + -I$(top_srcdir)/gladeui \ + -I$(top_builddir)/gladeui \ + $(PYTHON_CFLAGS) \ + $(GTK_CFLAGS) \ + $(AM_CFLAGS) +libgladepython_la_LDFLAGS = -module -avoid-version $(PYTHON_LIBS) $(AM_LDFLAGS) +libgladepython_la_LIBADD = $(libgladeui) $(PYTHON_LIBS) + +if WITH_WIN32 + libgladepython_la_LDFLAGS += -no-undefined +endif diff --git a/bindings/python/glade-python-gwa.c b/bindings/python/glade-python-gwa.c new file mode 100644 index 00000000..64e0f06d --- /dev/null +++ b/bindings/python/glade-python-gwa.c @@ -0,0 +1,1676 @@ +/* -- THIS FILE IS GENERATED - DO NOT EDIT *//* -*- Mode: C; c-basic-offset: 4 -*- */ + +#include <Python.h> + + + +#line 23 "glade-python-gwa.override" +#include <Python.h> +#include <pygobject.h> +#include <glade.h> + +static gboolean +glade_python_support_init_value (GObject *object, + gboolean is_pack, + const gchar *property_name, + GValue *value) +{ + GladeWidget *widget; + GladeProperty *property; + + if ((widget = glade_widget_get_from_gobject (object)) == NULL) + { + PyErr_Format (PyExc_AssertionError, "GladeWidget != NULL"); + return FALSE; + } + + if (is_pack) + property = glade_widget_get_pack_property (widget, property_name); + else + property = glade_widget_get_property (widget, property_name); + + if (property == NULL) + { + PyErr_Format (PyExc_TypeError, "'%s' does not support %s property `%s'", + glade_widget_get_name (widget), + (is_pack) ? "packing" : "", + property_name); + return FALSE; + } + + g_value_init (value, G_VALUE_TYPE (property->value)); + return TRUE; +} + + +static GList * +glade_python_support_glist_from_list (PyObject *list) +{ + gint i, size = PyList_Size (list); + GList *retval = NULL; + + for (i = 0; i < size; i++) + { + PyObject *val = PyList_GetItem (list, i); + retval = g_list_prepend (retval, pygobject_get(val)); + } + return retval; +} + +static PyObject * +glade_python_support_list_from_glist (GList *list) +{ + PyObject *retval = PyList_New (0);; + + for (; list; list = g_list_next (list)) + { + GObject *obj = list->data; + PyList_Append (retval, Py_BuildValue ("O", pygobject_new (obj))); + } + + return retval; +} + +/* + NOTE: the next functions where created by codegen and adapted to support + GValue* and GList* types. +*/ + +#line 80 "glade-python-gwa.c" + + +/* ---------- types from other modules ---------- */ +static PyTypeObject *_PyGObject_Type; +#define PyGObject_Type (*_PyGObject_Type) + + +/* ---------- forward type declarations ---------- */ +PyTypeObject PyGladeWidgetAdaptor_Type; + +#line 91 "glade-python-gwa.c" + + + +/* ----------- GladeWidgetAdaptor ----------- */ + +#line 98 "glade-python-gwa.override" +static PyObject * +_wrap_GladeWidgetAdaptor__do_verify_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", "property_name", "value", NULL }; + PyGObject *self, *object; + char *property_name; + int ret; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!sO:GladeWidgetAdaptor.verify_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (object->obj, FALSE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->verify_property) + ret = GLADE_WIDGET_ADAPTOR_CLASS(klass)->verify_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.verify_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return PyBool_FromLong(ret); + +} +#line 127 "glade-python-gwa.c" + + +#line 212 "glade-python-gwa.override" +static PyObject * +_wrap_GladeWidgetAdaptor__do_set_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", "property_name", "value", NULL }; + PyGObject *self, *object; + char *property_name; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!sO:GladeWidgetAdaptor.set_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (object->obj, FALSE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->set_property) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->set_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.set_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} +#line 159 "glade-python-gwa.c" + + +#line 332 "glade-python-gwa.override" +static PyObject * +_wrap_GladeWidgetAdaptor__do_get_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", "property_name", NULL }; + PyGObject *self, *object; + char *property_name; + GValue value = {0,}; + PyObject *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!s:GladeWidgetAdaptor.get_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object, &property_name)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_property) + { + glade_python_support_init_value (object->obj, FALSE, property_name, &value); + GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj), property_name, &value); + ret = pyg_value_as_pyobject (&value, TRUE); + g_value_unset (&value); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.get_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return ret; +} +#line 192 "glade-python-gwa.c" + + +#line 432 "glade-python-gwa.override" +static PyObject * +_wrap_GladeWidgetAdaptor__do_child_verify_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", "child", "property_name", "value", NULL }; + PyGObject *self, *container, *child; + char *property_name; + int ret; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!sO:GladeWidgetAdaptor.child_verify_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container, &PyGObject_Type, &child, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (child->obj, TRUE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_verify_property) + ret = GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_verify_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.child_verify_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return PyBool_FromLong(ret); + +} +#line 225 "glade-python-gwa.c" + + +#line 556 "glade-python-gwa.override" +static PyObject * +_wrap_GladeWidgetAdaptor__do_child_set_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", "child", "property_name", "value", NULL }; + PyGObject *self, *container, *child; + char *property_name; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!sO:GladeWidgetAdaptor.child_set_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container, &PyGObject_Type, &child, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (child->obj, TRUE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_set_property) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_set_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.child_set_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} +#line 257 "glade-python-gwa.c" + + +#line 686 "glade-python-gwa.override" +static PyObject * +_wrap_GladeWidgetAdaptor__do_child_get_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", "child", "property_name", NULL }; + PyGObject *self, *container, *child; + char *property_name; + PyObject *ret; + GValue value = { 0, } ; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!s:GladeWidgetAdaptor.child_get_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container, &PyGObject_Type, &child, &property_name)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property) + { + glade_python_support_init_value (child->obj, TRUE, property_name, &value); + GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); + ret = pyg_value_as_pyobject (&value, TRUE); + g_value_unset (&value); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.child_get_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return ret; +} +#line 289 "glade-python-gwa.c" + + +#line 794 "glade-python-gwa.override" +static PyObject * +_wrap_GladeWidgetAdaptor__do_get_children(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", NULL }; + PyGObject *self, *container; + PyObject *list; + GList *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GladeWidgetAdaptor.get_children", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_children) + ret = GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_children(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj)); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.get_children not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + + list = glade_python_support_list_from_glist (ret); + g_list_free (ret); + return list; +} +#line 318 "glade-python-gwa.c" + + +static PyObject * +_wrap_GladeWidgetAdaptor__do_add(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "parent", "child", NULL }; + PyGObject *self, *parent, *child; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!:GladeWidgetAdaptor.add", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &parent, &PyGObject_Type, &child)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->add) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->add(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(parent->obj), G_OBJECT(child->obj)); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.add not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +_wrap_GladeWidgetAdaptor__do_remove(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "parent", "child", NULL }; + PyGObject *self, *parent, *child; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!:GladeWidgetAdaptor.remove", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &parent, &PyGObject_Type, &child)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->remove) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->remove(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(parent->obj), G_OBJECT(child->obj)); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.remove not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +_wrap_GladeWidgetAdaptor__do_replace_child(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", "old", "new", NULL }; + PyGObject *self, *container, *old_obj, *new_obj; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!O!:GladeWidgetAdaptor.replace_child", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container, &PyGObject_Type, &old_obj, &PyGObject_Type, &new_obj)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->replace_child) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->replace_child(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(old_obj->obj), G_OBJECT(new_obj->obj)); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.replace_child not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +_wrap_GladeWidgetAdaptor__do_post_create(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", "reason", NULL }; + PyGObject *self, *object; + PyObject *py_reason = NULL; + GladeCreateReason reason; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O:GladeWidgetAdaptor.post_create", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object, &py_reason)) + return NULL; + if (pyg_enum_get_value(GLADE_CREATE_REASON, py_reason, (gint *)&reason)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->post_create) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->post_create(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj), reason); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.post_create not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +_wrap_GladeWidgetAdaptor__do_get_internal_child(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "parent", "name", NULL }; + PyGObject *self, *parent; + char *name; + GObject *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!s:GladeWidgetAdaptor.get_internal_child", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &parent, &name)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_internal_child) + ret = GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_internal_child(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(parent->obj), name); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.get_internal_child not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + /* pygobject_new handles NULL checking */ + return pygobject_new((GObject *)ret); +} + +static PyObject * +_wrap_GladeWidgetAdaptor__do_launch_editor(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", NULL }; + PyGObject *self, *object; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GladeWidgetAdaptor.launch_editor", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->launch_editor) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->launch_editor(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj)); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.launch_editor not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef _PyGladeWidgetAdaptor_methods[] = { + { "do_verify_property", (PyCFunction)_wrap_GladeWidgetAdaptor__do_verify_property, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_set_property", (PyCFunction)_wrap_GladeWidgetAdaptor__do_set_property, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_get_property", (PyCFunction)_wrap_GladeWidgetAdaptor__do_get_property, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_child_verify_property", (PyCFunction)_wrap_GladeWidgetAdaptor__do_child_verify_property, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_child_set_property", (PyCFunction)_wrap_GladeWidgetAdaptor__do_child_set_property, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_child_get_property", (PyCFunction)_wrap_GladeWidgetAdaptor__do_child_get_property, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_get_children", (PyCFunction)_wrap_GladeWidgetAdaptor__do_get_children, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_add", (PyCFunction)_wrap_GladeWidgetAdaptor__do_add, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_remove", (PyCFunction)_wrap_GladeWidgetAdaptor__do_remove, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_replace_child", (PyCFunction)_wrap_GladeWidgetAdaptor__do_replace_child, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_post_create", (PyCFunction)_wrap_GladeWidgetAdaptor__do_post_create, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_get_internal_child", (PyCFunction)_wrap_GladeWidgetAdaptor__do_get_internal_child, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { "do_launch_editor", (PyCFunction)_wrap_GladeWidgetAdaptor__do_launch_editor, METH_VARARGS|METH_KEYWORDS|METH_CLASS }, + { NULL, NULL, 0 } +}; + +PyTypeObject PyGladeWidgetAdaptor_Type = { + PyObject_HEAD_INIT(NULL) + 0, /* ob_size */ + "GladeWidgetAdaptor", /* tp_name */ + sizeof(PyGObject), /* tp_basicsize */ + 0, /* tp_itemsize */ + /* methods */ + (destructor)0, /* tp_dealloc */ + (printfunc)0, /* tp_print */ + (getattrfunc)0, /* tp_getattr */ + (setattrfunc)0, /* tp_setattr */ + (cmpfunc)0, /* tp_compare */ + (reprfunc)0, /* tp_repr */ + (PyNumberMethods*)0, /* tp_as_number */ + (PySequenceMethods*)0, /* tp_as_sequence */ + (PyMappingMethods*)0, /* tp_as_mapping */ + (hashfunc)0, /* tp_hash */ + (ternaryfunc)0, /* tp_call */ + (reprfunc)0, /* tp_str */ + (getattrofunc)0, /* tp_getattro */ + (setattrofunc)0, /* tp_setattro */ + (PyBufferProcs*)0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, /* tp_flags */ + NULL, /* Documentation string */ + (traverseproc)0, /* tp_traverse */ + (inquiry)0, /* tp_clear */ + (richcmpfunc)0, /* tp_richcompare */ + offsetof(PyGObject, weakreflist), /* tp_weaklistoffset */ + (getiterfunc)0, /* tp_iter */ + (iternextfunc)0, /* tp_iternext */ + _PyGladeWidgetAdaptor_methods, /* tp_methods */ + 0, /* tp_members */ + 0, /* tp_getset */ + NULL, /* tp_base */ + NULL, /* tp_dict */ + (descrgetfunc)0, /* tp_descr_get */ + (descrsetfunc)0, /* tp_descr_set */ + offsetof(PyGObject, inst_dict), /* tp_dictoffset */ + (initproc)0, /* tp_init */ + (allocfunc)0, /* tp_alloc */ + (newfunc)0, /* tp_new */ + (freefunc)0, /* tp_free */ + (inquiry)0 /* tp_is_gc */ +}; + +#line 129 "glade-python-gwa.override" +static gboolean +_wrap_GladeWidgetAdaptor__proxy_do_verify_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, const GValue*value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_property_name; + PyObject *py_value; + gboolean retval; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return FALSE; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_value = pyg_value_as_pyobject(value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_object); + PyTuple_SET_ITEM(py_args, 1, py_property_name); + PyTuple_SET_ITEM(py_args, 2, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_verify_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + retval = PyObject_IsTrue(py_retval)? TRUE : FALSE; + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + + return retval; +} +#line 603 "glade-python-gwa.c" + + +#line 242 "glade-python-gwa.override" +static void +_wrap_GladeWidgetAdaptor__proxy_do_set_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, const GValue*value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_property_name; + PyObject *py_value; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_value = pyg_value_as_pyobject(value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_object); + PyTuple_SET_ITEM(py_args, 1, py_property_name); + PyTuple_SET_ITEM(py_args, 2, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_set_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +#line 695 "glade-python-gwa.c" + + +#line 363 "glade-python-gwa.override" +static void +_wrap_GladeWidgetAdaptor__proxy_do_get_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, GValue *value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_property_name; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_object); + PyTuple_SET_ITEM(py_args, 1, py_property_name); + + py_method = PyObject_GetAttrString(py_self, "do_get_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + pyg_value_from_pyobject (value, py_retval); + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +#line 766 "glade-python-gwa.c" + + +#line 463 "glade-python-gwa.override" +static gboolean +_wrap_GladeWidgetAdaptor__proxy_do_child_verify_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, GValue*value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + PyObject *py_child = NULL; + PyObject *py_property_name; + PyObject *py_value; + gboolean retval; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return FALSE; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_value = pyg_value_as_pyobject(value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + + py_args = PyTuple_New(4); + PyTuple_SET_ITEM(py_args, 0, py_container); + PyTuple_SET_ITEM(py_args, 1, py_child); + PyTuple_SET_ITEM(py_args, 2, py_property_name); + PyTuple_SET_ITEM(py_args, 3, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_child_verify_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + retval = PyObject_IsTrue(py_retval)? TRUE : FALSE; + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + + return retval; +} +#line 861 "glade-python-gwa.c" + + +#line 586 "glade-python-gwa.override" +static void +_wrap_GladeWidgetAdaptor__proxy_do_child_set_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, const GValue *value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + PyObject *py_child = NULL; + PyObject *py_property_name; + PyObject *py_value; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_value = pyg_value_as_pyobject (value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(4); + PyTuple_SET_ITEM(py_args, 0, py_container); + PyTuple_SET_ITEM(py_args, 1, py_child); + PyTuple_SET_ITEM(py_args, 2, py_property_name); + PyTuple_SET_ITEM(py_args, 3, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_child_set_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +#line 963 "glade-python-gwa.c" + + +#line 716 "glade-python-gwa.override" +static void +_wrap_GladeWidgetAdaptor__proxy_do_child_get_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, GValue *value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + PyObject *py_child = NULL; + PyObject *py_property_name; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_container); + PyTuple_SET_ITEM(py_args, 1, py_child); + PyTuple_SET_ITEM(py_args, 2, py_property_name); + + py_method = PyObject_GetAttrString(py_self, "do_child_get_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + pyg_value_from_pyobject (value, py_retval); + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +#line 1043 "glade-python-gwa.c" + + +#line 821 "glade-python-gwa.override" +static GList* +_wrap_GladeWidgetAdaptor__proxy_do_get_children(GladeWidgetAdaptor *self, GObject*container) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + GList* retval; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return NULL; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + + py_args = PyTuple_New(1); + PyTuple_SET_ITEM(py_args, 0, py_container); + + py_method = PyObject_GetAttrString(py_self, "do_get_children"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + + retval = glade_python_support_glist_from_list (py_retval); + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + + return retval; +} +#line 1106 "glade-python-gwa.c" + + +static void +_wrap_GladeWidgetAdaptor__proxy_do_add(GladeWidgetAdaptor *self, GObject*parent, GObject*child) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_parent = NULL; + PyObject *py_child = NULL; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (parent) + py_parent = pygobject_new((GObject *) parent); + else { + Py_INCREF(Py_None); + py_parent = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + + py_args = PyTuple_New(2); + PyTuple_SET_ITEM(py_args, 0, py_parent); + PyTuple_SET_ITEM(py_args, 1, py_child); + + py_method = PyObject_GetAttrString(py_self, "do_add"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +static void +_wrap_GladeWidgetAdaptor__proxy_do_remove(GladeWidgetAdaptor *self, GObject*parent, GObject*child) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_parent = NULL; + PyObject *py_child = NULL; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (parent) + py_parent = pygobject_new((GObject *) parent); + else { + Py_INCREF(Py_None); + py_parent = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + + py_args = PyTuple_New(2); + PyTuple_SET_ITEM(py_args, 0, py_parent); + PyTuple_SET_ITEM(py_args, 1, py_child); + + py_method = PyObject_GetAttrString(py_self, "do_remove"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +static void +_wrap_GladeWidgetAdaptor__proxy_do_replace_child(GladeWidgetAdaptor *self, GObject*container, GObject*old_obj, GObject*new_obj) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + PyObject *py_old = NULL; + PyObject *py_new = NULL; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + if (old_obj) + py_old = pygobject_new((GObject *) old_obj); + else { + Py_INCREF(Py_None); + py_old = Py_None; + } + if (new_obj) + py_new = pygobject_new((GObject *) new_obj); + else { + Py_INCREF(Py_None); + py_new = Py_None; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_container); + PyTuple_SET_ITEM(py_args, 1, py_old); + PyTuple_SET_ITEM(py_args, 2, py_new); + + py_method = PyObject_GetAttrString(py_self, "do_replace_child"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +static void +_wrap_GladeWidgetAdaptor__proxy_do_post_create(GladeWidgetAdaptor *self, GObject*object, GladeCreateReason reason) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_reason; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + py_reason = pyg_enum_from_gtype(GLADE_CREATE_REASON, reason); + if (!py_reason) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(2); + PyTuple_SET_ITEM(py_args, 0, py_object); + PyTuple_SET_ITEM(py_args, 1, py_reason); + + py_method = PyObject_GetAttrString(py_self, "do_post_create"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +static GObject* +_wrap_GladeWidgetAdaptor__proxy_do_get_internal_child(GladeWidgetAdaptor *self, GObject*parent, const gchar*name) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_parent = NULL; + PyObject *py_name; + GObject* retval; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return NULL; + } + if (parent) + py_parent = pygobject_new((GObject *) parent); + else { + Py_INCREF(Py_None); + py_parent = Py_None; + } + py_name = PyString_FromString(name); + if (!py_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_parent); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + + py_args = PyTuple_New(2); + PyTuple_SET_ITEM(py_args, 0, py_parent); + PyTuple_SET_ITEM(py_args, 1, py_name); + + py_method = PyObject_GetAttrString(py_self, "do_get_internal_child"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + if (!PyObject_TypeCheck(py_retval, &PyGObject_Type)) { + PyErr_SetString(PyExc_TypeError, "retval should be a GObject"); + PyErr_Print(); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + retval = (GObject*) pygobject_get(py_retval); + g_object_ref((GObject *) retval); + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + + return retval; +} +static void +_wrap_GladeWidgetAdaptor__proxy_do_launch_editor(GladeWidgetAdaptor *self, GObject*object) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + + py_args = PyTuple_New(1); + PyTuple_SET_ITEM(py_args, 0, py_object); + + py_method = PyObject_GetAttrString(py_self, "do_launch_editor"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} + +static int +__GladeWidgetAdaptor_class_init(gpointer gclass, PyTypeObject *pyclass) +{ + PyObject *o; + GladeWidgetAdaptorClass *klass = GLADE_WIDGET_ADAPTOR_CLASS(gclass); + PyObject *gsignals = PyDict_GetItemString(pyclass->tp_dict, "__gsignals__"); + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_verify_property")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "verify_property"))) + klass->verify_property = _wrap_GladeWidgetAdaptor__proxy_do_verify_property; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_set_property")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "set_property"))) + klass->set_property = _wrap_GladeWidgetAdaptor__proxy_do_set_property; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_get_property")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "get_property"))) + klass->get_property = _wrap_GladeWidgetAdaptor__proxy_do_get_property; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_child_verify_property")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "child_verify_property"))) + klass->child_verify_property = _wrap_GladeWidgetAdaptor__proxy_do_child_verify_property; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_child_set_property")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "child_set_property"))) + klass->child_set_property = _wrap_GladeWidgetAdaptor__proxy_do_child_set_property; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_child_get_property")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "child_get_property"))) + klass->child_get_property = _wrap_GladeWidgetAdaptor__proxy_do_child_get_property; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_get_children")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "get_children"))) + klass->get_children = _wrap_GladeWidgetAdaptor__proxy_do_get_children; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_add")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "add"))) + klass->add = _wrap_GladeWidgetAdaptor__proxy_do_add; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_remove")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "remove"))) + klass->remove = _wrap_GladeWidgetAdaptor__proxy_do_remove; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_replace_child")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "replace_child"))) + klass->replace_child = _wrap_GladeWidgetAdaptor__proxy_do_replace_child; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_post_create")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "post_create"))) + klass->post_create = _wrap_GladeWidgetAdaptor__proxy_do_post_create; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_get_internal_child")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "get_internal_child"))) + klass->get_internal_child = _wrap_GladeWidgetAdaptor__proxy_do_get_internal_child; + + if ((o = PyDict_GetItemString(pyclass->tp_dict, "do_launch_editor")) + && !PyObject_TypeCheck(o, &PyCFunction_Type) + && !(gsignals && PyDict_GetItemString(gsignals, "launch_editor"))) + klass->launch_editor = _wrap_GladeWidgetAdaptor__proxy_do_launch_editor; + return 0; +} + + +/* ----------- functions ----------- */ + +PyMethodDef glade_python_gwa_functions[] = { + { NULL, NULL, 0 } +}; + + +/* ----------- enums and flags ----------- */ + +void +glade_python_gwa_add_constants(PyObject *module, const gchar *strip_prefix) +{ + pyg_enum_add(module, "GladeCreateReason", strip_prefix, GLADE_CREATE_REASON); + + if (PyErr_Occurred()) + PyErr_Print(); +} + +/* initialise stuff extension classes */ +void +glade_python_gwa_register_classes(PyObject *d) +{ + PyObject *module; + + if ((module = PyImport_ImportModule("gobject")) != NULL) { + PyObject *moddict = PyModule_GetDict(module); + + _PyGObject_Type = (PyTypeObject *)PyDict_GetItemString(moddict, "GObject"); + if (_PyGObject_Type == NULL) { + PyErr_SetString(PyExc_ImportError, + "cannot import name GObject from gobject"); + return; + } + } else { + PyErr_SetString(PyExc_ImportError, + "could not import gobject"); + return; + } + + +#line 1673 "glade-python-gwa.c" + pygobject_register_class(d, "GladeWidgetAdaptor", GLADE_TYPE_WIDGET_ADAPTOR, &PyGladeWidgetAdaptor_Type, Py_BuildValue("(O)", &PyGObject_Type)); + pyg_set_object_has_new_constructor(GLADE_TYPE_WIDGET_ADAPTOR); + pyg_register_class_init(GLADE_TYPE_WIDGET_ADAPTOR, __GladeWidgetAdaptor_class_init); +} diff --git a/bindings/python/glade-python-gwa.defs b/bindings/python/glade-python-gwa.defs new file mode 100644 index 00000000..d3d42c80 --- /dev/null +++ b/bindings/python/glade-python-gwa.defs @@ -0,0 +1,161 @@ +; Copyright (C) 2006 Juan Pablo Ugarte. +; +; This program is free software; you can redistribute it and/or modify +; it under the terms of the GNU General Public License as +; published by the Free Software Foundation; either version 2 of the +; License, or (at your option) any later version. +; +; This program is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU General Public License for more details. +; +; You should have received a copy of the GNU General Public License +; along with this program; if not, write to the Free Software +; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +; +; Authors: +; Juan Pablo Ugarte <juanpablougarte@gmail.com> + +(define-object GladeWidgetAdaptor + (parent "GObject") + (c-name "GladeWidgetAdaptor") + (gtype-id "GLADE_TYPE_WIDGET_ADAPTOR") +) + +(define-enum GladeCreateReason + (in-module "Glade") + (c-name "GladeCreateReason") + (gtype-id "GLADE_CREATE_REASON") + (values + '("create-user" "GLADE_CREATE_USER") + '("create-copy" "GLADE_CREATE_COPY") + '("create-load" "GLADE_CREATE_LOAD") + '("create-rebuild" "GLADE_CREATE_REBUILD") + ) +) + +(define-virtual verify_property + (of-object "GladeWidgetAdaptor") + (return-type "gboolean") + (parameters + '("GObject*" "object") + '("const-gchar*" "property_name") + '("const-GValue*" "value") + ) +) + +(define-virtual set_property + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "object") + '("const-gchar*" "property_name") + '("const-GValue*" "value") + ) +) + +(define-virtual get_property + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "object") + '("const-gchar*" "property_name") + '("GValue*" "value") + ) +) + +(define-virtual child_verify_property + (of-object "GladeWidgetAdaptor") + (return-type "gboolean") + (parameters + '("GObject*" "container") + '("GObject*" "child") + '("const-gchar*" "property_name") + '("const-GValue*" "value") + ) +) + +(define-virtual child_set_property + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "container") + '("GObject*" "child") + '("const-gchar*" "property_name") + '("const-GValue*" "value") + ) +) + +(define-virtual child_get_property + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "container") + '("GObject*" "child") + '("const-gchar*" "property_name") + '("GValue*" "value") + ) +) + +(define-virtual get_children + (of-object "GladeWidgetAdaptor") + (return-type "GList*") + (parameters + '("GObject*" "container") + ) +) + +(define-virtual add + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "parent") + '("GObject*" "child") + ) +) + +(define-virtual remove + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "parent") + '("GObject*" "child") + ) +) + +(define-virtual replace_child + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "container") + '("GObject*" "old") + '("GObject*" "new") + ) +) + +(define-virtual post_create + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "object") + '("GladeCreateReason" "reason") + ) +) + +(define-virtual get_internal_child + (of-object "GladeWidgetAdaptor") + (return-type "GObject*") + (parameters + '("GObject*" "parent") + '("const-gchar*" "name") + ) +) + +(define-virtual launch_editor + (of-object "GladeWidgetAdaptor") + (return-type "none") + (parameters + '("GObject*" "object") + ) +) diff --git a/bindings/python/glade-python-gwa.override b/bindings/python/glade-python-gwa.override new file mode 100644 index 00000000..d9ab5093 --- /dev/null +++ b/bindings/python/glade-python-gwa.override @@ -0,0 +1,879 @@ +/* + * Copyright (C) 2006 Juan Pablo Ugarte. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Juan Pablo Ugarte <juanpablougarte@gmail.com> + */ +%% +headers +#include <glade.h> +#include <Python.h> +#include <pygobject.h> + +static gboolean +glade_python_support_init_value (GObject *object, + gboolean is_pack, + const gchar *property_name, + GValue *value) +{ + GladeWidget *widget; + GladeProperty *property; + + if ((widget = glade_widget_get_from_gobject (object)) == NULL) + { + PyErr_Format (PyExc_AssertionError, "GladeWidget != NULL"); + return FALSE; + } + + if (is_pack) + property = glade_widget_get_pack_property (widget, property_name); + else + property = glade_widget_get_property (widget, property_name); + + if (property == NULL) + { + PyErr_Format (PyExc_TypeError, "'%s' does not support %s property `%s'", + glade_widget_get_name (widget), + (is_pack) ? "packing" : "", + property_name); + return FALSE; + } + + g_value_init (value, G_VALUE_TYPE (property->value)); + return TRUE; +} + + +static GList * +glade_python_support_glist_from_list (PyObject *list) +{ + gint i, size = PyList_Size (list); + GList *retval = NULL; + + for (i = 0; i < size; i++) + { + PyObject *val = PyList_GetItem (list, i); + retval = g_list_prepend (retval, pygobject_get(val)); + } + return retval; +} + +static PyObject * +glade_python_support_list_from_glist (GList *list) +{ + PyObject *retval = PyList_New (0);; + + for (; list; list = g_list_next (list)) + { + GObject *obj = list->data; + PyList_Append (retval, Py_BuildValue ("O", pygobject_new (obj))); + } + + return retval; +} + +/* + NOTE: the next functions where created by codegen and adapted to support + GValue* and GList* types. +*/ + +%% +import gobject.GObject as PyGObject_Type +%% +override GladeWidgetAdaptor__do_verify_property kwargs +static PyObject * +_wrap_GladeWidgetAdaptor__do_verify_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", "property_name", "value", NULL }; + PyGObject *self, *object; + char *property_name; + int ret; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!sO:GladeWidgetAdaptor.verify_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (object->obj, FALSE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->verify_property) + ret = GLADE_WIDGET_ADAPTOR_CLASS(klass)->verify_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.verify_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return PyBool_FromLong(ret); + +} +%% +override GladeWidgetAdaptor__proxy_do_verify_property +static gboolean +_wrap_GladeWidgetAdaptor__proxy_do_verify_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, const GValue*value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_property_name; + PyObject *py_value; + gboolean retval; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return FALSE; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_value = pyg_value_as_pyobject(value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_object); + PyTuple_SET_ITEM(py_args, 1, py_property_name); + PyTuple_SET_ITEM(py_args, 2, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_verify_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + retval = PyObject_IsTrue(py_retval)? TRUE : FALSE; + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + + return retval; +} +%% +override GladeWidgetAdaptor__do_set_property kwargs +static PyObject * +_wrap_GladeWidgetAdaptor__do_set_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", "property_name", "value", NULL }; + PyGObject *self, *object; + char *property_name; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!sO:GladeWidgetAdaptor.set_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (object->obj, FALSE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->set_property) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->set_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.set_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} +%% +override GladeWidgetAdaptor__proxy_do_set_property +static void +_wrap_GladeWidgetAdaptor__proxy_do_set_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, const GValue*value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_property_name; + PyObject *py_value; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_value = pyg_value_as_pyobject(value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_object); + PyTuple_SET_ITEM(py_args, 1, py_property_name); + PyTuple_SET_ITEM(py_args, 2, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_set_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +%% +override GladeWidgetAdaptor__do_get_property kwargs +static PyObject * +_wrap_GladeWidgetAdaptor__do_get_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "object", "property_name", NULL }; + PyGObject *self, *object; + char *property_name; + GValue value = {0,}; + PyObject *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!s:GladeWidgetAdaptor.get_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &object, &property_name)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_property) + { + glade_python_support_init_value (object->obj, FALSE, property_name, &value); + GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(object->obj), property_name, &value); + ret = pyg_value_as_pyobject (&value, TRUE); + g_value_unset (&value); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.get_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return ret; +} +%% +override GladeWidgetAdaptor__proxy_do_get_property +static void +_wrap_GladeWidgetAdaptor__proxy_do_get_property(GladeWidgetAdaptor *self, GObject*object, const gchar*property_name, GValue *value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_object = NULL; + PyObject *py_property_name; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (object) + py_object = pygobject_new((GObject *) object); + else { + Py_INCREF(Py_None); + py_object = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_object); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_object); + PyTuple_SET_ITEM(py_args, 1, py_property_name); + + py_method = PyObject_GetAttrString(py_self, "do_get_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + pyg_value_from_pyobject (value, py_retval); + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +%% +override GladeWidgetAdaptor__do_child_verify_property kwargs +static PyObject * +_wrap_GladeWidgetAdaptor__do_child_verify_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", "child", "property_name", "value", NULL }; + PyGObject *self, *container, *child; + char *property_name; + int ret; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!sO:GladeWidgetAdaptor.child_verify_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container, &PyGObject_Type, &child, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (child->obj, TRUE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_verify_property) + ret = GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_verify_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.child_verify_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return PyBool_FromLong(ret); + +} +%% +override GladeWidgetAdaptor__proxy_do_child_verify_property +static gboolean +_wrap_GladeWidgetAdaptor__proxy_do_child_verify_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, GValue*value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + PyObject *py_child = NULL; + PyObject *py_property_name; + PyObject *py_value; + gboolean retval; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return FALSE; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_value = pyg_value_as_pyobject(value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + + py_args = PyTuple_New(4); + PyTuple_SET_ITEM(py_args, 0, py_container); + PyTuple_SET_ITEM(py_args, 1, py_child); + PyTuple_SET_ITEM(py_args, 2, py_property_name); + PyTuple_SET_ITEM(py_args, 3, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_child_verify_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return FALSE; + } + retval = PyObject_IsTrue(py_retval)? TRUE : FALSE; + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + + return retval; +} +%% +override GladeWidgetAdaptor__do_child_set_property kwargs +static PyObject * +_wrap_GladeWidgetAdaptor__do_child_set_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", "child", "property_name", "value", NULL }; + PyGObject *self, *container, *child; + char *property_name; + GValue value = {0,}; + PyObject *val; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!sO:GladeWidgetAdaptor.child_set_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container, &PyGObject_Type, &child, &property_name, &val)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + + glade_python_support_init_value (child->obj, TRUE, property_name, &value); + pyg_value_from_pyobject (&value, val); + + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_set_property) + GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_set_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.child_set_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + Py_INCREF(Py_None); + return Py_None; +} +%% +override GladeWidgetAdaptor__proxy_do_child_set_property +static void +_wrap_GladeWidgetAdaptor__proxy_do_child_set_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, const GValue *value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + PyObject *py_child = NULL; + PyObject *py_property_name; + PyObject *py_value; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_value = pyg_value_as_pyobject (value, TRUE); + if (!py_value) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_property_name); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(4); + PyTuple_SET_ITEM(py_args, 0, py_container); + PyTuple_SET_ITEM(py_args, 1, py_child); + PyTuple_SET_ITEM(py_args, 2, py_property_name); + PyTuple_SET_ITEM(py_args, 3, py_value); + + py_method = PyObject_GetAttrString(py_self, "do_child_set_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + if (py_retval != Py_None) { + if (PyErr_Occurred()) + PyErr_Print(); + PyErr_SetString(PyExc_TypeError, "retval should be None"); + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +%% +override GladeWidgetAdaptor__do_child_get_property kwargs +static PyObject * +_wrap_GladeWidgetAdaptor__do_child_get_property(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", "child", "property_name", NULL }; + PyGObject *self, *container, *child; + char *property_name; + PyObject *ret; + GValue value = { 0, } ; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!O!s:GladeWidgetAdaptor.child_get_property", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container, &PyGObject_Type, &child, &property_name)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property) + { + glade_python_support_init_value (child->obj, TRUE, property_name, &value); + GLADE_WIDGET_ADAPTOR_CLASS(klass)->child_get_property(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj), G_OBJECT(child->obj), property_name, &value); + ret = pyg_value_as_pyobject (&value, TRUE); + g_value_unset (&value); + } + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.child_get_property not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + return ret; +} +%% +override GladeWidgetAdaptor__proxy_do_child_get_property +static void +_wrap_GladeWidgetAdaptor__proxy_do_child_get_property(GladeWidgetAdaptor *self, GObject*container, GObject*child, const gchar*property_name, GValue *value) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + PyObject *py_child = NULL; + PyObject *py_property_name; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + if (child) + py_child = pygobject_new((GObject *) child); + else { + Py_INCREF(Py_None); + py_child = Py_None; + } + py_property_name = PyString_FromString(property_name); + if (!py_property_name) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_child); + Py_DECREF(py_container); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + py_args = PyTuple_New(3); + PyTuple_SET_ITEM(py_args, 0, py_container); + PyTuple_SET_ITEM(py_args, 1, py_child); + PyTuple_SET_ITEM(py_args, 2, py_property_name); + + py_method = PyObject_GetAttrString(py_self, "do_child_get_property"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return; + } + + pyg_value_from_pyobject (value, py_retval); + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); +} +%% +override GladeWidgetAdaptor__do_get_children kwargs +static PyObject * +_wrap_GladeWidgetAdaptor__do_get_children(PyObject *cls, PyObject *args, PyObject *kwargs) +{ + gpointer klass; + static char *kwlist[] = { "self", "container", NULL }; + PyGObject *self, *container; + PyObject *list; + GList *ret; + + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O!:GladeWidgetAdaptor.get_children", kwlist, &PyGladeWidgetAdaptor_Type, &self, &PyGObject_Type, &container)) + return NULL; + klass = g_type_class_ref(pyg_type_from_object(cls)); + if (GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_children) + ret = GLADE_WIDGET_ADAPTOR_CLASS(klass)->get_children(GLADE_WIDGET_ADAPTOR(self->obj), G_OBJECT(container->obj)); + else { + PyErr_SetString(PyExc_NotImplementedError, "virtual method GladeWidgetAdaptor.get_children not implemented"); + g_type_class_unref(klass); + return NULL; + } + g_type_class_unref(klass); + + list = glade_python_support_list_from_glist (ret); + g_list_free (ret); + return list; +} +%% +override GladeWidgetAdaptor__proxy_do_get_children +static GList* +_wrap_GladeWidgetAdaptor__proxy_do_get_children(GladeWidgetAdaptor *self, GObject*container) +{ + PyGILState_STATE __py_state; + PyObject *py_self; + PyObject *py_container = NULL; + GList* retval; + PyObject *py_retval; + PyObject *py_args; + PyObject *py_method; + + __py_state = pyg_gil_state_ensure(); + py_self = pygobject_new((GObject *) self); + if (!py_self) { + if (PyErr_Occurred()) + PyErr_Print(); + pyg_gil_state_release(__py_state); + return NULL; + } + if (container) + py_container = pygobject_new((GObject *) container); + else { + Py_INCREF(Py_None); + py_container = Py_None; + } + + py_args = PyTuple_New(1); + PyTuple_SET_ITEM(py_args, 0, py_container); + + py_method = PyObject_GetAttrString(py_self, "do_get_children"); + if (!py_method) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + py_retval = PyObject_CallObject(py_method, py_args); + if (!py_retval) { + if (PyErr_Occurred()) + PyErr_Print(); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + return NULL; + } + + retval = glade_python_support_glist_from_list (py_retval); + + Py_DECREF(py_retval); + Py_DECREF(py_method); + Py_DECREF(py_args); + Py_DECREF(py_self); + pyg_gil_state_release(__py_state); + + return retval; +} diff --git a/bindings/python/glade-python.c b/bindings/python/glade-python.c new file mode 100644 index 00000000..5e98e531 --- /dev/null +++ b/bindings/python/glade-python.c @@ -0,0 +1,626 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * Copyright (C) 2006 Juan Pablo Ugarte. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Authors: + * Juan Pablo Ugarte <juanpablougarte@gmail.com> + */ + +#include <config.h> + + +#include <glade.h> +#include <glade-binding.h> + +#include <Python.h> +#include <pygobject.h> + + +static GtkTextBuffer *PythonBuffer = NULL; +static GtkTextMark *PythonBufferEnd; + +static PyObject *glade, *glade_dict, *GladeError, *GladeStdout, *GladeStderr; + +static PyObject * +glade_python_undo (PyObject *self, PyObject *args) +{ + glade_app_command_undo (); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_redo (PyObject *self, PyObject *args) +{ + glade_app_command_redo (); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_project_new (PyObject *self, PyObject *args) +{ + glade_app_add_project (glade_project_new (TRUE)); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_project_open (PyObject *self, PyObject *args) +{ + gchar *path; + + Py_INCREF(Py_None); + + if (PyArg_ParseTuple(args, "s", &path)) + { + GladeProject *project; + + if ((project = glade_app_get_project_by_path (path))) + glade_app_set_project (project); + else if ((project = glade_project_open (path))) + glade_app_add_project (project); + else + return Py_None; + } + + return Py_None; +} + +static PyObject * +glade_python_project_save (PyObject *self, PyObject *args) +{ + gchar *path; + + if (PyArg_ParseTuple(args, "s", &path)) + glade_project_save (glade_app_get_project (), path, NULL); + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_project_close (PyObject *self, PyObject *args) +{ + gchar *path; + + if (PyArg_ParseTuple(args, "s", &path)) + { + GladeProject *project = glade_app_get_project_by_path (path); + if (project) glade_app_remove_project (project); + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_project_get (PyObject *self, PyObject *args) +{ + GladeProject *project = glade_app_get_project (); + return Py_BuildValue ("s", (project) ? project->name : ""); +} + +static PyObject * +glade_python_project_list (PyObject *self, PyObject *args) +{ + GList *p, *projects = glade_app_get_projects (); + PyObject *list; + + list = PyList_New (0); + + for (p = projects; p && p->data; p = g_list_next (p)) + { + GladeProject *project = p->data; + PyList_Append (list, Py_BuildValue ("s", project->name)); + } + + return list; +} + +static PyObject * +glade_python_project_set (PyObject *self, PyObject *args) +{ + gchar *path; + + if (PyArg_ParseTuple(args, "s", &path)) + { + GladeProject *project = glade_app_get_project_by_path (path); + if (project) glade_app_set_project (project); + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_widget_new (PyObject *self, PyObject *args) +{ + GladeProject *project = glade_app_get_project (); + GladeWidgetAdaptor *adaptor; + GladeWidget *widget = NULL; + gchar *class_name, *parent; + + if (project && PyArg_ParseTuple(args, "ss", &class_name, &parent) && + (adaptor = glade_widget_adaptor_get_by_name (class_name))) + widget = glade_command_create (adaptor, + glade_project_get_widget_by_name (project, parent), + NULL, project); + + return Py_BuildValue ("s", (widget) ? widget->name : ""); +} + +static PyObject * +glade_python_widget_delete (PyObject *self, PyObject *args) +{ + GladeProject *project = glade_app_get_project (); + gchar *name; + + if (project && PyArg_ParseTuple(args, "s", &name)) + { + GladeWidget *widget; + if ((widget = glade_project_get_widget_by_name (project, name))) + { + GList list; + list.data = widget; + list.next = list.prev = NULL; + glade_command_delete (&list); + } + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_widget_set (PyObject *self, PyObject *args) +{ + GladeProject *project = glade_app_get_project (); + gchar *name, *id_property; + PyObject *val; + + if (project && PyArg_ParseTuple(args, "ssO", &name, &id_property, &val)) + { + GladeWidget *widget; + GladeProperty *property; + + if ((widget = glade_project_get_widget_by_name (project, name)) && + (property = glade_widget_get_property (widget, id_property))) + { + GValue value = {0,}; + g_value_init (&value, G_VALUE_TYPE (property->value)); + if (pyg_value_from_pyobject (&value, val) == 0) + glade_command_set_property_value (property, &value); + } + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_widget_get (PyObject *self, PyObject *args) +{ + GladeProject *project = glade_app_get_project (); + gchar *name, *id_property; + + if (project && PyArg_ParseTuple(args, "ss", &name, &id_property)) + { + GladeWidget *widget; + GladeProperty *property; + + if ((widget = glade_project_get_widget_by_name (project, name)) && + (property = glade_widget_get_property (widget, id_property))) + return pyg_value_as_pyobject (property->value, TRUE); + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_widget_list (PyObject *self, PyObject *args) +{ + GList *p; + GladeProject *project = glade_app_get_project (); + PyObject *list; + + list = PyList_New (0); + + for (p = project->objects; p && p->data; p = g_list_next (p)) + { + GladeWidget *widget = glade_widget_get_from_gobject (p->data); + if (widget) + PyList_Append (list, Py_BuildValue ("s", glade_widget_get_name (widget))); + } + + return list; +} + +extern PyTypeObject PyGladeWidgetAdaptor_Type; + +static GHashTable *registered_classes = NULL; + +static PyTypeObject * +glade_python_register_class (GType type) +{ + GType parent = g_type_parent (type); + PyTypeObject *klass, *parent_class; + + if (parent == 0 || type == GLADE_TYPE_WIDGET_ADAPTOR) + return &PyGladeWidgetAdaptor_Type; + + if (g_hash_table_lookup (registered_classes, GUINT_TO_POINTER (parent)) == NULL) + parent_class = glade_python_register_class (parent); + else + parent_class = pygobject_lookup_class (parent); + + klass = pygobject_lookup_class (type); + + pygobject_register_class (glade_dict, g_type_name (type), type, klass, + Py_BuildValue("(O)", parent_class)); + pyg_set_object_has_new_constructor (type); + + g_hash_table_insert (registered_classes, GUINT_TO_POINTER (type), klass); + + return klass; +} + +static PyObject * +glade_python_get_adaptor_for_type (PyObject *self, PyObject *args) +{ + GladeWidgetAdaptor *adaptor; + PyObject *klass; + gchar *name; + + if (PyArg_ParseTuple(args, "s", &name) && + (adaptor = glade_widget_adaptor_get_by_name (name))) + { + GType type = G_TYPE_FROM_INSTANCE (adaptor); + + if ((klass = g_hash_table_lookup (registered_classes, GUINT_TO_POINTER (type)))) + return (PyObject *) klass; + else + return (PyObject *) glade_python_register_class (type); + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyMethodDef GladeMethods[] = { + {"undo", glade_python_undo, METH_VARARGS, "Execute undo command."}, + {"redo", glade_python_redo, METH_VARARGS, "Execute redo command."}, + {"project_new", glade_python_project_new, METH_VARARGS, "Create a new project."}, + {"project_open", glade_python_project_open, METH_VARARGS, "Open an existing project."}, + {"project_save", glade_python_project_save, METH_VARARGS, "Save the current project."}, + {"project_close", glade_python_project_close, METH_VARARGS, "Close the current project."}, + {"project_get", glade_python_project_get, METH_VARARGS, "Get the current project."}, + {"project_set", glade_python_project_set, METH_VARARGS, "Set the current project."}, + {"project_list", glade_python_project_list, METH_VARARGS, "List all projects."}, + {"widget_new", glade_python_widget_new, METH_VARARGS, "Create a new GtkWidget."}, + {"widget_delete", glade_python_widget_delete, METH_VARARGS, "Delete a GtkWidget."}, + {"widget_set", glade_python_widget_set, METH_VARARGS, "Set a GtkWidget's property."}, + {"widget_get", glade_python_widget_get, METH_VARARGS, "Get a GtkWidget's property."}, + {"widget_list", glade_python_widget_list, METH_VARARGS, "List all widgets."}, + {"get_adaptor_for_type", glade_python_get_adaptor_for_type, METH_VARARGS, "Get the corresponding GladeWidgetAdaptor. Use this function to create your own derived Adaptor."}, + {NULL, NULL, 0, NULL} +}; + +/* GladeStdout GladeStderr write method */ +static PyObject * +glade_python_std_write (PyObject *self, PyObject *args, gboolean stdout) +{ + gchar *string; + + if (PythonBuffer && PyArg_ParseTuple(args, "s", &string)) + { + GtkTextIter iter; + gtk_text_buffer_get_end_iter (PythonBuffer, &iter); + if (stdout) + gtk_text_buffer_insert (PythonBuffer, &iter, string, -1); + else + gtk_text_buffer_insert_with_tags_by_name (PythonBuffer, + &iter, string, -1, "red_foreground", NULL); + } + + Py_INCREF(Py_None); + return Py_None; +} + +static PyObject * +glade_python_stdout_write (PyObject *self, PyObject *args) +{ + return glade_python_std_write (self, args, TRUE); +} +static PyObject * +glade_python_stderr_write (PyObject *self, PyObject *args) +{ + return glade_python_std_write (self, args, FALSE); +} + +static PyMethodDef GladeStdoutMethods[] = { + {"write", glade_python_stdout_write, METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} +}; + +static PyMethodDef GladeStderrMethods[] = { + {"write", glade_python_stderr_write, METH_VARARGS, NULL}, + {NULL, NULL, 0, NULL} +}; + +/* Bindings */ +void +glade_python_binding_finalize (GladeBindingCtrl *ctrl) +{ + if (PythonBuffer) + { + Py_Finalize (); + g_object_unref (PythonBuffer); + } +} + +void +glade_python_binding_library_load (const gchar *library) +{ + gchar *str = g_strdup_printf ("import %s;", library); + PyRun_SimpleString (str); + g_free (str); +} + +gint +glade_python_binding_run_script (const gchar *path, gchar **argv) +{ + FILE *fp = fopen (path, "r"); + gint retval, i; + + if (fp == NULL) return -1; + + PyRun_SimpleString ("sys.argv = [];"); + + if (argv) + { + GString *string = g_string_new (""); + + for (i = 0; argv[i]; i++) + { + g_string_printf (string, "sys.argv += ['%s'];", argv[i]); + PyRun_SimpleString (string->str); + } + + g_string_free (string, TRUE); + } + + retval = PyRun_SimpleFile (fp, path); + fclose (fp); + + return retval; +} + +static void +glade_python_console_entry_activate (GtkEntry *entry, GtkTextView *textview) +{ + const gchar *command = gtk_entry_get_text (entry); + GtkTextIter iter; + + gtk_text_buffer_get_end_iter (PythonBuffer, &iter); + gtk_text_buffer_insert_with_tags_by_name (PythonBuffer, &iter, ">>> ", -1, + "blue_foreground", NULL); + gtk_text_buffer_get_end_iter (PythonBuffer, &iter); + gtk_text_buffer_insert_with_tags_by_name (PythonBuffer, &iter, command, -1, + "blue_foreground", NULL); + gtk_text_buffer_get_end_iter (PythonBuffer, &iter); + gtk_text_buffer_insert (PythonBuffer, &iter, "\n", -1); + + if (PyRun_SimpleString (command) == 0) gtk_entry_set_text (entry, ""); +} + +static void +glade_python_buffer_changed (GtkTextBuffer *buffer, GtkTextView *textview) +{ + gtk_text_view_scroll_to_mark (textview, PythonBufferEnd, 0.0, TRUE, 0.0, 1.0); +} + +static void +glade_python_textview_destroy (GtkObject *object, gpointer data) +{ + g_signal_handler_disconnect (PythonBuffer, GPOINTER_TO_UINT (data)); +} + +GtkWidget * +glade_python_binding_console_new (void) +{ + GtkWidget *vbox, *hbox, *textview, *label, *entry, *sw; + gulong handler_id; + + vbox = gtk_vbox_new (FALSE, 4); + gtk_container_set_border_width (GTK_CONTAINER (vbox), + GLADE_GENERIC_BORDER_WIDTH); + + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), + GTK_SHADOW_ETCHED_IN); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_box_pack_start (GTK_BOX (vbox), sw, TRUE, TRUE, 0); + + textview = gtk_text_view_new_with_buffer (PythonBuffer); + gtk_text_view_set_editable (GTK_TEXT_VIEW (textview), FALSE); + gtk_text_view_set_cursor_visible (GTK_TEXT_VIEW (textview), FALSE); + gtk_container_add (GTK_CONTAINER (sw), textview); + handler_id = g_signal_connect (PythonBuffer, "changed", + G_CALLBACK (glade_python_buffer_changed), + GTK_TEXT_VIEW (textview)); + g_signal_connect (textview, "destroy", + G_CALLBACK (glade_python_textview_destroy), + GUINT_TO_POINTER (handler_id)); + + hbox = gtk_hbox_new (FALSE, 4); + gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); + + label = gtk_label_new (">>>"); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + entry = gtk_entry_new (); + g_signal_connect (entry, "activate", + G_CALLBACK (glade_python_console_entry_activate), + GTK_TEXT_VIEW (textview)); + gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, TRUE, 0); + + gtk_widget_show (textview); + gtk_widget_show (label); + gtk_widget_show (entry); + gtk_widget_show (hbox); + gtk_widget_show (sw); + + return vbox; +} + +/* + Generated by pygtk-codegen-2.0 + pygtk-codegen-2.0 -p glade_python_gwa -o glade-python-gwa.override glade-python-gwa.defs > glade-python-gwa.c +*/ +void glade_python_gwa_register_classes (PyObject *d); + +static void +glade_python_init (void) +{ + char *argv[2] = {"", NULL}; + + /* Init interpreter */ + Py_Initialize (); + PySys_SetArgv (1, argv); +} + +static void +glade_python_init_pygtk_check (gint req_major, gint req_minor, gint req_micro) +{ + PyObject *gobject, *mdict, *version; + int found_major, found_minor, found_micro; + + init_pygobject(); + + gobject = PyImport_ImportModule("gobject"); + mdict = PyModule_GetDict(gobject); + version = PyDict_GetItemString(mdict, "pygtk_version"); + if (!version) + { + PyErr_SetString(PyExc_ImportError, "PyGObject version too old"); + return; + } + if (!PyArg_ParseTuple(version, "iii", &found_major, &found_minor, &found_micro)) + return; + if (req_major != found_major || req_minor > found_minor || + (req_minor == found_minor && req_micro > found_micro)) + { + PyErr_Format(PyExc_ImportError, + "PyGObject version mismatch, %d.%d.%d is required, " + "found %d.%d.%d.", req_major, req_minor, req_micro, + found_major, found_minor, found_micro); + return; + } +} + +gboolean +glade_binding_init (GladeBindingCtrl *ctrl) +{ + GtkTextIter iter; + gchar *command; + + if (PythonBuffer == NULL) + { + PythonBuffer = gtk_text_buffer_new (NULL); + gtk_text_buffer_create_tag (PythonBuffer, "blue_foreground", + "foreground", "blue", NULL); + gtk_text_buffer_create_tag (PythonBuffer, "red_foreground", + "foreground", "red", NULL); + gtk_text_buffer_get_end_iter (PythonBuffer, &iter); + PythonBufferEnd = gtk_text_buffer_create_mark (PythonBuffer, NULL, &iter, FALSE); + } + else return FALSE; + + Py_SetProgramName (PACKAGE_NAME); + + /* Initialize the Python interpreter */ + glade_python_init (); + + /* Check and init pygobject >= 2.12.0 */ + PyErr_Clear (); + glade_python_init_pygtk_check (PYGTK_REQ_MAYOR, PYGTK_REQ_MINOR, PYGTK_REQ_MICRO); + if (PyErr_Occurred ()) + { + g_warning ("Unable to load pygobject module >= %d.%d.%d, " + "please make sure it is in python's path (sys.path). " + "(use PYTHONPATH env variable to specify non default paths)", + PYGTK_REQ_MAYOR, PYGTK_REQ_MINOR, PYGTK_REQ_MICRO); + PyErr_Clear (); + Py_Finalize (); + g_object_unref (PythonBuffer); + return FALSE; + } + + pyg_disable_warning_redirections (); + + /* Create glade object */ + glade = Py_InitModule ("glade", GladeMethods); + GladeError = PyErr_NewException ("glade.error", NULL, NULL); + Py_INCREF (GladeError); + PyModule_AddObject (glade, "error", GladeError); + + /* Create GladeStdout and GladeStderr objects */ + GladeStdout = Py_InitModule ("stdout", GladeStdoutMethods); + PySys_SetObject("stdout", GladeStdout); + + GladeStderr = Py_InitModule ("stderr", GladeStderrMethods); + PySys_SetObject("stderr", GladeStderr); + + /* Register GladeUI classes (GladeWidgetAdaptor) */ + glade_dict = PyModule_GetDict (glade); + glade_python_gwa_register_classes (glade_dict); + + /* Create registered_classes hash table */ + registered_classes = g_hash_table_new (g_direct_hash, g_direct_equal); + + /* Insert GladeWidgetAdaptor class in the hash table */ + g_hash_table_insert (registered_classes, + GUINT_TO_POINTER (GLADE_TYPE_WIDGET_ADAPTOR), + &PyGladeWidgetAdaptor_Type); + + /* Import glade module and set path */ + command = g_strdup_printf ("import sys; import glade; sys.path+=['.', '%s'];\n", + glade_modules_dir); + PyRun_SimpleString (command); + g_free (command); + + gtk_text_buffer_get_end_iter (PythonBuffer, &iter); + gtk_text_buffer_insert_with_tags_by_name (PythonBuffer, &iter, + ">>> import sys;\n>>> import glade;\n", + -1, "blue_foreground", NULL); + + /* Setup ctrl members */ + ctrl->name = "python"; + ctrl->finalize = glade_python_binding_finalize; + ctrl->library_load = glade_python_binding_library_load; + ctrl->run_script = glade_python_binding_run_script; + ctrl->console_new = glade_python_binding_console_new; + + return TRUE; +} |