summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gui/panels
diff options
context:
space:
mode:
authorCyrille Bagard <nocbos@gmail.com>2019-01-03 23:36:47 (GMT)
committerCyrille Bagard <nocbos@gmail.com>2019-01-03 23:36:47 (GMT)
commit55ccf25e0c6666436f0ecd222e60208ebf6ab30e (patch)
tree21c1ecc9e6d6ae50d0cfb0ffa4eaf61bf78a45a2 /plugins/pychrysalide/gui/panels
parent28bfc34862513acb8fe9fcd02afca493c2411c02 (diff)
Defined a dynamic type for each plugin.
Diffstat (limited to 'plugins/pychrysalide/gui/panels')
-rw-r--r--plugins/pychrysalide/gui/panels/panel.c39
1 files changed, 15 insertions, 24 deletions
diff --git a/plugins/pychrysalide/gui/panels/panel.c b/plugins/pychrysalide/gui/panels/panel.c
index 1df0670..d4062d3 100644
--- a/plugins/pychrysalide/gui/panels/panel.c
+++ b/plugins/pychrysalide/gui/panels/panel.c
@@ -32,11 +32,11 @@
#include <core/params.h>
#include <gui/core/panels.h>
#include <gui/panels/panel-int.h>
+#include <plugins/dt.h>
#include "../editem.h"
#include "../../access.h"
-#include "../../dt.h"
#include "../../helpers.h"
#include "../../gtkext/dockable.h"
@@ -89,18 +89,16 @@ static bool py_panel_item_define_constants(PyTypeObject *);
static PyObject *py_panel_item_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *result; /* Objet à retourner */
- bool abstract; /* Validation du type parent */
+ PyTypeObject *base; /* Type de base à dériver */
+ bool first_time; /* Evite les multiples passages*/
GType gtype; /* Nouveau type de processeur */
- PyObject *sys_mod_dict; /* Dictionnaire des modules */
- PyObject *modname; /* Nom du module du type */
- PyObject *module; /* Module à recompléter */
- PyObject *dict; /* Dictionnaire dudit module */
+ bool status; /* Bilan d'un enregistrement */
/* Validations diverses */
- abstract = (type == get_python_panel_item_type());
+ base = get_python_panel_item_type();
- if (abstract)
+ if (type == base)
{
result = NULL;
PyErr_Format(PyExc_RuntimeError, _("%s is an abstract class"), type->tp_name);
@@ -109,30 +107,23 @@ static PyObject *py_panel_item_new(PyTypeObject *type, PyObject *args, PyObject
/* Mise en place d'un type dédié */
- gtype = built_dynamic_type(G_TYPE_PANEL_ITEM, type->tp_name,
- (GClassInitFunc)py_panel_item_init_gclass);
-
- /* Enregistrement du nouveau GType dans Python */
-
- sys_mod_dict = PyImport_GetModuleDict();
+ first_time = (g_type_from_name(type->tp_name) == 0);
- modname = PyDict_GetItemString(type->tp_dict, "__module__");
-
- module = PyObject_GetItem(sys_mod_dict, modname);
+ gtype = built_dynamic_type(G_TYPE_PANEL_ITEM, type->tp_name,
+ (GClassInitFunc)py_panel_item_init_gclass, NULL);
- dict = PyModule_GetDict(module);
+ if (first_time)
+ status = register_class_for_dynamic_pygobject(gtype, type, base);
+ else
+ status = true;
- if (!_register_class_for_pygobject(dict, gtype, type,
- &PyGObject_Type, get_python_panel_item_type(), NULL))
+ if (!status)
{
result = NULL;
goto exit;
}
- Py_DECREF(module);
- Py_DECREF(modname);
-
- /* On créé, et on laisse ensuite la main à PyGObject_Type.tp_init() */
+ /* On crée, et on laisse ensuite la main à PyGObject_Type.tp_init() */
result = PyType_GenericNew(type, args, kwds);