summaryrefslogtreecommitdiff
path: root/plugins/pychrysa/gui/panels/panel.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysa/gui/panels/panel.c')
-rw-r--r--plugins/pychrysa/gui/panels/panel.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/plugins/pychrysa/gui/panels/panel.c b/plugins/pychrysa/gui/panels/panel.c
index b1bcc61..4b982d0 100644
--- a/plugins/pychrysa/gui/panels/panel.c
+++ b/plugins/pychrysa/gui/panels/panel.c
@@ -40,7 +40,6 @@ static PyObject *py_panel_item_dock(PyObject *, PyObject *);
-
/******************************************************************************
* *
* Paramètres : type = type de l'objet à instancier. *
@@ -71,7 +70,7 @@ static PyObject *py_panel_item_new(PyTypeObject *type, PyObject *args, PyObject
item = g_panel_item_new(get_internal_ref(), name, lname,
GTK_WIDGET(pygobject_get(widget)), path);
- result = py_panel_item_from_c(G_PANEL_ITEM(item));
+ result = _py_panel_item_from_c(G_PANEL_ITEM(item), type);
g_object_unref(item);
return (PyObject *)result;
@@ -79,9 +78,11 @@ static PyObject *py_panel_item_new(PyTypeObject *type, PyObject *args, PyObject
}
+
/******************************************************************************
* *
* Paramètres : item = instance existante GLib. *
+* type = éventuel type final de l'instance Python imposé. *
* *
* Description : Crée un nouvel objet Python de type 'PanelItem'. *
* *
@@ -91,14 +92,16 @@ static PyObject *py_panel_item_new(PyTypeObject *type, PyObject *args, PyObject
* *
******************************************************************************/
-PyObject *py_panel_item_from_c(GPanelItem *item)
+PyObject *_py_panel_item_from_c(GPanelItem *item, PyTypeObject *type)
{
PyObject *module; /* Module d'appartenance */
- PyTypeObject *type; /* Type Python correspondant */
- module = PyImport_ImportModule("pychrysalide.gui.panels");
- type = (PyTypeObject *)PyObject_GetAttrString(module, "PanelItem");
- Py_DECREF(module);
+ if (type == NULL)
+ {
+ module = PyImport_ImportModule("pychrysalide.gui.panels");
+ type = (PyTypeObject *)PyObject_GetAttrString(module, "PanelItem");
+ Py_DECREF(module);
+ }
pychrysalide_set_instance_data(G_OBJECT(item), type);
@@ -128,7 +131,7 @@ static PyObject *py_panel_item_dock(PyObject *self, PyObject *args)
g_panel_item_dock(item);
- return Py_None;
+ Py_RETURN_NONE;
}
@@ -145,8 +148,6 @@ static PyObject *py_panel_item_dock(PyObject *self, PyObject *args)
-
-
/******************************************************************************
* *
* Paramètres : module = module dont la définition est à compléter. *
@@ -161,14 +162,14 @@ static PyObject *py_panel_item_dock(PyObject *self, PyObject *args)
bool register_python_panel_item(PyObject *module)
{
- PyObject *pygobj_mod; /* Module Python-GObject */
+ PyObject *parent_mod; /* Module Python-EditorItem */
int ret; /* Bilan d'un appel */
static PyMethodDef py_panel_item_methods[] = {
{
"dock", (PyCFunction)py_panel_item_dock,
METH_NOARGS,
- "DIsplay the panel item in the right place."
+ "Display the panel item in the right place."
},
{ NULL }
};
@@ -195,11 +196,11 @@ bool register_python_panel_item(PyObject *module)
};
- pygobj_mod = PyImport_ImportModule("gobject");
- if (pygobj_mod == NULL) return false;
+ parent_mod = PyImport_ImportModule("pychrysalide.gui");
+ if (parent_mod == NULL) return false;
- py_panel_item_type.tp_base = (PyTypeObject *)PyObject_GetAttrString(pygobj_mod, "GObject");
- Py_DECREF(pygobj_mod);
+ py_panel_item_type.tp_base = (PyTypeObject *)PyObject_GetAttrString(parent_mod, "EditorItem");
+ Py_DECREF(parent_mod);
if (PyType_Ready(&py_panel_item_type) < 0)
return false;