diff options
Diffstat (limited to 'plugins/pychrysa/gtkext')
-rw-r--r-- | plugins/pychrysa/gtkext/blockview.c | 15 | ||||
-rw-r--r-- | plugins/pychrysa/gtkext/bufferview.c | 15 | ||||
-rw-r--r-- | plugins/pychrysa/gtkext/viewpanel.c | 16 |
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; } |