summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2016-07-30 10:57:08 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2016-07-30 10:57:08 (GMT)
commitfb1d26845908d131b1c92d7d7cd1bc402b656ca4 (patch)
treea6c6a30482ce97dfe7b985116877bb0ce8b7b0a0 /plugins/pychrysa/gtkext
parent7b8eed3f8207fe9b629165f8230e38ee620900ea (diff)
Registered properly the PyGObject wrappers for Python classes.
Diffstat (limited to 'plugins/pychrysa/gtkext')
-rw-r--r--plugins/pychrysa/gtkext/blockview.c15
-rw-r--r--plugins/pychrysa/gtkext/bufferview.c15
-rw-r--r--plugins/pychrysa/gtkext/viewpanel.c16
3 files changed, 10 insertions, 36 deletions
diff --git a/plugins/pychrysa/gtkext/blockview.c b/plugins/pychrysa/gtkext/blockview.c
index 973538b..5b8ab79 100644
--- a/plugins/pychrysa/gtkext/blockview.c
+++ b/plugins/pychrysa/gtkext/blockview.c
@@ -32,6 +32,7 @@
#include "bufferview.h"
+#include "../helpers.h"
@@ -93,25 +94,15 @@ PyTypeObject *get_python_block_view_type(void)
bool register_python_block_view(PyObject *module)
{
PyTypeObject *py_block_view_type; /* Type Python 'BlockView' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_block_view_type = get_python_block_view_type();
- py_block_view_type->tp_base = get_python_buffer_view_type();
- py_block_view_type->tp_basicsize = py_block_view_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_block_view_type) != 0)
+ if (!register_class_for_pygobject(dict, GTK_TYPE_BLOCK_VIEW, py_block_view_type, get_python_buffer_view_type()))
return false;
- Py_INCREF(py_block_view_type);
- ret = PyModule_AddObject(module, "BlockView", (PyObject *)py_block_view_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "BlockView", GTK_TYPE_BLOCK_VIEW, py_block_view_type,
- Py_BuildValue("(O)", py_block_view_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/gtkext/bufferview.c b/plugins/pychrysa/gtkext/bufferview.c
index a8b86e8..00f32bc 100644
--- a/plugins/pychrysa/gtkext/bufferview.c
+++ b/plugins/pychrysa/gtkext/bufferview.c
@@ -32,6 +32,7 @@
#include "viewpanel.h"
+#include "../helpers.h"
@@ -93,25 +94,15 @@ PyTypeObject *get_python_buffer_view_type(void)
bool register_python_buffer_view(PyObject *module)
{
PyTypeObject *py_buffer_view_type; /* Type Python 'Bufferview' */
- int ret; /* Bilan d'un appel */
PyObject *dict; /* Dictionnaire du module */
py_buffer_view_type = get_python_buffer_view_type();
- py_buffer_view_type->tp_base = get_python_view_panel_type();
- py_buffer_view_type->tp_basicsize = py_buffer_view_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_buffer_view_type) != 0)
+ if (!register_class_for_pygobject(dict, GTK_TYPE_BUFFER_VIEW, py_buffer_view_type, get_python_view_panel_type()))
return false;
- Py_INCREF(py_buffer_view_type);
- ret = PyModule_AddObject(module, "Bufferview", (PyObject *)py_buffer_view_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "Bufferview", GTK_TYPE_BUFFER_VIEW, py_buffer_view_type,
- Py_BuildValue("(O)", py_buffer_view_type->tp_base));
-
return true;
}
diff --git a/plugins/pychrysa/gtkext/viewpanel.c b/plugins/pychrysa/gtkext/viewpanel.c
index c031627..f8d6d4e 100644
--- a/plugins/pychrysa/gtkext/viewpanel.c
+++ b/plugins/pychrysa/gtkext/viewpanel.c
@@ -228,7 +228,7 @@ bool register_python_view_panel(PyObject *module)
{
PyTypeObject *py_view_panel_type; /* Type Python 'ViewPanel' */
PyObject *parent_mod; /* Module Python Fixed */
- int ret; /* Bilan d'un appel */
+ PyObject *fixed; /* Module "GtkFixed" */
PyObject *dict; /* Dictionnaire du module */
py_view_panel_type = get_python_view_panel_type();
@@ -236,25 +236,17 @@ bool register_python_view_panel(PyObject *module)
parent_mod = PyImport_ImportModule("gi.repository.Gtk");
if (parent_mod == NULL) return false;
- py_view_panel_type->tp_base = (PyTypeObject *)PyObject_GetAttrString(parent_mod, "Fixed");
+ fixed = PyObject_GetAttrString(parent_mod, "Fixed");
Py_DECREF(parent_mod);
- py_view_panel_type->tp_basicsize = py_view_panel_type->tp_base->tp_basicsize;
+ dict = PyModule_GetDict(module);
- if (PyType_Ready(py_view_panel_type) != 0)
+ if (!register_class_for_pygobject(dict, GTK_TYPE_VIEW_PANEL, py_view_panel_type, (PyTypeObject *)fixed))
return false;
if (!py_view_panel_define_constants(py_view_panel_type))
return false;
- Py_INCREF(py_view_panel_type);
- ret = PyModule_AddObject(module, "ViewPanel", (PyObject *)py_view_panel_type);
- if (ret != 0) return false;
-
- dict = PyModule_GetDict(module);
- pygobject_register_class(dict, "ViewPanel", GTK_TYPE_VIEW_PANEL, py_view_panel_type,
- Py_BuildValue("(O)", py_view_panel_type->tp_base));
-
return true;
}