diff options
60 files changed, 2944 insertions, 2393 deletions
diff --git a/configure.ac b/configure.ac index 63d1bb4..300c970 100644 --- a/configure.ac +++ b/configure.ac @@ -802,6 +802,7 @@ AC_CONFIG_FILES([Makefile plugins/pychrysalide/gui/panels/Makefile plugins/pychrysalide/mangling/Makefile plugins/pychrysalide/plugins/Makefile + plugins/pynb/Makefile plugins/python/Makefile plugins/python/abackup/Makefile plugins/python/apkfiles/Makefile diff --git a/plugins/Makefile.am b/plugins/Makefile.am index 89a8e25..529f4fe 100644 --- a/plugins/Makefile.am +++ b/plugins/Makefile.am @@ -14,7 +14,8 @@ endif # androhelpers SUBDIRS = \ $(PYTHON3_SUBDIRS) \ - pe + pe \ + pynb # arm \ # bootimg \ diff --git a/plugins/pynb/Makefile.am b/plugins/pynb/Makefile.am new file mode 100644 index 0000000..50e549f --- /dev/null +++ b/plugins/pynb/Makefile.am @@ -0,0 +1,77 @@ + +BUILT_SOURCES = resources.h resources.c + + +lib_LTLIBRARIES = libpynbui.la + +libdir = $(pluginslibdir) + + +# if BUILD_PYTHON3_BINDINGS + +# PYTHON3_LIBADD = python/libpynbpython.la + +# if BUILD_DISCARD_LOCAL + +# PYTHON3_LDFLAGS = -Wl,-rpath,$(pluginslibdir) \ +# -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + +# else + +# PYTHON3_LDFLAGS = -Wl,-rpath,$(abs_top_srcdir)/plugins/pychrysalide/.libs \ +# -L$(top_srcdir)/plugins/pychrysalide/.libs -l:pychrysalide.so + +# endif + +# PYTHON3_SUBDIRS = python + +# endif + + +libpynbui_la_SOURCES = \ + core-ui-int.h \ + core-ui.h core-ui.c \ + panel-int.h \ + panel.h panel.c \ + params-int.h \ + params.h params.c \ + prefs-int.h \ + prefs.h prefs.c \ + resources.h resources.c + +libpynbui_la_LIBADD = \ + $(PYTHON3_LIBADD) + +libpynbui_la_CFLAGS = $(LIBGTK4_CFLAGS) + +libpynbui_la_LDFLAGS = \ + $(LIBGTK4_LIBS) $(PYTHON3_LDFLAGS) + + +devdir = $(includedir)/chrysalide-$(subdir) + +dev_HEADERS = $(libpynbui_la_SOURCES:%c=) + + +RES_FILES = \ + panel.ui \ + params.ui \ + prefs.ui \ + data/images/pynb-symbolic.svg + + +resources.c: gresource.xml $(RES_FILES) + glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-source --c-name plugins_pynb gresource.xml + +resources.h: gresource.xml + glib-compile-resources --target=$@ --sourcedir=$(srcdir) --generate-header --c-name plugins_pynb gresource.xml + + +CLEANFILES = resources.h resources.c + +EXTRA_DIST = gresource.xml $(RES_FILES) + + +AM_CPPFLAGS = -I$(top_srcdir)/src $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = $(PYTHON3_SUBDIRS) diff --git a/plugins/pynb/core-ui-int.h b/plugins/pynb/core-ui-int.h new file mode 100644 index 0000000..caf5713 --- /dev/null +++ b/plugins/pynb/core-ui-int.h @@ -0,0 +1,56 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core-ui-int.h - prototypes internes pour le plugin présentant des notes avec 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_PYNB_CORE_UI_INT_H +#define _PLUGINS_PYNB_CORE_UI_INT_H + + +#include <plugins/native-int.h> + + +#include "core-ui.h" + + + +/* Greffon natif pour la présentation de notes avec texte et code Python (instance) */ +struct _GPythonNotebookPluginUI +{ + GNativePlugin parent; /* A laisser en premier */ + +}; + + +/* Greffon natif pour la présentation de notes avec texte et code Python (classe) */ +struct _GPythonNotebookPluginUIClass +{ + GNativePluginClass parent; /* A laisser en premier */ + +}; + + +/* Met en place un module pour un module pour présentation. */ +bool g_python_notebook_plugin_ui_create(GPythonNotebookPluginUI *, GModule *); + + + +#endif /* _PLUGINS_PYNB_CORE_UI_INT_H */ diff --git a/plugins/pynb/core-ui.c b/plugins/pynb/core-ui.c new file mode 100644 index 0000000..dd49a83 --- /dev/null +++ b/plugins/pynb/core-ui.c @@ -0,0 +1,363 @@ + +/* 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 <http://www.gnu.org/licenses/>. + */ + + +#include "core-ui.h" + + +#include <i18n.h> +#include <gui/core/panels.h> +#include <plugins/self.h> +#include <plugins/tweakable-int.h> + + +#include "core-ui-int.h" +#include "panel.h" +#include "params.h" +#include "prefs.h" + + + +/* ---------------------- COMPOSITION DE NOUVEAU GREFFON NATIF ---------------------- */ + + +/* Initialise la classe des recherches et identifications. */ +static void g_python_notebook_plugin_ui_class_init(GPythonNotebookPluginUIClass *); + +/* Procède à l'initialisation de l'interface d'intervention. */ +static void g_python_notebook_plugin_ui_tweakable_plugin_interface_init(GTweakablePluginInterface *); + +/* 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 *); + + + +/* ------------------- INTEGRATION DANS L'EDITION DES PREFERENCES ------------------- */ + + +/* Fournit une liste de sections de configuration. */ +static tweak_info_t *g_python_notebook_plugin_ui_get_tweak_info(const GTweakablePlugin *, size_t *); + + + +/* ---------------------------------------------------------------------------------- */ +/* COMPOSITION DE NOUVEAU GREFFON NATIF */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour une présentation de notes texte et code Python. */ +G_DEFINE_TYPE_WITH_CODE(GPythonNotebookPluginUI, g_python_notebook_plugin_ui, G_TYPE_NATIVE_PLUGIN, + G_IMPLEMENT_INTERFACE(G_TYPE_TWEAKABLE_PLUGIN, g_python_notebook_plugin_ui_tweakable_plugin_interface_init)); + + +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 : iface = interface GLib à initialiser. * +* * +* Description : Procède à l'initialisation de l'interface d'intervention. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_python_notebook_plugin_ui_tweakable_plugin_interface_init(GTweakablePluginInterface *iface) +{ + iface->get_info = g_python_notebook_plugin_ui_get_tweak_info; + +} + + +/****************************************************************************** +* * +* 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; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* INTEGRATION DANS L'EDITION DES PREFERENCES */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : plugin = interface à manipuler. * +* count = taille de la liste renvoyée. [OUT] * +* * +* Description : Fournit une liste de sections de configuration. * +* * +* Retour : Définition(s) de section de configuration ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static tweak_info_t *g_python_notebook_plugin_ui_get_tweak_info(const GTweakablePlugin *plugin, size_t *count) +{ + tweak_info_t *result; /* Liste à renvoyer */ + + tweak_info_t infos[] = { + TWEAK_SIMPLE_DEF("root", "Basics", + "pynb-symbolic", "pynotebook", "Notebook", GTK_TYPE_PYTHON_NOTEBOOK_TWEAK_PANEL), + }; + + *count = 1; + result = malloc(*count * sizeof(tweak_info_t)); + + memcpy(result, infos, *count * sizeof(tweak_info_t)); + + return result; + +} diff --git a/plugins/pynb/core-ui.h b/plugins/pynb/core-ui.h new file mode 100644 index 0000000..8ab9dd9 --- /dev/null +++ b/plugins/pynb/core-ui.h @@ -0,0 +1,43 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * core-ui.h - prototypes pour la 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_FIDO_CORE_UI_H +#define _PLUGINS_FIDO_CORE_UI_H + + +#include <plugins/plugin.h> +#include <plugins/plugin-int.h> + + + +#define G_TYPE_PYTHON_NOTEBOOK_PLUGIN_UI (g_python_notebook_plugin_ui_get_type()) + +DECLARE_GTYPE(GPythonNotebookPluginUI, g_python_notebook_plugin_ui, G, PYTHON_NOTEBOOK_PLUGIN_UI); + + +/* Crée un module pour présentation de notes. */ +GPluginModule *g_python_notebook_plugin_ui_new(GModule *); + + + +#endif /* _PLUGINS_FIDO_CORE_UI_H */ diff --git a/plugins/pynb/data/images/pynb-symbolic.svg b/plugins/pynb/data/images/pynb-symbolic.svg new file mode 100644 index 0000000..f8cae60 --- /dev/null +++ b/plugins/pynb/data/images/pynb-symbolic.svg @@ -0,0 +1,144 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="256" + height="256" + viewBox="0 0 67.73333 67.733333" + version="1.1" + id="svg2759" + sodipodi:docname="pynotebook.svg" + inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview2761" + pagecolor="#ffffff" + bordercolor="#000000" + borderopacity="0.25" + inkscape:showpageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="false" + inkscape:deskcolor="#d1d1d1" + inkscape:document-units="px" + showgrid="false" + inkscape:zoom="2.9329997" + inkscape:cx="126.83261" + inkscape:cy="128.1964" + inkscape:window-width="1920" + inkscape:window-height="1011" + inkscape:window-x="0" + inkscape:window-y="0" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" /> + <defs + id="defs2756"> + <linearGradient + id="b" + x1="28.809" + y1="28.882" + x2="45.803001" + y2="45.162998" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(12.026515,0,0,11.963752,-37.015053,-73.520624)"> + <stop + stop-color="#FFE052" + id="stop3586" /> + <stop + offset="1" + stop-color="#FFC331" + id="stop3588" /> + </linearGradient> + <linearGradient + id="a" + x1="19.075001" + y1="18.782" + x2="34.897999" + y2="34.658001" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(12.026515,0,0,11.963752,-37.015053,-73.520624)"> + <stop + stop-color="#387EB8" + id="stop3581" /> + <stop + offset="1" + stop-color="#366994" + id="stop3583" /> + </linearGradient> + </defs> + <g + inkscape:label="Calque 1" + inkscape:groupmode="layer" + id="layer1"> + <g + id="g3524" + transform="translate(2.9562937,-0.62320885)" + sodipodi:insensitive="true" + style="display:none"> + <path + id="rect2966" + style="fill:#3a1616;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="m 49.272443,10.836031 c 0.102978,0.351405 0.158647,0.723392 0.158647,1.108976 V 57.03476 c 0,2.168007 -1.745406,3.913456 -3.913456,3.913456 H 16.30288 c -0.385538,0 -0.75709,-0.05622 -1.108459,-0.159163 0.237938,0.812336 0.730853,1.513585 1.387112,2.01175 0.65626,0.498165 1.475864,0.793246 2.367181,0.793246 h 29.214753 c 2.16805,0 3.913456,-1.745449 3.913456,-3.913456 V 14.59084 c 0,-1.782422 -1.180022,-3.278791 -2.80448,-3.754809 z" + sodipodi:nodetypes="csssscsssssc" /> + <path + id="rect2964" + style="display:inline;fill:#a44040;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="m 13.657273,5.3857002 h 29.21476 c 2.168053,0 3.913452,1.7453645 3.913452,3.9133733 V 54.388991 c 0,2.168009 -1.745399,3.913373 -3.913452,3.913373 h -29.21476 c -1.084026,0 -2.062389,-0.436341 -2.769745,-1.143683 -0.707357,-0.707342 -1.1437069,-1.685685 -1.1437069,-2.76969 V 9.2990735 c 0,-2.1680088 1.7453999,-3.9133733 3.9134519,-3.9133733 z" + sodipodi:nodetypes="ssssssssss" /> + <path + id="rect3518" + style="fill:#2d3a16;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="m 10.887528,57.158681 5.291742,4.9e-5 5.29299,5.29246 h -5.291667 z" + sodipodi:nodetypes="ccccc" /> + </g> + <g + id="g3807" + transform="matrix(0.275,0,0,0.27644269,10.179141,20.324238)" + style="display:none;stroke-width:3.62685"> + <path + d="m 76.135321,-13.223349 c -26.868437,0 -25.19164,11.6515879 -25.19164,11.6515879 l 0.03307,12.0716141 h 25.638125 v 3.621485 h -35.82789 c 0,0 -17.187994,-1.951302 -17.187994,25.161874 0,27.106562 15.005182,26.147447 15.005182,26.147447 h 8.956145 V 52.849722 c 0,0 -0.482864,-15.005182 14.767057,-15.005182 h 25.426458 c 0,0 14.287506,0.231511 14.287506,-13.807942 V 0.82271803 c 0,0 2.16958,-14.04606703 -25.906021,-14.04606703 z m -14.138672,8.1160932 c 2.549922,0 4.613672,2.0637499 4.613672,4.61367177 0,2.54992183 -2.06375,4.61367183 -4.613672,4.61367183 a 4.6070572,4.6070572 0 0 1 -4.613672,-4.61367183 c 0,-2.54992187 2.06375,-4.61367177 4.613672,-4.61367177 z" + fill="url(#a)" + id="path3577" + style="fill:url(#a);stroke-width:11.9951" /> + <path + d="m 76.895998,92.057664 c 26.868432,0 25.191642,-11.651588 25.191642,-11.651588 l -0.0331,-12.071615 h -25.6381 v -3.621484 h 35.82458 c 0,0 17.1913,1.951302 17.1913,-25.158567 0,-27.109869 -15.00518,-26.147447 -15.00518,-26.147447 H 105.471 v 12.57763 c 0,0 0.48286,15.005182 -14.76706,15.005182 H 65.277482 c 0,0 -14.287499,-0.231511 -14.287499,13.807942 v 23.21388 c 0,0 -2.169584,14.046067 25.906015,14.046067 z m 14.138671,-8.116093 a 4.6070572,4.6070572 0 0 1 -4.613671,-4.613672 c 0,-2.546615 2.06375,-4.610365 4.613671,-4.610365 2.549922,0 4.613672,2.060443 4.613672,4.610365 0,2.553229 -2.06375,4.613672 -4.613672,4.613672 z" + fill="url(#b)" + id="path3579" + style="fill:url(#b);stroke-width:11.9951" /> + </g> + <g + id="g3859" + style="display:none;fill:#000000;fill-opacity:1"> + <path + id="path3544" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="m 52.228737,10.212822 c 0.102978,0.351405 0.158647,0.723392 0.158647,1.108976 v 45.089753 c 0,2.168007 -1.745406,3.913456 -3.913456,3.913456 H 19.259174 c -0.385538,0 -0.75709,-0.05622 -1.108459,-0.159163 0.237938,0.812336 0.730853,1.513585 1.387112,2.01175 0.65626,0.498165 1.475864,0.793246 2.367181,0.793246 h 29.214753 c 2.16805,0 3.913456,-1.745449 3.913456,-3.913456 V 13.967631 c 0,-1.782422 -1.180022,-3.278791 -2.80448,-3.754809 z" + sodipodi:nodetypes="csssscsssssc" /> + <path + id="path3546" + style="display:inline;fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 16.613456,4.7624999 C 14.445408,4.7625 12.7,6.5079516 12.7,8.675956 v 45.089753 c 0,1.084003 0.436244,2.062515 1.143599,2.769857 0.707354,0.70734 1.685833,1.143599 2.769857,1.143599 h 29.214753 c 2.168049,0 3.913456,-1.745451 3.913456,-3.913456 V 8.675956 c 0,-2.1680044 -1.745407,-3.9134561 -3.913456,-3.9134561 z M 31.116446,16.66875 c 7.720775,0 7.124113,3.882967 7.124113,3.882967 v 6.417179 c 0,3.881096 -3.928959,3.817338 -3.928959,3.817338 h -6.992338 c -4.19372,0 -4.061251,4.148067 -4.061251,4.148067 v 3.477824 h -2.462898 c 0,0 -4.126363,0.264897 -4.126363,-7.2285 0,-7.495223 4.726843,-6.955647 4.726843,-6.955647 h 9.852628 v -1.000973 h -7.050215 l -0.0093,-3.337264 c 0,0 -0.461064,-3.220991 6.927742,-3.220991 z m -3.888135,2.24379 c -0.701226,0 -1.268656,0.570469 -1.268656,1.275374 a 1.2669408,1.2735872 0 0 0 1.268656,1.275375 c 0.701229,0 1.268657,-0.570467 1.268657,-1.275375 0,-0.704905 -0.567428,-1.275374 -1.268657,-1.275374 z m 14.46475,5.117 c 0.453342,-0.0018 4.079854,0.203094 4.079854,7.229016 0,7.494318 -4.727359,6.955131 -4.727359,6.955131 h -9.852112 v 1.000973 h 7.050732 l 0.0093,3.337263 c 0,0 0.461069,3.220992 -6.927742,3.220992 -7.720783,0 -7.124113,-3.882967 -7.124113,-3.882967 v -6.417179 c 0,-3.881101 3.928959,-3.817338 3.928959,-3.817338 h 6.992338 c 4.193725,0 4.060734,-4.148067 4.060734,-4.148067 v -3.47679 h 2.462898 c 0,0 0.01629,-9.15e-4 0.04651,-0.001 z M 35.21387,40.97941 c -0.701227,0 -1.269173,0.570348 -1.269173,1.27434 a 1.2669408,1.2735872 0 0 0 1.269173,1.275375 c 0.701228,0 1.268657,-0.569554 1.268657,-1.275375 0,-0.704906 -0.567429,-1.27434 -1.268657,-1.27434 z" /> + <path + id="path3548" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="m 13.843822,56.535472 5.291742,4.9e-5 5.29299,5.29246 h -5.291667 z" + sodipodi:nodetypes="ccccc" /> + </g> + <path + id="rect3934" + style="display:none;fill:#00ba2b;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 4.7624999,62.970832 20.637499,4.7624999 h 42.333333 l -15.875,58.2083321 z" + sodipodi:nodetypes="ccccc" /> + <path + id="path4924" + style="fill:#000000;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 24.551 4.7625 C 22.3829 4.7625 20.1615 6.50795 19.5702 8.67596 L 7.27299 53.7657 C 6.97735 54.8497 7.14673 55.8282 7.66117 56.5356 L 11.5111 61.8277 L 11.5147 61.8277 C 11.6056 61.9525 11.7049 62.0706 11.8167 62.1776 C 12.3371 62.6758 13.0763 62.9708 13.9676 62.9708 L 43.1824 62.9708 C 45.3504 62.9708 47.5719 61.2254 48.1631 59.0574 L 60.4603 13.9676 C 60.9465 12.1852 60.1745 10.6888 58.6799 10.2128 C 58.687 10.5642 58.6413 10.9362 58.5361 11.3218 L 46.2389 56.4115 C 45.6476 58.5795 43.4262 60.325 41.2581 60.325 L 15.7098 60.325 L 13.7851 57.6792 L 39.3339 57.6792 C 41.5019 57.6792 43.7234 55.9337 44.3147 53.7657 L 56.6119 8.67596 C 57.2031 6.50795 55.9338 4.7625 53.7657 4.7625 L 24.551 4.7625 Z M 35.8068 16.6688 C 43.5276 16.6688 41.8719 20.5517 41.8719 20.5517 L 40.1218 26.9689 C 39.0633 30.85 35.1517 30.7862 35.1517 30.7862 L 28.1594 30.7862 C 23.9657 30.7862 22.9668 34.9343 22.9668 34.9343 L 22.0183 38.4121 L 19.5554 38.4121 C 19.5554 38.4121 15.3568 38.677 17.4005 31.1836 C 19.4446 23.6884 24.0243 24.228 24.0243 24.228 L 33.877 24.228 L 34.1499 23.227 L 27.0997 23.227 L 28.0006 19.8897 C 28.0006 19.8897 28.418 16.6688 35.8068 16.6688 Z M 31.3067 18.9125 C 30.6055 18.9125 29.8825 19.483 29.6902 20.1879 C 29.5975 20.5263 29.6424 20.851 29.8152 21.0902 C 29.9879 21.3295 30.2743 21.4637 30.611 21.4633 C 31.3123 21.4633 32.0353 20.8928 32.2275 20.1879 C 32.4198 19.483 32.0079 18.9125 31.3067 18.9125 Z M 44.3759 24.0295 C 44.8297 24.0277 48.4004 24.2326 46.4842 31.2586 C 44.4403 38.7529 39.86 38.2137 39.86 38.2137 L 30.0079 38.2137 L 29.7349 39.2147 L 36.7856 39.2147 L 35.8848 42.5519 C 35.8848 42.5519 35.4674 45.7729 28.0786 45.7729 C 20.3578 45.7729 22.0135 41.8899 22.0135 41.8899 L 23.7636 35.4728 C 24.8221 31.5917 28.7336 31.6554 28.7336 31.6554 L 35.726 31.6554 C 39.9197 31.6554 40.918 27.5074 40.918 27.5074 L 41.8662 24.0306 L 44.3291 24.0306 C 44.3291 24.0306 44.3457 24.0296 44.3759 24.0295 Z M 33.274 40.9794 C 32.5728 40.9794 31.8493 41.5498 31.6573 42.2538 C 31.5645 42.5922 31.6095 42.917 31.7824 43.1563 C 31.9553 43.3956 32.2418 43.5297 32.5787 43.5291 C 33.2799 43.5291 34.0026 42.9596 34.1951 42.2538 C 34.3874 41.5488 33.9753 40.9794 33.274 40.9794 Z" /> + <path + style="display:none;fill:#af00ba;fill-opacity:1;stroke-width:0.529167;stroke-linecap:round;stroke-linejoin:round;paint-order:fill markers stroke" + d="M 4.7624999,62.970832 20.637499,4.7624999 h 42.333333 l -15.875,58.2083321 z" + id="path5158" + sodipodi:nodetypes="ccccc" /> + </g> +</svg> diff --git a/plugins/pynb/gresource.xml b/plugins/pynb/gresource.xml new file mode 100644 index 0000000..71eb8ed --- /dev/null +++ b/plugins/pynb/gresource.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/re/chrysalide/framework/gui/panels"> + <file compressed="true" alias="pynb-panel.ui">panel.ui</file> + <file compressed="true" alias="pynb-params.ui">params.ui</file> + <file compressed="true" alias="pynb-prefs.ui">prefs.ui</file> + </gresource> + <gresource prefix="/re/chrysalide/framework/gui/icons/scalable/actions"> + <file compressed="true" alias="pynb-symbolic.svg">data/images/pynb-symbolic.svg</file> + </gresource> +</gresources> diff --git a/plugins/pynb/panel-int.h b/plugins/pynb/panel-int.h new file mode 100644 index 0000000..23884c7 --- /dev/null +++ b/plugins/pynb/panel-int.h @@ -0,0 +1,56 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * panel-int.h - prototypes internes pour le panneau dédié à la présentation de notes + * + * 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYNB_PANEL_INT_H +#define _PLUGINS_PYNB_PANEL_INT_H + + +#include <gtkext/panel-int.h> + + +#include "panel.h" + + + +/* Panneau de cartopgraphie des dispositions d'échantillons (instance) */ +struct _GtkPythonNotebookPanel +{ + GtkTiledPanel parent; /* A laisser en premier */ + +}; + +/* Panneau de cartopgraphie des dispositions d'échantillons (classe) */ +struct _GtkPythonNotebookPanelClass +{ + GtkTiledPanelClass parent; /* A laisser en premier */ + +}; + + +/* Met en place nouvelle instance de panneau de présentation. */ +bool gtk_python_notebook_panel_create(GtkPythonNotebookPanel *); + + + +#endif /* _PLUGINS_PYNB_PANEL_INT_H */ diff --git a/plugins/pynb/panel.c b/plugins/pynb/panel.c new file mode 100644 index 0000000..8ce9cdb --- /dev/null +++ b/plugins/pynb/panel.c @@ -0,0 +1,210 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * panel.c - panneau dédié à la présentation de notes + * + * 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include "panel.h" + + +#include <gtkext/helpers.h> + + +#include "panel-int.h" + + + +/* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ + + +/* Initialise la classe des panneaux pour binaires. */ +static void gtk_python_notebook_panel_class_init(GtkPythonNotebookPanelClass *); + +/* Initialise une instance de panneau pour binaire. */ +static void gtk_python_notebook_panel_init(GtkPythonNotebookPanel *); + +/* Supprime toutes les références externes. */ +static void gtk_python_notebook_panel_dispose(GObject *); + +/* Procède à la libération totale de la mémoire. */ +static void gtk_python_notebook_panel_finalize(GObject *); + + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Fournit les composants adaptés pour la barre de titre. */ +//static GListStore *gtk_python_notebook_panel_get_title_widgets(GtkTiledPanel *, bool); + + + +/* ---------------------------------------------------------------------------------- */ +/* COEUR D'UN PANNEAU D'AFFICHAGE */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour un panneau de présentation de notes. */ +G_DEFINE_TYPE(GtkPythonNotebookPanel, gtk_python_notebook_panel, GTK_TYPE_TILED_PANEL); + + +/****************************************************************************** +* * +* Paramètres : class = classe à initialiser. * +* * +* Description : Initialise la classe des panneaux pour binaires. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_panel_class_init(GtkPythonNotebookPanelClass *class) +{ + GObjectClass *object; /* Autre version de la classe */ + GtkWidgetClass *widget; /* Classe de haut niveau */ + GtkTiledPanelClass *panel; /* Version parente de classe */ + + object = G_OBJECT_CLASS(class); + + object->dispose = gtk_python_notebook_panel_dispose; + object->finalize = gtk_python_notebook_panel_finalize; + + widget = GTK_WIDGET_CLASS(class); + + gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/panels/pynb-panel.ui"); + + //gtk_widget_class_bind_template_child(widget, GtkPythonNotebookPanel, summary); + + panel = GTK_TILED_PANEL_CLASS(class); + + //panel->get_widgets = (get_tiled_panel_widgets_cb)gtk_python_notebook_panel_get_title_widgets; + +} + + +/****************************************************************************** +* * +* Paramètres : panel = instance à initialiser. * +* * +* Description : Initialise une instance de panneau pour binaire. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_panel_init(GtkPythonNotebookPanel *panel) +{ + gtk_widget_init_template(GTK_WIDGET(panel)); + +} + + +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_panel_dispose(GObject *object) +{ + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_PYTHON_NOTEBOOK_PANEL); + + G_OBJECT_CLASS(gtk_python_notebook_panel_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 gtk_python_notebook_panel_finalize(GObject *object) +{ + G_OBJECT_CLASS(gtk_python_notebook_panel_parent_class)->finalize(object); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée une nouvelle instance de panneau de présentation. * +* * +* Retour : Composant GTK mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkTiledPanel *gtk_python_notebook_panel_new(void) +{ + GtkTiledPanel *result; /* Instance à retourner */ + + result = g_object_new(GTK_TYPE_PYTHON_NOTEBOOK_PANEL, NULL); + + if (!gtk_python_notebook_panel_create(GTK_PYTHON_NOTEBOOK_PANEL(result))) + g_clear_object(&result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : panel = panneau de recherche et récupération à remplir. * +* * +* Description : Met en place nouvelle instance de panneau de présentation. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool gtk_python_notebook_panel_create(GtkPythonNotebookPanel *panel) +{ + bool result; /* Bilan à retourner */ + + result = true; + + return result; + +} diff --git a/plugins/pynb/panel.h b/plugins/pynb/panel.h new file mode 100644 index 0000000..f9f8016 --- /dev/null +++ b/plugins/pynb/panel.h @@ -0,0 +1,47 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * panel.h - prototypes pour le panneau dédié à la présentation de notes + * + * 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#ifndef _PLUGINS_PYNB_PANEL_H +#define _PLUGINS_PYNB_PANEL_H + + +#include <gtk/gtk.h> + + +#include <glibext/helpers.h> +#include <gtkext/panel.h> + + + +#define GTK_TYPE_PYTHON_NOTEBOOK_PANEL (gtk_python_notebook_panel_get_type()) + +DECLARE_GTYPE(GtkPythonNotebookPanel, gtk_python_notebook_panel, GTK, PYTHON_NOTEBOOK_PANEL); + + +/* Crée une nouvelle instance de panneau de présentation. */ +GtkTiledPanel *gtk_python_notebook_panel_new(void); + + + +#endif /* _PLUGINS_PYNB_PANEL_H */ diff --git a/plugins/pynb/panel.ui b/plugins/pynb/panel.ui new file mode 100644 index 0000000..d16af80 --- /dev/null +++ b/plugins/pynb/panel.ui @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + + <template class="GtkPythonNotebookPanel" parent="GtkTiledPanel"> + <child> + <object class="GtkScrolledWindow"> + <property name="hscrollbar-policy">automatic</property> + <property name="vscrollbar-policy">automatic</property> + <property name="hexpand">true</property> + <property name="vexpand">true</property> + <property name="has-frame">true</property> + <property name="margin-start">8</property> + <property name="margin-top">8</property> + <property name="margin-end">8</property> + <property name="margin-bottom">8</property> + + </object> + </child> + </template> + +</interface> diff --git a/plugins/pynb/params-int.h b/plugins/pynb/params-int.h new file mode 100644 index 0000000..7f3bc8b --- /dev/null +++ b/plugins/pynb/params-int.h @@ -0,0 +1,50 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * params-int.h - définitions internes pour l'édition des paramètres initiaux d'une présentation de notes + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_PYNB_PARAMS_INT_H +#define _PLUGINS_PYNB_PARAMS_INT_H + + +#include "params.h" + + + +/* Composant pour les paramètres de chargement d'un binaire (instance) */ +struct _GtkPythonNotebookParameters +{ + GtkGrid parent; /* A laisser en premier */ + + //GtkEntry *filename; /* CHemin d'un binaire */ + +}; + +/* Composant pour les paramètres de chargement d'un binaire (classe) */ +struct _GtkPythonNotebookParametersClass +{ + GtkGridClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _PLUGINS_PYNB_PARAMS_INT_H */ diff --git a/plugins/pynb/params.c b/plugins/pynb/params.c new file mode 100644 index 0000000..690ff95 --- /dev/null +++ b/plugins/pynb/params.c @@ -0,0 +1,171 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * params.c - édition des paramètres initiaux d'une présentation de notes + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#include "params.h" + + +#include "panel.h" +#include "params-int.h" +#include <gtkext/helpers.h> +#include <gui/window.h> + + + +/* Initialise la classe des composants d'édition de paramètres. */ +static void gtk_python_notebook_parameters_class_init(GtkPythonNotebookParametersClass *); + +/* Initialise une instance de composant d'édition de paramètres. */ +static void gtk_python_notebook_parameters_init(GtkPythonNotebookParameters *); + +/* Supprime toutes les références externes. */ +static void gtk_python_notebook_parameters_dispose(GObject *); + +/* Procède à la libération totale de la mémoire. */ +static void gtk_python_notebook_parameters_finalize(GObject *); + +/* Réagit à une demande de création de notes. */ +static void gtk_python_notebook_parameters_on_create_clicked(GtkButton *, GtkPythonNotebookParameters *); + + + +/* Indique le type du composant d'édition des paramètres de chargement. */ +G_DEFINE_TYPE(GtkPythonNotebookParameters, gtk_python_notebook_parameters, GTK_TYPE_GRID); + + +/****************************************************************************** +* * +* Paramètres : class = classe GTK à initialiser. * +* * +* Description : Initialise la classe des composants d'édition de paramètres. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_parameters_class_init(GtkPythonNotebookParametersClass *class) +{ + GObjectClass *object; /* Plus haut niveau équivalent */ + GtkWidgetClass *widget; /* Classe de haut niveau */ + + object = G_OBJECT_CLASS(class); + + object->dispose = gtk_python_notebook_parameters_dispose; + object->finalize = gtk_python_notebook_parameters_finalize; + + widget = GTK_WIDGET_CLASS(class); + + gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/panels/pynb-params.ui"); + + gtk_widget_class_bind_template_callback_full(widget, BUILDER_CB(gtk_python_notebook_parameters_on_create_clicked)); + + //gtk_widget_class_bind_template_child(widget, GtkPythonNotebookParameters, filename); + +} + + +/****************************************************************************** +* * +* Paramètres : params = composant GTK à initialiser. * +* * +* Description : Initialise une instance de composant d'édition de paramètres.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_parameters_init(GtkPythonNotebookParameters *params) +{ + gtk_widget_init_template(GTK_WIDGET(params)); + +} + + +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_parameters_dispose(GObject *object) +{ + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_PYTHON_NOTEBOOK_PARAMETERS); + + G_OBJECT_CLASS(gtk_python_notebook_parameters_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 gtk_python_notebook_parameters_finalize(GObject *object) +{ + G_OBJECT_CLASS(gtk_python_notebook_parameters_parent_class)->finalize(object); + +} + + +/****************************************************************************** +* * +* Paramètres : button = bouton GTK concerné par l'appel. * +* params = paramètres du panneau à mettre en place. * +* * +* Description : Réagit à une demande de création de notes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_parameters_on_create_clicked(GtkButton *button, GtkPythonNotebookParameters *params) +{ + GtkRoot *root; /* Racine du composant */ + GtkTiledPanel *tiled; /* Panneau d'affichage complet */ + + root = gtk_widget_get_root(GTK_WIDGET(button)); + + tiled = gtk_python_notebook_panel_new(); + + gtk_framework_window_add(GTK_FRAMEWORK_WINDOW(root), tiled); + +} diff --git a/plugins/pynb/params.h b/plugins/pynb/params.h new file mode 100644 index 0000000..2d4b39b --- /dev/null +++ b/plugins/pynb/params.h @@ -0,0 +1,41 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * params.h - prototypes pour l'édition des paramètres initiaux d'une présentation de notes + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_PYNB_PARAMS_H +#define _PLUGINS_PYNB_PARAMS_H + + +#include <gtk/gtk.h> + + +#include <glibext/helpers.h> + + + +#define GTK_TYPE_PYTHON_NOTEBOOK_PARAMETERS (gtk_python_notebook_parameters_get_type()) + +DECLARE_GTYPE(GtkPythonNotebookParameters, gtk_python_notebook_parameters, GTK, PYTHON_NOTEBOOK_PARAMETERS); + + + +#endif /* _PLUGINS_PYNB_PARAMS_H */ diff --git a/plugins/pynb/params.ui b/plugins/pynb/params.ui new file mode 100644 index 0000000..21a4788 --- /dev/null +++ b/plugins/pynb/params.ui @@ -0,0 +1,52 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + + <template class="GtkPythonNotebookParameters" parent="GtkGrid"> + <property name="margin-bottom">12</property> + <property name="margin-end">12</property> + <property name="margin-start">12</property> + <property name="margin-top">12</property> + <property name="column-spacing">12</property> + <property name="row-spacing">8</property> + + <child> + <object class="GtkLabel"> + <property name="label">Load and analyze a new notebook file:</property> + <property name="xalign">0</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + </layout> + </object> + </child> + + <child> + <object class="GtkEntry" id="filename"> + <property name="secondary-icon-name">document-open-symbolic</property> + <property name="placeholder-text">File location</property> + <property name="hexpand">TRUE</property> + <property name="hexpand-set">TRUE</property> + <layout> + <property name="column">0</property> + <property name="row">1</property> + </layout> + <style> + <class name="background"/> + </style> + </object> + </child> + + <child> + <object class="GtkButton" id="create"> + <property name="label">Create</property> + <layout> + <property name="column">0</property> + <property name="row">2</property> + </layout> + <signal name="clicked" handler="gtk_python_notebook_parameters_on_create_clicked"/> + </object> + </child> + + </template> + +</interface> diff --git a/plugins/pynb/prefs-int.h b/plugins/pynb/prefs-int.h new file mode 100644 index 0000000..9c44c68 --- /dev/null +++ b/plugins/pynb/prefs-int.h @@ -0,0 +1,48 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * prefs-int.h - définitions internes pour la configuration des paramètres liés aux notes + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_PYNB_PREFS_INT_H +#define _PLUGINS_PYNB_PREFS_INT_H + + +#include "prefs.h" + + + +/* Composant d'édition des paramètres liés aux notes (instance) */ +struct _GtkPythonNotebookTweakPanel +{ + GtkBox parent; /* A laisser en premier */ + +}; + +/* Composant d'édition des paramètres liés aux notes (classe) */ +struct _GtkPythonNotebookTweakPanelClass +{ + GtkBoxClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _PLUGINS_PYNB_PREFS_INT_H */ diff --git a/plugins/pynb/prefs.c b/plugins/pynb/prefs.c new file mode 100644 index 0000000..9363e9b --- /dev/null +++ b/plugins/pynb/prefs.c @@ -0,0 +1,143 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * prefs.c - configuration des paramètres liés aux notes + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#include "prefs.h" + + +#include <gtkext/helpers.h> + + +#include "prefs-int.h" + + + +/* Procède à l'initialisation de classe des configurations. */ +static void gtk_python_notebook_tweak_panel_class_init(GtkPythonNotebookTweakPanelClass *); + +/* Procède à l'initialisation des configurations de sécurité. */ +static void gtk_python_notebook_tweak_panel_init(GtkPythonNotebookTweakPanel *); + +/* Supprime toutes les références externes. */ +static void gtk_python_notebook_tweak_panel_dispose(GObject *); + +/* Procède à la libération totale de la mémoire. */ +static void gtk_python_notebook_tweak_panel_finalize(GObject *); + + + +/* Indique le type du composant de configuration des notes. */ +G_DEFINE_TYPE(GtkPythonNotebookTweakPanel, gtk_python_notebook_tweak_panel, GTK_TYPE_BOX); + + +/****************************************************************************** +* * +* Paramètres : class = classe GTK à initialiser. * +* * +* Description : Procède à l'initialisation de classe des configurations. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_tweak_panel_class_init(GtkPythonNotebookTweakPanelClass *class) +{ + GObjectClass *object; /* Plus haut niveau équivalent */ + GtkWidgetClass *widget; /* Classe de haut niveau */ + + object = G_OBJECT_CLASS(class); + + object->dispose = gtk_python_notebook_tweak_panel_dispose; + object->finalize = gtk_python_notebook_tweak_panel_finalize; + + widget = GTK_WIDGET_CLASS(class); + + gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/panels/pynb-prefs.ui"); + + /* Stockage sécurisé */ + + //gtk_widget_class_bind_template_callback_full(widget, BUILDER_CB(gtk_python_notebook_tweak_panel_on_new_passwords_changed)); + + //gtk_widget_class_bind_template_child(widget, GtkPythonNotebookTweakPanel, current_primary_passwd); + +} + + +/****************************************************************************** +* * +* Paramètres : panel = composant GTK à initialiser. * +* * +* Description : Procède à l'initialisation des configurations de sécurité. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_tweak_panel_init(GtkPythonNotebookTweakPanel *panel) +{ + gtk_widget_init_template(GTK_WIDGET(panel)); + +} + + +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_python_notebook_tweak_panel_dispose(GObject *object) +{ + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_PYTHON_NOTEBOOK_TWEAK_PANEL); + + G_OBJECT_CLASS(gtk_python_notebook_tweak_panel_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 gtk_python_notebook_tweak_panel_finalize(GObject *object) +{ + G_OBJECT_CLASS(gtk_python_notebook_tweak_panel_parent_class)->finalize(object); + +} diff --git a/plugins/pynb/prefs.h b/plugins/pynb/prefs.h new file mode 100644 index 0000000..6551983 --- /dev/null +++ b/plugins/pynb/prefs.h @@ -0,0 +1,41 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * prefs.h - prototypes pour la configuration des paramètres liés aux notes + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_PYNB_PREFS_H +#define _PLUGINS_PYNB_PREFS_H + + +#include <gtk/gtk.h> + + +#include <glibext/helpers.h> + + + +#define GTK_TYPE_PYTHON_NOTEBOOK_TWEAK_PANEL (gtk_python_notebook_tweak_panel_get_type()) + +DECLARE_GTYPE(GtkPythonNotebookTweakPanel, gtk_python_notebook_tweak_panel, GTK, PYTHON_NOTEBOOK_TWEAK_PANEL); + + + +#endif /* _PLUGINS_PYNB_PREFS_H */ diff --git a/plugins/pynb/prefs.ui b/plugins/pynb/prefs.ui new file mode 100644 index 0000000..b8a6962 --- /dev/null +++ b/plugins/pynb/prefs.ui @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + + <template class="GtkPythonNotebookTweakPanel" parent="GtkBox"> + + <property name="orientation">vertical</property> + + <!-- Conservation de paramètres sécurisée --> + <child> + <object class="GtkGrid"> + <property name="margin-start">20</property> + <property name="margin-end">20</property> + <property name="margin-top">20</property> + <property name="margin-bottom">20</property> + <property name="row-spacing">10</property> + <property name="column-spacing">10</property> + + <child> + <object class="GtkLabel"> + <property name="label">Notes config</property> + <property name="use-markup">true</property> + <property name="xalign">0</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + <property name="column-span">2</property> + </layout> + <style> + <class name="heading"/> + </style> + </object> + </child> + + </object> + </child> + + </template> +</interface> diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am index c63a447..839ee8f 100644 --- a/src/gtkext/Makefile.am +++ b/src/gtkext/Makefile.am @@ -31,6 +31,7 @@ IMG_PATH = ../../data/images RES_FILES = \ hexview.css \ hexview.ui \ + launcher.ui \ statusstack.ui \ $(IMG_PATH)/nolock-symbolic.svg \ $(IMG_PATH)/locked-symbolic.svg \ @@ -51,6 +52,8 @@ libgtkext4_la_SOURCES = \ helpers.h \ hexview-int.h \ hexview.h hexview.c \ + launcher-int.h \ + launcher.h launcher.c \ panel-int.h \ panel.h panel.c \ resources.h resources.c \ diff --git a/src/gtkext/gresource.xml b/src/gtkext/gresource.xml index 60680b5..640985f 100644 --- a/src/gtkext/gresource.xml +++ b/src/gtkext/gresource.xml @@ -3,6 +3,7 @@ <gresource prefix="/re/chrysalide/framework/gtkext"> <file compressed="true">hexview.css</file> <file compressed="true">hexview.ui</file> + <file compressed="true">launcher.ui</file> <file compressed="true">statusstack.ui</file> <file compressed="true">tweak.ui</file> </gresource> diff --git a/src/gtkext/launcher-int.h b/src/gtkext/launcher-int.h new file mode 100644 index 0000000..07152f0 --- /dev/null +++ b/src/gtkext/launcher-int.h @@ -0,0 +1,56 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * tweak-int.h - définitions internes pour un lanceur de panneau majeur + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GTKEXT_LAUNCHER_INT_H +#define _GTKEXT_LAUNCHER_INT_H + + +#include "launcher.h" + + + +/* Elément de lancement d'un panneau majeur pour l'interface (instance) */ +struct _GtkPanelLauncher +{ + GtkListBoxRow parent; /* A laisser en premier */ + + GtkImage *icon; /* Eventuelle image */ + GtkLabel *title; /* Etiquette associée */ + GtkLabel *desc; /* Description du panneau */ + +}; + +/* Elément de lancement d'un panneau majeur pour l'interface (classe) */ +struct _GtkPanelLauncherClass +{ + GtkListBoxRowClass parent; /* A laisser en premier */ + +}; + + +/* Met en place un nouveau lanceur de panneau majeur. */ +bool gtk_panel_launcher_create(GtkPanelLauncher *, const char *, const char *, const char *); + + + +#endif /* _GTKEXT_LAUNCHER_INT_H */ diff --git a/src/gtkext/launcher.c b/src/gtkext/launcher.c new file mode 100644 index 0000000..5bb850b --- /dev/null +++ b/src/gtkext/launcher.c @@ -0,0 +1,211 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * launcher.c - lanceur de panneau majeur + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#include "launcher.h" + + +#include <malloc.h> +#include <string.h> + + +#include "helpers.h" +#include "launcher-int.h" +#include "../common/extstr.h" + + + +/* Initialise la classe des sections d'éléments paramétrables. */ +static void gtk_panel_launcher_class_init(GtkPanelLauncherClass *); + +/* Initialise une instance de lanceur de panneau majeur. */ +static void gtk_panel_launcher_init(GtkPanelLauncher *); + +/* Supprime toutes les références externes. */ +static void gtk_panel_launcher_dispose(GObject *); + +/* Procède à la libération totale de la mémoire. */ +static void gtk_panel_launcher_finalize(GObject *); + + + +/* Détermine le type du composant d'affichage générique. */ +G_DEFINE_TYPE(GtkPanelLauncher, gtk_panel_launcher, GTK_TYPE_LIST_BOX_ROW); + + +/****************************************************************************** +* * +* Paramètres : class = classe GTK à initialiser. * +* * +* Description : Initialise la classe des sections d'éléments paramétrables. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_panel_launcher_class_init(GtkPanelLauncherClass *class) +{ + GObjectClass *object; /* Plus haut niveau équivalent */ + GtkWidgetClass *widget; /* Classe de haut niveau */ + + object = G_OBJECT_CLASS(class); + + object->dispose = gtk_panel_launcher_dispose; + object->finalize = gtk_panel_launcher_finalize; + + widget = GTK_WIDGET_CLASS(class); + + gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gtkext/launcher.ui"); + + gtk_widget_class_bind_template_child(widget, GtkPanelLauncher, icon); + gtk_widget_class_bind_template_child(widget, GtkPanelLauncher, title); + gtk_widget_class_bind_template_child(widget, GtkPanelLauncher, desc); + +} + + +/****************************************************************************** +* * +* Paramètres : launcher = composant GTK à initialiser. * +* * +* Description : Initialise une instance de lanceur de panneau majeur. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_panel_launcher_init(GtkPanelLauncher *launcher) +{ + gtk_widget_init_template(GTK_WIDGET(launcher)); + +} + + +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_panel_launcher_dispose(GObject *object) +{ + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_PANEL_LAUNCHER); + + G_OBJECT_CLASS(gtk_panel_launcher_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 gtk_panel_launcher_finalize(GObject *object) +{ + G_OBJECT_CLASS(gtk_panel_launcher_parent_class)->finalize(object); + +} + + +/****************************************************************************** +* * +* Paramètres : icon = désignation de l'image de représentation. * +* title = titre principal à afficher. * +* desc = description du panneau ciblé. * +* * +* Description : Crée un nouveau lanceur de panneau majeur. * +* * +* Retour : Composant GTK mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkPanelLauncher *gtk_panel_launcher_new(const char *icon, const char *title, const char *desc) +{ + GtkPanelLauncher *result; /* Instance à retourner */ + + result = g_object_new(GTK_TYPE_PANEL_LAUNCHER, NULL); + + if (!gtk_panel_launcher_create(result, icon, title, desc)) + g_clear_object(&result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : launcher = lanceur à initialiser pleinement. * +* icon = désignation de l'image de représentation. * +* title = titre principal à afficher. * +* desc = description du panneau ciblé. * +* * +* Description : Met en place un nouveau lanceur de panneau majeur. * +* * +* Retour : Bilan de l'opération. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool gtk_panel_launcher_create(GtkPanelLauncher *launcher, const char *icon, const char *title, const char *desc) +{ + bool result; /* Bilan à retourner */ + char *bold; /* Titre sublimé */ + + result = true; + + gtk_image_set_from_icon_name(launcher->icon, icon); + + bold = strdup(title); + bold = strprep(bold, "<b>"); + bold = stradd(bold, "</b>"); + + gtk_label_set_label(launcher->title, bold); + + free(bold); + + gtk_label_set_label(launcher->desc, desc); + + return result; + +} diff --git a/src/gtkext/launcher.h b/src/gtkext/launcher.h new file mode 100644 index 0000000..3857216 --- /dev/null +++ b/src/gtkext/launcher.h @@ -0,0 +1,45 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * launcher.h - prototypes pour pour un lanceur de panneau majeur + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GTKEXT_LAUNCHER_H +#define _GTKEXT_LAUNCHER_H + + +#include <gtk/gtk.h> + + +#include "../glibext/helpers.h" + + + +#define GTK_TYPE_PANEL_LAUNCHER (gtk_panel_launcher_get_type()) + +DECLARE_GTYPE(GtkPanelLauncher, gtk_panel_launcher, GTK, PANEL_LAUNCHER); + + +/* Crée un nouveau lanceur de panneau majeur. */ +GtkPanelLauncher *gtk_panel_launcher_new(const char *, const char *, const char *); + + + +#endif /* _GTKEXT_LAUNCHER_H */ diff --git a/src/gtkext/launcher.ui b/src/gtkext/launcher.ui new file mode 100644 index 0000000..f6f4fec --- /dev/null +++ b/src/gtkext/launcher.ui @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <template class="GtkPanelLauncher" parent="GtkListBoxRow"> + + <property name="child"> + + <object class="GtkGrid"> + <property name="margin-bottom">12</property> + <property name="margin-end">12</property> + <property name="margin-start">12</property> + <property name="margin-top">12</property> + <property name="column-spacing">12</property> + + <child> + <object class="GtkImage" id="icon"> + <property name="icon-name"></property> + <property name="pixel-size">48</property> + <layout> + <property name="column">0</property> + <property name="row">0</property> + <property name="row-span">2</property> + </layout> + <style> + <class name="icon-dropshadow"/> + </style> + </object> + </child> + + <child> + <object class="GtkLabel" id="title"> + <property name="label"></property> + <property name="use-markup">TRUE</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">0</property> + </layout> + </object> + </child> + + <child> + <object class="GtkLabel" id="desc"> + <property name="label"></property> + <property name="hexpand">true</property> + <property name="xalign">0</property> + <layout> + <property name="column">1</property> + <property name="row">1</property> + </layout> + <style> + <class name="dim-label"/> + </style> + </object> + </child> + + <child> + <object class="GtkImage"> + <property name="icon-name">go-next-symbolic</property> + <property name="margin-start">12</property> + <layout> + <property name="column">2</property> + <property name="row">0</property> + <property name="row-span">2</property> + </layout> + <style> + <class name="icon-dropshadow"/> + </style> + </object> + </child> + + </object> + + </property> + + </template> +</interface> diff --git a/src/gtkext/tweak.h b/src/gtkext/tweak.h index 568a793..8c44844 100644 --- a/src/gtkext/tweak.h +++ b/src/gtkext/tweak.h @@ -25,6 +25,7 @@ #define _GTKEXT_TWEAK_H +#include <stdbool.h> #include <gtk/gtk.h> diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 42761c4..be70445 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -26,8 +26,6 @@ libgui_la_CFLAGS = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) libgui4_la_SOURCES = \ - panel-int.h \ - panel.h panel.c \ resources.h resources.c \ window-int.h \ window.h window.c diff --git a/src/gui/core/core.c b/src/gui/core/core.c index 4a6809c..57a398a 100644 --- a/src/gui/core/core.c +++ b/src/gui/core/core.c @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * core.c - chargement et le déchargement du tronc commun pour l'éditeur graphique * - * Copyright (C) 2016-2019 Cyrille Bagard + * Copyright (C) 2016-2025 Cyrille Bagard * * This file is part of Chrysalide. * @@ -63,7 +63,7 @@ bool load_gui_components(AvailableGuiComponent flags) if ((flags & AGC_PANELS) != 0 && (__loaded & AGC_PANELS) == 0) { - result = load_main_panels(); + result = load_main_framework_panel_definitions(); if (!result) goto done; __loaded |= AGC_PANELS; @@ -93,7 +93,7 @@ void unload_gui_components(AvailableGuiComponent flags) { if ((flags & AGC_PANELS) != 0 && (__loaded & AGC_PANELS) == 0) { - unload_all_panels(); + unload_all_framework_panel_definitions(); __loaded &= ~AGC_PANELS; diff --git a/src/gui/core/panels.c b/src/gui/core/panels.c index 69ab2aa..4c113b8 100644 --- a/src/gui/core/panels.c +++ b/src/gui/core/panels.c @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * panels.c - gestion d'ensemble de tous les panneaux graphiques du framework * - * Copyright (C) 2016-2024 Cyrille Bagard + * Copyright (C) 2016-2025 Cyrille Bagard * * This file is part of Chrysalide. * @@ -25,25 +25,137 @@ #include "panels.h" +#include <assert.h> #include <malloc.h> +#include <string.h> + + +#include <i18n.h> #include "../panels/binary.h" +#include "../panels/binary-params.h" #include "../panels/welcome.h" +#include "../../gtkext/launcher.h" + + + +/* Définition générique complète d'un panneau */ +typedef struct _ext_panel_info_t +{ + /* Début des champs copiés de panel_info_t */ + + char *category; /* Groupe de rassemblement */ + + char *image; /* Eventuelle image associée */ + char *title; /* Désignation humaine */ + char *desc; /* Description humaine */ + FrameworkPanelPersonality personality; /* Comportement attendu */ + + GType panel_type; /* Type du panneau représenté */ + GType params_type; /* Composant de paramètre */ + + /* Fin des champs copiés de panel_info_t */ + + GtkTiledPanel *singleton; /* Conservation des allocations*/ + +} ext_panel_info_t; /* Liste des panneaux disponibles */ -static GPanelItem **_panels_list = NULL; +static ext_panel_info_t **_panels_list = NULL; static size_t _panels_count = 0; +/* Copie une définition basique de panneau graphqiue. */ +static ext_panel_info_t *copy_panel_info(const panel_info_t *); + +/* Efface une définition étendue de panneau graphique. */ +static void delete_panel_info(ext_panel_info_t *); + + + +/****************************************************************************** +* * +* Paramètres : info = information de base à copier. * +* * +* Description : Copie une définition basique de panneau graphqiue. * +* * +* Retour : Structure mémorisant l'ensemble des informations. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static ext_panel_info_t *copy_panel_info(const panel_info_t *info) +{ + ext_panel_info_t *result; /* Structure à retourner */ + + result = calloc(1, sizeof(ext_panel_info_t)); + + if (info->category != NULL) + result->category = strdup(info->category); + + if (info->image != NULL) + result->image = strdup(info->image); + + result->title = strdup(info->title); + + if (info->desc != NULL) + result->desc = strdup(info->desc); + + result->personality = info->personality; + + result->panel_type = info->panel_type; + result->params_type = info->params_type; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : info = informations à supprimer de la mémoire. * +* * +* Description : Efface une définition étendue de panneau graphique. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void delete_panel_info(ext_panel_info_t *info) +{ + if (info->category != NULL) + free(info->category); + + if (info->image != NULL) + free(info->image); + + free(info->title); + + if (info->desc != NULL) + free(info->desc); + + if (info->singleton != NULL) + { + assert(info->personality & FPP_SINGLETON); + unref_object(info->singleton); + } + + free(info); + +} + /****************************************************************************** * * * Paramètres : - * * * -* Description : Charge les principaux panneaux graphiques du framework. * +* Description : Charge les définitions des principaux panneaux du framework. * * * * Retour : Bilan de l'opération. * * * @@ -51,19 +163,45 @@ static size_t _panels_count = 0; * * ******************************************************************************/ -bool load_main_panels(void) +bool load_main_framework_panel_definitions(void) { bool result; /* Bilan à retourner */ - - result = true; + panel_info_t info; /* Infos d'enregistrement */ // TODO register_panel_item(G_TYPE_LOG_PANEL, config); /* Chargement du panneau de rapport au plus tôt */ // TODO panel = g_panel_item_new(G_TYPE_LOG_PANEL, NULL); - register_panel_item(g_binary_panel_new()); - register_panel_item(g_welcome_panel_new()); + info.category = "Main"; + + info.image = "binfile-symbolic"; + info.title = _("Binary analysis"); + info.desc = _("Load a binary content and parse its format if recognized"); + + info.personality = FPP_MAIN_PANEL; + + info.panel_type = GTK_TYPE_BINARY_PANEL; + info.params_type = GTK_TYPE_BINARY_PARAMETERS; + + result = register_framework_panel_definition(&info); + if (!result) goto done; + + info.category = NULL; + + info.image = NULL; + info.title = _("Welcome"); + info.desc = NULL; + + info.personality = FPP_MAIN_PANEL | FPP_SINGLETON; + + info.panel_type = GTK_TYPE_WELCOME_PANEL; + info.params_type = G_TYPE_INVALID; + + result = register_framework_panel_definition(&info); + if (!result) goto done; + + done: return result; @@ -82,12 +220,12 @@ bool load_main_panels(void) * * ******************************************************************************/ -void unload_all_panels(void) +void unload_all_framework_panel_definitions(void) { size_t i; /* Boucle de parcours */ for (i = 0; i < _panels_count; i++) - unref_object(_panels_list[i]); + delete_panel_info(_panels_list[i]); _panels_list = NULL; _panels_count = 0; @@ -97,10 +235,9 @@ void unload_all_panels(void) /****************************************************************************** * * -* Paramètres : type = type du composant à présenter à l'affichage. * -* config = configuration à compléter. * +* Paramètres : info = information de base à copier. * * * -* Description : Enregistre un panneau comme partie intégrante de l'éditeur. * +* Description : Enregistre la définition d'un panneau graphique. * * * * Retour : - * * * @@ -108,11 +245,36 @@ void unload_all_panels(void) * * ******************************************************************************/ -void register_panel_item(/* __steal */ GPanelItem *item) +bool register_framework_panel_definition(const panel_info_t *info) { - _panels_list = realloc(_panels_list, ++_panels_count * sizeof(GPanelItem *)); + bool result; /* Bilan à retourner */ + size_t i; /* Boucle de parcours */ + ext_panel_info_t *ext_info; /* Informations conservées */ + + result = false; - _panels_list[_panels_count - 1] = item; + /* Validation */ + + for (i = 0; i < _panels_count; i++) + if (_panels_list[i]->panel_type == info->panel_type) + break; + + if (i < _panels_count) + goto done; + + /* Enregistrement */ + + ext_info = copy_panel_info(info); + + _panels_list = realloc(_panels_list, ++_panels_count * sizeof(ext_panel_info_t *)); + + _panels_list[_panels_count - 1] = ext_info; + + result = true; + + done: + + return result; } @@ -121,7 +283,7 @@ void register_panel_item(/* __steal */ GPanelItem *item) * * * Paramètres : target = type de définition de panneau recherchée. * * * -* Description : Retrouve la définition d'un type de panneau. * +* Description : Met en place (au besoin) un panneau graphique unique. * * * * Retour : Instance de définition identifiée ou NULL en cas d'échec. * * * @@ -129,23 +291,27 @@ void register_panel_item(/* __steal */ GPanelItem *item) * * ******************************************************************************/ -GPanelItem *find_item_panel_by_type(GType target) +GtkTiledPanel *get_framework_panel_singleton(GType target) { - GPanelItem *result; /* Instance à renvoyer */ + GtkTiledPanel *result; /* Instance à renvoyer */ size_t i; /* Boucle de parcours */ - GPanelItem *item; /* Définition de panneau */ + ext_panel_info_t *info; /* Informations conservées */ result = NULL; for (i = 0; i < _panels_count; i++) { - item = _panels_list[i]; + info = _panels_list[i]; - if (G_OBJECT_TYPE(item) == target) + if (info->panel_type == target) { - result = item; + if (info->singleton == NULL) + info->singleton = g_object_new(target, NULL); + + result = info->singleton; ref_object(result); break; + } } @@ -157,39 +323,84 @@ GPanelItem *find_item_panel_by_type(GType target) /****************************************************************************** * * -* Paramètres : skip = saute le panneau d'accueil lors du parcours ? * -* handle = routine à appeler pour chaque panneau. * -* data = données fournies pour accompagner cet appel. * +* Paramètres : list = liste à compléter. * * * -* Description : Effectue le parcours de tous les panneaux chargés. * +* Description : Intègre une définition de panneau enregistrée. * * * -* Retour : true si le parcours a été total, false sinon. * +* Retour : true pour un parcours complet de la liste des définitions. * * * * Remarques : - * * * ******************************************************************************/ -bool browse_all_item_panels(bool skip, handle_panel_item_fc handle, void *data) +void populate_framework_panel_launcher_list(GtkListBox *list) { - bool result; /* Résultat à renvoyer */ size_t i; /* Boucle de parcours */ - GPanelItem *item; /* Définition de panneau */ - - result = true; + ext_panel_info_t *info; /* Informations conservées */ + GtkPanelLauncher *launcher; /* Lanceur à intégrer */ for (i = 0; i < _panels_count; i++) { - item = _panels_list[i]; + info = _panels_list[i]; - if (skip && G_OBJECT_TYPE(item) == G_TYPE_WELCOME_PANEL) + if (info->category == NULL) continue; - result = handle(item, data); + launcher = gtk_panel_launcher_new(info->image, info->title, info->desc); + + g_object_set_data(G_OBJECT(launcher), "panel_type", GSIZE_TO_POINTER(info->panel_type)); + + gtk_list_box_append(list, GTK_WIDGET(launcher)); + + } + +} + + +/****************************************************************************** +* * +* Paramètres : row = lanceur sélectionné. * +* * +* Description : Fournit un composant d'édition de paramètres de panneau. * +* * +* Retour : Composant d'édition de paramètres ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *get_framework_panel_parameters(GtkListBoxRow *row) +{ + GtkWidget *result; /* Composant à retourner */ + gpointer *data; /* Valeur incrustée */ + GType target; /* Type de panneau recherché */ + ext_panel_info_t *info; /* Informations conservées */ + size_t i; /* Boucle de parcours */ + + data = g_object_get_data(G_OBJECT(row), "panel_type"); + assert(data != NULL); + + target = GPOINTER_TO_SIZE(data); - if (!result) break; + info = NULL; + + for (i = 0; i < _panels_count; i++) + { + info = _panels_list[i]; + + if (info->panel_type == target) + break; } + assert(info != NULL); + assert(i < _panels_count); + + if (info->params_type == G_TYPE_INVALID) + result = NULL; + else + result = g_object_new(info->params_type, NULL); + return result; } diff --git a/src/gui/core/panels.h b/src/gui/core/panels.h index aaea9e6..4d0ce41 100644 --- a/src/gui/core/panels.h +++ b/src/gui/core/panels.h @@ -2,7 +2,7 @@ /* Chrysalide - Outil d'analyse de fichiers binaires * panels.h - prototypes pour la gestion d'ensemble de tous les panneaux graphiques du framework * - * Copyright (C) 2016-2024 Cyrille Bagard + * Copyright (C) 2016-2025 Cyrille Bagard * * This file is part of Chrysalide. * @@ -26,30 +26,59 @@ #define _GUI_CORE_PANELS_H +#include <glib-object.h> #include <stdbool.h> +#include <gtk/gtk.h> -#include "../panel.h" +#include "../../gtkext/panel.h" -/* Charge les principaux panneaux graphiques du framework. */ -bool load_main_panels(void); +/* Types de panneaux pour éditeur */ +typedef enum _FrameworkPanelPersonality +{ + FPP_NONE = (0 << 0), /* Pas de particularité */ + + FPP_MAIN_PANEL = (1 << 0), /* Panneau principal */ + FPP_SINGLETON = (1 << 1), /* Instance unique */ + +} FrameworkPanelPersonality; + +/* Définition générique d'un panneau */ +typedef struct _panel_info_t +{ + const char *category; /* Groupe de rassemblement */ + + const char *image; /* Eventuelle image associée */ + const char *title; /* Désignation humaine */ + const char *desc; /* Description humaine */ + + FrameworkPanelPersonality personality; /* Comportement attendu */ + + GType panel_type; /* Type du panneau représenté */ + GType params_type; /* Composant de paramètre */ + +} panel_info_t; + + +/* Charge les définitions des principaux panneaux du framework. */ +bool load_main_framework_panel_definitions(void); /* Décharge tous les panneaux graphiques du framework. */ -void unload_all_panels(void); +void unload_all_framework_panel_definitions(void); -/* Enregistre un panneau comme partie intégrante de l'éditeur. */ -void register_panel_item(/* __steal */ GPanelItem *); +/* Enregistre la définition d'un panneau graphique. */ +bool register_framework_panel_definition(const panel_info_t *); -/* Retrouve la définition d'un type de panneau. */ -GPanelItem *find_item_panel_by_type(GType); +/* Met en place (au besoin) un panneau graphique unique. */ +GtkTiledPanel *get_framework_panel_singleton(GType); -/* Réalise un traitement sur un panneau de l'éditeur. */ -typedef bool (* handle_panel_item_fc) (GPanelItem *, void *); +/* Intègre une définition de panneau enregistrée. */ +void populate_framework_panel_launcher_list(GtkListBox *); -/* Effectue le parcours de tous les panneaux chargés. */ -bool browse_all_item_panels(bool, handle_panel_item_fc, void *); +/* Fournit un composant d'édition de paramètres de panneau. */ +GtkWidget *get_framework_panel_parameters(GtkListBoxRow *); diff --git a/src/gui/dialogs/preferences.c b/src/gui/dialogs/preferences.c index aca562a..68e7fd9 100644 --- a/src/gui/dialogs/preferences.c +++ b/src/gui/dialogs/preferences.c @@ -37,6 +37,8 @@ #include "prefs/security.h" #include "../../common/cpp.h" #include "../../gtkext/tweak.h" +#include "../../plugins/pglist.h" +#include "../../plugins/tweakable.h" @@ -133,6 +135,8 @@ static void gtk_preferences_dialog_init(GtkPreferencesDialog *dialog) const tweak_info_t *info; /* Informations à considérer */ GtkListBox *navigation; /* Liste de sections à afficher*/ GtkTweakSection *section; /* Nouvelle section à présenter*/ + tweak_info_t *dyn_infos; /* Informations supplémentaires*/ + size_t dyn_count; /* Quantité de ces informations*/ tweak_info_t infos[] = { TWEAK_SIMPLE_DEF("root", "Basics", @@ -158,6 +162,26 @@ static void gtk_preferences_dialog_init(GtkPreferencesDialog *dialog) } + /* Chargement des sections dynamiques */ + + dyn_infos = get_tweakable_plugins_info(&dyn_count); + + for (i = 0; i < dyn_count; i++) + { + info = &dyn_infos[i]; + + navigation = gtk_preferences_dialog_get_navigation(dialog, info->parent, true); + assert(navigation != NULL); + + section = gtk_tweak_section_new(info); + + gtk_list_box_append(navigation, GTK_WIDGET(section)); + + } + + if (dyn_infos != NULL) + free(dyn_infos); + /* Affichage de la liste racine */ navigation = gtk_preferences_dialog_get_navigation(dialog, "root", false); diff --git a/src/gui/dialogs/prefs/security-int.h b/src/gui/dialogs/prefs/security-int.h index c693fdb..be7867c 100644 --- a/src/gui/dialogs/prefs/security-int.h +++ b/src/gui/dialogs/prefs/security-int.h @@ -30,7 +30,7 @@ -/* Fenêtre d'édition générale de la configuration (instance) */ +/* Composant d'édition des paramètres de sécurité (instance) */ struct _GtkSecurityTweakPanel { GtkBox parent; /* A laisser en premier */ @@ -52,7 +52,7 @@ struct _GtkSecurityTweakPanel }; -/* Fenêtre d'édition générale de la configuration (classe) */ +/* Composant d'édition des paramètres de sécurité (classe) */ struct _GtkSecurityTweakPanelClass { GtkBoxClass parent; /* A laisser en premier */ diff --git a/src/gui/dialogs/prefs/security.c b/src/gui/dialogs/prefs/security.c index cf2f6c8..2b82339 100644 --- a/src/gui/dialogs/prefs/security.c +++ b/src/gui/dialogs/prefs/security.c @@ -1,6 +1,6 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * security.h - configuration des paramètres liés à la sécurité + * security.c - configuration des paramètres liés à la sécurité * * Copyright (C) 2025 Cyrille Bagard * @@ -82,7 +82,7 @@ static void gtk_security_tweak_panel_on_remove_password_clicked(GtkButton *, Gtk /* ---------------------------------------------------------------------------------- */ -/* Détermine le type du composant d'affichage générique. */ +/* Indique le type du composant d'édition des paramètres de sécurité. */ G_DEFINE_TYPE(GtkSecurityTweakPanel, gtk_security_tweak_panel, GTK_TYPE_BOX); diff --git a/src/gui/panel-int.h b/src/gui/panel-int.h deleted file mode 100644 index 7e6f7e3..0000000 --- a/src/gui/panel-int.h +++ /dev/null @@ -1,71 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * panel-int.h - prototypes pour les définitions internes liées aux panneaux d'affichage - * - * Copyright (C) 2019-2024 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 - */ - - -#ifndef _GUI_PANEL_INT_H -#define _GUI_PANEL_INT_H - - -#include "panel.h" - - - -/* Fournit une indication sur la personnalité du panneau. */ -typedef PanelItemPersonality (* get_panel_item_personality_cb) (const GPanelItem *); - -/* Fournit un composant pour lancer l'activité d'un panneau. */ -typedef GtkWidget * (* get_panel_item_widget_cb) (GPanelItem *); - -/* Fournit un composant représentant un panneau graphique. */ -typedef GtkTiledPanel * (* get_panel_item_panel_cb) (GPanelItem *, GtkWidget *); - - -/* Elément réactif pour panneaux de l'éditeur (instance) */ -struct _GPanelItem -{ - GObject parent; /* A laisser en premier */ - - GtkWidget *launcher; /* Eventuel lanceur associé */ - GtkWidget *properties; /* Propriétés de lancement */ - - GtkTiledPanel **panels; /* Instances complètes ouvertes*/ - size_t pcount; /* Quantité de ces instances */ - -}; - -/* Elément réactif pour panneaux de l'éditeur (classe) */ -struct _GPanelItemClass -{ - GObjectClass parent; /* A laisser en premier */ - - get_panel_item_personality_cb get_personality; /* Fourniture de nature */ - - get_panel_item_widget_cb get_launcher; /* Lancement d'une activité */ - get_panel_item_widget_cb get_properties;/* Préparation au lancement */ - get_panel_item_panel_cb get_panel; /* Panneau principal */ - -}; - - - -#endif /* _GUI_PANEL_INT_H */ diff --git a/src/gui/panel.c b/src/gui/panel.c deleted file mode 100644 index b361153..0000000 --- a/src/gui/panel.c +++ /dev/null @@ -1,1207 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * panel.c - gestion des éléments réactifs spécifiques aux panneaux - * - * Copyright (C) 2019-2024 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 "panel.h" - - -#include "panel-int.h" - - - -/* ---------------------- MANIPULATIONS D'UN PANNEAU GRAPHIQUE ---------------------- */ - - - - - -/* Initialise la classe des panneaux graphiques de l'éditeur. */ -static void g_panel_item_class_init(GPanelItemClass *); - -/* Initialise une instance de panneau graphique pour l'éditeur. */ -static void g_panel_item_init(GPanelItem *); - -/* Supprime toutes les références externes. */ -static void g_panel_item_dispose(GPanelItem *); - -/* Procède à la libération totale de la mémoire. */ -static void g_panel_item_finalize(GPanelItem *); - - - - - -/* Indique le type défini pour un élément destiné à un panneau. */ -G_DEFINE_TYPE(GPanelItem, g_panel_item, G_TYPE_OBJECT); - - -/****************************************************************************** -* * -* Paramètres : class = classe à initialiser. * -* * -* Description : Initialise la classe des panneaux graphiques de l'éditeur. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_panel_item_class_init(GPanelItemClass *class) -{ - GObjectClass *object; /* Autre version de la classe */ - - object = G_OBJECT_CLASS(class); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_panel_item_dispose; - object->finalize = (GObjectFinalizeFunc)g_panel_item_finalize; - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance à initialiser. * -* * -* Description : Initialise une instance de panneau graphique pour l'éditeur. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_panel_item_init(GPanelItem *item) -{ - //item->docked = false; - - //item->widget = NULL; - //item->cached_widget = NULL; - - //item->filter = NULL; - - //g_atomic_int_set(&item->switched, 0); - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_panel_item_dispose(GPanelItem *item) -{ - //g_clear_object(&item->widget); - //g_clear_object(&item->cached_widget); - - G_OBJECT_CLASS(g_panel_item_parent_class)->dispose(G_OBJECT(item)); - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_panel_item_finalize(GPanelItem *item) -{ - G_OBJECT_CLASS(g_panel_item_parent_class)->finalize(G_OBJECT(item)); - -} - - -/****************************************************************************** -* * -* Paramètres : item = définition de panneau à consulter. * -* * -* Description : Fournit une indication sur la personnalité du panneau. * -* * -* Retour : Identifiant lié à la nature du panneau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -PanelItemPersonality g_panel_item_get_personality(const GPanelItem *item) -{ - PanelItemPersonality result; /* Personnalité à retourner */ - GPanelItemClass *class; /* Classe à actionner */ - - class = G_PANEL_ITEM_GET_CLASS(item); - - result = class->get_personality(item); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = définition de panneau à manipuler. * -* * -* Description : Fournit un composant pour lancer l'activité d'un panneau. * -* * -* Retour : Composant GTK (déjà ?) mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GtkWidget *g_panel_item_get_launcher(GPanelItem *item) -{ - GtkWidget *result; /* Composant à retourner */ - GPanelItemClass *class; /* Classe à actionner */ - - if (item->launcher == NULL) - { - class = G_PANEL_ITEM_GET_CLASS(item); - item->launcher = class->get_launcher(item); - } - - result = item->launcher; - - if (result != NULL) - ref_object(result); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = définition de panneau à manipuler. * -* * -* Description : Fournit un composant pour paramétrer l'activité d'un panneau.* -* * -* Retour : Composant GTK (déjà ?) mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GtkWidget *g_panel_item_get_properties(GPanelItem *item) -{ - GtkWidget *result; /* Composant à retourner */ - GPanelItemClass *class; /* Classe à actionner */ - - if (item->properties == NULL) - { - class = G_PANEL_ITEM_GET_CLASS(item); - item->properties = class->get_properties(item); - } - - result = item->properties; - - if (result != NULL) - ref_object(result); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = définition de panneau à manipuler. * -* * -* Description : Fournit un composant représentant un panneau graphique. * -* * -* Retour : Composant GTK (déjà ?) mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GtkTiledPanel *g_panel_item_get_panel(GPanelItem *item) -{ - GtkTiledPanel *result; /* Composant à retourner */ - GPanelItemClass *class; /* Classe à actionner */ - - if (item->pcount == 0 /* || !singleton */) - { - class = G_PANEL_ITEM_GET_CLASS(item); - result = class->get_panel(item, item->properties); - - if (result != NULL) - { - item->panels = realloc(item->panels, ++item->pcount * sizeof(GtkTiledPanel *)); - item->panels[item->pcount - 1] = result; - } - - } - - else - result = item->panels[item->pcount - 1]; - - if (result != NULL) - ref_object(result); - - return result; - -} - - - - - - - - - - - - - -#if 0 - - -#include <assert.h> -#include <stdio.h> -#include <string.h> - - -#include "panel-int.h" -#include "core/global.h" -#include "core/items.h" -#include "../common/extstr.h" -#include "../core/params.h" -#include "../gtkext/gtkdockable-int.h" -#include "../gtkext/named.h" -#include "../plugins/dt.h" -#include "../plugins/pglist.h" - - - -/* ------------------------- COEUR DES PANNEAUX D'AFFICHAGE ------------------------- */ - - - - -/* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ - - -/* Construit la chaîne d'accès à un élément de configuration. */ -static char *gtk_panel_item_class_build_configuration_key(const GPanelItemClass *, const char *); - -/* Fournit le nom court du composant encapsulable. */ -static char *gtk_panel_item_get_name(const GPanelItem *); - -/* Fournit le nom long du composant encapsulable. */ -static char *gtk_panel_item_get_desc(const GPanelItem *); - -/* Détermine si un panneau peut être filtré. */ -static bool gtk_panel_item_can_search(const GPanelItem *); - -/* Fournit le composant graphique intégrable dans un ensemble. */ -static GtkWidget *gtk_panel_item_get_widget(GPanelItem *); - -/* Démarre l'actualisation du filtrage du contenu. */ -static void gtk_panel_item_update_filtered(GPanelItem *, const char *); - - - -/* ---------------------- MECANISMES DE MISE A JOUR DE PANNEAU ---------------------- */ - - -/* Présente une copie de l'affichage du composant rafraîchi. */ -static gboolean g_panel_item_draw_mask(GtkWidget *, cairo_t *, GPanelItem *); - - - -/* ---------------------------------------------------------------------------------- */ -/* COEUR DES PANNEAUX D'AFFICHAGE */ -/* ---------------------------------------------------------------------------------- */ - - - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Fournit une indication sur la personnalité du panneau. * -* * -* Retour : Identifiant lié à la nature unique du panneau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -PanelItemPersonality gtk_panel_item_class_get_personality_singleton(const GPanelItemClass *class) -{ - PanelItemPersonality result; /* Personnalité à retourner */ - - result = PIP_SINGLETON; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Fournit une indication d'accroche du panneau au démarrage. * -* * -* Retour : true si le panneau doit être affiché de prime abord. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool gtk_panel_item_class_dock_at_startup(const GPanelItemClass *class) -{ - bool result; /* Statut à retourner */ - GGenConfig *config; /* Configuration courante */ - char *key; /* Clef d'accès à un paramètre */ -#ifndef NDEBUG - bool status; /* Bilan de consultation */ -#endif - - config = get_main_configuration(); - - key = gtk_panel_item_class_build_configuration_key(class, "dock_at_startup"); - -#ifndef NDEBUG - status = g_generic_config_get_value(config, key, &result); - assert(status); -#else - g_generic_config_get_value(config, key, &result); -#endif - - free(key); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe associée à la consultation. * -* * -* Description : Renvoie false lors d'une consultation de la classe. * -* * -* Retour : false. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool gtk_panel_item_class_return_false(const GPanelItemClass *class) -{ - bool result; /* Statut à retourner */ - - result = false; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe associée à la consultation. * -* * -* Description : Renvoie true lors d'une consultation de la classe. * -* * -* Retour : true. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool gtk_panel_item_class_return_true(const GPanelItemClass *class) -{ - bool result; /* Statut à retourner */ - - result = true; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Détermine si un panneau peut être filtré. * -* * -* Retour : Bilan de la consultation. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool gtk_panel_item_class_can_search(const GPanelItemClass *class) -{ - bool result; /* Statut à retourner */ - - result = class->can_search(class); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Indique le chemin initial de la localisation d'un panneau. * -* * -* Retour : Chemin fixé associé à la position initiale. * -* * -* Remarques : - * -* * -******************************************************************************/ - -char *gtk_panel_item_class_get_path(const GPanelItemClass *class) -{ - char *result; /* Emplacement à retourner */ - GGenConfig *config; /* Configuration courante */ - char *key; /* Clef d'accès à un paramètre */ - const char *path; /* Nouveau chemin de placement */ -#ifndef NDEBUG - bool status; /* Statut de l'encapsulation */ -#endif - - config = get_main_configuration(); - - key = gtk_panel_item_class_build_configuration_key(class, "path"); - -#ifndef NDEBUG - status = g_generic_config_get_value(config, key, &path); - assert(status); -#else - g_generic_config_get_value(config, key, &path); -#endif - - free(key); - - result = strdup(path); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Indique la définition d'un éventuel raccourci clavier. * -* * -* Retour : Description d'un raccourci ou NULL si aucun de défini. * -* * -* Remarques : - * -* * -******************************************************************************/ - -char *gtk_panel_item_class_get_key_bindings(const GPanelItemClass *class) -{ - char *result; /* Emplacement à retourner */ - - if (class->get_bindings != NULL) - result = class->get_bindings(class); - - else - result = NULL; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe du type de panneau à traiter. * -* attrib = élément de configuration à inclure dans le résultat.* -* * -* Description : Construit la chaîne d'accès à un élément de configuration. * -* * -* Retour : Chaîne de caractères à libérer après usage. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static char *gtk_panel_item_class_build_configuration_key(const GPanelItemClass *class, const char *attrib) -{ - char *result; /* Construction à renvoyer */ - const char *name; /* Nom court du panneau */ - - name = g_editor_item_class_get_key(G_EDITOR_ITEM_CLASS(class)); - - asprintf(&result, "gui.panels.%s.%s", attrib, name); - - result = strrpl(result, " ", "_"); - - result = strlower(result); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe de panneau à consulter. * -* config = configuration à compléter. * -* * -* Description : Met en place les bases de la configuration d'un panneau. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool gtk_panel_item_class_setup_configuration(const GPanelItemClass *class, GGenConfig *config) -{ - bool result; /* Bilan à retourner */ - char *key; /* Clef d'accès à un paramètre */ - bool dock_at_startup; /* Affichage dès le départ ? */ - char *path; /* Localisation du panneau */ - - key = gtk_panel_item_class_build_configuration_key(class, "dock_at_startup"); - - dock_at_startup = class->dock_at_startup(class); - - result = g_generic_config_create_param_if_not_exist(config, key, CPT_BOOLEAN, dock_at_startup); - - free(key); - - if (!result) - goto exit; - - key = gtk_panel_item_class_build_configuration_key(class, "path"); - - path = class->get_path(class); - - result = g_generic_config_create_param_if_not_exist(config, key, CPT_STRING, path); - - free(path); - - free(key); - - exit: - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : type = type de panneau à mettre en place. * -* path = emplacement d'affichage ou NULL. * -* * -* Description : Crée un élément de panneau réactif. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GPanelItem *g_panel_item_new(GType type, const char *path) -{ - GPanelItem *result; /* Structure à retourner */ - GPanelItemClass *class; /* Classe associée au type */ - PanelItemPersonality personality; /* Caractéristique de panneau */ - GtkTiledGrid *grid; /* Composant d'affichage */ - - class = g_type_class_ref(type); - - personality = gtk_panel_item_class_get_personality(class); - assert(path != NULL || personality == PIP_PERSISTENT_SINGLETON); - - g_type_class_unref(class); - - if (personality == PIP_PERSISTENT_SINGLETON || personality == PIP_SINGLETON) - { - result = G_PANEL_ITEM(find_editor_item_by_type(type)); - - if (result != NULL) - goto singleton; - - } - - result = create_object_from_type(type); - - grid = get_tiled_grid(); - - g_signal_connect_swapped(result, "dock-request", G_CALLBACK(gtk_tiled_grid_add), grid); - g_signal_connect_swapped(result, "undock-request", G_CALLBACK(gtk_tiled_grid_remove), grid); - - gtk_dockable_setup_dnd(GTK_DOCKABLE(result)); - - register_editor_item(G_EDITOR_ITEM(result)); - - notify_panel_creation(result); - - singleton: - - if (path != NULL) - { - if (path[0] != '\0') - gtk_panel_item_set_path(result, path); - - g_panel_item_dock(result); - - } - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance de panneau à consulter. * -* * -* Description : Indique le composant graphique principal du panneau. * -* * -* Retour : Composant graphique avec nom constituant le panneau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GNamedWidget *gtk_panel_item_get_named_widget(const GPanelItem *item) -{ - GNamedWidget *result; /* Composant nommé à retourner */ - - result = item->widget; - - g_object_ref(G_OBJECT(result)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance GTK dont l'interface est à consulter. * -* * -* Description : Fournit le nom court du composant encapsulable. * -* * -* Retour : Désignation humaine pour titre d'onglet ou de fenêtre. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static char *gtk_panel_item_get_name(const GPanelItem *item) -{ - char *result; /* Désignation à retourner */ - - result = g_named_widget_get_name(G_NAMED_WIDGET(item->widget), false); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance GTK dont l'interface est à consulter. * -* * -* Description : Fournit le nom long du composant encapsulable. * -* * -* Retour : Désignation humaine pour titre d'onglet ou de fenêtre. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static char *gtk_panel_item_get_desc(const GPanelItem *item) -{ - char *result; /* Description à retourner */ - - result = g_named_widget_get_name(G_NAMED_WIDGET(item->widget), true); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance GTK dont l'interface est à consulter. * -* * -* Description : Détermine si un panneau peut être filtré. * -* * -* Retour : Bilan de la consultation. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool gtk_panel_item_can_search(const GPanelItem *item) -{ - bool result; /* Indication à retourner */ - GPanelItemClass *class; /* Classe de l'élément visé */ - - class = G_PANEL_ITEM_GET_CLASS(item); - - result = gtk_panel_item_class_can_search(class); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance GTK dont l'interface est à consulter. * -* * -* Description : Fournit le composant graphique intégrable dans un ensemble. * -* * -* Retour : Composant graphique prêt à emploi. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GtkWidget *gtk_panel_item_get_widget(GPanelItem *item) -{ - GtkWidget *result; /* Composant à retourner */ - - if (item->cached_widget == NULL) - item->cached_widget = g_named_widget_get_widget(G_NAMED_WIDGET(item->widget)); - - result = item->cached_widget; - - g_object_ref(G_OBJECT(result)); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance GTK dont l'interface est à sollicitée. * -* * -* Description : Démarre l'actualisation du filtrage du contenu. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void gtk_panel_item_update_filtered(GPanelItem *item, const char *filter) -{ - assert(gtk_panel_item_can_search(item)); - - if (item->filter != NULL) - free(item->filter); - - item->filter = (filter ? strdup(filter) : NULL); - - G_PANEL_ITEM_GET_CLASS(item)->update_filtered(item); - -} - - -/****************************************************************************** -* * -* Paramètres : item = instance GTK à consulter. * -* path = nouvelle emplacement d'inclusion. * -* * -* Description : Définit le chemin d'accès à utiliser pour les encapsulations.* -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void gtk_panel_item_set_path(GPanelItem *item, const char *path) -{ - GGenConfig *config; /* Configuration courante */ - char *key; /* Clef d'accès à un paramètre */ - - config = get_main_configuration(); - - key = gtk_panel_item_class_build_configuration_key(G_PANEL_ITEM_GET_CLASS(item), "path"); - - g_generic_config_set_value(config, key, path); - - free(key); - -} - - -/****************************************************************************** -* * -* Paramètres : item = composant à présenter à l'affichage. * -* * -* Description : Place un panneau dans l'ensemble affiché. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_panel_item_dock(GPanelItem *item) -{ - assert(!item->docked); - - g_signal_emit_by_name(item, "dock-request"); - - if (G_PANEL_ITEM_GET_CLASS(item)->ack_dock != NULL) - G_PANEL_ITEM_GET_CLASS(item)->ack_dock(item); - - notify_panel_docking(item, true); - -} - - -/****************************************************************************** -* * -* Paramètres : item = composant d'affichage à mettre à jour. * -* status = nouvel état d'encapsulation. * -* * -* Description : Définit si le composant repose sur un support de l'éditeur. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_panel_item_set_dock_at_startup(GPanelItem *item, bool status) -{ - char *key; /* Clef d'accès à un paramètre */ - - item->docked = status; - - key = gtk_panel_item_class_build_configuration_key(G_PANEL_ITEM_GET_CLASS(item), "dock_at_startup"); - - g_generic_config_set_value(get_main_configuration(), key, status); - - free(key); - -} - - -/****************************************************************************** -* * -* Paramètres : item = composant d'affichage à consulter. * -* * -* Description : Indique si le composant repose sur un support de l'éditeur. * -* * -* Retour : true si le composant est bien incrusté quelque part. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool g_panel_item_is_docked(const GPanelItem *item) -{ - bool result; /* Statut à retourner */ - - result = item->docked; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : item = composant à retirer de l'affichage. * -* * -* Description : Supprime un panneau de l'ensemble affiché. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_panel_item_undock(GPanelItem *item) -{ - PanelItemPersonality personality; /* Caractéristique de panneau */ - - assert(item->docked); - - g_signal_emit_by_name(item, "undock-request"); - - if (G_PANEL_ITEM_GET_CLASS(item)->ack_undock != NULL) - G_PANEL_ITEM_GET_CLASS(item)->ack_undock(item); - - notify_panel_docking(item, false); - - personality = gtk_panel_item_class_get_personality(G_PANEL_ITEM_GET_CLASS(item)); - - if (personality != PIP_PERSISTENT_SINGLETON) - unregister_editor_item(G_EDITOR_ITEM(item)); - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* MECANISMES DE MISE A JOUR DE PANNEAU */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : item = panneau ciblé par une mise à jour. * -* * -* Description : Obtient le groupe de travail dédié à une mise à jour. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -wgroup_id_t g_panel_item_get_group(const GPanelItem *item) -{ - wgroup_id_t result; /* Identifiant à retourner */ - - result = G_PANEL_ITEM_GET_CLASS(item)->gid; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : widget = composant graphique sur lequel dessiner. * -* cr = contexte graphique pour le dessin. * -* panel = panneau ciblé par une mise à jour. * -* * -* Description : Présente une copie de l'affichage du composant rafraîchi. * -* * -* Retour : FALSE afin de poursuivre les traitements. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static gboolean g_panel_item_draw_mask(GtkWidget *widget, cairo_t *cr, GPanelItem *item) -{ - int width; /* Largeur du composant actuel */ - int height; /* Hauteur du composant actuel */ - - width = gtk_widget_get_allocated_width(widget); - height = gtk_widget_get_allocated_height(widget); - - cairo_save(cr); - - cairo_set_source_surface(cr, item->surface, 0, 0); - cairo_rectangle(cr, 0, 0, width, height); - - cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE); - cairo_fill(cr); - - cairo_restore(cr); - - return FALSE; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = panneau ciblé par une mise à jour. * -* * -* Description : Bascule l'affichage d'un panneau avant sa mise à jour. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_panel_item_switch_to_updating_mask(GPanelItem *item) -{ - GtkBuilder *builder; /* Constructeur sous-jacent */ - GtkWidget *content; /* Composant à faire évoluer */ - GdkWindow *window; /* Fenêtre au contenu à copier */ - int width; /* Largeur du composant actuel */ - int height; /* Hauteur du composant actuel */ - cairo_t *cr; /* Pinceau pour les dessins */ - GtkAdjustment *adj; /* Défilement éventuel */ - GtkStack *stack; /* Pile de composants GTK */ - GtkWidget *mask; /* Masque des travaux */ - - if (g_atomic_int_add(&item->switched, 1) > 0) - return; - - /* Copie de l'affichage courant */ - - assert(item->surface == NULL); - - builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(item->widget)); - - content = GTK_WIDGET(gtk_builder_get_object(builder, "content")); - - window = gtk_widget_get_window(content); - - if (window != NULL) - { - width = gtk_widget_get_allocated_width(content); - height = gtk_widget_get_allocated_height(content); - - item->surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, width, height); - - cr = cairo_create(item->surface); - - gdk_cairo_set_source_window(cr, window, 0, 0); - - cairo_paint(cr); - - cairo_destroy(cr); - - } - - /* Sauvegarde de l'éventuelle position */ - - if (GTK_IS_SCROLLED_WINDOW(content)) - { - adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(content)); - item->hadj_value = gtk_adjustment_get_value(adj); - - adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(content)); - item->vadj_value = gtk_adjustment_get_value(adj); - - } - - /* Opération de basculement effectif */ - - stack = GTK_STACK(gtk_builder_get_object(builder, "stack")); - - mask = GTK_WIDGET(gtk_builder_get_object(builder, "mask")); - - gtk_spinner_start(GTK_SPINNER(mask)); - - if (item->surface != NULL) - g_signal_connect(mask, "draw", G_CALLBACK(g_panel_item_draw_mask), item); - - gtk_stack_set_visible_child(stack, mask); - - g_object_unref(G_OBJECT(builder)); - -} - - -/****************************************************************************** -* * -* Paramètres : panel = panneau ciblé par une mise à jour. * -* * -* Description : Bascule l'affichage d'un panneau après sa mise à jour. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void g_panel_item_switch_to_updated_content(GPanelItem *item) -{ - GtkBuilder *builder; /* Constructeur sous-jacent */ - GtkWidget *content; /* Composant à faire évoluer */ - GtkAdjustment *adj; /* Défilement éventuel */ - GtkStack *stack; /* Pile de composants GTK */ - GtkWidget *mask; /* Masque des travaux */ - - if (g_atomic_int_get(&item->switched) > 1) - goto skip; - - /* Restauration d'une éventuelle position */ - - builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(item->widget)); - - content = GTK_WIDGET(gtk_builder_get_object(builder, "content")); - - if (GTK_IS_SCROLLED_WINDOW(content)) - { - adj = gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(content)); - gtk_adjustment_set_value(adj, item->hadj_value); - - adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(content)); - gtk_adjustment_set_value(adj, item->vadj_value); - - } - - /* Opération de basculement effectif */ - - stack = GTK_STACK(gtk_builder_get_object(builder, "stack")); - - gtk_stack_set_visible_child(stack, content); - - mask = GTK_WIDGET(gtk_builder_get_object(builder, "mask")); - - g_signal_handlers_disconnect_by_func(mask, G_CALLBACK(g_panel_item_draw_mask), item); - - gtk_spinner_stop(GTK_SPINNER(mask)); - - /* Supression de la copie d'affichage */ - - if (item->surface != NULL) - { - cairo_surface_destroy(item->surface); - item->surface = NULL; - } - - g_object_unref(G_OBJECT(builder)); - - skip: - - g_atomic_int_dec_and_test(&item->switched); - -} - - -#endif diff --git a/src/gui/panel.h b/src/gui/panel.h deleted file mode 100644 index 03b67d4..0000000 --- a/src/gui/panel.h +++ /dev/null @@ -1,148 +0,0 @@ - -/* Chrysalide - Outil d'analyse de fichiers binaires - * panel.h - prototypes pour la gestion des éléments réactifs spécifiques aux panneaux - * - * Copyright (C) 2019-2024 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 - */ - - -#ifndef _GUI_PANEL_H -#define _GUI_PANEL_H - - -#include "../glibext/helpers.h" -#include "../gtkext/panel.h" - - -#include <gtk/gtk.h> - - - -#define G_TYPE_PANEL_ITEM (g_panel_item_get_type()) - -DECLARE_GTYPE(GPanelItem, g_panel_item, G, PANEL_ITEM); - - -/* Types de panneaux pour éditeur */ -typedef enum _PanelItemPersonality -{ - PIP_NONE, /* Pas de particularité */ - - PIP_MAIN_PANEL, /* Panneau principal */ - PIP_SINGLETON, /* Instance unique */ - - PIP_COUNT - -} PanelItemPersonality; - - -/* Fournit une indication sur la personnalité du panneau. */ -PanelItemPersonality g_panel_item_get_personality(const GPanelItem *); - -/* Fournit un composant pour lancer l'activité d'un panneau. */ -GtkWidget *g_panel_item_get_launcher(GPanelItem *); - -/* Fournit un composant pour paramétrer l'activité d'un panneau. */ -GtkWidget *g_panel_item_get_properties(GPanelItem *); - -/* Fournit un composant représentant un panneau graphique. */ -GtkTiledPanel *g_panel_item_get_panel(GPanelItem *); - - - - - - - - - -#if 0 - - -#include <stdbool.h> -#include <gtk/gtk.h> - - -#include "../glibext/configuration.h" -#include "../glibext/named.h" - - - -#define G_TYPE_PANEL_ITEM g_panel_item_get_type() -#define G_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), G_TYPE_PANEL_ITEM, GPanelItem)) -#define G_IS_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), G_TYPE_PANEL_ITEM)) -#define G_PANEL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_PANEL_ITEM, GPanelItemClass)) -#define G_IS_PANEL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_PANEL_ITEM)) -#define G_PANEL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_PANEL_ITEM, GPanelItemClass)) - - -/* Elément réactif pour panneaux de l'éditeur (instance) */ -typedef struct _GPanelItem GPanelItem; - -/* Elément réactif pour panneaux de l'éditeur (classe) */ -typedef struct _GPanelItemClass GPanelItemClass; - - - - -/* Indique le type défini pour un élément destiné à un panneau. */ -GType g_panel_item_get_type(void); - -/* Fournit une indication d'accroche du panneau au démarrage. */ -bool gtk_panel_item_class_dock_at_startup(const GPanelItemClass *); - -/* Détermine si un panneau peut être filtré. */ -bool gtk_panel_item_class_can_search(const GPanelItemClass *); - -/* Indique le chemin initial de la localisation d'un panneau. */ -char *gtk_panel_item_class_get_path(const GPanelItemClass *); - -/* Indique la définition d'un éventuel raccourci clavier. */ -char *gtk_panel_item_class_get_key_bindings(const GPanelItemClass *); - -/* Met en place les bases de la configuration du panneau. */ -bool gtk_panel_item_class_setup_configuration(const GPanelItemClass *, GGenConfig *); - -/* Crée un élément de panneau réactif. */ -GPanelItem *g_panel_item_new(GType, const char *); - -/* Indique le composant graphique principal du panneau. */ -GNamedWidget *gtk_panel_item_get_named_widget(const GPanelItem *); - -/* Définit le chemin d'accès à utiliser pour les encapsulations. */ -void gtk_panel_item_set_path(GPanelItem *, const char *); - -/* Place un panneau dans l'ensemble affiché. */ -void g_panel_item_dock(GPanelItem *); - -/* Définit si le composant repose sur un support de l'éditeur. */ -void g_panel_item_set_dock_at_startup(GPanelItem *, bool); - -/* Indique si le composant repose sur un support de l'éditeur. */ -bool g_panel_item_is_docked(const GPanelItem *); - -/* Supprime un panneau de l'ensemble affiché. */ -void g_panel_item_undock(GPanelItem *); - - -#endif - - - -#endif /* _GUI_PANEL_H */ diff --git a/src/gui/panels/Makefile.am b/src/gui/panels/Makefile.am index 476a436..2765405 100644 --- a/src/gui/panels/Makefile.am +++ b/src/gui/panels/Makefile.am @@ -38,8 +38,7 @@ IMG_PATH = ../../../data/images RES_FILES = \ binary.ui \ - binary-launch.ui \ - binary-props.ui \ + binary-params.ui \ $(IMG_PATH)/binfile-symbolic.svg \ welcome.ui \ welcome-hints.txt \ @@ -48,6 +47,8 @@ RES_FILES = \ libguipanels4_la_SOURCES = \ binary-int.h \ binary.h binary.c \ + binary-params-int.h \ + binary-params.h binary-params.c \ resources.h resources.c \ welcome-int.h \ welcome.h welcome.c diff --git a/src/gui/panels/binary-int.h b/src/gui/panels/binary-int.h index f68da9b..5116f5c 100644 --- a/src/gui/panels/binary-int.h +++ b/src/gui/panels/binary-int.h @@ -27,14 +27,10 @@ #include "binary.h" -#include "../panel-int.h" #include "../../gtkext/panel-int.h" -/* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ - - /* Panneau d'accueil par défaut (instance) */ struct _GtkBinaryPanel { @@ -53,23 +49,4 @@ struct _GtkBinaryPanelClass -/* ---------------------- MANIPULATIONS D'UN PANNEAU GRAPHIQUE ---------------------- */ - - -/* Définition pour gestion par le framework d'un panneau graphique (instance) */ -struct _GBinaryPanel -{ - GPanelItem parent; /* A laisser en premier */ - -}; - -/* Définition pour gestion par le framework d'un panneau graphique (classe) */ -struct _GBinaryPanelClass -{ - GPanelItemClass parent; /* A laisser en premier */ - -}; - - - #endif /* _GUI_PANELS_BINARY_INT_H */ diff --git a/src/gui/panels/binary-launch.ui b/src/gui/panels/binary-launch.ui deleted file mode 100644 index 553f758..0000000 --- a/src/gui/panels/binary-launch.ui +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<interface> - - <object class="GtkGrid" id="launcher"> - <property name="margin-bottom">12</property> - <property name="margin-end">12</property> - <property name="margin-start">12</property> - <property name="margin-top">12</property> - <property name="column-spacing">12</property> - <child> - <object class="GtkImage"> - <property name="icon-name">binfile-symbolic</property> - <property name="pixel-size">48</property> - <layout> - <property name="column">0</property> - <property name="row">0</property> - <property name="row-span">2</property> - </layout> - <style> - <class name="icon-dropshadow"/> - </style> - </object> - </child> - <child> - <object class="GtkLabel"> - <property name="label"><b>Binary analysis</b></property> - <property name="use-markup">TRUE</property> - <property name="xalign">0</property> - <layout> - <property name="column">1</property> - <property name="row">0</property> - </layout> - </object> - </child> - <child> - <object class="GtkLabel"> - <property name="label">Load a binary content and parse its format if recognized</property> - <property name="hexpand">true</property> - <property name="xalign">0</property> - <layout> - <property name="column">1</property> - <property name="row">1</property> - </layout> - <style> - <class name="dim-label"/> - </style> - </object> - </child> - <child> - <object class="GtkImage"> - <property name="icon-name">go-next-symbolic</property> - <property name="margin-start">12</property> - <layout> - <property name="column">2</property> - <property name="row">0</property> - <property name="row-span">2</property> - </layout> - <style> - <class name="icon-dropshadow"/> - </style> - </object> - </child> - </object> - -</interface> diff --git a/src/gui/panels/binary-params-int.h b/src/gui/panels/binary-params-int.h new file mode 100644 index 0000000..0fbef24 --- /dev/null +++ b/src/gui/panels/binary-params-int.h @@ -0,0 +1,50 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * binary-params-int.h - définitions internes pour l'édition des paramètres initiaux d'un chargement de binaire + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GUI_PANELS_BINARY_PARAMS_INT_H +#define _GUI_PANELS_BINARY_PARAMS_INT_H + + +#include "binary-params.h" + + + +/* Composant pour les paramètres de chargement d'un binaire (instance) */ +struct _GtkBinaryParameters +{ + GtkGrid parent; /* A laisser en premier */ + + GtkEntry *filename; /* CHemin d'un binaire */ + +}; + +/* Composant pour les paramètres de chargement d'un binaire (classe) */ +struct _GtkBinaryParametersClass +{ + GtkGridClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _GUI_PANELS_BINARY_PARAMS_INT_H */ diff --git a/src/gui/panels/binary-params.c b/src/gui/panels/binary-params.c new file mode 100644 index 0000000..1059761 --- /dev/null +++ b/src/gui/panels/binary-params.c @@ -0,0 +1,178 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * binary-params.c - édition des paramètres initiaux d'un chargement de binaire + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#include "binary-params.h" + + +#include "binary.h" +#include "binary-params-int.h" +#include "../window.h" +#include "../../analysis/contents/file.h" +#include "../../gtkext/helpers.h" + + + +/* Initialise la classe des composants d'édition de paramètres. */ +static void gtk_binary_parameters_class_init(GtkBinaryParametersClass *); + +/* Initialise une instance de composant d'édition de paramètres. */ +static void gtk_binary_parameters_init(GtkBinaryParameters *); + +/* Supprime toutes les références externes. */ +static void gtk_binary_parameters_dispose(GObject *); + +/* Procède à la libération totale de la mémoire. */ +static void gtk_binary_parameters_finalize(GObject *); + +/* Ouvre une boîte de dialogue pour récupérer un fichier. */ +static void gtk_binary_parameters_on_new_file_entry_icon_release(GtkEntry *, GtkEntryIconPosition, GtkBinaryParameters *); + + + +/* Détermine le type du composant d'édition des paramètres de chargement. */ +G_DEFINE_TYPE(GtkBinaryParameters, gtk_binary_parameters, GTK_TYPE_GRID); + + +/****************************************************************************** +* * +* Paramètres : class = classe GTK à initialiser. * +* * +* Description : Initialise la classe des composants d'édition de paramètres. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_binary_parameters_class_init(GtkBinaryParametersClass *class) +{ + GObjectClass *object; /* Plus haut niveau équivalent */ + GtkWidgetClass *widget; /* Classe de haut niveau */ + + object = G_OBJECT_CLASS(class); + + object->dispose = gtk_binary_parameters_dispose; + object->finalize = gtk_binary_parameters_finalize; + + widget = GTK_WIDGET_CLASS(class); + + gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/panels/binary-params.ui"); + + gtk_widget_class_bind_template_callback_full(widget, BUILDER_CB(gtk_binary_parameters_on_new_file_entry_icon_release)); + + gtk_widget_class_bind_template_child(widget, GtkBinaryParameters, filename); + +} + + +/****************************************************************************** +* * +* Paramètres : params = composant GTK à initialiser. * +* * +* Description : Initialise une instance de composant d'édition de paramètres.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_binary_parameters_init(GtkBinaryParameters *params) +{ + gtk_widget_init_template(GTK_WIDGET(params)); + +} + + +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_binary_parameters_dispose(GObject *object) +{ + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_BINARY_PARAMETERS); + + G_OBJECT_CLASS(gtk_binary_parameters_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 gtk_binary_parameters_finalize(GObject *object) +{ + G_OBJECT_CLASS(gtk_binary_parameters_parent_class)->finalize(object); + +} + + +/****************************************************************************** +* * +* Paramètres : entry = zone de saisie concernée par l'appel. * +* icon_pos = position de l'icone incrustée dans la zone. * +* params = composant d'édition des paramètres. * +* * +* Description : Ouvre une boîte de dialogue pour récupérer un fichier. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_binary_parameters_on_new_file_entry_icon_release(GtkEntry *entry, GtkEntryIconPosition icon_pos, GtkBinaryParameters *params) +{ + GtkRoot *root; /* Racine du composant */ + GBinContent *content; /* Contenu binaire à afficher */ + GtkTiledPanel *tiled; /* Panneau d'affichage complet */ + + root = gtk_widget_get_root(GTK_WIDGET(entry)); + + content = g_file_content_new("/bin/id"); + + tiled = gtk_binary_panel_new_for_content(content); + + unref_object(content); + + gtk_framework_window_add(GTK_FRAMEWORK_WINDOW(root), tiled); + +} diff --git a/src/gui/panels/binary-params.h b/src/gui/panels/binary-params.h new file mode 100644 index 0000000..450da25 --- /dev/null +++ b/src/gui/panels/binary-params.h @@ -0,0 +1,41 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * binary-params.h - prototypes pour l'édition des paramètres initiaux d'un chargement de binaire + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _GUI_PANELS_BINARY_PARAMS_H +#define _GUI_PANELS_BINARY_PARAMS_H + + +#include <gtk/gtk.h> + + +#include "../../glibext/helpers.h" + + + +#define GTK_TYPE_BINARY_PARAMETERS (gtk_binary_parameters_get_type()) + +DECLARE_GTYPE(GtkBinaryParameters, gtk_binary_parameters, GTK, BINARY_PARAMETERS); + + + +#endif /* _GUI_PANELS_BINARY_PARAMS_H */ diff --git a/src/gui/panels/binary-props.ui b/src/gui/panels/binary-params.ui index bd48ea8..dcbaf7c 100644 --- a/src/gui/panels/binary-props.ui +++ b/src/gui/panels/binary-params.ui @@ -1,13 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> <interface> - <object class="GtkGrid" id="properties"> + <template class="GtkBinaryParameters" parent="GtkGrid"> <property name="margin-bottom">12</property> <property name="margin-end">12</property> <property name="margin-start">12</property> <property name="margin-top">12</property> <property name="column-spacing">12</property> <property name="row-spacing">8</property> + <child> <object class="GtkLabel"> <property name="label">Load and analyze a new file:</property> @@ -18,8 +19,9 @@ </layout> </object> </child> + <child> - <object class="GtkEntry" id="new_file"> + <object class="GtkEntry" id="filename"> <property name="secondary-icon-name">document-open-symbolic</property> <property name="placeholder-text">File location</property> <property name="hexpand">TRUE</property> @@ -31,9 +33,10 @@ <style> <class name="background"/> </style> - <signal name="icon-release" handler="g_binary_panel_on_new_file_entry_icon_release"/> + <signal name="icon-release" handler="gtk_binary_parameters_on_new_file_entry_icon_release"/> </object> </child> - </object> + + </template> </interface> diff --git a/src/gui/panels/binary.c b/src/gui/panels/binary.c index de0a4d0..f58c06b 100644 --- a/src/gui/panels/binary.c +++ b/src/gui/panels/binary.c @@ -26,8 +26,6 @@ #include "binary-int.h" -#include "../window.h" -#include "../../analysis/contents/file.h" #include "../../gtkext/helpers.h" #include "../../gtkext/hexview.h" @@ -43,10 +41,10 @@ static void gtk_binary_panel_class_init(GtkBinaryPanelClass *); static void gtk_binary_panel_init(GtkBinaryPanel *); /* Supprime toutes les références externes. */ -static void gtk_binary_panel_dispose(GtkBinaryPanel *); +static void gtk_binary_panel_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ -static void gtk_binary_panel_finalize(GtkBinaryPanel *); +static void gtk_binary_panel_finalize(GObject *); @@ -57,49 +55,12 @@ static void gtk_binary_panel_finalize(GtkBinaryPanel *); -/* ---------------------- MANIPULATIONS D'UN PANNEAU GRAPHIQUE ---------------------- */ - - -/* Initialise la classe des panneaux graphiques pour binaires. */ -static void g_binary_panel_class_init(GBinaryPanelClass *); - -/* Initialise une instance de panneau graphique pour binaire. */ -static void g_binary_panel_init(GBinaryPanel *); - -/* Supprime toutes les références externes. */ -static void g_binary_panel_dispose(GBinaryPanel *); - -/* Procède à la libération totale de la mémoire. */ -static void g_binary_panel_finalize(GBinaryPanel *); - - - -/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ - - -/* Fournit une indication sur la personnalité du panneau. */ -static PanelItemPersonality g_binary_panel_get_personality(const GBinaryPanel *); - -/* Fournit un composant pour lancer l'activité d'un panneau. */ -static GtkWidget *g_binary_panel_get_launcher(GBinaryPanel *); - -/* Fournit un composant pour paramétrer l'activité d'un panneau. */ -static GtkWidget *g_binary_panel_get_properties(GBinaryPanel *); - -/* Ouvre une boîte de dialogue pour récupérer un fichier. */ -static void g_binary_panel_on_new_file_entry_icon_release(GtkEntry *, GtkEntryIconPosition, GBinaryPanel *); - -/* Fournit un composant représentant un panneau graphique. */ -static GtkTiledPanel *g_binary_panel_get_panel(GBinaryPanel *, GtkWidget *); - - - /* ---------------------------------------------------------------------------------- */ /* COEUR D'UN PANNEAU D'AFFICHAGE */ /* ---------------------------------------------------------------------------------- */ -/* Indique le type défini pour un panneau d'accueil. */ +/* Indique le type défini pour un panneau d'affichage de contenus d'un binaire. */ G_DEFINE_TYPE(GtkBinaryPanel, gtk_binary_panel, GTK_TYPE_TILED_PANEL); @@ -122,8 +83,8 @@ static void gtk_binary_panel_class_init(GtkBinaryPanelClass *class) object = G_OBJECT_CLASS(class); - object->dispose = (GObjectFinalizeFunc/* ! */)gtk_binary_panel_dispose; - object->finalize = (GObjectFinalizeFunc)gtk_binary_panel_finalize; + object->dispose = gtk_binary_panel_dispose; + object->finalize = gtk_binary_panel_finalize; widget = GTK_WIDGET_CLASS(class); @@ -155,7 +116,7 @@ static void gtk_binary_panel_init(GtkBinaryPanel *panel) /****************************************************************************** * * -* Paramètres : panel = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Supprime toutes les références externes. * * * @@ -165,18 +126,18 @@ static void gtk_binary_panel_init(GtkBinaryPanel *panel) * * ******************************************************************************/ -static void gtk_binary_panel_dispose(GtkBinaryPanel *panel) +static void gtk_binary_panel_dispose(GObject *object) { - gtk_widget_dispose_template(GTK_WIDGET(panel), GTK_TYPE_BINARY_PANEL); + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_BINARY_PANEL); - G_OBJECT_CLASS(gtk_binary_panel_parent_class)->dispose(G_OBJECT(panel)); + G_OBJECT_CLASS(gtk_binary_panel_parent_class)->dispose(object); } /****************************************************************************** * * -* Paramètres : panel = instance d'objet GLib à traiter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * * Description : Procède à la libération totale de la mémoire. * * * @@ -186,9 +147,9 @@ static void gtk_binary_panel_dispose(GtkBinaryPanel *panel) * * ******************************************************************************/ -static void gtk_binary_panel_finalize(GtkBinaryPanel *panel) +static void gtk_binary_panel_finalize(GObject *object) { - G_OBJECT_CLASS(gtk_binary_panel_parent_class)->finalize(G_OBJECT(panel)); + G_OBJECT_CLASS(gtk_binary_panel_parent_class)->finalize(object); } @@ -232,286 +193,3 @@ GtkTiledPanel *gtk_binary_panel_new_for_content(GBinContent *content) - -/* ---------------------------------------------------------------------------------- */ -/* MANIPULATIONS D'UN PANNEAU GRAPHIQUE */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini pour une manipulation de panneau pour binaires. */ -G_DEFINE_TYPE(GBinaryPanel, g_binary_panel, G_TYPE_PANEL_ITEM); - - -/****************************************************************************** -* * -* Paramètres : class = classe à initialiser. * -* * -* Description : Initialise la classe des panneaux graphiques pour binaires. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_panel_class_init(GBinaryPanelClass *class) -{ - GObjectClass *object; /* Autre version de la classe */ - GPanelItemClass *panel; /* Encore une autre vision... */ - - object = G_OBJECT_CLASS(class); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_binary_panel_dispose; - object->finalize = (GObjectFinalizeFunc)g_binary_panel_finalize; - - panel = G_PANEL_ITEM_CLASS(class); - - panel->get_personality = (get_panel_item_personality_cb)g_binary_panel_get_personality; - panel->get_launcher = (get_panel_item_widget_cb)g_binary_panel_get_launcher; - panel->get_properties = (get_panel_item_widget_cb)g_binary_panel_get_properties; - panel->get_panel = (get_panel_item_panel_cb)g_binary_panel_get_panel; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance à initialiser. * -* * -* Description : Initialise une instance de panneau graphique pour binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_panel_init(GBinaryPanel *panel) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_panel_dispose(GBinaryPanel *panel) -{ - G_OBJECT_CLASS(g_binary_panel_parent_class)->dispose(G_OBJECT(panel)); - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_panel_finalize(GBinaryPanel *panel) -{ - G_OBJECT_CLASS(g_binary_panel_parent_class)->finalize(G_OBJECT(panel)); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Constitue une définition de manipulation de panneau. * -* * -* Retour : Définition de propriétés mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GPanelItem *g_binary_panel_new(void) -{ - GPanelItem *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_BINARY_PANEL, NULL); - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : panel = définition de panneau à consulter. * -* * -* Description : Fournit une indication sur la personnalité du panneau. * -* * -* Retour : Identifiant lié à la nature du panneau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PanelItemPersonality g_binary_panel_get_personality(const GBinaryPanel *panel) -{ - PanelItemPersonality result; /* Personnalité à retourner */ - - result = PIP_MAIN_PANEL; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = définition de panneau à manipuler. * -* * -* Description : Fournit un composant pour lancer l'activité d'un panneau. * -* * -* Retour : Composant GTK (déjà ?) mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GtkWidget *g_binary_panel_get_launcher(GBinaryPanel *panel) -{ - GtkWidget *result; /* Composant à retourner */ - GtkBuilder *builder; /* Constructeur d'UI */ - - builder = gtk_builder_new_from_resource("/re/chrysalide/framework/gui/panels/binary-launch.ui"); - - result = GTK_WIDGET(gtk_builder_get_object(builder, "launcher")); - ref_object(result); - - unref_object(builder); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = définition de panneau à manipuler. * -* * -* Description : Fournit un composant pour paramétrer l'activité d'un panneau.* -* * -* Retour : Composant GTK (déjà ?) mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GtkWidget *g_binary_panel_get_properties(GBinaryPanel *panel) -{ - GtkWidget *result; /* Composant à retourner */ - GtkBuilderScope *scope; /* Fonctions pour signaux */ - GtkBuilderCScope *cscope; /* Fonctions pour signaux */ - GtkBuilder *builder; /* Constructeur d'UI */ -#ifndef NDEBUG - gboolean status; /* Bilan d'un chargement */ -#endif - - scope = gtk_builder_cscope_new(); - cscope = GTK_BUILDER_CSCOPE(scope); - - gtk_builder_cscope_add_callback_symbol(cscope, BUILDER_CB(g_binary_panel_on_new_file_entry_icon_release)); - - builder = gtk_builder_new(); - gtk_builder_set_scope(builder, scope); - gtk_builder_set_current_object(builder, G_OBJECT(panel)); - -#ifndef NDEBUG - status = gtk_builder_add_from_resource(builder, "/re/chrysalide/framework/gui/panels/binary-props.ui", NULL); - assert(status); -#else - gtk_builder_add_from_resource(builder, "/re/chrysalide/framework/gui/panels/binary-props.ui", NULL); -#endif - - result = GTK_WIDGET(gtk_builder_get_object(builder, "properties")); - ref_object(result); - - unref_object(builder); - unref_object(scope); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : entry = zone de saisie concernée par l'appel. * -* icon_pos = position de l'icone incrustée dans la zone. * -* panel = définition de panneau à manipuler. * -* * -* Description : Ouvre une boîte de dialogue pour récupérer un fichier. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_binary_panel_on_new_file_entry_icon_release(GtkEntry *entry, GtkEntryIconPosition icon_pos, GBinaryPanel *panel) -{ - GtkRoot *root; /* Racine du composant */ - GtkTiledPanel *tiled; /* Panneau d'affichage complet */ - - root = gtk_widget_get_root(GTK_WIDGET(entry)); - - tiled = g_binary_panel_get_panel(panel, NULL); - - gtk_framework_window_add(GTK_FRAMEWORK_WINDOW(root), tiled); - -} - - -/****************************************************************************** -* * -* Paramètres : panel = définition de panneau à manipuler. * -* props = éventuels éléments graphiques de paramétrages. * -* * -* Description : Fournit un composant représentant un panneau graphique. * -* * -* Retour : Composant GTK (déjà ?) mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GtkTiledPanel *g_binary_panel_get_panel(GBinaryPanel *panel, GtkWidget *props) -{ - GtkTiledPanel *result; /* Composant à retourner */ - GBinContent *content; /* Contenu binaire à afficher */ - - content = g_file_content_new("/bin/id"); - - result = gtk_binary_panel_new_for_content(content); - - unref_object(content); - - return result; - -} diff --git a/src/gui/panels/binary.h b/src/gui/panels/binary.h index e92895b..26f8a7d 100644 --- a/src/gui/panels/binary.h +++ b/src/gui/panels/binary.h @@ -29,16 +29,12 @@ #include <gtk/gtk.h> -#include "../panel.h" #include "../../analysis/content.h" #include "../../glibext/helpers.h" #include "../../gtkext/panel.h" -/* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ - - #define GTK_TYPE_BINARY_PANEL (gtk_binary_panel_get_type()) DECLARE_GTYPE(GtkBinaryPanel, gtk_binary_panel, GTK, BINARY_PANEL); @@ -49,17 +45,4 @@ GtkTiledPanel *gtk_binary_panel_new_for_content(GBinContent *); -/* ---------------------- MANIPULATIONS D'UN PANNEAU GRAPHIQUE ---------------------- */ - - -#define G_TYPE_BINARY_PANEL (g_binary_panel_get_type()) - -DECLARE_GTYPE(GBinaryPanel, g_binary_panel, G, BINARY_PANEL); - - -/* Constitue une définition de manipulation de panneau. */ -GPanelItem *g_binary_panel_new(void); - - - #endif /* _GUI_PANELS_BINARY_H */ diff --git a/src/gui/panels/gresource.xml b/src/gui/panels/gresource.xml index d00953d..f49a16f 100644 --- a/src/gui/panels/gresource.xml +++ b/src/gui/panels/gresource.xml @@ -2,8 +2,7 @@ <gresources> <gresource prefix="/re/chrysalide/framework/gui/panels"> <file compressed="true">binary.ui</file> - <file compressed="true">binary-launch.ui</file> - <file compressed="true">binary-props.ui</file> + <file compressed="true">binary-params.ui</file> <file compressed="true">welcome.ui</file> <file compressed="true">welcome-hints.txt</file> </gresource> diff --git a/src/gui/panels/welcome-int.h b/src/gui/panels/welcome-int.h index d99d316..206bc2c 100644 --- a/src/gui/panels/welcome-int.h +++ b/src/gui/panels/welcome-int.h @@ -27,20 +27,15 @@ #include "welcome.h" -#include "../panel-int.h" #include "../../gtkext/panel-int.h" -/* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ - - /* Panneau d'accueil par défaut (instance) */ struct _GtkWelcomePanel { GtkTiledPanel parent; /* A laisser en premier */ - GListStore *store; /* Données brutes */ GtkListBox *list; /* Liste de lanceurs */ GtkStack *properties; /* Premières propriétés */ @@ -62,28 +57,5 @@ struct _GtkWelcomePanelClass }; -/* Met en place un nouveau panneau d'accueil. */ -bool gtk_welcome_panel_create(GtkWelcomePanel *); - - - -/* ---------------------- MANIPULATIONS D'UN PANNEAU GRAPHIQUE ---------------------- */ - - -/* Définition pour gestion par le framework d'un panneau graphique (instance) */ -struct _GWelcomePanel -{ - GPanelItem parent; /* A laisser en premier */ - -}; - -/* Définition pour gestion par le framework d'un panneau graphique (classe) */ -struct _GWelcomePanelClass -{ - GPanelItemClass parent; /* A laisser en premier */ - -}; - - #endif /* _GUI_PANELS_WELCOME_INT_H */ diff --git a/src/gui/panels/welcome.c b/src/gui/panels/welcome.c index 3cd349f..6e8763b 100644 --- a/src/gui/panels/welcome.c +++ b/src/gui/panels/welcome.c @@ -28,9 +28,6 @@ #include <assert.h> -#include <i18n.h> - - #include "welcome-int.h" #include "../core/panels.h" #include "../../common/shuffle.h" @@ -48,16 +45,10 @@ static void gtk_welcome_panel_class_init(GtkWelcomePanelClass *); static void gtk_welcome_panel_init(GtkWelcomePanel *); /* Supprime toutes les références externes. */ -static void gtk_welcome_panel_dispose(GtkWelcomePanel *); +static void gtk_welcome_panel_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ -static void gtk_welcome_panel_finalize(GtkWelcomePanel *); - -/* Intègre une définition de panneau enregistrée. */ -static bool gtk_welcome_panel_add_launcher(GPanelItem *, GListStore *); - -/* Prépare un composant pour représenter une définition. */ -static GtkWidget *gtk_welcome_panel_create_launcher_widget(GPanelItem *, gpointer); +static void gtk_welcome_panel_finalize(GObject *); /* Réagit à un changement de sélection de la liste de panneaux. */ static void gtk_welcome_panel_on_selected_rows_changed(GtkListBox *, GtkWelcomePanel *); @@ -78,32 +69,6 @@ static void gtk_welcome_panel_on_next_hint_clicked(GtkButton *, GtkWelcomePanel -/* ---------------------- MANIPULATIONS D'UN PANNEAU GRAPHIQUE ---------------------- */ - - -/* Initialise la classe des panneaux graphiques pour binaires. */ -static void g_welcome_panel_class_init(GWelcomePanelClass *); - -/* Initialise une instance de panneau graphique pour binaire. */ -static void g_welcome_panel_init(GWelcomePanel *); - -/* Supprime toutes les références externes. */ -static void g_welcome_panel_dispose(GWelcomePanel *); - -/* Procède à la libération totale de la mémoire. */ -static void g_welcome_panel_finalize(GWelcomePanel *); - - - -/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ - - -/* Fournit une indication sur la personnalité du panneau. */ -static PanelItemPersonality g_welcome_panel_get_personality(const GWelcomePanel *); - -/* Fournit un composant représentant un panneau graphique. */ -static GtkTiledPanel *g_welcome_panel_get_panel(GWelcomePanel *, GtkWidget *); - /* ---------------------------------------------------------------------------------- */ @@ -134,8 +99,8 @@ static void gtk_welcome_panel_class_init(GtkWelcomePanelClass *class) object = G_OBJECT_CLASS(class); - object->dispose = (GObjectFinalizeFunc/* ! */)gtk_welcome_panel_dispose; - object->finalize = (GObjectFinalizeFunc)gtk_welcome_panel_finalize; + object->dispose = gtk_welcome_panel_dispose; + object->finalize = gtk_welcome_panel_finalize; widget = GTK_WIDGET_CLASS(class); @@ -169,13 +134,16 @@ static void gtk_welcome_panel_init(GtkWelcomePanel *panel) { GBytes *bytes; /* Données brutes de ressource */ const gchar *data; /* Données brutes natives */ + int min; /* Taille à gauche minimale */ + GtkConstraintLayout *layout; /* Disposition fixant la taille*/ + GtkConstraint *constraint; /* Contrainte à considérer */ gtk_widget_init_template(GTK_WIDGET(panel)); - panel->store = g_list_store_new(G_TYPE_PANEL_ITEM); - panel->other_child = NULL; + /* Chargement des astuces */ + bytes = g_resources_lookup_data("/re/chrysalide/framework/gui/panels/welcome-hints.txt", G_RESOURCE_LOOKUP_FLAGS_NONE, NULL); assert(bytes != NULL); @@ -191,105 +159,9 @@ static void gtk_welcome_panel_init(GtkWelcomePanel *panel) panel->cur_hint = 0; -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void gtk_welcome_panel_dispose(GtkWelcomePanel *panel) -{ - gtk_widget_dispose_template(GTK_WIDGET(panel), GTK_TYPE_WELCOME_PANEL); - - g_clear_object(&panel->other_child); - - G_OBJECT_CLASS(gtk_welcome_panel_parent_class)->dispose(G_OBJECT(panel)); - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void gtk_welcome_panel_finalize(GtkWelcomePanel *panel) -{ - G_OBJECT_CLASS(gtk_welcome_panel_parent_class)->finalize(G_OBJECT(panel)); - - g_strfreev(panel->raw_hints); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée une nouvelle instance de panneau d'accueil. * -* * -* Retour : Composant GTK mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GtkTiledPanel *gtk_welcome_panel_new(void) -{ - GtkTiledPanel *result; /* Instance à retourner */ - - result = g_object_new(GTK_TYPE_WELCOME_PANEL, NULL); - - if (!gtk_welcome_panel_create(GTK_WELCOME_PANEL(result))) - g_clear_object(&result); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = panneau d'accueil à initialiser. * -* * -* Description : Met en place un nouveau panneau d'accueil. * -* * -* Retour : Bilan de l'opération. * -* * -* Remarques : - * -* * -******************************************************************************/ - -bool gtk_welcome_panel_create(GtkWelcomePanel *panel) -{ - bool result; /* Bilan à retourner */ - int min; /* Taille à gauche minimale */ - GtkConstraintLayout *layout; /* Disposition fixant la taille*/ - GtkConstraint *constraint; /* Contrainte à considérer */ - /* Constitution de la liste des démarreurs */ - result = browse_all_item_panels(true, (handle_panel_item_fc)gtk_welcome_panel_add_launcher, panel->store); - - gtk_list_box_bind_model(panel->list, G_LIST_MODEL(panel->store), - (GtkListBoxCreateWidgetFunc)gtk_welcome_panel_create_launcher_widget, - NULL, NULL); + populate_framework_panel_launcher_list(panel->list); /* Dimensionnement de la zone d'astuces */ @@ -327,57 +199,57 @@ bool gtk_welcome_panel_create(GtkWelcomePanel *panel) gtk_label_set_markup(panel->hints, panel->raw_hints[panel->cur_hint]); - return result; - } /****************************************************************************** * * -* Paramètres : item = définition de panneau à intégrer. * -* store = liste à compléter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * -* Description : Intègre une définition de panneau enregistrée. * +* Description : Supprime toutes les références externes. * * * -* Retour : true pour un parcours complet de la liste des définitions. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -static bool gtk_welcome_panel_add_launcher(GPanelItem *item, GListStore *store) +static void gtk_welcome_panel_dispose(GObject *object) { - bool result; /* Poursuite du parcours */ + GtkWelcomePanel *panel; /* Version spécialisée */ + + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_WELCOME_PANEL); - result = true; + panel = GTK_WELCOME_PANEL(object); - g_list_store_append(store, G_OBJECT(item)); + g_clear_object(&panel->other_child); - return result; + G_OBJECT_CLASS(gtk_welcome_panel_parent_class)->dispose(object); } /****************************************************************************** * * -* Paramètres : item = définition de panneau à consulter. * -* unused = adresse non utilisée ici. * +* Paramètres : object = instance d'objet GLib à traiter. * * * -* Description : Prépare un composant pour représenter une définition. * +* Description : Procède à la libération totale de la mémoire. * * * -* Retour : Composant de représentation de définition de panneau. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -static GtkWidget *gtk_welcome_panel_create_launcher_widget(GPanelItem *item, gpointer unused) +static void gtk_welcome_panel_finalize(GObject *object) { - GtkWidget *result; /* Composant GTK à retourner */ + GtkWelcomePanel *panel; /* Version spécialisée */ + + panel = GTK_WELCOME_PANEL(object); - result = g_panel_item_get_launcher(item); + g_strfreev(panel->raw_hints); - return result; + G_OBJECT_CLASS(gtk_welcome_panel_parent_class)->finalize(object); } @@ -398,8 +270,6 @@ static GtkWidget *gtk_welcome_panel_create_launcher_widget(GPanelItem *item, gpo static void gtk_welcome_panel_on_selected_rows_changed(GtkListBox *box, GtkWelcomePanel *panel) { GtkListBoxRow *row; /* Ligne sélectionnée */ - int selected; /* Indice de sélection */ - GPanelItem *item; /* Elément correspondant */ GtkWidget *new; /* Nouvelles propriétés */ row = gtk_list_box_get_selected_row(box); @@ -414,7 +284,7 @@ static void gtk_welcome_panel_on_selected_rows_changed(GtkListBox *box, GtkWelco gtk_stack_set_visible_child(panel->properties, panel->def_child); gtk_stack_remove(panel->properties, panel->other_child); - g_clear_object(&panel->other_child); + panel->other_child = NULL; } @@ -423,24 +293,16 @@ static void gtk_welcome_panel_on_selected_rows_changed(GtkListBox *box, GtkWelco */ else { - selected = gtk_list_box_row_get_index(row); - item = g_list_model_get_item(G_LIST_MODEL(panel->store), selected); + new = get_framework_panel_parameters(row); + assert(new != NULL); - new = g_panel_item_get_properties(item); - - if (new == panel->other_child) - unref_object(new); - - else + if (new != panel->other_child) { gtk_stack_add_child(panel->properties, new); gtk_stack_set_visible_child(panel->properties, new); if (panel->other_child != NULL) - { gtk_stack_remove(panel->properties, panel->other_child); - g_clear_object(&panel->other_child); - } panel->other_child = new; @@ -513,178 +375,3 @@ static void gtk_welcome_panel_on_next_hint_clicked(GtkButton *button, GtkWelcome - -/* ---------------------------------------------------------------------------------- */ -/* MANIPULATIONS D'UN PANNEAU GRAPHIQUE */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type défini pour une manipulation de panneau de bienvenue. */ -G_DEFINE_TYPE(GWelcomePanel, g_welcome_panel, G_TYPE_PANEL_ITEM); - - -/****************************************************************************** -* * -* Paramètres : class = classe à initialiser. * -* * -* Description : Initialise la classe des panneaux graphiques pour binaires. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_welcome_panel_class_init(GWelcomePanelClass *class) -{ - GObjectClass *object; /* Autre version de la classe */ - GPanelItemClass *panel; /* Encore une autre vision... */ - - object = G_OBJECT_CLASS(class); - - object->dispose = (GObjectFinalizeFunc/* ! */)g_welcome_panel_dispose; - object->finalize = (GObjectFinalizeFunc)g_welcome_panel_finalize; - - panel = G_PANEL_ITEM_CLASS(class); - - panel->get_personality = (get_panel_item_personality_cb)g_welcome_panel_get_personality; - panel->get_panel = (get_panel_item_panel_cb)g_welcome_panel_get_panel; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance à initialiser. * -* * -* Description : Initialise une instance de panneau graphique pour binaire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_welcome_panel_init(GWelcomePanel *panel) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_welcome_panel_dispose(GWelcomePanel *panel) -{ - G_OBJECT_CLASS(g_welcome_panel_parent_class)->dispose(G_OBJECT(panel)); - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance d'objet GLib à traiter. * -* * -* Description : Procède à la libération totale de la mémoire. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_welcome_panel_finalize(GWelcomePanel *panel) -{ - G_OBJECT_CLASS(g_welcome_panel_parent_class)->finalize(G_OBJECT(panel)); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Constitue une définition de manipulation de panneau. * -* * -* Retour : Définition de propriétés mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GPanelItem *g_welcome_panel_new(void) -{ - GPanelItem *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_WELCOME_PANEL, NULL); - - return result; - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : panel = définition de panneau à consulter. * -* * -* Description : Fournit une indication sur la personnalité du panneau. * -* * -* Retour : Identifiant lié à la nature du panneau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PanelItemPersonality g_welcome_panel_get_personality(const GWelcomePanel *panel) -{ - PanelItemPersonality result; /* Personnalité à retourner */ - - result = PIP_MAIN_PANEL | PIP_SINGLETON; - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = définition de panneau à manipuler. * -* props = éventuels éléments graphiques de paramétrages. * -* * -* Description : Fournit un composant représentant un panneau graphique. * -* * -* Retour : Composant GTK (déjà ?) mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GtkTiledPanel *g_welcome_panel_get_panel(GWelcomePanel *panel, GtkWidget *props) -{ - GtkTiledPanel *result; /* Composant à retourner */ - - /** - * Il n'existe pas de composants de paramètrage pour ce panneau. - */ - assert(props == NULL); - - result = gtk_welcome_panel_new(); - - return result; - -} diff --git a/src/gui/panels/welcome.h b/src/gui/panels/welcome.h index d267f80..d9ea18d 100644 --- a/src/gui/panels/welcome.h +++ b/src/gui/panels/welcome.h @@ -29,36 +29,15 @@ #include <gtk/gtk.h> -#include "../panel.h" #include "../../glibext/helpers.h" #include "../../gtkext/panel.h" -/* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ - - #define GTK_TYPE_WELCOME_PANEL (gtk_welcome_panel_get_type()) DECLARE_GTYPE(GtkWelcomePanel, gtk_welcome_panel, GTK, WELCOME_PANEL); -/* Crée une nouvelle instance de panneau d'accueil. */ -GtkTiledPanel *gtk_welcome_panel_new(void); - - - -/* ---------------------- MANIPULATIONS D'UN PANNEAU GRAPHIQUE ---------------------- */ - - -#define G_TYPE_WELCOME_PANEL (g_welcome_panel_get_type()) - -DECLARE_GTYPE(GWelcomePanel, g_welcome_panel, G, WELCOME_PANEL); - - -/* Constitue une définition de manipulation de panneau. */ -GPanelItem *g_welcome_panel_new(void); - - #endif /* _GUI_PANELS_WELCOME_H */ diff --git a/src/gui/window.c b/src/gui/window.c index a11e8aa..f45cec9 100644 --- a/src/gui/window.c +++ b/src/gui/window.c @@ -215,7 +215,6 @@ GtkApplicationWindow *gtk_framework_window_new(GtkApplication *app) bool gtk_framework_window_create(GtkFrameworkWindow *window, GtkApplication *app) { bool result; /* Bilan à retourner */ - GPanelItem *item; /* Définition de panneau */ GtkTiledPanel *panel; /* Panneau d'affichage */ GtkCssProvider *css; /* Feuille de style maison */ @@ -225,13 +224,10 @@ bool gtk_framework_window_create(GtkFrameworkWindow *window, GtkApplication *app /* Inclusion d'un écran d'accueil */ - item = find_item_panel_by_type(G_TYPE_WELCOME_PANEL); + panel = get_framework_panel_singleton(GTK_TYPE_WELCOME_PANEL); - panel = g_panel_item_get_panel(item); gtk_framework_window_add(window, panel); - unref_object(item); - /* Chargement des extensions de thème */ css = gtk_css_provider_new(); diff --git a/src/plugins/Makefile.am b/src/plugins/Makefile.am index 7d375e3..fa65484 100644 --- a/src/plugins/Makefile.am +++ b/src/plugins/Makefile.am @@ -10,7 +10,9 @@ libplugins_la_SOURCES = \ plugin-def.h \ plugin-int.h \ plugin.h plugin.c \ - self.h + self.h \ + tweakable-int.h \ + tweakable.h tweakable.c libplugins_la_CFLAGS = $(TOOLKIT_CFLAGS) $(LIBXML_CFLAGS) diff --git a/src/plugins/manager-int.h b/src/plugins/manager-int.h index 5ccc8f8..dbd1d69 100644 --- a/src/plugins/manager-int.h +++ b/src/plugins/manager-int.h @@ -1,6 +1,6 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * singleton-int.h - définitions internes propres aux interventions dans la gestion des extensions + * manager-int.h - définitions internes propres aux interventions dans la gestion des extensions * * Copyright (C) 2025 Cyrille Bagard * @@ -21,8 +21,8 @@ */ -#ifndef _PLUGINS_CONTAINER_INT_H -#define _PLUGINS_CONTAINER_INT_H +#ifndef _PLUGINS_MANAGER_INT_H +#define _PLUGINS_MANAGER_INT_H #include "manager.h" @@ -39,7 +39,7 @@ typedef void (* handle_native_plugins_cb) (GPluginManager *); typedef void (* handle_all_plugins_cb) (GPluginManager *); -/* Instance d'objet visant à être unique (interface) */ +/* Accompagnant dans la gestion des extensions (interface) */ struct _GPluginManagerInterface { GTypeInterface base_iface; /* A laisser en premier */ @@ -51,4 +51,4 @@ struct _GPluginManagerInterface -#endif /* _PLUGINS_CONTAINER_INT_H */ +#endif /* _PLUGINS_MANAGER_INT_H */ diff --git a/src/plugins/pglist.c b/src/plugins/pglist.c index 6dc2d9c..3e107b8 100644 --- a/src/plugins/pglist.c +++ b/src/plugins/pglist.c @@ -344,22 +344,10 @@ static void browse_directory_for_plugins(const char *dir) else { - - printf("// Candidate // %s\n", filename); - has_alt = check_for_plugin_versions(dir, namelist[k]->d_name, &is_nox, &is_ui); - printf(" -> nox=%d ui=%d -> alt? %d\n", is_nox, is_ui, has_alt); - - if ((nox_mode && is_nox) || (!nox_mode && ((is_nox && !has_alt) || is_ui))) { - - - printf(" ---> load!\n"); - - - module = g_module_open(filename, G_MODULE_BIND_LAZY); if (module == NULL) { @@ -369,32 +357,18 @@ static void browse_directory_for_plugins(const char *dir) goto next_file; } - - printf(" (main) module=%p '%s'\n", module, g_module_name(module)); - + get_instance = NULL; if (!g_module_symbol(module, "get_chrysalide_plugin_instance", (gpointer *)&get_instance)) - { log_variadic_message(LMT_ERROR, _("No '%s' entry in plugin candidate '%s'"), "<sym>", filename); - - - } - - if (get_instance == NULL) plugin = NULL; else plugin = get_instance(module); - - - printf(" ===> plugin: %p\n", plugin); - - - if (plugin != NULL) { register_plugin(plugin); diff --git a/src/plugins/pglist.h b/src/plugins/pglist.h index 5541493..777b19c 100644 --- a/src/plugins/pglist.h +++ b/src/plugins/pglist.h @@ -69,25 +69,60 @@ GPluginModule **get_all_plugins(size_t *); * Définitions des opérations appliquables à une catégories de greffons. */ -#define process_all_plugins_for(tp, cst, fc) \ - do \ - { \ - size_t __count; \ - GPluginModule **__list; \ - size_t __i; \ - __list = get_all_plugins(&__count); \ - for (__i = 0; __i < __count; __i++) \ - { \ - if (G_TYPE_CHECK_INSTANCE_TYPE(__list[__i], tp)) \ - fc(cst(__list[__i])); \ - unref_object(__list[__i]); \ - } \ - if (__list != NULL) \ - free(__list); \ - } \ +#define process_all_plugins_for(tp, cst, fc) \ + do \ + { \ + size_t __count; \ + GPluginModule **__list; \ + size_t __i; \ + GPluginModule *__pg; \ + __list = get_all_plugins(&__count); \ + for (__i = 0; __i < __count; __i++) \ + { \ + __pg = __list[__i]; \ + if (G_TYPE_CHECK_INSTANCE_TYPE(__pg, tp)) \ + fc(cst(__pg)); \ + unref_object(__pg); \ + } \ + if (__list != NULL) \ + free(__list); \ + } \ while (0) - +#define accumulate_from_all_plugins(tp, cst, fc, atp, cnt) \ + ({ \ + atp *__acc_list; \ + size_t __count; \ + GPluginModule **__list; \ + size_t __i; \ + GPluginModule *__pg; \ + size_t __tmp_count; \ + atp *__tmp_list; \ + *cnt = 0; \ + __acc_list = NULL; \ + __list = get_all_plugins(&__count); \ + for (__i = 0; __i < __count; __i++) \ + { \ + __pg = __list[__i]; \ + if (G_TYPE_CHECK_INSTANCE_TYPE(__pg, tp)) \ + { \ + __tmp_list = fc(cst(__pg), &__tmp_count); \ + if (__tmp_list != NULL) \ + { \ + __acc_list = realloc(__acc_list, \ + (*cnt + __tmp_count) * sizeof(atp)); \ + memcpy(&__acc_list[*cnt], __tmp_list, \ + __tmp_count * sizeof(atp)); \ + *cnt += __tmp_count; \ + free(__tmp_list); \ + } \ + } \ + unref_object(__pg); \ + } \ + if (__list != NULL) \ + free(__list); \ + __acc_list; \ + }) diff --git a/src/plugins/plugin.c b/src/plugins/plugin.c index b7f85d5..dfdf3ed 100644 --- a/src/plugins/plugin.c +++ b/src/plugins/plugin.c @@ -196,8 +196,6 @@ static void g_plugin_module_finalize(GPluginModule *plugin) { size_t i; /* Boucle de parcours */ - printf("[!!!] Finalizing plugin %s\n", plugin->name); - if (plugin->name != NULL) free(plugin->name); diff --git a/src/plugins/tweakable-int.h b/src/plugins/tweakable-int.h new file mode 100644 index 0000000..776626f --- /dev/null +++ b/src/plugins/tweakable-int.h @@ -0,0 +1,50 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * tweakable-int.h - définitions internes propres aux participations aux mécanismes de configuration + * + * 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 <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_TWEAKABLE_INT_H +#define _PLUGINS_TWEAKABLE_INT_H + + +#include "tweakable.h" + + + +/* ------------------- INTEGRATION DANS L'EDITION DES PREFERENCES ------------------- */ + + +/* Fournit une liste de sections de configuration. */ +typedef tweak_info_t * (* get_tweakable_plugin_info) (const GTweakablePlugin *, size_t *); + + +/* Greffon avec des compléments pour l'interface de configuration (interface) */ +struct _GTweakablePluginInterface +{ + GTypeInterface base_iface; /* A laisser en premier */ + + get_tweakable_plugin_info get_info; /* Récupération de section(s) */ + +}; + + + +#endif /* _PLUGINS_TWEAKABLE_INT_H */ diff --git a/src/plugins/tweakable.c b/src/plugins/tweakable.c new file mode 100644 index 0000000..517c4a3 --- /dev/null +++ b/src/plugins/tweakable.c @@ -0,0 +1,98 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * tweakable.c - participation aux mécanismes de configuration + * + * 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 Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#include "tweakable.h" + + +#include "tweakable-int.h" + + + +/* ------------------- INTEGRATION DANS L'EDITION DES PREFERENCES ------------------- */ + + +/* Procède à l'initialisation de l'interface d'intervention. */ +static void g_tweakable_plugin_default_init(GTweakablePluginInterface *); + + + +/* ---------------------------------------------------------------------------------- */ +/* INTEGRATION DANS L'EDITION DES PREFERENCES */ +/* ---------------------------------------------------------------------------------- */ + + +/* Détermine le type d'une interface pour l'intervention dans la gestion des greffons. */ +G_DEFINE_INTERFACE(GTweakablePlugin, g_tweakable_plugin, G_TYPE_OBJECT) + + +/****************************************************************************** +* * +* Paramètres : iface = interface GLib à initialiser. * +* * +* Description : Procède à l'initialisation de l'interface d'intervention. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_tweakable_plugin_default_init(GTweakablePluginInterface *iface) +{ + iface->get_info = NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : plugin = interface à manipuler. * +* count = taille de la liste renvoyée. [OUT] * +* * +* Description : Fournit une liste de sections de configuration. * +* * +* Retour : Définition(s) de section de configuration ou NULL. * +* * +* Remarques : - * +* * +******************************************************************************/ + +tweak_info_t *g_tweakable_plugin_get_tweak_info(const GTweakablePlugin *plugin, size_t *count) +{ + tweak_info_t *result; /* Liste à renvoyer */ + GTweakablePluginInterface *iface; /* Interface utilisée */ + + iface = G_TWEAKABLE_PLUGIN_GET_IFACE(plugin); + + if (iface->get_info != NULL) + result = iface->get_info(plugin, count); + + else + { + *count = 0; + result = NULL; + } + + return result; + +} diff --git a/src/plugins/tweakable.h b/src/plugins/tweakable.h new file mode 100644 index 0000000..aea70b4 --- /dev/null +++ b/src/plugins/tweakable.h @@ -0,0 +1,62 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * tweakable.h - prototypes pour la participation aux mécanismes de configuration + * + * 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 Foobar. If not, see <http://www.gnu.org/licenses/>. + */ + + +#ifndef _PLUGINS_TWEAKABLE_H +#define _PLUGINS_TWEAKABLE_H + + +#include "../glibext/helpers.h" +#include "../gtkext/tweak.h" + + + +/* ------------------- INTEGRATION DANS L'EDITION DES PREFERENCES ------------------- */ + + +#define G_TYPE_TWEAKABLE_PLUGIN (g_tweakable_plugin_get_type()) + +DECLARE_INTERFACE(GTweakablePlugin, g_tweakable_plugin, G, TWEAKABLE_PLUGIN); + + +/* Fournit une liste de sections de configuration. */ +tweak_info_t *g_tweakable_plugin_get_tweak_info(const GTweakablePlugin *, size_t *); + + + +/* -------------------- SOLLICITATION DES FONCTIONNALITES CREEES -------------------- */ + + +#define get_tweakable_plugins_info(c) \ + ({ \ + tweak_info_t *__all_info; \ + __all_info = accumulate_from_all_plugins(G_TYPE_TWEAKABLE_PLUGIN, \ + G_TWEAKABLE_PLUGIN, \ + g_tweakable_plugin_get_tweak_info, \ + tweak_info_t, \ + c); \ + __all_info; \ + }) + + + +#endif /* _PLUGINS_TWEAKABLE_H */ diff --git a/tests/glibext/secstorage.py b/tests/glibext/secstorage.py index 248b3e3..5b8f680 100644 --- a/tests/glibext/secstorage.py +++ b/tests/glibext/secstorage.py @@ -22,8 +22,6 @@ class TestSecretStorage(ChrysalideTestCase): subprocess.run([ 'glib-compile-schemas', path ]) - os.environ['GSETTINGS_SCHEMA_DIR'] = path + ':' + os.environ['GSETTINGS_SCHEMA_DIR'] - @classmethod def tearDownClass(cls): @@ -32,8 +30,6 @@ class TestSecretStorage(ChrysalideTestCase): cls.log('Removing compiled GSettings schema...') - os.environ['GSETTINGS_SCHEMA_DIR'] = ':'.join(os.environ['GSETTINGS_SCHEMA_DIR'].split(':')[1:]) - path = os.path.dirname(os.path.realpath(__file__)) filename = os.path.join(path, 'gschemas.compiled') @@ -42,10 +38,24 @@ class TestSecretStorage(ChrysalideTestCase): os.remove(filename) + def _get_settings(self, sid): + """Provide local GSettings instance.""" + + path = os.path.dirname(os.path.realpath(__file__)) + + source = Gio.SettingsSchemaSource.new_from_directory(path, None, True) + + schema = Gio.SettingsSchemaSource.lookup(source, sid, False) + + settings = Gio.Settings.new_full(schema, None, None) + + return settings + + def testMasterKeyDefinition(self): """Check for cryptographic parameters for secret storage.""" - settings = Gio.Settings.new('re.chrysalide.tests.secstorage') + settings = self._get_settings('re.chrysalide.tests.secstorage') storage = SecretStorage(settings) @@ -67,7 +77,7 @@ class TestSecretStorage(ChrysalideTestCase): def testMasterKeyCreation(self): """Create and update cryptographic parameters for secret storage.""" - settings = Gio.Settings.new('re.chrysalide.tests.secstorage') + settings = self._get_settings('re.chrysalide.tests.secstorage') storage = SecretStorage(settings) @@ -101,9 +111,9 @@ class TestSecretStorage(ChrysalideTestCase): def testDataEncryption(self): - """Create and update cryptographic parameters for secret storage.""" + """Encrypt and decrypt data with the secret storage.""" - settings = Gio.Settings.new('re.chrysalide.tests.secstorage') + settings = self._get_settings('re.chrysalide.tests.secstorage') storage = SecretStorage(settings) |