summaryrefslogtreecommitdiff
path: root/plugins/pychrysalide/gui/core/panels.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/pychrysalide/gui/core/panels.c')
-rw-r--r--plugins/pychrysalide/gui/core/panels.c122
1 files changed, 122 insertions, 0 deletions
diff --git a/plugins/pychrysalide/gui/core/panels.c b/plugins/pychrysalide/gui/core/panels.c
new file mode 100644
index 0000000..3b88b18
--- /dev/null
+++ b/plugins/pychrysalide/gui/core/panels.c
@@ -0,0 +1,122 @@
+
+/* Chrysalide - Outil d'analyse de fichiers binaires
+ * panels.c - équivalent Python du fichier "gui/core/panels.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 "panels.h"
+
+
+#include <pygobject.h>
+
+
+#include <core/params.h>
+#include <gui/core/panels.h>
+
+
+#include "../../access.h"
+#include "../../helpers.h"
+#include "../panels/panel.h"
+
+
+
+/* Enregistre un panneau comme partie intégrante de l'éditeur. */
+static PyObject *py_panels_register_item(PyObject *, PyObject *);
+
+
+
+/******************************************************************************
+* *
+* Paramètres : self = objet Python concerné par l'appel. *
+* args = arguments fournis à l'appel. *
+* *
+* Description : Enregistre un panneau comme partie intégrante de l'éditeur. *
+* *
+* Retour : None. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+static PyObject *py_panels_register_item(PyObject *self, PyObject *args)
+{
+ GPanelItem *item; /* Panneau à traiter */
+ GGenConfig *config; /* Configuration à consulter */
+ int ret; /* Bilan de lecture des args. */
+
+ config = NULL;
+
+ ret = PyArg_ParseTuple(args, "O&", convert_to_panel_item, &item);
+ if (!ret) return NULL;
+
+ if (config == NULL)
+ config = get_main_configuration();
+
+ register_panel_item(item, config);
+
+ /**
+ * Si Python ne voit plus la variable représentant le panneau utilisée,
+ * il va la supprimer, ce qui va supprimer le composant GTK.
+ *
+ * On sera donc en situation de Use-After-Free, dont les conséquences
+ * arrivent très vite.
+ */
+ pygobject_new(G_OBJECT(item));
+
+ Py_RETURN_NONE;
+
+}
+
+
+/******************************************************************************
+* *
+* Paramètres : - *
+* *
+* Description : Définit une extension du module 'gui.core' à compléter. *
+* *
+* Retour : Bilan de l'opération. *
+* *
+* Remarques : - *
+* *
+******************************************************************************/
+
+bool populate_gui_core_module_with_panels(void)
+{
+ bool result; /* Bilan à retourner */
+ PyObject *module; /* Module à recompléter */
+
+ static PyMethodDef py_panels_methods[] = {
+
+ { "register_panel", py_panels_register_item,
+ METH_VARARGS,
+ "register_panel(item, config, /)\n--\n\nRegister a panel for the GUI."
+ },
+ { NULL }
+
+ };
+
+ module = get_access_to_python_module("pychrysalide.gui.core");
+
+ result = register_python_module_methods(module, py_panels_methods);
+
+ return result;
+
+}