/* 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 #include #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) { GLoadedContent *content; /* Instance GLib correspondante*/ int ret; /* Bilan de lecture des args. */ ret = PyArg_ParseTuple(args, "O&", convert_to_loaded_content, &content); if (!ret) return NULL; 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) { GLoadedPanel *panel; /* Instance GLib correspondante*/ int ret; /* Bilan de lecture des args. */ ret = PyArg_ParseTuple(args, "O&", convert_to_loaded_panel, &panel); if (!ret) return NULL; 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) { GLoadedPanel *panel; /* Instance GLib correspondante*/ int ret; /* Bilan de lecture des args. */ ret = PyArg_ParseTuple(args, "O&", convert_to_loaded_panel, &panel); if (!ret) return NULL; 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) { GStudyProject *project; /* Instance GLib correspondante*/ int ret; /* Bilan de lecture des args. */ ret = PyArg_ParseTuple(args, "O&", convert_to_study_project, &project); if (!ret) return NULL; 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 */ 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"); if (!register_python_module_object(module, type)) return false; } return true; }