diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2024-07-20 23:23:43 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2024-07-20 23:23:43 (GMT) |
commit | e4ccb9e56e822628e299527fee0b7325f0d25662 (patch) | |
tree | 10d5eb35fad4ba01b757d4c403c912f209eacb3e /src/gui/core/panels.c | |
parent | 9d0d5edf372a9f681bbfd0a3639ee8fc367ce96d (diff) |
Prepare a welcome screen.
Diffstat (limited to 'src/gui/core/panels.c')
-rw-r--r-- | src/gui/core/panels.c | 143 |
1 files changed, 83 insertions, 60 deletions
diff --git a/src/gui/core/panels.c b/src/gui/core/panels.c index 1b6f604..69ab2aa 100644 --- a/src/gui/core/panels.c +++ b/src/gui/core/panels.c @@ -1,8 +1,8 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * panels.c - gestion d'ensemble de tous les panneaux pour l'éditeur + * panels.c - gestion d'ensemble de tous les panneaux graphiques du framework * - * Copyright (C) 2016-2019 Cyrille Bagard + * Copyright (C) 2016-2024 Cyrille Bagard * * This file is part of Chrysalide. * @@ -25,28 +25,16 @@ #include "panels.h" -#include <assert.h> #include <malloc.h> -#include "items.h" -#include "../panel-int.h" -#include "../panels/bintree.h" -#include "../panels/bookmarks.h" -#include "../panels/errors.h" -#include "../panels/glance.h" -#include "../panels/history.h" -#include "../panels/log.h" -#include "../panels/regedit.h" -#include "../panels/strings.h" -#include "../panels/symbols.h" +#include "../panels/binary.h" #include "../panels/welcome.h" -#include "../../core/params.h" /* Liste des panneaux disponibles */ -static GType *_panels_list = NULL; +static GPanelItem **_panels_list = NULL; static size_t _panels_count = 0; @@ -55,36 +43,54 @@ static size_t _panels_count = 0; * * * Paramètres : - * * * -* Description : Charge les principaux panneaux de l'éditeur. * +* Description : Charge les principaux panneaux graphiques du framework. * * * -* Retour : - * +* Retour : Bilan de l'opération. * * * * Remarques : - * * * ******************************************************************************/ -void load_main_panels(void) +bool load_main_panels(void) { - GGenConfig *config; /* Configuration globale */ - GPanelItem *panel; /* Panneau à précharger */ + bool result; /* Bilan à retourner */ - config = get_main_configuration(); + result = true; - register_panel_item(G_TYPE_LOG_PANEL, config); + // TODO register_panel_item(G_TYPE_LOG_PANEL, config); /* Chargement du panneau de rapport au plus tôt */ - panel = g_panel_item_new(G_TYPE_LOG_PANEL, NULL); - g_object_unref(G_OBJECT(panel)); - - register_panel_item(G_TYPE_WELCOME_PANEL, config); - register_panel_item(G_TYPE_REGEDIT_PANEL, config); - register_panel_item(G_TYPE_SYMBOLS_PANEL, config); - register_panel_item(G_TYPE_HISTORY_PANEL, config); - register_panel_item(G_TYPE_STRINGS_PANEL, config); - register_panel_item(G_TYPE_GLANCE_PANEL, config); - register_panel_item(G_TYPE_BOOKMARKS_PANEL, config); - register_panel_item(G_TYPE_BINTREE_PANEL, config); - register_panel_item(G_TYPE_ERROR_PANEL, config); + // 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()); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Décharge tous les panneaux graphiques du framework. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void unload_all_panels(void) +{ + size_t i; /* Boucle de parcours */ + + for (i = 0; i < _panels_count; i++) + unref_object(_panels_list[i]); + + _panels_list = NULL; + _panels_count = 0; } @@ -102,27 +108,49 @@ void load_main_panels(void) * * ******************************************************************************/ -void register_panel_item(GType type, GGenConfig *config) +void register_panel_item(/* __steal */ GPanelItem *item) { - GPanelItemClass *class; /* Classe associée au type */ -#ifndef NDEBUG - bool status; /* Bilan de mise en place */ -#endif + _panels_list = realloc(_panels_list, ++_panels_count * sizeof(GPanelItem *)); - _panels_list = realloc(_panels_list, ++_panels_count * sizeof(GType)); + _panels_list[_panels_count - 1] = item; - _panels_list[_panels_count - 1] = type; +} - class = g_type_class_ref(type); -#ifndef NDEBUG - status = gtk_panel_item_class_setup_configuration(class, config); - assert(status); -#else - gtk_panel_item_class_setup_configuration(class, config); -#endif +/****************************************************************************** +* * +* Paramètres : target = type de définition de panneau recherchée. * +* * +* Description : Retrouve la définition d'un type de panneau. * +* * +* Retour : Instance de définition identifiée ou NULL en cas d'échec. * +* * +* Remarques : - * +* * +******************************************************************************/ - g_type_class_unref(class); +GPanelItem *find_item_panel_by_type(GType target) +{ + GPanelItem *result; /* Instance à renvoyer */ + size_t i; /* Boucle de parcours */ + GPanelItem *item; /* Définition de panneau */ + + result = NULL; + + for (i = 0; i < _panels_count; i++) + { + item = _panels_list[i]; + + if (G_OBJECT_TYPE(item) == target) + { + result = item; + ref_object(result); + break; + } + + } + + return result; } @@ -141,27 +169,22 @@ void register_panel_item(GType type, GGenConfig *config) * * ******************************************************************************/ -bool _browse_all_item_panels(bool skip, handle_panel_item_fc handle, void *data) +bool browse_all_item_panels(bool skip, handle_panel_item_fc handle, void *data) { bool result; /* Résultat à renvoyer */ - GType type; /* Type de panneau à traiter */ size_t i; /* Boucle de parcours */ - GPanelItemClass *class; /* Classe associée au type */ + GPanelItem *item; /* Définition de panneau */ result = true; for (i = 0; i < _panels_count; i++) { - type = _panels_list[i]; + item = _panels_list[i]; - if (skip && type == G_TYPE_WELCOME_PANEL) + if (skip && G_OBJECT_TYPE(item) == G_TYPE_WELCOME_PANEL) continue; - class = g_type_class_ref(type); - - result = handle(class, data); - - g_type_class_unref(class); + result = handle(item, data); if (!result) break; |