From d1665deb8929feeb3df4d8e1913063b8431a6d41 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 16 Apr 2025 10:48:35 +0200 Subject: Restore the log panel. --- src/app.c | 26 +++ src/data/images/Makefile.am | 3 +- src/data/images/gresource.xml | 1 + src/data/images/logs-symbolic.svg | 93 ++++++++++ src/glibext/Makefile.am | 2 + src/glibext/log-int.h | 58 ++++++ src/glibext/log.c | 306 ++++++++++++++++++++++++++++++ src/glibext/log.h | 43 +++++ src/gui/core/logs.c | 32 ++-- src/gui/core/panels.c | 22 ++- src/gui/panels/Makefile.am | 7 +- src/gui/panels/gresource.xml | 3 + src/gui/panels/logs-col-icon.ui | 17 ++ src/gui/panels/logs-col-message.ui | 19 ++ src/gui/panels/logs-int.h | 53 ++++++ src/gui/panels/logs.c | 370 ++++++++----------------------------- src/gui/panels/logs.h | 42 ++--- src/gui/panels/logs.ui | 103 +++++------ 18 files changed, 799 insertions(+), 401 deletions(-) create mode 100644 src/data/images/logs-symbolic.svg create mode 100644 src/glibext/log-int.h create mode 100644 src/glibext/log.c create mode 100644 src/glibext/log.h create mode 100644 src/gui/panels/logs-col-icon.ui create mode 100644 src/gui/panels/logs-col-message.ui create mode 100644 src/gui/panels/logs-int.h diff --git a/src/app.c b/src/app.c index 2e0d4fa..8c1a3e4 100644 --- a/src/app.c +++ b/src/app.c @@ -505,6 +505,32 @@ int main(int argc, char **argv) set_log_verbosity(verbosity); + /** + * Même s'il est dit que l'usage de GtkApplication permet de s'affranchir + * d'un appel à gtk_init(), il se trouve que la journalisation en mode + * graphique peut solliciter le panneau en GTK pour afficher des messages + * avant la mise en place de l'applicatif GTK principal : + * + * #2 0x00007ffff7b33403 in gtk_css_lookup_resolve (lookup=lookup@entry=0x7fffffff88a0, provider=provider@entry=0x0, sstyle=sstyle@entry=0x7fffe800a730, parent_style=parent_style@entry=0x0) at ../gtk/gtkcssstaticstyle.c:911 + * #3 0x00007ffff7b3389f in gtk_css_static_style_new_compute (provider=0x0, filter=filter@entry=0x7fffffff8ea0, node=node@entry=0x0, change=, change@entry=0) at ../gtk/gtkcssstaticstyle.c:1026 + * #4 0x00007ffff7b3392c in gtk_css_static_style_get_default () at ../gtk/gtkcssstaticstyle.c:711 + * #5 0x00007ffff7b24b09 in gtk_css_node_init (cssnode=0x7fffe800a5b0) at ../gtk/gtkcssnode.c:641 + * #6 0x00007ffff75d8dab in g_type_create_instance () at /lib/x86_64-linux-gnu/libgobject-2.0.so.0 + * [...] + * #10 0x00007ffff7b3b8fa in gtk_css_widget_node_new (widget=widget@entry=0x5555555bf1b0) at ../gtk/gtkcsswidgetnode.c:160 + * #11 0x00007ffff7ae4576 in gtk_widget_init (instance=, g_class=0x5555555be380) at ../gtk/gtkwidget.c:2345 + * [...] + * #16 0x00007ffff73fd3f4 in get_framework_panel_singleton (...) at panels.c:329 + * #17 0x00007ffff73fce35 in do_log_message_alt (...) at logs.c:56 + * [...] + * #23 0x00007ffff74566db in init_all_plugins (load=true) at pglist.c:103 + * #24 0x0000555555556d44 in main (argc=2, argv=0x7fffffffb568) at app.c:514 + * + * L'initialisation permettant un retour de gtk_settings_get_default() non + * nul est ainsi forcée au plus tôt avec un appel à gtk_init() manuel. + */ + gtk_init(); + if (!load_core_components(ACC_GLOBAL_VARS)) goto exit; diff --git a/src/data/images/Makefile.am b/src/data/images/Makefile.am index f5782c6..068e43f 100644 --- a/src/data/images/Makefile.am +++ b/src/data/images/Makefile.am @@ -6,7 +6,8 @@ noinst_LTLIBRARIES = libdataimages.la RES_FILES = \ dock-station-left-symbolic.svg \ dock-station-right-symbolic.svg \ - dock-station-bottom-symbolic.svg + dock-station-bottom-symbolic.svg \ + logs-symbolic.svg libdataimages_la_SOURCES = \ resources.h resources.c diff --git a/src/data/images/gresource.xml b/src/data/images/gresource.xml index a0c4f64..7659da3 100644 --- a/src/data/images/gresource.xml +++ b/src/data/images/gresource.xml @@ -4,5 +4,6 @@ dock-station-left-symbolic.svg dock-station-right-symbolic.svg dock-station-bottom-symbolic.svg + logs-symbolic.svg diff --git a/src/data/images/logs-symbolic.svg b/src/data/images/logs-symbolic.svg new file mode 100644 index 0000000..f541607 --- /dev/null +++ b/src/data/images/logs-symbolic.svg @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + diff --git a/src/glibext/Makefile.am b/src/glibext/Makefile.am index f946665..4cf14ef 100644 --- a/src/glibext/Makefile.am +++ b/src/glibext/Makefile.am @@ -43,6 +43,8 @@ libglibext_la_SOURCES = \ hashable-int.h \ hashable.h hashable.c \ helpers.h \ + log-int.h \ + log.h log.c \ objhole-int.h \ objhole.h objhole.c \ portion-int.h \ diff --git a/src/glibext/log-int.h b/src/glibext/log-int.h new file mode 100644 index 0000000..3b3208a --- /dev/null +++ b/src/glibext/log-int.h @@ -0,0 +1,58 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * log-int.h - prototypes internes pour la conservation à destination graphique des éléments de journalisation + * + * 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 . + */ + + +#ifndef _GLIBEXT_LOG_INT_H +#define _GLIBEXT_LOG_INT_H + + +#include + + +#include "log.h" + + + +/* Définition d'une conservation d'objets construits (instance) */ +struct _GLogEntry +{ + GObject parent; /* A laisser en premier */ + + LogMessageType type; /* Type de message porté */ + char *msg; /* Contenu du message diffusé */ + +}; + +/* Définition d'une conservation d'objets construits (classe) */ +struct _GLogEntryClass +{ + GObjectClass parent; /* A laisser en premier */ + +}; + + +/* Met en place une conservation pour élément de journalisation. */ +bool g_log_entry_create(GLogEntry *, LogMessageType, const char *); + + + +#endif /* _GLIBEXT_LOG_INT_H */ diff --git a/src/glibext/log.c b/src/glibext/log.c new file mode 100644 index 0000000..039172c --- /dev/null +++ b/src/glibext/log.c @@ -0,0 +1,306 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * log.c - conservation hors mémoire d'objets choisis + * + * Copyright (C) 2020-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 . + */ + + +#include "log.h" + + +#include +#include + + +#include "log-int.h" + + + +/* ---------------------------- ENTREE DE JOURNALISATION ---------------------------- */ + + +/* Liste des propriétés */ + +typedef enum _LogEntryProperty { + + PROP_0, /* Réservé */ + + PROP_ICON_NAME, /* Nom d'image de représentat° */ + PROP_MESSAGE, /* Contenu du message diffusé */ + + N_PROPERTIES + +} LogEntryProperty; + +static GParamSpec *_log_entry_properties[N_PROPERTIES] = { NULL, }; + + +/* Initialise la classe des conservations d'objets en place. */ +static void g_log_entry_class_init(GLogEntryClass *); + +/* Initialise une instance de conservation d'objets en place. */ +static void g_log_entry_init(GLogEntry *); + +/* Supprime toutes les références externes. */ +static void g_log_entry_dispose(GObject *); + +/* Procède à la libération totale de la mémoire. */ +static void g_log_entry_finalize(GObject *); + + + +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ + + +/* Fournit la valeur d'une propriété d'instance GObject. */ +static void gtk_log_entry_get_property(GObject *, guint, GValue *, GParamSpec *); + + + +/* ---------------------------------------------------------------------------------- */ +/* ENTREE DE JOURNALISATION */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type défini pour une conservation d'objets construits. */ +G_DEFINE_TYPE(GLogEntry, g_log_entry, G_TYPE_OBJECT); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des conservations d'objets en place. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_log_entry_class_init(GLogEntryClass *klass) +{ + GObjectClass *object; /* Autre version de la classe */ + + object = G_OBJECT_CLASS(klass); + + object->dispose = g_log_entry_dispose; + object->finalize = g_log_entry_finalize; + object->get_property = gtk_log_entry_get_property; + + _log_entry_properties[PROP_ICON_NAME] = + g_param_spec_string("icon-name", NULL, NULL, + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + _log_entry_properties[PROP_MESSAGE] = + g_param_spec_string("message", NULL, NULL, + NULL, + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties(object, N_PROPERTIES, _log_entry_properties); + +} + + +/****************************************************************************** +* * +* Paramètres : entry = instance à initialiser. * +* * +* Description : Initialise une instance de conservation d'objets en place. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_log_entry_init(GLogEntry *entry) +{ + entry->type = LMT_COUNT; + entry->msg = NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à traiter. * +* * +* Description : Supprime toutes les références externes. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_log_entry_dispose(GObject *object) +{ + G_OBJECT_CLASS(g_log_entry_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_log_entry_finalize(GObject *object) +{ + GLogEntry *entry; /* Version spécialisée */ + + entry = G_LOG_ENTRY(object); + + if (entry->msg != NULL) + free(entry->msg); + + G_OBJECT_CLASS(g_log_entry_parent_class)->finalize(object); + +} + + +/****************************************************************************** +* * +* Paramètres : type = espèce du message à représenter. * +* msg = message à faire apparaître à l'écran. * +* * +* Description : Crée une conservation pour un élément de journalisation. * +* * +* Retour : Conservation mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GLogEntry *g_log_entry_new(LogMessageType type, const char *msg) +{ + GLogEntry *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_LOG_ENTRY, NULL); + + if (!g_log_entry_create(result, type, msg)) + g_clear_object(&result); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : entry = instance de conservation à initialiser pleinement. * +* type = espèce du message à représenter. * +* msg = message à faire apparaître à l'écran. * +* * +* Description : Met en place une conservation pour élément de journalisation.* +* * +* Retour : Conservation mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +bool g_log_entry_create(GLogEntry *entry, LogMessageType type, const char *msg) +{ + bool result; /* Bilan à retourner */ + + result = true; + + entry->type = type; + entry->msg = strdup(msg); + + return result; + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : object = instance d'objet GLib à mamnipuler. * +* prop_id = identifiant de la propriété visée. * +* value = valeur à transmettre. [OUT] * +* pspec = définition de la propriété. * +* * +* Description : Fournit la valeur d'une propriété d'instance GObject. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_log_entry_get_property(GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) +{ + GLogEntry *entry; /* Version spécialisée */ + + entry = G_LOG_ENTRY(object); + + switch (prop_id) + { + case PROP_ICON_NAME: + switch (entry->type) + { + case LMT_INFO: + g_value_set_string(value, "dialog-information-symbolic"); + break; + + case LMT_PROCESS: + g_value_set_string(value, "system-run-symbolic"); + break; + + case LMT_WARNING: + case LMT_BAD_BINARY: + g_value_set_string(value, "dialog-warning-symbolic"); + break; + + case LMT_ERROR: + case LMT_EXT_ERROR: + g_value_set_string(value, "computer-fail-symbolic"); + break; + + + case LMT_COUNT: + g_value_set_string(value, "dialog-question-symbolic"); + break; + + } + break; + + case PROP_MESSAGE: + g_value_set_string(value, entry->msg); + break; + + } + +} diff --git a/src/glibext/log.h b/src/glibext/log.h new file mode 100644 index 0000000..472773c --- /dev/null +++ b/src/glibext/log.h @@ -0,0 +1,43 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * log.h - prototypes pour la conservation à destination graphique des éléments de journalisation + * + * 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 . + */ + + +#ifndef _GLIBEXT_LOG_H +#define _GLIBEXT_LOG_H + + +#include "helpers.h" +#include "../core/logs.h" + + + +#define G_TYPE_LOG_ENTRY (g_log_entry_get_type()) + +DECLARE_GTYPE(GLogEntry, g_log_entry, G, LOG_ENTRY); + + +/* Crée une conservation pour un élément de journalisation. */ +GLogEntry *g_log_entry_new(LogMessageType, const char *); + + + +#endif /* _GLIBEXT_LOG_H */ diff --git a/src/gui/core/logs.c b/src/gui/core/logs.c index 59910f1..cdb2a0d 100644 --- a/src/gui/core/logs.c +++ b/src/gui/core/logs.c @@ -24,6 +24,14 @@ #include "logs.h" +#include + + +#include "panels.h" +#include "../panels/logs.h" +#include "../../glibext/log.h" + + /****************************************************************************** * * @@ -38,26 +46,20 @@ * * ******************************************************************************/ -void do_log_message_alt2(LogMessageType type, const char *msg) +void do_log_message_alt(LogMessageType type, const char *msg) { -#if 0 - -#ifdef INCLUDE_GTK_SUPPORT - - GEditorItem *item; /* Eventuel affichage présent */ + GLogEntry *entry; /* Nouvel élément de journal */ + GtkTiledPanel *panel; /* Panneau de journalisation */ - item = find_editor_item_by_type(G_TYPE_LOG_PANEL); + entry = g_log_entry_new(type, msg); - if (item != NULL) - { - g_log_panel_add_message(G_LOG_PANEL(item), type, msg); - g_object_unref(G_OBJECT(item)); - } + panel = get_framework_panel_singleton(GTK_TYPE_LOGS_PANEL); + assert(panel != NULL); -#endif + g_log_panel_add_message(GTK_LOGS_PANEL(panel), entry); -#endif + unref_object(panel); - printf("[log GUI] [%u] %s\n", type, msg); + unref_object(entry); } diff --git a/src/gui/core/panels.c b/src/gui/core/panels.c index 4c113b8..3232e0c 100644 --- a/src/gui/core/panels.c +++ b/src/gui/core/panels.c @@ -35,6 +35,7 @@ #include "../panels/binary.h" #include "../panels/binary-params.h" +#include "../panels/logs.h" #include "../panels/welcome.h" #include "../../gtkext/launcher.h" @@ -168,10 +169,23 @@ bool load_main_framework_panel_definitions(void) bool result; /* Bilan à retourner */ 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); + + info.category = NULL; + + info.image = NULL; + info.title = _("Logs"); + info.desc = NULL; + + info.personality = FPP_SINGLETON; + + info.panel_type = GTK_TYPE_LOGS_PANEL; + info.params_type = G_TYPE_INVALID; + + result = register_framework_panel_definition(&info); + if (!result) goto done; + + /* Chargements des panneaux restants */ info.category = "Main"; @@ -187,6 +201,8 @@ bool load_main_framework_panel_definitions(void) result = register_framework_panel_definition(&info); if (!result) goto done; + /* --- */ + info.category = NULL; info.image = NULL; diff --git a/src/gui/panels/Makefile.am b/src/gui/panels/Makefile.am index 467aae5..ecff6c7 100644 --- a/src/gui/panels/Makefile.am +++ b/src/gui/panels/Makefile.am @@ -11,7 +11,6 @@ UI_FILES = \ errors.ui \ glance.ui \ history.ui \ - logs.ui \ regedit.ui \ strings.ui \ symbols.ui @@ -22,7 +21,6 @@ libguipanels_la_SOURCES = \ errors.h errors.c \ glance.h glance.c \ history.h history.c \ - logs.h logs.c \ regedit.h regedit.c \ resources.h resources.c \ strings.h strings.c \ @@ -40,6 +38,9 @@ RES_FILES = \ binary.ui \ binary-params.ui \ $(IMG_PATH)/binfile-symbolic.svg \ + logs.ui \ + logs-col-icon.ui \ + logs-col-message.ui \ welcome.ui \ welcome-hints.txt \ $(IMG_PATH)/tipoftheday-symbolic.svg @@ -49,6 +50,8 @@ libguipanels4_la_SOURCES = \ binary.h binary.c \ binary-params-int.h \ binary-params.h binary-params.c \ + logs-int.h \ + logs.h logs.c \ resources.h resources.c \ welcome-int.h \ welcome.h welcome.c diff --git a/src/gui/panels/gresource.xml b/src/gui/panels/gresource.xml index f49a16f..2765b25 100644 --- a/src/gui/panels/gresource.xml +++ b/src/gui/panels/gresource.xml @@ -3,6 +3,9 @@ binary.ui binary-params.ui + logs.ui + logs-col-icon.ui + logs-col-message.ui welcome.ui welcome-hints.txt diff --git a/src/gui/panels/logs-col-icon.ui b/src/gui/panels/logs-col-icon.ui new file mode 100644 index 0000000..6463e84 --- /dev/null +++ b/src/gui/panels/logs-col-icon.ui @@ -0,0 +1,17 @@ + + + + + + diff --git a/src/gui/panels/logs-col-message.ui b/src/gui/panels/logs-col-message.ui new file mode 100644 index 0000000..49839e4 --- /dev/null +++ b/src/gui/panels/logs-col-message.ui @@ -0,0 +1,19 @@ + + + + + + diff --git a/src/gui/panels/logs-int.h b/src/gui/panels/logs-int.h new file mode 100644 index 0000000..692c1b4 --- /dev/null +++ b/src/gui/panels/logs-int.h @@ -0,0 +1,53 @@ + +/* Chrysalide - Outil d'analyse de fichiers binaires + * logs-int.h - prototypes internes pour le panneau d'affichage des messages système + * + * 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 _GUI_PANELS_LOGS_INT_H +#define _GUI_PANELS_LOGS_INT_H + + +#include "logs.h" +#include "../../gtkext/panel-int.h" + + + +/* Panneau d'affichage de messages (instance) */ +struct _GtkLogsPanel +{ + GtkTiledPanel parent; /* A laisser en premier */ + + GListStore *store; /* Liste des eléments conservés*/ + GtkWidget *list; /* Composant d'affichage */ + +}; + +/* Panneau d'affichage de messages (classe) */ +struct _GtkLogsPanelClass +{ + GtkTiledPanelClass parent; /* A laisser en premier */ + +}; + + + +#endif /* _GUI_PANELS_LOGS_INT_H */ diff --git a/src/gui/panels/logs.c b/src/gui/panels/logs.c index d11fbd2..729a62b 100644 --- a/src/gui/panels/logs.c +++ b/src/gui/panels/logs.c @@ -1,8 +1,8 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * log.c - panneau d'affichage des messages système + * logs.c - panneau d'affichage des messages système * - * Copyright (C) 2012-2019 Cyrille Bagard + * Copyright (C) 2012-2025 Cyrille Bagard * * This file is part of Chrysalide. * @@ -22,98 +22,57 @@ */ -#include "log.h" +#include "logs.h" -#include -#include -#include +#include #include -#include -#include "../panel-int.h" -#include "../core/panels.h" -#include "../../gtkext/easygtk.h" -#include "../../gtkext/named.h" +#include "logs-int.h" +#include "../../gtkext/helpers.h" -/* Colonnes de la liste des messages */ -typedef enum _LogColumn -{ - LGC_PICTURE, /* Image de représentation */ - LGC_STRING, /* Chaîne de caractères */ - - LGC_COUNT /* Nombre de colonnes */ - -} LogColumn; +/* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ -/* Paramètres à transmettre pour un affichage */ -typedef struct _log_data -{ - GPanelItem *item; /* Intermédiaire mis en place */ - LogMessageType type; /* Type de message à afficher */ - char *msg; /* Contenu du message */ - -} log_data; - - -/* Panneau d'accueil (instance) */ -struct _GLogPanel -{ - GPanelItem parent; /* A laisser en premier */ - -}; +/* Initialise la classe des panneaux d'accueil par défaut. */ +static void gtk_logs_panel_class_init(GtkLogsPanelClass *); - -/* Panneau d'accueil (classe) */ -struct _GLogPanelClass -{ - GPanelItemClass parent; /* A laisser en premier */ - -}; - - -/* Initialise la classe des panneaux d'affichage des messages. */ -static void g_log_panel_class_init(GLogPanelClass *); - -/* Initialise une instance de panneau d'affichage des messages. */ -static void g_log_panel_init(GLogPanel *); +/* Initialise une instance de panneau d'accueil par défaut. */ +static void gtk_logs_panel_init(GtkLogsPanel *); /* Supprime toutes les références externes. */ -static void g_log_panel_dispose(GLogPanel *); +static void gtk_logs_panel_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ -static void g_log_panel_finalize(GLogPanel *); +static void gtk_logs_panel_finalize(GObject *); + + -/* Fournit le nom interne attribué à l'élément réactif. */ -static char *g_log_panel_class_get_key(const GLogPanelClass *); +/* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ -/* Fournit une indication sur la personnalité du panneau. */ -static PanelItemPersonality g_log_panel_class_get_personality(const GLogPanelClass *); -/* Indique le chemin initial de la localisation d'un panneau. */ -static char *g_log_panel_class_get_path(const GLogPanelClass *); +/* Indique l'emplacement par défaut pour un affichage. */ +static char *gtk_logs_panel_get_default_path(const GtkTiledPanel *); -/* Indique la définition d'un éventuel raccourci clavier. */ -static char *g_log_panel_class_get_key_bindings(const GLogPanelClass *); -/* Affiche un message dans le journal des messages système. */ -static gboolean log_message(log_data *); +/* ---------------------------------------------------------------------------------- */ +/* COEUR D'UN PANNEAU D'AFFICHAGE */ +/* ---------------------------------------------------------------------------------- */ -/* Indique le type défini pour un panneau d'affichage de messages. */ -G_DEFINE_TYPE(GLogPanel, g_log_panel, G_TYPE_PANEL_ITEM); +/* Indique le type défini pour un panneau d'accueil. */ +G_DEFINE_TYPE(GtkLogsPanel, gtk_logs_panel, GTK_TYPE_TILED_PANEL); /****************************************************************************** * * * Paramètres : class = classe à initialiser. * * * -* Description : Initialise la classe des panneaux d'affichage des messages. * +* Description : Initialise la classe des panneaux d'accueil par défaut. * * * * Retour : - * * * @@ -121,81 +80,40 @@ G_DEFINE_TYPE(GLogPanel, g_log_panel, G_TYPE_PANEL_ITEM); * * ******************************************************************************/ -static void g_log_panel_class_init(GLogPanelClass *class) +static void gtk_logs_panel_class_init(GtkLogsPanelClass *class) { GObjectClass *object; /* Autre version de la classe */ - GEditorItemClass *item; /* Encore une autre vision... */ - GPanelItemClass *panel; /* Version parente de la classe*/ + GtkWidgetClass *widget; /* Classe de haut niveau */ + GtkTiledPanelClass *panel; /* Classe parente */ object = G_OBJECT_CLASS(class); - object->dispose = (GObjectFinalizeFunc/* ! */)g_log_panel_dispose; - object->finalize = (GObjectFinalizeFunc)g_log_panel_finalize; + object->dispose = gtk_logs_panel_dispose; + object->finalize = gtk_logs_panel_finalize; - item = G_EDITOR_ITEM_CLASS(class); + widget = GTK_WIDGET_CLASS(class); - item->get_key = (get_item_key_fc)g_log_panel_class_get_key; + g_type_ensure(G_TYPE_LOG_ENTRY); - panel = G_PANEL_ITEM_CLASS(class); + gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/panels/logs.ui"); - panel->get_personality = (get_panel_personality_fc)g_log_panel_class_get_personality; - panel->get_path = (get_panel_path_fc)g_log_panel_class_get_path; - panel->get_bindings = (get_panel_bindings_fc)g_log_panel_class_get_key_bindings; + //gtk_widget_class_bind_template_callback_full(widget, BUILDER_CB(gtk_logs_panel_on_selected_rows_changed)); -} + gtk_widget_class_bind_template_child(widget, GtkLogsPanel, store); + gtk_widget_class_bind_template_child(widget, GtkLogsPanel, list); + panel = GTK_TILED_PANEL_CLASS(class); -/****************************************************************************** -* * -* Paramètres : panel = instance à initialiser. * -* * -* Description : Initialise une instance de panneau d'affichage des messages. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_log_panel_init(GLogPanel *panel) -{ - GPanelItem *pitem; /* Version parente du panneau */ - - /* Eléments de base */ - - pitem = G_PANEL_ITEM(panel); - - pitem->widget = G_NAMED_WIDGET(gtk_built_named_widget_new_for_panel(_("Messages"), - _("Misc information"), - PANEL_LOG_ID)); + panel->get_default_path = gtk_logs_panel_get_default_path; } /****************************************************************************** * * -* Paramètres : panel = instance d'objet GLib à traiter. * -* * -* Description : Supprime toutes les références externes. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_log_panel_dispose(GLogPanel *panel) -{ - G_OBJECT_CLASS(g_log_panel_parent_class)->dispose(G_OBJECT(panel)); - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance d'objet GLib à traiter. * +* Paramètres : panel = instance à initialiser. * * * -* Description : Procède à la libération totale de la mémoire. * +* Description : Initialise une instance de panneau d'accueil par défaut. * * * * Retour : - * * * @@ -203,124 +121,59 @@ static void g_log_panel_dispose(GLogPanel *panel) * * ******************************************************************************/ -static void g_log_panel_finalize(GLogPanel *panel) -{ - G_OBJECT_CLASS(g_log_panel_parent_class)->finalize(G_OBJECT(panel)); - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Fournit le nom interne attribué à l'élément réactif. * -* * -* Retour : Désignation (courte) de l'élément de l'éditeur. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static char *g_log_panel_class_get_key(const GLogPanelClass *class) +static void gtk_logs_panel_init(GtkLogsPanel *panel) { - char *result; /* Description à renvoyer */ + GtkWidget *headers; /* Composant à cacher */ - result = strdup(PANEL_LOG_ID); + gtk_widget_init_template(GTK_WIDGET(panel)); - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Fournit une indication sur la personnalité du panneau. * -* * -* Retour : Identifiant lié à la nature unique du panneau. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static PanelItemPersonality g_log_panel_class_get_personality(const GLogPanelClass *class) -{ - PanelItemPersonality result; /* Personnalité à retourner */ - - result = PIP_PERSISTENT_SINGLETON; - - return result; + /** + * Retrait des entêtes de colonne de l'affichage. + */ -} + headers = gtk_widget_get_first_child(panel->list); - -/****************************************************************************** -* * -* Paramètres : class = classe à consulter. * -* * -* Description : Indique le chemin initial de la localisation d'un panneau. * -* * -* Retour : Chemin fixé associé à la position initiale. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static char *g_log_panel_class_get_path(const GLogPanelClass *class) -{ - char *result; /* Emplacement à retourner */ - - result = strdup("Ms"); - - return result; + gtk_widget_set_visible(headers, FALSE); } /****************************************************************************** * * -* Paramètres : class = classe à consulter. * +* Paramètres : object = instance d'objet GLib à traiter. * * * -* Description : Indique la définition d'un éventuel raccourci clavier. * +* Description : Supprime toutes les références externes. * * * -* Retour : Description d'un raccourci ou NULL si aucun de défini. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -static char *g_log_panel_class_get_key_bindings(const GLogPanelClass *class) +static void gtk_logs_panel_dispose(GObject *object) { - char *result; /* Emplacement à retourner */ - - result = strdup("F1"); + gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_LOGS_PANEL); - return result; + G_OBJECT_CLASS(gtk_logs_panel_parent_class)->dispose(object); } /****************************************************************************** * * -* Paramètres : - * +* Paramètres : object = instance d'objet GLib à traiter. * * * -* Description : Crée un panneau d'affichage des messages système. * +* Description : Procède à la libération totale de la mémoire. * * * -* Retour : Adresse de la structure mise en place. * +* Retour : - * * * * Remarques : - * * * ******************************************************************************/ -GPanelItem *g_log_panel_new(void) +static void gtk_logs_panel_finalize(GObject *object) { - GPanelItem *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_LOG_PANEL, NULL); - - return result; + G_OBJECT_CLASS(gtk_logs_panel_parent_class)->finalize(object); } @@ -328,8 +181,7 @@ GPanelItem *g_log_panel_new(void) /****************************************************************************** * * * Paramètres : panel = instance d'objet GLib à traiter. * -* type = espèce du message à ajouter. * -* msg = message à faire apparaître à l'écran. * +* entry = élément de journalisation à intégrer. * * * * Description : Affiche un message dans le journal des messages système. * * * @@ -339,113 +191,37 @@ GPanelItem *g_log_panel_new(void) * * ******************************************************************************/ -void g_log_panel_add_message(GLogPanel *panel, LogMessageType type, const char *msg) +void g_log_panel_add_message(GtkLogsPanel *panel, GLogEntry *entry) { - log_data *data; /* Paramètres à joindre */ - - data = calloc(1, sizeof(log_data)); + g_list_store_append(panel->store, entry); - data->item = G_PANEL_ITEM(panel); - data->type = type; - data->msg = strdup(msg); +} - g_object_ref(G_OBJECT(data->item)); - g_main_context_invoke(NULL, (GSourceFunc)log_message, data); -} +/* ---------------------------------------------------------------------------------- */ +/* IMPLEMENTATION DES FONCTIONS DE CLASSE */ +/* ---------------------------------------------------------------------------------- */ /****************************************************************************** * * -* Paramètres : data = paramètres destinés à l'affichage d'un message. * +* Paramètres : panel = panneau graphique à consulter. * * * -* Description : Affiche un message dans le journal des messages système. * +* Description : Indique l'emplacement par défaut pour un affichage. * * * -* Retour : - * +* Retour : Chemin représenté ou NULL pour l'emplacement "M" par défaut. * * * -* Remarques : Cette fonction, et c'est tout son intérêt, est toujours * -* exécutée dans le contexte GTK principal. * +* Remarques : - * * * ******************************************************************************/ -static gboolean log_message(log_data *data) +static char *gtk_logs_panel_get_default_path(const GtkTiledPanel *panel) { - GtkBuilder *builder; /* Constructeur utilisé */ - GtkListStore *store; /* Modèle de gestion */ - GtkTreeIter iter; /* Point d'insertion */ - GtkTreeView *treeview; /* Affichage de la liste */ - - builder = gtk_built_named_widget_get_builder(GTK_BUILT_NAMED_WIDGET(G_PANEL_ITEM(data->item)->widget)); - - /* Mise en place du message */ - - store = GTK_LIST_STORE(gtk_builder_get_object(builder, "store")); + char *result; /* Chemin à retourner */ - gtk_list_store_append(store, &iter); + result = strdup("S"); - switch (data->type) - { - case LMT_INFO: - gtk_list_store_set(store, &iter, - LGC_PICTURE, "gtk-info", - LGC_STRING, data->msg, - -1); - break; - - case LMT_PROCESS: - gtk_list_store_set(store, &iter, - LGC_PICTURE, "gtk-execute", - LGC_STRING, data->msg, - -1); - break; - - case LMT_WARNING: - gtk_list_store_set(store, &iter, - LGC_PICTURE, "gtk-dialog-warning", - LGC_STRING, data->msg, - -1); - break; - - case LMT_BAD_BINARY: - gtk_list_store_set(store, &iter, - LGC_PICTURE, "gtk-dialog-warning", - LGC_STRING, data->msg, - -1); - break; - - case LMT_ERROR: - case LMT_EXT_ERROR: - gtk_list_store_set(store, &iter, - LGC_PICTURE, "gtk-dialog-error", - LGC_STRING, data->msg, - -1); - break; - - default: - gtk_list_store_set(store, &iter, - LGC_STRING, data->msg, - -1); - break; - - } - - /* Défilement pour pointer à l'affichage */ - - treeview = GTK_TREE_VIEW(gtk_builder_get_object(builder, "treeview")); - - scroll_to_treeview_iter(treeview, GTK_TREE_MODEL(store), &iter); - - g_object_unref(G_OBJECT(builder)); - - /* Nettoyage de la mémoire */ - - g_object_unref(G_OBJECT(data->item)); - - free(data->msg); - - free(data); - - return G_SOURCE_REMOVE; + return result; } diff --git a/src/gui/panels/logs.h b/src/gui/panels/logs.h index 4d155a2..a8b902b 100644 --- a/src/gui/panels/logs.h +++ b/src/gui/panels/logs.h @@ -1,8 +1,8 @@ /* Chrysalide - Outil d'analyse de fichiers binaires - * log.h - prototypes pour le panneau d'affichage des messages système + * logs.h - prototypes pour le panneau d'affichage des messages système * - * Copyright (C) 2012-2019 Cyrille Bagard + * Copyright (C) 2012-2025 Cyrille Bagard * * This file is part of Chrysalide. * @@ -22,46 +22,26 @@ */ -#ifndef _GUI_PANELS_LOG_H -#define _GUI_PANELS_LOG_H +#ifndef _GUI_PANELS_LOGS_H +#define _GUI_PANELS_LOGS_H -#include +#include -#include "../panel.h" -#include "../../core/logs.h" +#include "../../glibext/helpers.h" +#include "../../glibext/log.h" -#define PANEL_LOG_ID "log" +#define GTK_TYPE_LOGS_PANEL (gtk_logs_panel_get_type()) +DECLARE_GTYPE(GtkLogsPanel, gtk_logs_panel, GTK, LOGS_PANEL); -#define G_TYPE_LOG_PANEL g_log_panel_get_type() -#define G_LOG_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_log_panel_get_type(), GLogPanel)) -#define G_IS_LOG_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_log_panel_get_type())) -#define G_LOG_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_LOG_PANEL, GLogPanelClass)) -#define G_IS_LOG_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_LOG_PANEL)) -#define G_LOG_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_LOG_PANEL, GLogPanelClass)) - - -/* Panneau d'affichage de messages (instance) */ -typedef struct _GLogPanel GLogPanel; - -/* Panneau d'affichage de messages (classe) */ -typedef struct _GLogPanelClass GLogPanelClass; - - - -/* Indique le type défini pour un panneau d'affichage de messages. */ -GType g_log_panel_get_type(void); - -/* Crée un panneau d'affichage des messages système. */ -GPanelItem *g_log_panel_new(void); /* Affiche un message dans le journal des messages système. */ -void g_log_panel_add_message(GLogPanel *, LogMessageType, const char *); +void g_log_panel_add_message(GtkLogsPanel *, GLogEntry *); -#endif /* _GUI_PANELS_LOG_H */ +#endif /* _GUI_PANELS_LOGS_H */ diff --git a/src/gui/panels/logs.ui b/src/gui/panels/logs.ui index 4ffe96c..ba920cd 100644 --- a/src/gui/panels/logs.ui +++ b/src/gui/panels/logs.ui @@ -1,59 +1,58 @@ - - - - - - - - - - - - False - - - True - True - in + + + + + GLogEntry + + + + + + -- cgit v0.11.2-87-g4458