summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gui/core/items.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/gui/core/items.c')
-rw-r--r--plugins/pychrysalide/gui/core/items.c135
1 files changed, 53 insertions, 82 deletions
diff --git a/plugins/pychrysalide/gui/core/items.c b/plugins/pychrysalide/gui/core/items.c
index bc5bbd6..f60cd93 100644
--- a/plugins/pychrysalide/gui/core/items.c
+++ b/plugins/pychrysalide/gui/core/items.c
@@ -71,6 +71,16 @@ static PyObject *py_items_change_current_content(PyObject *self, PyObject *args)
GLoadedContent *content; /* Instance GLib correspondante*/
int ret; /* Bilan de lecture des args. */
+#define ITEMS_CHANGE_CURRENT_CONTENT_METHOD PYTHON_METHOD_DEF \
+( \
+ change_current_content, "content", \
+ METH_VARARGS, py_items, \
+ "Change the current loaded content in the GUI." \
+ "\n" \
+ "The new content has to be a pychrysalide.analysis.LoadedContent" \
+ " instance." \
+)
+
ret = PyArg_ParseTuple(args, "O&", convert_to_loaded_content, &content);
if (!ret) return NULL;
@@ -99,6 +109,16 @@ static PyObject *py_items_change_current_view(PyObject *self, PyObject *args)
GLoadedPanel *panel; /* Instance GLib correspondante*/
int ret; /* Bilan de lecture des args. */
+#define ITEMS_CHANGE_CURRENT_VIEW_METHOD PYTHON_METHOD_DEF \
+( \
+ change_current_view, "view", \
+ METH_VARARGS, py_items, \
+ "Change the current view in the GUI." \
+ "\n" \
+ "The new content has to be a pychrysalide.glibext.LoadedPanel" \
+ " instance." \
+)
+
ret = PyArg_ParseTuple(args, "O&", convert_to_loaded_panel, &panel);
if (!ret) return NULL;
@@ -127,6 +147,16 @@ static PyObject *py_items_update_current_view(PyObject *self, PyObject *args)
GLoadedPanel *panel; /* Instance GLib correspondante*/
int ret; /* Bilan de lecture des args. */
+#define ITEMS_UPDATE_CURRENT_VIEW_METHOD PYTHON_METHOD_DEF \
+( \
+ update_current_view, "view", \
+ METH_VARARGS, py_items, \
+ "Update the current view in the GUI." \
+ "\n" \
+ "The new view has to be a pychrysalide.glibext.LoadedPanel" \
+ " instance." \
+)
+
ret = PyArg_ParseTuple(args, "O&", convert_to_loaded_panel, &panel);
if (!ret) return NULL;
@@ -137,8 +167,6 @@ static PyObject *py_items_update_current_view(PyObject *self, PyObject *args)
}
-
-
/******************************************************************************
* *
* Paramètres : self = classe représentant un binaire. *
@@ -157,6 +185,16 @@ static PyObject *py_items_update_project(PyObject *self, PyObject *args)
GStudyProject *project; /* Instance GLib correspondante*/
int ret; /* Bilan de lecture des args. */
+#define ITEMS_UPDATE_PROJECT_METHOD PYTHON_METHOD_DEF \
+( \
+ update_project, "project", \
+ METH_VARARGS, py_items, \
+ "Update the GUI for the current project." \
+ "\n" \
+ "The provided project has to be an instance (or a subclass)" \
+ " of pychrysalide.analysis.StudyProject." \
+)
+
ret = PyArg_ParseTuple(args, "O&", convert_to_study_project, &project);
if (!ret) return NULL;
@@ -171,70 +209,7 @@ static PyObject *py_items_update_project(PyObject *self, PyObject *args)
* *
* Paramètres : - *
* *
-* Description : Fournit un accès à une définition de type à diffuser. *
-* *
-* Retour : Définition d'objet pour Python. *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-PyTypeObject *get_python_items_type(void)
-{
- static PyMethodDef py_items_methods[] = {
- {
- "change_current_content", py_items_change_current_content,
- METH_VARARGS | METH_STATIC,
- "change_current_content($self, content/)\n--\n\nChange the current loaded content in the GUI."
- },
- {
- "change_current_view", py_items_change_current_view,
- METH_VARARGS | METH_STATIC,
- "change_current_view($self, view/)\n--\n\nChange the current view in the GUI."
- },
- {
- "update_current_view", py_items_update_current_view,
- METH_VARARGS | METH_STATIC,
- "update_current_view($self, view/)\n--\n\nUpdate the current view in the GUI."
- },
- {
- "update_project", py_items_update_project,
- METH_VARARGS | METH_STATIC,
- "update_project($self, view/)\n--\n\nUpdate the GUI for the current project."
- },
- { NULL }
- };
-
- static PyGetSetDef py_items_getseters[] = {
- { NULL }
- };
-
- static PyTypeObject py_items_type = {
-
- PyVarObject_HEAD_INIT(NULL, 0)
-
- .tp_name = "pychrysalide.gui.core.items",
- .tp_basicsize = sizeof(PyObject),
-
- .tp_flags = Py_TPFLAGS_DEFAULT,
-
- .tp_doc = "Dealing with items of the GUI.",
-
- .tp_methods = py_items_methods,
- .tp_getset = py_items_getseters
-
- };
-
- return &py_items_type;
-
-}
-
-
-/******************************************************************************
-* *
-* Paramètres : module = module dont la définition est à compléter. *
-* *
-* Description : Prend en charge l'objet 'pychrysalide.gui.core.items'. *
+* Description : Définit une extension du module 'gui.core' à compléter. *
* *
* Retour : Bilan de l'opération. *
* *
@@ -242,27 +217,23 @@ PyTypeObject *get_python_items_type(void)
* *
******************************************************************************/
-bool ensure_python_items_is_registered(void)
+bool populate_gui_core_module_with_items(void)
{
- PyTypeObject *type; /* Type Python de 'items' */
+ bool result; /* Bilan à retourner */
PyObject *module; /* Module à recompléter */
- type = get_python_items_type();
-
- if (!PyType_HasFeature(type, Py_TPFLAGS_READY))
- {
- type->tp_new = PyType_GenericNew;
-
- if (PyType_Ready(type) != 0)
- return false;
-
- module = get_access_to_python_module("pychrysalide.gui.core");
+ static PyMethodDef py_items_methods[] = {
+ ITEMS_CHANGE_CURRENT_CONTENT_METHOD,
+ ITEMS_CHANGE_CURRENT_VIEW_METHOD,
+ ITEMS_UPDATE_CURRENT_VIEW_METHOD,
+ ITEMS_UPDATE_PROJECT_METHOD,
+ { NULL }
+ };
- if (!register_python_module_object(module, type))
- return false;
+ module = get_access_to_python_module("pychrysalide.gui.core");
- }
+ result = register_python_module_methods(module, py_items_methods);
- return true;
+ return result;
}