/* Chrysalide - Outil d'analyse de fichiers binaires * core-ui.c - présentation de notes sous forme de texte et de code Python * * Copyright (C) 2025 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 Chrysalide. If not, see . */ #include "core-ui.h" #include #include #include #include "core-ui-int.h" #include "panel.h" #include "params.h" /* ---------------------- COMPOSITION DE NOUVEAU GREFFON NATIF ---------------------- */ /* Initialise la classe des recherches et identifications. */ static void g_python_notebook_plugin_ui_class_init(GPythonNotebookPluginUIClass *); /* Initialise une instance de recherches et identifications. */ static void g_python_notebook_plugin_ui_init(GPythonNotebookPluginUI *); /* Supprime toutes les références externes. */ static void g_python_notebook_plugin_ui_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ static void g_python_notebook_plugin_ui_finalize(GObject *); /* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ /* Prend acte de l'activation du greffon. */ static bool g_python_notebook_plugin_ui_enable(GPythonNotebookPluginUI *); /* Prend acte de la désactivation du greffon. */ static bool g_python_notebook_plugin_ui_disable(GPythonNotebookPluginUI *); /* ---------------------------------------------------------------------------------- */ /* COMPOSITION DE NOUVEAU GREFFON NATIF */ /* ---------------------------------------------------------------------------------- */ /* Indique le type défini pour un greffon de liaison Python */ G_DEFINE_TYPE(GPythonNotebookPluginUI, g_python_notebook_plugin_ui, G_TYPE_NATIVE_PLUGIN); NATIVE_PLUGIN_ENTRYPOINT(g_python_notebook_plugin_ui_new); /****************************************************************************** * * * Paramètres : class = classe à initialiser. * * * * Description : Initialise la classe des recherches et identifications. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_python_notebook_plugin_ui_class_init(GPythonNotebookPluginUIClass *class) { GObjectClass *object; /* Autre version de la classe */ GPluginModuleClass *plugin; /* Version parente de la classe*/ object = G_OBJECT_CLASS(class); object->dispose = g_python_notebook_plugin_ui_dispose; object->finalize = g_python_notebook_plugin_ui_finalize; plugin = G_PLUGIN_MODULE_CLASS(class); plugin->enable = (pg_management_fc)g_python_notebook_plugin_ui_enable; plugin->disable = (pg_management_fc)g_python_notebook_plugin_ui_disable; } /****************************************************************************** * * * Paramètres : plugin = instance à initialiser. * * * * Description : Initialise une instance de recherches et identifications. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_python_notebook_plugin_ui_init(GPythonNotebookPluginUI *plugin) { STORE_PLUGIN_ABI(plugin); } /****************************************************************************** * * * Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_python_notebook_plugin_ui_dispose(GObject *object) { G_OBJECT_CLASS(g_python_notebook_plugin_ui_parent_class)->dispose(object); } /****************************************************************************** * * * Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Procède à la libération totale de la mémoire. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void g_python_notebook_plugin_ui_finalize(GObject *object) { G_OBJECT_CLASS(g_python_notebook_plugin_ui_parent_class)->finalize(object); } /****************************************************************************** * * * Paramètres : module = extension vue du système. * * * * Description : Crée un module pour présentation de notes. * * * * Retour : Adresse de la structure mise en place. * * * * Remarques : Le transfert de propriétée du module est total. * * * ******************************************************************************/ GPluginModule *g_python_notebook_plugin_ui_new(GModule *module) { GPythonNotebookPluginUI *result; /* Structure à retourner */ result = g_object_new(G_TYPE_PYTHON_NOTEBOOK_PLUGIN_UI, NULL); if (!g_python_notebook_plugin_ui_create(result, module)) g_clear_object(&result); return G_PLUGIN_MODULE(result); } /****************************************************************************** * * * Paramètres : plugin = instance à initialiser pleinement. * * module = extension vue du système. * * * * Description : Met en place un module pour un module pour présentation. * * * * Retour : Bilan de l'opération. * * * * Remarques : Le transfert de propriétée du module est total. * * * ******************************************************************************/ bool g_python_notebook_plugin_ui_create(GPythonNotebookPluginUI *plugin, GModule *module) { bool result; /* Bilan à retourner */ #ifdef INCLUDE_PYTHON3_BINDINGS # define PG_REQ REQ_LIST("PyChrysalide") #else # define PG_REQ NO_REQ #endif result = g_native_plugin_create(G_NATIVE_PLUGIN(plugin), "PythonNotebook", "Edit notebook with text and code to support binary analysis", PACKAGE_VERSION, CHRYSALIDE_WEBSITE("doc/plugins/pynb"), PG_REQ, module); return result; } /* ---------------------------------------------------------------------------------- */ /* IMPLEMENTATION DES FONCTIONS DE CLASSE */ /* ---------------------------------------------------------------------------------- */ /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * * * * Description : Prend acte de l'activation du greffon. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static bool g_python_notebook_plugin_ui_enable(GPythonNotebookPluginUI *plugin) { bool result; /* Bilan à retourner */ panel_info_t info; /* Infos d'enregistrement */ info.category = "Main"; info.image = "pynb-symbolic"; info.title = _("Python notebook"); info.desc = _("Edit notebook with text and code to support binary analysis"); info.personality = FPP_MAIN_PANEL; info.panel_type = GTK_TYPE_PYTHON_NOTEBOOK_PANEL; info.params_type = GTK_TYPE_PYTHON_NOTEBOOK_PARAMETERS; result = register_framework_panel_definition(&info); return result; } /****************************************************************************** * * * Paramètres : plugin = greffon à manipuler. * * * * Description : Prend acte de la désactivation du greffon. * * * * Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ static bool g_python_notebook_plugin_ui_disable(GPythonNotebookPluginUI *plugin) { bool result; /* Bilan à retourner */ // TODO : unregister result = true; return result; }