/* OpenIDA - Outil d'analyse de fichiers binaires * portions.c - navigation dans les portions de binaire * * Copyright (C) 2013 Cyrille Bagard * * This file is part of OpenIDA. * * OpenIDA 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. * * OpenIDA 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 "portions.h" #include #include "toolbar.h" #include "../editem-int.h" #include "../../format/format.h" #include "../../gtkext/gtkbinarystrip.h" /* Construit l'élément GTK pour une barre d'outils. */ static GtkWidget *build_portions_tb_widget(GObject *); /* Fait suivre un changement d'adresse dans la barre. */ static void track_address_on_binary_strip(GtkBinaryStrip *, vmpa_t, GObject *); /* Réagit à un changement du binaire courant. */ static void update_portions_item_binary(GEditorItem *, GLoadedBinary *); /****************************************************************************** * * * Paramètres : ref = espace de référencement global. * * * * Description : Construit l'élément GTK pour une barre d'outils. * * * * Retour : Adresse du composant mis en place. * * * * Remarques : - * * * ******************************************************************************/ static GtkWidget *build_portions_tb_widget(GObject *ref) { GtkWidget *result; /* Composant à retourner */ GtkWidget *handlebox; /* Support relocalisable */ GtkWidget *strip; /* Bande pour binaire */ result = GTK_WIDGET(gtk_tool_item_new()); gtk_tool_item_set_expand(GTK_TOOL_ITEM(result), TRUE); gtk_widget_show(result); handlebox = gtk_handle_box_new(); gtk_widget_show(handlebox); gtk_container_add(GTK_CONTAINER(result), handlebox); strip = gtk_binary_strip_new(); gtk_widget_show(strip); gtk_container_add(GTK_CONTAINER(handlebox), strip); g_object_set_data(G_OBJECT(result), "strip", strip); g_signal_connect(strip, "select-address", G_CALLBACK(track_address_on_binary_strip), ref); return result; } /****************************************************************************** * * * Paramètres : strip = composant d'affichage parcouru. * * addr = nouvelle adresse du curseur courant. * * ref = espace de référencement global. * * * * Description : Fait suivre un changement d'adresse dans la barre. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void track_address_on_binary_strip(GtkBinaryStrip *strip, vmpa_t addr, GObject *ref) { printf("===> CHANGE TO 0x%08llx\n", addr); } /****************************************************************************** * * * Paramètres : ref = espace de référencement global. * * * * Description : Crée une sélection de fichier réactive pour barre d'outils. * * * * Retour : Adresse de la structure d'encadrement mise en place. * * * * Remarques : - * * * ******************************************************************************/ GEditorItem *create_portions_tb_item(GObject *ref) { GEditorItem *result; /* Structure à retourner */ GtkWidget *widget; /* Composant affiché à l'écran */ widget = build_portions_tb_widget(ref); result = g_toolbar_item_new(ref, "portions", widget, _("Portions")); result->update_binary = update_portions_item_binary; return result; } /****************************************************************************** * * * Paramètres : item = élément réactif sollicité. * * binary = binaire chargé nouvellement affiché. * * * * Description : Réagit à un changement du binaire courant. * * * * Retour : - * * * * Remarques : - * * * ******************************************************************************/ static void update_portions_item_binary(GEditorItem *item, GLoadedBinary *binary) { GtkBinaryStrip *strip; /* Bande pour binaire */ strip = GTK_BINARY_STRIP(g_object_get_data(G_OBJECT(item->widget), "strip")); gtk_binary_strip_attach(strip, binary); }