/* Chrysalide - Outil d'analyse de fichiers binaires * panels.c - équivalent Python du fichier "gui/core/panels.c" * * Copyright (C) 2018-2020 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 #include #include #include "../panel.h" #include "../../access.h" #include "../../helpers.h" /* Enregistre un panneau comme partie intégrante de l'éditeur. */ static PyObject *py_panels_register_panel(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_panel(PyObject *self, PyObject *args) { GPanelItem *item; /* Panneau à traiter */ GGenConfig *config; /* Configuration à consulter */ int ret; /* Bilan de lecture des args. */ #define PANELS_REGISTER_PANEL_METHOD PYTHON_METHOD_DEF \ ( \ register_panel, "panel", \ METH_VARARGS, py_panels, \ "Register a panel for the GUI." \ "\n" \ "The provided panel has to be a pychrysalide.gui.PanelItem" \ " instance." \ ) 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[] = { PANELS_REGISTER_PANEL_METHOD, { NULL } }; module = get_access_to_python_module("pychrysalide.gui.core"); result = register_python_module_methods(module, py_panels_methods); return result; }