diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2025-02-22 11:04:18 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2025-02-22 11:04:18 (GMT) |
commit | e16bc694115b5487df601858a471eea34eadc1ba (patch) | |
tree | 55407659053eb906d70ffb1af41530ba6fd6883c /src/gui/panels | |
parent | 0bec2b96a14da29a680aafe54895fd9cfb3bcf09 (diff) |
Simplify panel handling code.
Diffstat (limited to 'src/gui/panels')
-rw-r--r-- | src/gui/panels/Makefile.am | 4 | ||||
-rw-r--r-- | src/gui/panels/binary-int.h | 23 | ||||
-rw-r--r-- | src/gui/panels/binary-params-int.h | 50 | ||||
-rw-r--r-- | src/gui/panels/binary-params.c | 178 | ||||
-rw-r--r-- | src/gui/panels/binary-params.h | 41 | ||||
-rw-r--r-- | src/gui/panels/binary-params.ui (renamed from src/gui/panels/binary-props.ui) | 11 | ||||
-rw-r--r-- | src/gui/panels/binary.c | 340 | ||||
-rw-r--r-- | src/gui/panels/binary.h | 17 | ||||
-rw-r--r-- | src/gui/panels/gresource.xml | 2 | ||||
-rw-r--r-- | src/gui/panels/welcome-int.h | 28 | ||||
-rw-r--r-- | src/gui/panels/welcome.c | 376 | ||||
-rw-r--r-- | src/gui/panels/welcome.h | 21 |
12 files changed, 324 insertions, 767 deletions
diff --git a/src/gui/panels/Makefile.am b/src/gui/panels/Makefile.am index 525b1f6..2765405 100644 --- a/src/gui/panels/Makefile.am +++ b/src/gui/panels/Makefile.am @@ -38,7 +38,7 @@ IMG_PATH = ../../../data/images RES_FILES = \ binary.ui \ - binary-props.ui \ + binary-params.ui \ $(IMG_PATH)/binfile-symbolic.svg \ welcome.ui \ welcome-hints.txt \ @@ -47,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-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 23426e3..bb98c10 100644 --- a/src/gui/panels/binary.c +++ b/src/gui/panels/binary.c @@ -29,8 +29,6 @@ #include "binary-int.h" -#include "../window.h" -#include "../../analysis/contents/file.h" #include "../../gtkext/helpers.h" #include "../../gtkext/hexview.h" @@ -46,10 +44,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 *); @@ -60,43 +58,6 @@ 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 GtkPanelLauncher *g_binary_panel_get_launcher(GPanelItem *); - -/* 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 */ /* ---------------------------------------------------------------------------------- */ @@ -125,8 +86,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); @@ -158,7 +119,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. * * * @@ -168,18 +129,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. * * * @@ -189,9 +150,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); } @@ -235,282 +196,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 = g_binary_panel_get_launcher; - panel->get_properties = (get_panel_item_props_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 GtkPanelLauncher *g_binary_panel_get_launcher(GPanelItem *panel) -{ - GtkPanelLauncher *result; /* Composant à retourner */ - - result = gtk_panel_launcher_new("binfile-symbolic", - _("Binary analysis"), - _("Load a binary content and parse its format if recognized")); - - 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 2fecc8c..f49a16f 100644 --- a/src/gui/panels/gresource.xml +++ b/src/gui/panels/gresource.xml @@ -2,7 +2,7 @@ <gresources> <gresource prefix="/re/chrysalide/framework/gui/panels"> <file compressed="true">binary.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..6fd1304 100644 --- a/src/gui/panels/welcome.c +++ b/src/gui/panels/welcome.c @@ -48,16 +48,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 +72,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 +102,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 +137,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 +162,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 +202,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 */ - result = true; + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_WELCOME_PANEL); - g_list_store_append(store, G_OBJECT(item)); + panel = GTK_WELCOME_PANEL(object); - return result; + g_clear_object(&panel->other_child); + + 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 */ - result = g_panel_item_get_launcher(item); + panel = GTK_WELCOME_PANEL(object); - return result; + g_strfreev(panel->raw_hints); + + G_OBJECT_CLASS(gtk_welcome_panel_parent_class)->finalize(object); } @@ -398,8 +273,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 +287,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 +296,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 = g_panel_item_get_properties(item); - - if (new == panel->other_child) - unref_object(new); + new = get_framework_panel_parameters(row); + assert(new != NULL); - 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 +378,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 */ |