summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/gtkext
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2017-08-12 15:08:53 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2017-08-12 15:08:53 (GMT)
commitfcc78751e1e733b8662fde7d5e8ac6023cb34582 (patch)
treed57096d898446b6c2387bd2bd7ead0d3f175b617 /plugins/pychrysa/gtkext
parenta9328553fc558bca2e75f2c93b35acc5518d9568 (diff)
Fixed many mistakes in the Python bindings.
Diffstat (limited to 'plugins/pychrysa/gtkext')
-rw-r--r--plugins/pychrysa/gtkext/blockdisplay.c19
-rw-r--r--plugins/pychrysa/gtkext/bufferdisplay.c19
-rw-r--r--plugins/pychrysa/gtkext/displaypanel.c14
3 files changed, 19 insertions, 33 deletions
diff --git a/plugins/pychrysa/gtkext/blockdisplay.c b/plugins/pychrysa/gtkext/blockdisplay.c
index a329daf..c2ccfbb 100644
--- a/plugins/pychrysa/gtkext/blockdisplay.c
+++ b/plugins/pychrysa/gtkext/blockdisplay.c
@@ -66,7 +66,7 @@ PyTypeObject *get_python_block_display_type(void)
.tp_name = "pychrysalide.gtkext.BlockDisplay",
.tp_basicsize = sizeof(PyGObject),
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = "PyChrysalide block display.",
@@ -78,12 +78,7 @@ PyTypeObject *get_python_block_display_type(void)
static PyTypeObject *result = NULL;
if (result == NULL)
- {
- result = calloc(1, sizeof(PyTypeObject));
-
- memcpy(result, &py_block_display_type, sizeof(PyTypeObject));
-
- }
+ result = define_python_dynamic_type(&py_block_display_type);
return result;
@@ -104,17 +99,17 @@ PyTypeObject *get_python_block_display_type(void)
bool register_python_block_display(PyObject *module)
{
- PyTypeObject *py_block_display_type; /* Type Python 'BlockDisplay' */
+ bool result; /* Bilan à retourner */
+ PyTypeObject *py_block_display_type; /* Type Python 'BlockDisplay' */
PyObject *dict; /* Dictionnaire du module */
py_block_display_type = get_python_block_display_type();
dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, GTK_TYPE_BLOCK_DISPLAY,
- py_block_display_type, get_python_buffer_display_type()))
- return false;
+ result = register_class_for_pygobject(dict, GTK_TYPE_BLOCK_DISPLAY,
+ py_block_display_type, get_python_buffer_display_type());
- return true;
+ return result;
}
diff --git a/plugins/pychrysa/gtkext/bufferdisplay.c b/plugins/pychrysa/gtkext/bufferdisplay.c
index a6e5327..9aa1bca 100644
--- a/plugins/pychrysa/gtkext/bufferdisplay.c
+++ b/plugins/pychrysa/gtkext/bufferdisplay.c
@@ -66,7 +66,7 @@ PyTypeObject *get_python_buffer_display_type(void)
.tp_name = "pychrysalide.gtkext.BufferDisplay",
.tp_basicsize = sizeof(PyGObject),
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HEAPTYPE,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = "PyChrysalide buffer display.",
@@ -78,12 +78,7 @@ PyTypeObject *get_python_buffer_display_type(void)
static PyTypeObject *result = NULL;
if (result == NULL)
- {
- result = calloc(1, sizeof(PyTypeObject));
-
- memcpy(result, &py_buffer_display_type, sizeof(PyTypeObject));
-
- }
+ result = define_python_dynamic_type(&py_buffer_display_type);
return result;
@@ -104,17 +99,17 @@ PyTypeObject *get_python_buffer_display_type(void)
bool register_python_buffer_display(PyObject *module)
{
- PyTypeObject *py_buffer_display_type; /* Type Python 'Bufferdisplay' */
+ bool result; /* Bilan à retourner */
+ PyTypeObject *py_buffer_display_type; /* Type Python 'BufferDisplay' */
PyObject *dict; /* Dictionnaire du module */
py_buffer_display_type = get_python_buffer_display_type();
dict = PyModule_GetDict(module);
- if (!register_class_for_pygobject(dict, GTK_TYPE_BUFFER_DISPLAY,
- py_buffer_display_type, get_python_display_panel_type()))
- return false;
+ result = register_class_for_pygobject(dict, GTK_TYPE_BUFFER_DISPLAY,
+ py_buffer_display_type, get_python_display_panel_type());
- return true;
+ return result;
}
diff --git a/plugins/pychrysa/gtkext/displaypanel.c b/plugins/pychrysa/gtkext/displaypanel.c
index e857475..aa166e5 100644
--- a/plugins/pychrysa/gtkext/displaypanel.c
+++ b/plugins/pychrysa/gtkext/displaypanel.c
@@ -197,7 +197,7 @@ PyTypeObject *get_python_display_panel_type(void)
.tp_name = "pychrysalide.gtkext.DisplayPanel",
.tp_basicsize = sizeof(PyGObject),
- .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HEAPTYPE,
+ .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_doc = "PyChrysalide view panel.",
@@ -211,12 +211,7 @@ PyTypeObject *get_python_display_panel_type(void)
static PyTypeObject *result = NULL;
if (result == NULL)
- {
- result = calloc(1, sizeof(PyTypeObject));
-
- memcpy(result, &py_display_panel_type, sizeof(PyTypeObject));
-
- }
+ result = define_python_dynamic_type(&py_display_panel_type);
return result;
@@ -248,7 +243,9 @@ bool register_python_display_panel(PyObject *module)
py_display_panel_type = get_python_display_panel_type();
parent_mod = PyImport_ImportModule("gi.repository.Gtk");
- if (parent_mod == NULL) return false;
+
+ if (parent_mod == NULL)
+ goto rpdp_exit;
fixed = PyObject_GetAttrString(parent_mod, "Fixed");
@@ -258,7 +255,6 @@ bool register_python_display_panel(PyObject *module)
result = register_class_for_pygobject(dict, GTK_TYPE_DISPLAY_PANEL,
py_display_panel_type, (PyTypeObject *)fixed);
-
Py_DECREF(fixed);
if (!result)