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.c284
1 files changed, 284 insertions, 0 deletions
diff --git a/plugins/pychrysalide/gui/core/items.c b/plugins/pychrysalide/gui/core/items.c
new file mode 100644
index 0000000..82c2c1c
--- /dev/null
+++ b/plugins/pychrysalide/gui/core/items.c
@@ -0,0 +1,284 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * items.c - équivalent Python du fichier "gui/core/items.c"
+ *
+ * Copyright (C) 2018 Cyrille Bagard
+ *
+ * This file is part of Chrysalide.
+ *
+ * Chrysalide is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Chrysalide is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+
+#include "items.h"
+
+
+#include <pygobject.h>
+
+
+#include <gui/core/items.h>
+
+
+#include "../../access.h"
+#include "../../helpers.h"
+#include "../../analysis/loaded.h"
+#include "../../analysis/project.h"
+#include "../../glibext/loadedpanel.h"
+
+
+
+/* Lance une actualisation du fait d'un changement de contenu. */
+static PyObject *py_items_change_current_content(PyObject *, PyObject *);
+
+/* Lance une actualisation du fait d'un changement de vue. */
+static PyObject *py_items_change_current_view(PyObject *, PyObject *);
+
+/* Lance une actualisation du fait d'un changement de contenu. */
+static PyObject *py_items_update_current_view(PyObject *, PyObject *);
+
+/* Lance une actualisation relative à l'étendue du projet. */
+static PyObject *py_items_update_project(PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe représentant un binaire. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Lance une actualisation du fait d'un changement de contenu. *
+* *
+* Retour : None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_items_change_current_content(PyObject *self, PyObject *args)
+{
+ PyObject *content_obj; /* Objet pour le contenu */
+ int ret; /* Bilan de lecture des args. */
+ GLoadedContent *content; /* Instance GLib correspondante*/
+
+ ret = PyArg_ParseTuple(args, "O!", get_python_loaded_content_type(), &content_obj);
+ if (!ret) return NULL;
+
+ content = G_LOADED_CONTENT(pygobject_get(content_obj));
+
+ change_editor_items_current_content(content);
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe représentant un binaire. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Lance une actualisation du fait d'un changement de vue. *
+* *
+* Retour : None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_items_change_current_view(PyObject *self, PyObject *args)
+{
+ PyObject *panel_obj; /* Objet de panneau chargé */
+ int ret; /* Bilan de lecture des args. */
+ GLoadedPanel *panel; /* Instance GLib correspondante*/
+
+ ret = PyArg_ParseTuple(args, "O!", get_python_loaded_panel_type(), &panel_obj);
+ if (!ret) return NULL;
+
+ panel = G_LOADED_PANEL(pygobject_get(panel_obj));
+
+ change_editor_items_current_view(panel);
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe représentant un binaire. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Lance une actualisation du fait d'un changement de contenu. *
+* *
+* Retour : None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_items_update_current_view(PyObject *self, PyObject *args)
+{
+ PyObject *panel_obj; /* Objet de panneau chargé */
+ int ret; /* Bilan de lecture des args. */
+ GLoadedPanel *panel; /* Instance GLib correspondante*/
+
+ ret = PyArg_ParseTuple(args, "O!", get_python_loaded_panel_type(), &panel_obj);
+ if (!ret) return NULL;
+
+ panel = G_LOADED_PANEL(pygobject_get(panel_obj));
+
+ update_editor_items_current_view(panel);
+
+ Py_RETURN_NONE;
+
+}
+
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = classe représentant un binaire. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Lance une actualisation relative à l'étendue du projet. *
+* *
+* Retour : None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_items_update_project(PyObject *self, PyObject *args)
+{
+ PyObject *project_obj; /* Objet de panneau chargé */
+ int ret; /* Bilan de lecture des args. */
+ GStudyProject *project; /* Instance GLib correspondante*/
+
+ ret = PyArg_ParseTuple(args, "O!", get_python_study_project_type(), &project_obj);
+ if (!ret) return NULL;
+
+ project = G_STUDY_PROJECT(pygobject_get(project_obj));
+
+ update_project_area(project);
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* 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'. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool ensure_python_items_is_registered(void)
+{
+ PyTypeObject *type; /* Type Python de 'items' */
+ PyObject *module; /* Module à recompléter */
+ int ret; /* Bilan d'un appel */
+
+ 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");
+
+ Py_INCREF(type);
+ ret = PyModule_AddObject(module, "items", (PyObject *)type);
+
+ if (ret != 0)
+ return false;
+
+ }
+
+ return true;
+
+}