/* Chrysalide - Outil d'analyse de fichiers binaires * binary.c - panneau d'affichage de contenus d'un binaire, bruts ou non * * Copyright (C) 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 "binary.h" #include "binary-int.h" #include "../../gtkext/helpers.h" #include "../../gtkext/hexview.h" /* ------------------------- COEUR D'UN PANNEAU D'AFFICHAGE ------------------------- */ /* Initialise la classe des panneaux pour binaires. */ static void gtk_binary_panel_class_init(GtkBinaryPanelClass *); /* Initialise une instance de panneau pour binaire. */ static void gtk_binary_panel_init(GtkBinaryPanel *); /* Supprime toutes les références externes. */ static void gtk_binary_panel_dispose(GObject *); /* Procède à la libération totale de la mémoire. */ static void gtk_binary_panel_finalize(GObject *); /* --------------------- IMPLEMENTATION DES FONCTIONS DE CLASSE --------------------- */ /* ---------------------------------------------------------------------------------- */ /* COEUR D'UN PANNEAU D'AFFICHAGE */ /* ---------------------------------------------------------------------------------- */ /* 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); /****************************************************************************** * * * Paramètres : class = classe à initialiser. * * * * Description : Initialise la classe des panneaux pour binaires. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void gtk_binary_panel_class_init(GtkBinaryPanelClass *class) { GObjectClass *object; /* Autre version de la classe */ GtkWidgetClass *widget; /* Classe de haut niveau */ object = G_OBJECT_CLASS(class); object->dispose = gtk_binary_panel_dispose; object->finalize = gtk_binary_panel_finalize; widget = GTK_WIDGET_CLASS(class); gtk_widget_class_set_template_from_resource(widget, "/re/chrysalide/framework/gui/panels/binary.ui"); gtk_widget_class_bind_template_child(widget, GtkBinaryPanel, hex_scroll); } /****************************************************************************** * * * Paramètres : panel = instance à initialiser. * * * * Description : Initialise une instance de panneau pour binaire. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void gtk_binary_panel_init(GtkBinaryPanel *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_binary_panel_dispose(GObject *object) { gtk_widget_dispose_template(GTK_WIDGET(object), GTK_TYPE_BINARY_PANEL); G_OBJECT_CLASS(gtk_binary_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_binary_panel_finalize(GObject *object) { G_OBJECT_CLASS(gtk_binary_panel_parent_class)->finalize(object); } /****************************************************************************** * * * Paramètres : content = contenu brut à exposer. * * * * Description : Crée une nouvelle instance de panneau pour binaire. * * * * Retour : Composant GTK mis en place. * * * * Remarques : - * * * ******************************************************************************/ GtkTiledPanel *gtk_binary_panel_new_for_content(GBinContent *content) { GtkTiledPanel *result; /* Instance à retourner */ GtkHexView *view; /* Composant d'affichage */ result = g_object_new(GTK_TYPE_BINARY_PANEL, NULL); view = gtk_hex_view_new(content); gtk_scrolled_window_set_child(GTK_BINARY_PANEL(result)->hex_scroll, GTK_WIDGET(view)); return result; } /* ---------------------------------------------------------------------------------- */ /* IMPLEMENTATION DES FONCTIONS DE CLASSE */ /* ---------------------------------------------------------------------------------- */