summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gui/panels
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/gui/panels')
-rw-r--r--plugins/pychrysalide/gui/panels/module.c50
-rw-r--r--plugins/pychrysalide/gui/panels/module.h7
-rw-r--r--plugins/pychrysalide/gui/panels/panel.c32
-rw-r--r--plugins/pychrysalide/gui/panels/panel.h2
4 files changed, 56 insertions, 35 deletions
diff --git a/plugins/pychrysalide/gui/panels/module.c b/plugins/pychrysalide/gui/panels/module.c
index 21b487e..dd6b91e 100644
--- a/plugins/pychrysalide/gui/panels/module.c
+++ b/plugins/pychrysalide/gui/panels/module.c
@@ -29,62 +29,66 @@
#include "panel.h"
-#include "../../access.h"
+#include "../../helpers.h"
/******************************************************************************
* *
-* Paramètres : module = module dont la définition est à compléter. *
+* Paramètres : super = module dont la définition est à compléter. *
* *
-* Description : Ajoute le module 'gui.panels' au module Python. *
+* Description : Ajoute le module 'gui.panels' à un module Python. *
* *
-* Retour : - *
+* Retour : Bilan de l'opération. *
* *
* Remarques : - *
* *
******************************************************************************/
-bool add_gui_panels_module_to_python_module(PyObject *super)
+bool add_gui_panels_module(PyObject *super)
{
bool result; /* Bilan à retourner */
PyObject *module; /* Sous-module mis en place */
- int ret; /* Bilan d'un appel */
- static PyModuleDef py_chrysalide_panels_module = {
+ static PyModuleDef py_chrysalide_gui_panels_module = {
.m_base = PyModuleDef_HEAD_INIT,
- .m_name = "gui.analysis.panels",
+ .m_name = "pychrysalide.gui.panels",
.m_doc = "Python module for Chrysalide.gui.panels",
.m_size = -1,
};
- result = false;
+ module = build_python_module(super, &py_chrysalide_gui_panels_module);
- module = PyModule_Create(&py_chrysalide_panels_module);
- if (module == NULL) return false;
+ result = (module != NULL);
- ret = PyState_AddModule(super, &py_chrysalide_panels_module);
- if (ret != 0) goto loading_failed;
+ return result;
- ret = _PyImport_FixupBuiltin(module, "pychrysalide.gui.panels");
- if (ret != 0) goto loading_failed;
+}
- Py_INCREF(module);
- ret = PyModule_AddObject(super, "panels", module);
- if (ret != 0) goto loading_failed;
- result = true;
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Intègre les objets du module 'gui.panels'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
- result &= register_python_panel_item(module);
+bool populate_gui_panels_module(void)
+{
+ bool result; /* Bilan à retourner */
- if (result)
- register_access_to_python_module("pychrysalide.gui.panels", module);
+ result = true;
- loading_failed:
+ if (result) result = ensure_python_panel_item_is_registered();
assert(result);
diff --git a/plugins/pychrysalide/gui/panels/module.h b/plugins/pychrysalide/gui/panels/module.h
index 34fac70..559a8c4 100644
--- a/plugins/pychrysalide/gui/panels/module.h
+++ b/plugins/pychrysalide/gui/panels/module.h
@@ -31,8 +31,11 @@
-/* Ajoute le module 'gui.panels' au module Python. */
-bool add_gui_panels_module_to_python_module(PyObject *);
+/* Ajoute le module 'gui.panels' à un module Python. */
+bool add_gui_panels_module(PyObject *);
+
+/* Intègre les objets du module 'gui.panels'. */
+bool populate_gui_panels_module(void);
diff --git a/plugins/pychrysalide/gui/panels/panel.c b/plugins/pychrysalide/gui/panels/panel.c
index 72c9e7e..6613fac 100644
--- a/plugins/pychrysalide/gui/panels/panel.c
+++ b/plugins/pychrysalide/gui/panels/panel.c
@@ -34,6 +34,7 @@
#include "../editem.h"
+#include "../../access.h"
#include "../../helpers.h"
#include "../../gtkext/dockable.h"
@@ -223,21 +224,34 @@ static bool py_panel_item_define_constants(PyTypeObject *obj_type)
* *
******************************************************************************/
-bool register_python_panel_item(PyObject *module)
+bool ensure_python_panel_item_is_registered(void)
{
- PyTypeObject *py_panel_item_type; /* Type Python 'LoadedBinary' */
+ PyTypeObject *type; /* Type Python 'LoadedBinary' */
+ PyObject *module; /* Module à recompléter */
PyObject *dict; /* Dictionnaire du module */
- py_panel_item_type = get_python_panel_item_type();
+ type = get_python_panel_item_type();
- dict = PyModule_GetDict(module);
+ if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
+ {
+ module = get_access_to_python_module("pychrysalide.gui.panels");
- if (!_register_class_for_pygobject(dict, G_TYPE_PANEL_ITEM, py_panel_item_type,
- get_python_editor_item_type(), get_python_gtk_dockable_type(), NULL))
- return false;
+ dict = PyModule_GetDict(module);
- if (!py_panel_item_define_constants(py_panel_item_type))
- return false;
+ if (!ensure_python_editor_item_is_registered())
+ return false;
+
+ if (!ensure_python_gtk_dockable_is_registered())
+ return false;
+
+ if (!_register_class_for_pygobject(dict, G_TYPE_PANEL_ITEM, type,
+ get_python_editor_item_type(), get_python_gtk_dockable_type(), NULL))
+ return false;
+
+ if (!py_panel_item_define_constants(type))
+ return false;
+
+ }
return true;
diff --git a/plugins/pychrysalide/gui/panels/panel.h b/plugins/pychrysalide/gui/panels/panel.h
index f0406d5..7fb473b 100644
--- a/plugins/pychrysalide/gui/panels/panel.h
+++ b/plugins/pychrysalide/gui/panels/panel.h
@@ -35,7 +35,7 @@
PyTypeObject *get_python_panel_item_type(void);
/* Prend en charge l'objet 'pychrysalide.gui.panels.PanelItem'. */
-bool register_python_panel_item(PyObject *);
+bool ensure_python_panel_item_is_registered(void);