From 486f0bf0a27ffed3e9fde2f183974ae029b45c54 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Wed, 11 Jan 2012 02:20:30 +0000 Subject: Defined new panel definitions for the editor GUI. git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@223 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a --- ChangeLog | 70 ++++ configure.ac | 1 + plugins/pyoida/py_log.c | 4 +- src/analysis/binary.c | 4 +- src/analysis/disass/disassembler.c | 6 +- src/arch/processor.c | 4 +- src/debug/jdwp/debugger.c | 4 +- src/debug/jdwp/tcp.c | 4 +- src/editor.c | 26 +- src/format/dex/class.c | 12 +- src/format/dex/method.c | 6 +- src/format/elf/elf.c | 4 +- src/format/elf/symbols.c | 4 +- src/format/format.c | 4 +- src/gtkext/Makefile.am | 1 + src/gtkext/gtkbufferview.c | 16 +- src/gtkext/gtkdockstation.c | 285 ++++++++++++++ src/gtkext/gtkdockstation.h | 94 +++++ src/gui/Makefile.am | 3 +- src/gui/menus/debug.c | 2 +- src/gui/panels/Makefile.am | 18 + src/gui/panels/log.c | 273 ++++++++++++++ src/gui/panels/log.h | 64 ++++ src/gui/panels/panel-int.h | 73 ++++ src/gui/panels/panel.c | 658 +++++++++++++++++++++++++++++++++ src/gui/panels/panel.h | 73 ++++ src/gui/panels/symbols.c | 734 +++++++++++++++++++++++++++++++++++++ src/gui/panels/symbols.h | 65 ++++ src/panels/Makefile.am | 4 +- src/panels/log.c | 244 ------------ src/panels/log.h | 58 --- src/panels/panel.c | 10 +- src/panels/symbols.c | 718 ------------------------------------ src/panels/symbols.h | 59 --- src/project.c | 14 +- 35 files changed, 2479 insertions(+), 1140 deletions(-) create mode 100644 src/gtkext/gtkdockstation.c create mode 100644 src/gtkext/gtkdockstation.h create mode 100644 src/gui/panels/Makefile.am create mode 100644 src/gui/panels/log.c create mode 100644 src/gui/panels/log.h create mode 100644 src/gui/panels/panel-int.h create mode 100644 src/gui/panels/panel.c create mode 100644 src/gui/panels/panel.h create mode 100644 src/gui/panels/symbols.c create mode 100644 src/gui/panels/symbols.h delete mode 100644 src/panels/log.c delete mode 100644 src/panels/log.h delete mode 100644 src/panels/symbols.c delete mode 100644 src/panels/symbols.h diff --git a/ChangeLog b/ChangeLog index 6b8a01f..9a0ade7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,73 @@ +12-01-11 Cyrille Bagard + + * configure.ac: + Add the new Makefile from the 'src/gui/panels' directory to AC_CONFIG_FILES. + + * plugins/pyoida/py_log.c: + * src/analysis/binary.c: + * src/analysis/disass/disassembler.c: + Update included headers. + + * src/arch/processor.c: + Disable debug code. + + * src/debug/jdwp/debugger.c: + * src/debug/jdwp/tcp.c: + Update included headers. + + * src/editor.c: + Update code. + + * src/format/dex/class.c: + * src/format/dex/method.c: + Disable debug code. + + * src/format/elf/elf.c: + * src/format/elf/symbols.c: + * src/format/format.c: + Update included headers. + + * src/gtkext/gtkbufferview.c: + Fix the code when getting reparented. + + * src/gtkext/gtkdockstation.c: + * src/gtkext/gtkdockstation.h: + New entries: build new proper dock station for widgets. + + * src/gtkext/Makefile.am: + Add gtkdockstation.[ch] and gtkbufferview-int.h to libgtkext_la_SOURCES. + + * src/gui/Makefile.am: + Add panels/libguipanels.la to libgui_la_LIBADD. + + * src/gui/menus/debug.c: + * src/gui/panels/log.c: + * src/gui/panels/log.h: + * src/gui/panels/Makefile.am: + * src/gui/panels/panel.c: + * src/gui/panels/panel.h: + * src/gui/panels/panel-int.h: + * src/gui/panels/symbols.c: + * src/gui/panels/symbols.h: + New entries: define new panel definitions for the editor GUI. + + * src/panels/log.c: + * src/panels/log.h: + Deleted entries. + + * src/panels/Makefile.am: + Remove the log.[ch] and symbols.[ch] files from libpanels_la_SOURCES. + + * src/panels/panel.c: + Disable the symbols panel. + + * src/panels/symbols.c: + * src/panels/symbols.h: + Deleted entries. + + * src/project.c: + Update code. + 12-01-02 Cyrille Bagard * src/dialogs/about.c: diff --git a/configure.ac b/configure.ac index 6830450..7828d7a 100644 --- a/configure.ac +++ b/configure.ac @@ -283,6 +283,7 @@ AC_CONFIG_FILES([Makefile src/gtkext/Makefile src/gui/Makefile src/gui/menus/Makefile + src/gui/panels/Makefile src/gui/tb/Makefile src/panels/Makefile src/plugins/Makefile diff --git a/plugins/pyoida/py_log.c b/plugins/pyoida/py_log.c index ea43e5c..fde7ae5 100644 --- a/plugins/pyoida/py_log.c +++ b/plugins/pyoida/py_log.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * py_log.c - intermédiaire du panneau de messages pour Python * - * Copyright (C) 2009 Cyrille Bagard + * Copyright (C) 2009-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -27,7 +27,7 @@ #include -#include "../../src/panels/log.h" +#include "../../src/gui/panels/log.h" typedef struct { diff --git a/src/analysis/binary.c b/src/analysis/binary.c index b1d41f2..2e1ecc2 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * binary.c - traitement des flots de code binaire * - * Copyright (C) 2008-2011 Cyrille Bagard + * Copyright (C) 2008-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -47,7 +47,7 @@ #include "../common/extstr.h" #include "../debug/break.h" #include "../format/format.h" -#include "../panels/log.h" +#include "../gui/panels/log.h" #include "../plugins/pglist.h" diff --git a/src/analysis/disass/disassembler.c b/src/analysis/disass/disassembler.c index 7a1c219..241233d 100644 --- a/src/analysis/disass/disassembler.c +++ b/src/analysis/disass/disassembler.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * disassembler.c - encadrement des phases de désassemblage * - * Copyright (C) 2010-2011 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -38,9 +38,7 @@ #include "../../decomp/lang/asm.h" #include "../../format/format.h" #include "../../glibext/delayed-int.h" -#ifdef DEBUG -# include "../../panels/log.h" -#endif +#include "../../gui/panels/log.h" diff --git a/src/arch/processor.c b/src/arch/processor.c index 0e9ad1f..41b9a66 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * processor.c - gestion générique des architectures * - * Copyright (C) 2008-2011 Cyrille Bagard + * Copyright (C) 2008-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -227,7 +227,7 @@ GArchInstruction *g_arch_processor_decode_instruction(const GArchProcessor *proc if (result == NULL || result == SKIPPED_INSTR) { - printf("BAD CODE :: 0x%02hhx @0x%08lx\n", data[*pos], addr); + //printf("BAD CODE :: 0x%02hhx @0x%08lx\n", data[*pos], addr); skipped = (result == SKIPPED_INSTR); diff --git a/src/debug/jdwp/debugger.c b/src/debug/jdwp/debugger.c index 6441f90..ada09bb 100644 --- a/src/debug/jdwp/debugger.c +++ b/src/debug/jdwp/debugger.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * debugger.c - débogage d'une cible en Java. * - * Copyright (C) 2010-2011 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -31,7 +31,7 @@ #include "tcp.h" #include "../debugger-int.h" #include "../stream.h" -#include "../../panels/log.h" +#include "../../gui/panels/log.h" diff --git a/src/debug/jdwp/tcp.c b/src/debug/jdwp/tcp.c index d389f51..554d5b6 100644 --- a/src/debug/jdwp/tcp.c +++ b/src/debug/jdwp/tcp.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * tcp.c - gestion des connexions TCP aux serveurs JDWP. * - * Copyright (C) 2010-2011 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -40,7 +40,7 @@ #include "sets/list.h" #include "../stream-int.h" #include "../../common/net.h" -#include "../../panels/log.h" +#include "../../gui/panels/log.h" diff --git a/src/editor.c b/src/editor.c index 8cb8d06..fb0ccc7 100644 --- a/src/editor.c +++ b/src/editor.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * editor.c - fenêtre principale de l'interface graphique * - * Copyright (C) 2008-2011 Cyrille Bagard + * Copyright (C) 2008-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -57,6 +57,7 @@ #include "dialogs/export.h" #include "dialogs/plugins.h" #include "gui/menus/menubar.h" +#include "gui/panels/panel.h" #include "gui/tb/source.h" #include "panels/panel.h" @@ -474,11 +475,26 @@ GtkWidget *create_editor(void) toolbar = build_editor_toolbar(G_OBJECT(result)); gtk_box_pack_start(GTK_BOX(vbox1), toolbar, FALSE, FALSE, 0); + do + { + GtkWidget *support; + + support = init_panels2(); + gtk_box_pack_start(GTK_BOX(vbox1), support, TRUE, TRUE, 0); + + load_main_panels(); + + + } while(0); + + + +#if 1 vpaned1 = gtk_vpaned_new (); gtk_widget_show (vpaned1); - gtk_box_pack_start (GTK_BOX (vbox1), vpaned1, TRUE, TRUE, 0); + //gtk_box_pack_start (GTK_BOX (vbox1), vpaned1, TRUE, TRUE, 0); gtk_paned_set_position (GTK_PANED (vpaned1), 400); hpaned1 = gtk_hpaned_new (); @@ -535,8 +551,8 @@ GtkWidget *create_editor(void) gtk_paned_pack2(GTK_PANED(vpaned1), dpanel, FALSE, FALSE); - ditem = g_dock_item_new(_("Messages"), get_panel(PNT_LOG)); - gtk_dock_panel_add_item(dpanel, ditem); + //ditem = g_dock_item_new(_("Messages"), get_panel(PNT_LOG)); + //gtk_dock_panel_add_item(dpanel, ditem); ditem = g_dock_item_new(_("Strings"), get_panel(PNT_STRINGS)); gtk_dock_panel_add_item(dpanel, ditem); @@ -580,6 +596,8 @@ GtkWidget *create_editor(void) */ +#endif + statusbar = gtk_extended_status_bar_new(); g_object_set_data(ref, "statusbar", statusbar); diff --git a/src/format/dex/class.c b/src/format/dex/class.c index 710b023..168d45d 100644 --- a/src/format/dex/class.c +++ b/src/format/dex/class.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * class.c - manipulation des classes du format DEX * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -153,8 +153,8 @@ static GDexClass *g_dex_class_new(const GDexFormat *format, off_t offset) - printf(" Classe :: d meth count == 0x%lld\n", data.direct_methods_size); - printf(" Classe :: v meth count == 0x%lld\n", data.virtual_methods_size); + //printf(" Classe :: d meth count == 0x%lld\n", data.direct_methods_size); + //printf(" Classe :: v meth count == 0x%lld\n", data.virtual_methods_size); @@ -228,9 +228,11 @@ static void g_dex_class_register_method(const GDexClass *class, GBinFormat *form routine = g_dex_method_get_routine(class->direct_methods[i]); g_binary_format_add_routine(format, routine); + /* printf("routine @ 0x%08llx :: '%s'\n", g_binary_routine_get_address(routine), g_binary_routine_get_name(routine)); + */ } @@ -239,9 +241,11 @@ static void g_dex_class_register_method(const GDexClass *class, GBinFormat *form routine = g_dex_method_get_routine(class->virtual_methods[i]); g_binary_format_add_routine(format, routine); + /* printf("routine @ 0x%08llx :: '%s'\n", g_binary_routine_get_address(routine), g_binary_routine_get_name(routine)); + */ } @@ -355,7 +359,7 @@ GBufferLine *line, GLangOutput *output) //g_buffer_line_insert_text(line, BLC_ASSEMBLY, "{", 3, RTT_SIGNS); - printf("Output :: %s\n", _g_openida_type_to_string(type, true)); + //printf("Output :: %s\n", _g_openida_type_to_string(type, true)); diff --git a/src/format/dex/method.c b/src/format/dex/method.c index b9023d8..95f121a 100644 --- a/src/format/dex/method.c +++ b/src/format/dex/method.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * method.c - manipulation des methodes du format DEX * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -151,13 +151,13 @@ GDexMethod *g_dex_method_new(const GDexFormat *format, const encoded_method *see //printf(" code size :: %d\n", item.insns_size); - printf(" method idx :: %lld\n", *last); + //printf(" method idx :: %lld\n", *last); result->offset = seed->code_off + 4 * sizeof(uint16_t) + 2 *sizeof(uint32_t);/* TODO : faire plus propre ! */ - printf(" method off :: 0x%08x\n", result->offset); + //printf(" method off :: 0x%08x\n", result->offset); g_binary_routine_set_address(routine, result->offset); diff --git a/src/format/elf/elf.c b/src/format/elf/elf.c index c3d2e42..158a6b6 100644 --- a/src/format/elf/elf.c +++ b/src/format/elf/elf.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * elf.c - support du format ELF * - * Copyright (C) 2009-2010 Cyrille Bagard + * Copyright (C) 2009-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -34,7 +34,7 @@ #include "section.h" #include "strings.h" #include "symbols.h" -#include "../../panels/log.h" +#include "../../gui/panels/log.h" diff --git a/src/format/elf/symbols.c b/src/format/elf/symbols.c index a243a6c..df1b613 100644 --- a/src/format/elf/symbols.c +++ b/src/format/elf/symbols.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * symbols.c - gestion des symboles d'un ELF * - * Copyright (C) 2008-2010 Cyrille Bagard + * Copyright (C) 2008-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -32,7 +32,7 @@ #include "helper_x86.h" #include "section.h" #include "../mangling/demangler.h" -#include "../../panels/log.h" +#include "../../gui/panels/log.h" diff --git a/src/format/format.c b/src/format/format.c index a44f676..e3f5a93 100644 --- a/src/format/format.c +++ b/src/format/format.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * format.c - support des différents formats binaires * - * Copyright (C) 2009-2011 Cyrille Bagard + * Copyright (C) 2009-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -34,7 +34,7 @@ #include "java/java.h" #include "pe/pe.h" #include "../decomp/expr/block.h" -#include "../panels/log.h" +#include "../gui/panels/log.h" #include "../plugins/pglist.h" diff --git a/src/gtkext/Makefile.am b/src/gtkext/Makefile.am index 47d4e41..bcaa730 100644 --- a/src/gtkext/Makefile.am +++ b/src/gtkext/Makefile.am @@ -13,6 +13,7 @@ libgtkext_la_SOURCES = \ gtkbufferview.h gtkbufferview.c \ gtkdockitem.h gtkdockitem.c \ gtkdockpanel.h gtkdockpanel.c \ + gtkdockstation.h gtkdockstation.c \ gtkdropwindow.h gtkdropwindow.c \ gtkgraphview.h gtkgraphview.c \ gtklinkrenderer.h gtklinkrenderer.c \ diff --git a/src/gtkext/gtkbufferview.c b/src/gtkext/gtkbufferview.c index bad88fc..796a001 100644 --- a/src/gtkext/gtkbufferview.c +++ b/src/gtkext/gtkbufferview.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * gtkbufferview.c - affichage de tampons de lignes * - * Copyright (C) 2010 Cyrille Bagard + * Copyright (C) 2010-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -175,16 +175,8 @@ static void gtk_buffer_view_compute_real_coord(GtkBufferView *view, gint *x, gin static void gtk_buffer_view_size_request(GtkWidget *widget, GtkRequisition *requisition) { if (GTK_BUFFER_VIEW(widget)->buffer_view != NULL) - { - - g_buffer_view_get_size(GTK_BUFFER_VIEW(widget)->buffer_view, - &requisition->width, &requisition->height); - - printf(" === size req :: (%d ; %d)\n", - requisition->width, requisition->height); - - } - else printf(" === size req :: ??\n"); + g_buffer_view_get_size(GTK_BUFFER_VIEW(widget)->buffer_view, + &requisition->width, &requisition->height); } @@ -394,7 +386,7 @@ void gtk_buffer_view_attach_buffer(GtkBufferView *view, GCodeBuffer *buffer) width += -view->left_text + 1; height += 1; - gtk_widget_set_size_request(GTK_WIDGET(view), width, height); + //gtk_widget_set_size_request(GTK_WIDGET(view), width, height); gtk_widget_queue_draw(GTK_WIDGET(view)); diff --git a/src/gtkext/gtkdockstation.c b/src/gtkext/gtkdockstation.c new file mode 100644 index 0000000..afea11d --- /dev/null +++ b/src/gtkext/gtkdockstation.c @@ -0,0 +1,285 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtkdockstation.c - manipulation et l'affichage de composants rassemblés + * + * Copyright (C) 2012 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 Foobar. If not, see . + */ + + +#include "gtkdockstation.h" + + +#include +#include + + +#include "easygtk.h" + + + +/* Procède à l'initialisation de l'afficheur concentré. */ +static void gtk_dock_station_class_init(GtkDockStationClass *); + +/* Procède à l'initialisation du support d'affichage concentré. */ +static void gtk_dock_station_init(GtkDockStation *); + +/* Met à jour le titre du support de panneaux concentrés. */ +static gboolean gtk_dock_station_switch_panel(GtkNotebook *, GtkNotebookPage *, guint, gpointer); + + + +/* Détermine le type du composant d'affichage concentré. */ +G_DEFINE_TYPE(GtkDockStation, gtk_dock_station, GTK_TYPE_VBOX) + + +/****************************************************************************** +* * +* Paramètres : class = classe GTK à initialiser. * +* * +* Description : Procède à l'initialisation de l'afficheur concentré. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_dock_station_class_init(GtkDockStationClass *class) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : station = composant GTK à initialiser. * +* * +* Description : Procède à l'initialisation du support d'affichage concentré. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_dock_station_init(GtkDockStation *station) +{ + GtkWidget *eventbox; /* Réceptacle actif */ + GtkWidget *hbox; /* Division supérieure */ + GtkWidget *button; /* Bouton de contrôle */ + GtkWidget *image; /* Image associée */ + + eventbox = gtk_event_box_new(); + gtk_widget_show(eventbox); + gtk_box_pack_start(GTK_BOX(station), eventbox, FALSE, TRUE, 0); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_widget_show(hbox); + gtk_container_add(GTK_CONTAINER(eventbox), hbox); + + station->title = GTK_LABEL(gtk_label_new(("titre"))); + gtk_widget_show(GTK_WIDGET(station->title)); + gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(station->title), TRUE, TRUE, 0); + gtk_label_set_use_markup(GTK_LABEL(station->title), TRUE); + gtk_misc_set_alignment(GTK_MISC(station->title), 0, 0.5); + + button = gtk_button_new(); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + + image = gtk_image_new_from_stock("gtk-media-play", GTK_ICON_SIZE_MENU); + gtk_widget_show(image); + gtk_container_add(GTK_CONTAINER(button), image); + gtk_widget_set_size_request(image, 10, 10); + + button = gtk_button_new(); + gtk_widget_show(button); + gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); + gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); + + image = gtk_image_new_from_stock("gtk-close", GTK_ICON_SIZE_MENU); + gtk_widget_show(image); + gtk_container_add(GTK_CONTAINER(button), image); + gtk_widget_set_size_request(image, 10, 10); + + station->notebook = GTK_NOTEBOOK(gtk_notebook_new()); + gtk_widget_show(GTK_WIDGET(station->notebook)); + gtk_box_pack_start(GTK_BOX(station), GTK_WIDGET(station->notebook), TRUE, TRUE, 0); + gtk_notebook_set_show_border(station->notebook, FALSE); + gtk_notebook_set_tab_pos(station->notebook, GTK_POS_BOTTOM); + gtk_notebook_set_scrollable(station->notebook, TRUE); + + g_signal_connect(station->notebook, "switch-page", + G_CALLBACK(gtk_dock_station_switch_panel), station); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un nouveau composant pour support d'affichage concentré.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *gtk_dock_station_new(void) +{ + return g_object_new(GTK_TYPE_DOCK_STATION, NULL); + +} + + +/****************************************************************************** +* * +* Paramètres : notebook = support à l'origine de la mise à jour. * +* page = onglet mis en avant. * +* index = indice de l'onglet actuellement actif. * +* data = adresse du conteneur supérieur. * +* * +* Description : Met à jour le titre du support de panneaux concentrés. * +* * +* Retour : TRUE ? * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean gtk_dock_station_switch_panel(GtkNotebook *notebook, GtkNotebookPage *page, guint index, gpointer data) +{ + GtkWidget *widget; /* Panneau concerné */ + char *caption; /* Texte à redonner */ + + widget = gtk_notebook_get_nth_page(notebook, index); + caption = g_object_get_data(G_OBJECT(widget), "title"); + + gtk_dock_panel_update_title(GTK_DOCK_STATION(data), widget, caption); + + //g_signal_emit_by_name(GTK_DOCK_PANEL(data), "switch-item", ditem); + + return TRUE; + +} + + +/****************************************************************************** +* * +* Paramètres : station = plateforme GTK à compléter. * +* widget = nouvel élément à intégrer. * +* caption = intitulé court à afficher sur les onglets. * +* * +* Description : Ajoute un paquet d'informations à l'affichage centralisé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void gtk_dock_panel_add_widget(GtkDockStation *station, GtkWidget *widget, const char *caption) +{ + GtkWidget *label; /* Etiquette d'onglet */ + + label = qck_create_label(NULL, NULL, caption); + + g_signal_handlers_disconnect_by_func(station->notebook, + G_CALLBACK(gtk_dock_station_switch_panel), station); + + gtk_notebook_insert_page(station->notebook, widget, label, -1); + + g_signal_connect(station->notebook, "switch-page", + G_CALLBACK(gtk_dock_station_switch_panel), station); + + gtk_notebook_set_show_tabs(station->notebook, gtk_notebook_get_n_pages(station->notebook) > 1); + + gtk_dock_panel_update_title(station, widget, caption); + +} + + + +/****************************************************************************** +* * +* Paramètres : station = plateforme GTK à compléter. * +* widget = nouvel élément à intégrer. * +* caption = intitulé court à afficher sur les onglets. * +* * +* Description : Met à jour, si besoin est, le titre de l'affichage concentré.* +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void gtk_dock_panel_update_title(GtkDockStation *station, GtkWidget *widget, const char *caption) +{ + char *str; /* Valeur finale reconstituée */ + gint index; /* Indice de l'onglet actif */ + + /* Sauvegarde pour une prochaine fois */ + + str = g_object_get_data(G_OBJECT(widget), "title"); + if (str != NULL) free(str); + + g_object_set_data(G_OBJECT(widget), "title", strdup(caption)); + + /* Mise à jour de l'affichage */ + + index = gtk_notebook_get_current_page(station->notebook); + + if (index == gtk_notebook_page_num(station->notebook, widget)) + { + str = calloc(strlen("") + strlen(caption) + strlen("") + 1, sizeof(char)); + + strcpy(str, ""); + strcat(str, caption); + strcat(str, ""); + + gtk_label_set_markup(station->title, str); + + free(str); + + } + +} + + +/****************************************************************************** +* * +* Paramètres : station = plateforme GTK à consulter. * +* index = indice de l'onglet visé. * +* * +* Description : Renvoie un composant intégré dans l'affichage centralisé. * +* * +* Retour : Composant associé à l'indice donné. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *station, gint index) +{ + return gtk_notebook_get_nth_page(station->notebook, index); + +} diff --git a/src/gtkext/gtkdockstation.h b/src/gtkext/gtkdockstation.h new file mode 100644 index 0000000..c92f43d --- /dev/null +++ b/src/gtkext/gtkdockstation.h @@ -0,0 +1,94 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * gtkdockstation.h - prototypes pour la manipulation et l'affichage de composants rassemblés + * + * Copyright (C) 2012 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 Foobar. If not, see . + */ + + +#ifndef _GTKEXT_GTKDOCKSTATION_H +#define _GTKEXT_GTKDOCKSTATION_H + + +#include + + +G_BEGIN_DECLS + + +#define GTK_TYPE_DOCK_STATION (gtk_dock_station_get_type()) +#define GTK_DOCK_STATION(obj) GTK_CHECK_CAST(obj, gtk_dock_station_get_type (), GtkDockStation) +#define GTK_DOCK_STATION_CLASS(klass) GTK_CHECK_CLASS_CAST(klass, gtk_dock_station_get_type(), GtkDockStationClass) +#define GTK_IS_DOCK_STATION(obj) GTK_CHECK_TYPE(obj, gtk_dock_station_get_type()) + + +/* Station de réception pour concentration d'éléments (instance) */ +typedef struct _GtkDockStation GtkDockStation; + +/* Station de réception pour concentration d'éléments (classe) */ +typedef struct _GtkDockStationClass GtkDockStationClass; + + +/* Station de réception pour concentration d'éléments (instance) */ +struct _GtkDockStation +{ + GtkVBox vbox; /* Présence obligatoire en 1er */ + + GtkLabel *title; /* Title du support principal */ + GtkNotebook *notebook; /* Support à onglets */ + +}; + +/* Station de réception pour concentration d'éléments (classe) */ +struct _GtkDockStationClass +{ + GtkVBoxClass parent_class; /* Présence obligatoire en 1er */ + +}; + + +/* Détermine le type du composant d'affichage concentré. */ +GtkType gtk_dock_station_get_type(void); + +/* Crée un nouveau composant pour support d'affichage concentré. */ +GtkWidget *gtk_dock_station_new(void); + +/* Ajoute un paquet d'informations à l'affichage centralisé. */ +void gtk_dock_panel_add_widget(GtkDockStation *, GtkWidget *, const char *); + +/* Met à jour, si besoin est, le titre de l'affichage concentré. */ +void gtk_dock_panel_update_title(GtkDockStation *, GtkWidget *, const char *); + +/* Renvoie un composant intégré dans l'affichage centralisé. */ +GtkWidget *gtk_dock_panel_get_widget(GtkDockStation *, gint); + + + +/* Ajoute un nouveau composant à l'ensemble. */ +//void gtk_dock_station_add_item(GtkDockStation *, GDockItem *); + +/* Supprime un composant à l'ensemble. */ +//void gtk_dock_station_remove_item(GtkDockStation *, GDockItem *); + + + +G_END_DECLS + + + +#endif /* _GTKEXT_GTKDOCKSTATION_H */ diff --git a/src/gui/Makefile.am b/src/gui/Makefile.am index 06f1a4e..24ba5e5 100644 --- a/src/gui/Makefile.am +++ b/src/gui/Makefile.am @@ -7,6 +7,7 @@ libgui_la_SOURCES = \ libgui_la_LIBADD = \ menus/libguimenus.la \ + panels/libguipanels.la \ tb/libguitb.la \ ../dialogs/libdialogs.la @@ -19,4 +20,4 @@ AM_CPPFLAGS = AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) -SUBDIRS = menus tb +SUBDIRS = menus panels tb diff --git a/src/gui/menus/debug.c b/src/gui/menus/debug.c index 366d789..0d9b41d 100644 --- a/src/gui/menus/debug.c +++ b/src/gui/menus/debug.c @@ -33,7 +33,7 @@ #include "../../project.h" #include "../../gtkext/easygtk.h" -#include "../../panels/log.h" +#include "../../gui/panels/log.h" diff --git a/src/gui/panels/Makefile.am b/src/gui/panels/Makefile.am new file mode 100644 index 0000000..0d43844 --- /dev/null +++ b/src/gui/panels/Makefile.am @@ -0,0 +1,18 @@ + +noinst_LTLIBRARIES = libguipanels.la + +libguipanels_la_SOURCES = \ + log.h log.c \ + panel.h panel.c \ + symbols.h symbols.c + +libguipanels_la_LDFLAGS = + + +INCLUDES = $(LIBGTK_CFLAGS) $(LIBXML_CFLAGS) + +AM_CPPFLAGS = + +AM_CFLAGS = $(DEBUG_CFLAGS) $(WARNING_FLAGS) $(COMPLIANCE_FLAGS) + +SUBDIRS = diff --git a/src/gui/panels/log.c b/src/gui/panels/log.c new file mode 100644 index 0000000..2ab6d0c --- /dev/null +++ b/src/gui/panels/log.c @@ -0,0 +1,273 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * log.c - panneau d'affichage des messages système + * + * Copyright (C) 2009-2012 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 "log.h" + + +#include +#include +#include + + + +/* 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; + + + +/* Construit le panneau d'affichage des messages système. */ +static GtkWidget *build_log_panel(void); + + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Construit le panneau d'affichage des messages système. * +* * +* Retour : Adresse du panneau mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GPanelItem *create_log_panel(void) +{ + GEditorItem *result; /* Elément réactif à renvoyer */ + GtkWidget *panel; /* Composant GTK visuel */ + + panel = build_log_panel(); + + result = g_panel_item_new(PANEL_LOG_ID, _("Misc information"), panel, "S"); + + return G_PANEL_ITEM(result); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Construit le panneau d'affichage des messages système. * +* * +* Retour : Adresse du panneau mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GtkWidget *build_log_panel(void) +{ + GtkWidget *result; /* Panneau à retourner */ + GtkTreeStore *store; /* Modèle de gestion */ + GtkWidget *treeview; /* Affichage de la liste */ + GtkCellRenderer *renderer; /* Moteur de rendu de colonne */ + GtkTreeViewColumn *column; /* Colonne de la liste */ + + result = gtk_scrolled_window_new(NULL, NULL); + gtk_widget_show(result); + + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(result), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(result), GTK_SHADOW_IN); + + store = gtk_tree_store_new(LGC_COUNT, G_TYPE_STRING, G_TYPE_STRING); + g_object_set_data(G_OBJECT(result), "store", store); + + treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); + g_object_set_data(G_OBJECT(result), "treeview", treeview); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); + gtk_widget_show(treeview); + gtk_container_add(GTK_CONTAINER(result), treeview); + + g_object_unref(G_OBJECT(store)); + + column = gtk_tree_view_column_new(); + gtk_tree_view_column_set_visible(column, FALSE); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); + + column = gtk_tree_view_column_new(); + + renderer = gtk_cell_renderer_pixbuf_new(); + gtk_tree_view_column_pack_start(column, renderer, FALSE); + gtk_tree_view_column_add_attribute(column, renderer, "stock-id", LGC_PICTURE); + + renderer = gtk_cell_renderer_text_new(); + gtk_tree_view_column_pack_start(column, renderer, TRUE); + gtk_tree_view_column_add_attribute(column, renderer, "text", LGC_STRING); + + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : type = espèce du message à ajouter. * +* msg = message à faire apparaître à l'écran. * +* * +* Description : Affiche un message dans le journal des messages système. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void log_simple_message(LogMessageType type, const char *msg) +{ + GPanelItem *item; /* Intermédiaire mis en place */ + GtkWidget *panel; /* Panneau à traiter */ + GtkTreeStore *store; /* Modèle de gestion */ + GtkTreeIter iter; /* Point d'insertion */ + GtkTreeView *treeview; /* Affichage de la liste */ + GtkTreePath *path; /* Chemin d'accès à la ligne */ + + item = g_panel_item_get(PANEL_LOG_ID); + panel = g_editor_item_get_widget(G_EDITOR_ITEM(item)); + + store = g_object_get_data(G_OBJECT(panel), "store"); + + gtk_tree_store_append(store, &iter, NULL); + + switch (type) + { + case LMT_INFO: + gtk_tree_store_set(store, &iter, + LGC_PICTURE, "gtk-info", + LGC_STRING, msg, + -1); + break; + + case LMT_BAD_BINARY: + gtk_tree_store_set(store, &iter, + LGC_PICTURE, "gtk-dialog-warning", + LGC_STRING, msg, + -1); + break; + + case LMT_PROCESS: + gtk_tree_store_set(store, &iter, + LGC_PICTURE, "gtk-execute", + LGC_STRING, msg, + -1); + break; + + case LMT_ERROR: + gtk_tree_store_set(store, &iter, + LGC_PICTURE, "gtk-dialog-error", + LGC_STRING, msg, + -1); + break; + + case LMT_WARNING: + gtk_tree_store_set(store, &iter, + LGC_PICTURE, "gtk-dialog-warning", + LGC_STRING, msg, + -1); + break; + + default: + gtk_tree_store_set(store, &iter, + LGC_STRING, msg, + -1); + break; + + } + + treeview = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(panel), "treeview")); + path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); + + gtk_tree_view_scroll_to_cell(treeview, path, NULL, FALSE, 0.0, 0.0); + + gtk_tree_path_free(path); + +} + + +/****************************************************************************** +* * +* Paramètres : type = espèce du message à ajouter. * +* fmt = format du message à faire apparaître à l'écran. * +* ... = éventuels arguments venant compléter le message. * +* * +* Description : Affiche un message dans le journal des messages système. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void log_variadic_message(LogMessageType type, const char *fmt, ...) +{ + size_t len; /* Taille tampon disponible */ + char *buffer; /* Tampon du msg reconstitué */ + int ret; /* Bilan d'une impression */ + char *ptr; /* Nouvelle allocation */ + va_list ap; /* Liste d'arguments variable */ + + len = 100; + buffer = calloc(len, sizeof(char)); + + while (buffer != NULL) + { + va_start(ap, fmt); + ret = vsnprintf(buffer, len, fmt, ap); + va_end(ap); + + if (ret >= 0 && ret < len) break; + + else + { + if (ret > -1) len += 1; /* glibc 2.1 */ + else len *= 2; /* glibc 2.0 */ + + if ((ptr = realloc(buffer, len)) == NULL) + { + free(buffer); + buffer = NULL; + } + else buffer = ptr; + + } + + } + + log_simple_message(type, buffer); + + free(buffer); + +} diff --git a/src/gui/panels/log.h b/src/gui/panels/log.h new file mode 100644 index 0000000..c8fe790 --- /dev/null +++ b/src/gui/panels/log.h @@ -0,0 +1,64 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * log.h - prototypes pour le panneau d'affichage des messages système + * + * Copyright (C) 2009-2012 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 + */ + + +#ifndef _GUI_PANELS_LOG_H +#define _GUI_PANELS_LOG_H + + +#include + + +#include "panel.h" + + + +#define PANEL_LOG_ID _("Messages") + + +/* Type de messages disponibles */ +typedef enum _LogMessageType +{ + LMT_INFO, /* Information sur l'exécution */ + LMT_BAD_BINARY, /* Binaire malformé */ + LMT_PROCESS, /* Début de tâche quelconque */ + LMT_ERROR, /* Erreur de traitement */ + LMT_WARNING, /* Avertissment à remonter */ + + LMT_COUNT + +} LogMessageType; + + +/* Construit le panneau d'affichage des messages système. */ +GPanelItem *create_log_panel(void); + +/* Affiche un message dans le journal des messages système. */ +void log_simple_message(LogMessageType, const char *); + +/* Affiche un message dans le journal des messages système. */ +void log_variadic_message(LogMessageType, const char *, ...); + + + +#endif /* _GUI_PANELS_LOG_H */ diff --git a/src/gui/panels/panel-int.h b/src/gui/panels/panel-int.h new file mode 100644 index 0000000..186092d --- /dev/null +++ b/src/gui/panels/panel-int.h @@ -0,0 +1,73 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * panel-int.h - prototypes pour les définitions internes liées aux panneaux d'affichage + * + * Copyright (C) 2012 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 + */ + + +#ifndef _GUI_PANELS_PANEL_INT_H +#define _GUI_PANELS_PANEL_INT_H + + +#include "panel.h" + + +#include + + +#include "../editem-int.h" +#include "../../common/dllist.h" + + + +/* Elément réactif pour panneaux de l'éditeur (instance) */ +struct _GPanelItem +{ + GEditorItem parent; /* A laisser en premier */ + + DL_LIST_ITEM(link); /* Maillon de liste chaînée */ + + const char *lname; /* Description longue */ + + const char *path; /* Chemin vers la place idéale */ + +}; + + +/* Elément réactif pour panneaux de l'éditeur (classe) */ +struct _GPanelItemClass +{ + GEditorItemClass parent; /* A laisser en premier */ + + GtkBin *first; /* Elément racine */ + +}; + + +#define panels_list_add_tail(new, head) dl_list_add_tail(new, head, GPanelItem, link) +#define panels_list_for_each(pos, head) dl_list_for_each(pos, head, GPanelItem, link) + + +/* Initialise dynamique les propriétés de l'instance. */ +void g_panel_item_init_ext(GPanelItem *, const char *, const char *, GtkWidget *, const char *); + + + +#endif /* _GUI_PANELS_PANEL_INT_H */ diff --git a/src/gui/panels/panel.c b/src/gui/panels/panel.c new file mode 100644 index 0000000..8cc79ce --- /dev/null +++ b/src/gui/panels/panel.c @@ -0,0 +1,658 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * panel.c - prototypes pour la gestion des éléments réactifs spécifiques aux panneaux + * + * Copyright (C) 2009-2012 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 "panel.h" + + +#include +#include + + +#include "log.h" +#include "panel-int.h" +#include "symbols.h" +#include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkdockstation.h" + + + +/* Support de fond pour les composants */ +static GtkWidget *_support; + +/* Liste des panneaux en place */ +static GPanelItem *_panels_list = NULL; + + +/* Initialise la classe des éléments réactifs de l'éditeur. */ +static void g_panel_item_class_init(GPanelItemClass *); + +/* Initialise une instance d'élément réactif pour l'éditeur. */ +static void g_panel_item_init(GPanelItem *); + +/* Renvoie un élément du chemin d'insertion du panneau. */ +static char g_panel_item_get_path_at(GPanelItem *, size_t); + +/* Détermine le support faisant office d'étendue donnée. */ +static GtkWidget *get_panel_given_part(GtkWidget *, size_t, char); + +/* Fournit le premier morceau de chemin rencontré. */ +static char get_first_path_found(GtkWidget *, size_t); + +/* Introduit une nouvelle division sur le support indiqué. */ +static void create_panel_division(GtkWidget *, GtkWidget *, const char *, GtkWidget *, const char *, char); + +/* Place un panneau dans l'ensemble affiché. */ +static void _g_panel_item_dock(GtkWidget *, GEditorItem *, const char *, size_t); + + + +/* Indique le type défini pour un élément destiné à un panneau. */ +G_DEFINE_TYPE(GPanelItem, g_panel_item, G_TYPE_EDITOR_ITEM); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des éléments réactifs de l'éditeur. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_panel_item_class_init(GPanelItemClass *klass) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : item = instance à initialiser. * +* * +* Description : Initialise une instance d'élément réactif pour l'éditeur. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_panel_item_init(GPanelItem *item) +{ + DL_LIST_ITEM_INIT(&item->link); + +} + + +/****************************************************************************** +* * +* Paramètres : item = composant à présenter à l'affichage. * +* ref = espace de référencement global. * +* name = nom associé à l'élément. * +* lname = description longue du panneau. * +* widget = composant à présenter à l'affichage. * +* path = chemin vers la place idéale pour le futur panneau. * +* * +* Description : Initialise dynamique les propriétés de l'instance. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_panel_item_init_ext(GPanelItem *item, const char *name, const char *lname, GtkWidget *widget, const char *path) +{ + GEditorItem *parent; /* Autre version de l'élément */ + + parent = G_EDITOR_ITEM(item); + + parent->name = name; + item->lname = lname; + + g_object_ref(widget); + parent->widget = widget; + g_object_set_data(G_OBJECT(widget), "pitem", item); + + item->path = path; + + panels_list_add_tail(item, &_panels_list); + +} + + +/****************************************************************************** +* * +* Paramètres : ref = espace de référencement global. * +* name = nom associé à l'élément. * +* lname = description longue du panneau. * +* widget = composant à présenter à l'affichage. * +* path = chemin vers la place idéale pour le futur panneau. * +* * +* Description : Crée un élément de panneau réactif. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GEditorItem *g_panel_item_new(const char *name, const char *lname, GtkWidget *widget, const char *path) +{ + GPanelItem *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_PANEL_ITEM, NULL); + + g_panel_item_init_ext(result, name, lname, widget, path); + + return G_EDITOR_ITEM(result); + +} + + + +/****************************************************************************** +* * +* Paramètres : item = composant d'affichage à consulter. * +* pos = position de la tête de lecture dans le chemin. * +* * +* Description : Renvoie un élément du chemin d'insertion du panneau. * +* * +* Retour : Lettre caractéristique ou '\0'. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static char g_panel_item_get_path_at(GPanelItem *item, size_t pos) +{ + if (pos >= strlen(item->path)) + return '\0'; + else + return item->path[pos]; + +} + + +/****************************************************************************** +* * +* Paramètres : name = désignation courte servant de clef. * +* * +* Description : Recherche un panneau à partir de son nom court. * +* * +* Retour : Panneau trouvé ou NULL si aucun. * +* * +* Remarques : Le parcours peut se faire aussi depuis la classe parente, * +* mais il est plus rapide par ici. * +* * +******************************************************************************/ + +GPanelItem *g_panel_item_get(const char *name) +{ + GPanelItem *iter; /* Boucle de parcours */ + + panels_list_for_each(iter, _panels_list) + { + if (strcmp(G_EDITOR_ITEM(iter)->name, name) == 0) + return iter; + + } + + return NULL; + +} + + +/****************************************************************************** +* * +* Paramètres : item = composant à présenter à l'affichage. * +* * +* Description : Place un panneau dans l'ensemble affiché. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_panel_item_dock(GPanelItem *item) +{ + GPanelItemClass *class; /* Encadrement global */ + GtkWidget *station; /* Premier support concentré */ + GEditorItem *editem; /* Autre vision des choses */ + + class = G_PANEL_ITEM_GET_CLASS(item); + + /* Tout est à faire... */ + if (class->first == NULL) + { + /** + * Note : on crée ici un support qui ne sera jamais déplacé, + * laissant ainsi la variable 'class->first' pour les départs + * de parcours toujours valide sans effort. + */ + class->first = GTK_BIN(qck_create_padded_alignment(0, 0, 0, 0)); + + gtk_widget_show(GTK_WIDGET(class->first)); + gtk_container_add(GTK_CONTAINER(_support), GTK_WIDGET(class->first)); + + station = gtk_dock_station_new(); + + gtk_widget_show(station); + gtk_container_add(GTK_CONTAINER(class->first), station); + + editem = G_EDITOR_ITEM(item); + gtk_dock_panel_add_widget(GTK_DOCK_STATION(station), + editem->widget, editem->name); + + } + else _g_panel_item_dock(gtk_bin_get_child(class->first), G_EDITOR_ITEM(item), item->path, 0); + +} + + +/****************************************************************************** +* * +* Paramètres : base = support sujet à analyse. * +* pos = position de la tête de lecture dans le chemin. * +* target = indentifiant de positionnement recherché. * +* * +* Description : Détermine le support faisant office d'étendue donnée. * +* * +* Retour : Composant en place retrouvé ou NULL si aucune correspondance.* +* * +* Remarques : - * +* * +******************************************************************************/ + +static GtkWidget *get_panel_given_part(GtkWidget *base, size_t pos, char target) +{ + GtkWidget *result; /* Trouvaille à retourner */ + GtkWidget *widget; /* Autre composant présent */ + GPanelItem *item; /* Autre version de l'instance */ + char path; /* Partie de chemin en place */ + + if (GTK_IS_DOCK_STATION(base)) + { + widget = gtk_dock_panel_get_widget(GTK_DOCK_STATION(base), 0); + item = G_PANEL_ITEM(g_object_get_data(G_OBJECT(widget), "pitem")); + + path = g_panel_item_get_path_at(item, pos); + + result = (path == target ? base : NULL); + + } + else + { + widget = gtk_paned_get_child1(GTK_PANED(base)); + result = get_panel_given_part(widget, pos, target); + + if (result == NULL) + { + widget = gtk_paned_get_child2(GTK_PANED(base)); + result = get_panel_given_part(widget, pos, target); + } + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : base = support sujet à analyse. * +* pos = position de la tête de lecture dans le chemin. * +* * +* Description : Fournit le premier morceau de chemin rencontré. * +* * +* Retour : Premier élément de chemin rencontré. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static char get_first_path_found(GtkWidget *base, size_t pos) +{ + char result; /* Trouvaille à retourner */ + GtkWidget *widget; /* Autre composant présent */ + GPanelItem *item; /* Autre version de l'instance */ + + if (GTK_IS_DOCK_STATION(base)) + { + widget = gtk_dock_panel_get_widget(GTK_DOCK_STATION(base), 0); + item = G_PANEL_ITEM(g_object_get_data(G_OBJECT(widget), "pitem")); + + result = g_panel_item_get_path_at(item, pos); + + } + else + { + /** + * A un certain niveau, si deux éléments sont groupés, + * c'est qu'ils ont une base commune ! On ne parcourt donc + * que le premier d'entre eux. + */ + widget = gtk_paned_get_child1(GTK_PANED(base)); + result = get_first_path_found(widget, pos); + + } + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : parent = support où placer la nouvelle division. * +* child1 = composant GTK à placer en position 1. * +* name1 = éventuelle désignation en cas d'isolement. * +* child2 = composant GTK à placer en position 2. * +* name2 = éventuelle désignation en cas d'isolement. * +* orientation = sens de la division. * +* * +* Description : Introduit une nouvelle division sur le support indiqué. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void create_panel_division(GtkWidget *parent, GtkWidget *child1, const char *name1, GtkWidget *child2, const char *name2, char orientation) +{ + unsigned int index; /* Indice de la réinsertion */ + bool resize; /* Redimensionnement à garder */ + GtkWidget *station; /* Nouvelle concentration */ + GtkWidget *paned; /* Nouveau support */ + + orientation = toupper(orientation); + + /* Détermination de la localisation d'origine */ + + if (GTK_IS_PANED(parent)) + { + if (gtk_paned_get_child1(GTK_PANED(parent)) == child1 + || gtk_paned_get_child1(GTK_PANED(parent)) == child2) + { + index = 1; + resize = GTK_PANED(parent)->child1_resize; + } + else + { + index = 2; + resize = GTK_PANED(parent)->child2_resize; + } + } + else + { + index = -1; + resize = false; /* Pour gcc (Debian 4.4.5-8) 4.4.5 */ + } + + gtk_widget_ref(name1 == NULL ? child1 : child2); + + gtk_container_remove(GTK_CONTAINER(parent), child2); + + /* Enrobages éventuels */ + + if (!GTK_IS_DOCK_STATION(child1)) + { + station = gtk_dock_station_new(); + gtk_widget_show(station); + gtk_dock_panel_add_widget(GTK_DOCK_STATION(station), child1, name1); + + child1 = station; + + } + + if (!GTK_IS_DOCK_STATION(child2)) + { + station = gtk_dock_station_new(); + gtk_widget_show(station); + gtk_dock_panel_add_widget(GTK_DOCK_STATION(station), child2, name2); + + child2 = station; + + } + + /* Insertion complète */ + + if (orientation == 'N' || orientation == 'S') + paned = gtk_vpaned_new(); + else + paned = gtk_hpaned_new(); + + gtk_widget_show(paned); + + switch (index) + { + case 1: + gtk_paned_pack1(GTK_PANED(parent), paned, resize, FALSE); + break; + case 2: + gtk_paned_pack2(GTK_PANED(parent), paned, resize, FALSE); + break; + default: + gtk_container_add(GTK_CONTAINER(parent), paned); + break; + } + + switch (orientation) + { + case 'N': + break; + case 'E': + gtk_paned_pack1(GTK_PANED(paned), child1, TRUE, FALSE); + gtk_paned_pack2(GTK_PANED(paned), child2, FALSE, FALSE); + gtk_paned_set_position(GTK_PANED(paned), 450); + break; + case 'S': + gtk_paned_pack1(GTK_PANED(paned), child1, TRUE, FALSE); + gtk_paned_pack2(GTK_PANED(paned), child2, FALSE, FALSE); + gtk_paned_set_position(GTK_PANED(paned), 350); + break; + case 'W': + break; + } + +} + + +/****************************************************************************** +* * +* Paramètres : base = départ courant de la déscente. * +* item = composant à présenter à l'affichage. * +* path = chemin à consulter pour le placement idéal. * +* pos = position de la tête de lecture dans le chemin. * +* * +* Description : Place un panneau dans l'ensemble affiché. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void _g_panel_item_dock(GtkWidget *base, GEditorItem *item, const char *path, size_t pos) +{ + GtkWidget *part; /* Support principal détecté */ + GtkWidget *widget; /* Autre composant présent */ + GPanelItem *other; /* Autre version de l'instance */ + char path_i; /* Partie de chemin à insérer */ + char path_o; /* Partie de chemin en place */ + GtkWidget *parent; /* Support supérieur */ + char sel_path; /* Chemin à appliquer */ + + + //printf(" ============== PATH :: '%c' =======================\n", path[pos]); + + part = get_panel_given_part(base, pos, path[pos]); + + + //printf("-- trouve :: %p ( station ?= %d) ( base ?= %d)\n", part, GTK_IS_DOCK_STATION(part), GTK_IS_DOCK_STATION(base)); + + + if (GTK_IS_DOCK_STATION(part)) + { + + + path_i = g_panel_item_get_path_at(G_PANEL_ITEM(item), pos); + + widget = gtk_dock_panel_get_widget(GTK_DOCK_STATION(part), 0); + other = G_PANEL_ITEM(g_object_get_data(G_OBJECT(widget), "pitem")); + + path_o = g_panel_item_get_path_at(other, pos); + + //printf(" -- path -- '%c' vs '%c'\n", path_i, path_o); + + + if (path_i == path_o) + gtk_dock_panel_add_widget(GTK_DOCK_STATION(part), item->widget, item->name); + + else + { + /* On fait primer le chemin d'importance */ + if (path_i == 'M' || (isupper(path_o) && !isupper(path_i))) + sel_path = path_o; + else + sel_path = path_i; + + parent = gtk_widget_get_parent(base); + create_panel_division(parent, item->widget, item->name, base, NULL, sel_path); + } + + } + + else if (GTK_IS_PANED(part)) + { + + + + printf("Paf Paned !\n"); + exit(0); + + + } + + /* Si on n'a rien trouvé, alors on redivise */ + else /*if (part == NULL)*/ + { + if (!GTK_IS_DOCK_STATION(base)) + { + path_i = get_first_path_found(gtk_paned_get_child1(GTK_PANED(base)), pos); + path_o = get_first_path_found(gtk_paned_get_child2(GTK_PANED(base)), pos); + + if (path_i == 'M' || (isupper(path_o) && islower(path_i))) + base = gtk_paned_get_child1(GTK_PANED(base)); + else + base = gtk_paned_get_child2(GTK_PANED(base)); + + } + + path_i = g_panel_item_get_path_at(G_PANEL_ITEM(item), pos); + + widget = gtk_dock_panel_get_widget(GTK_DOCK_STATION(base), 0); + other = G_PANEL_ITEM(g_object_get_data(G_OBJECT(widget), "pitem")); + + path_o = g_panel_item_get_path_at(other, pos); + + /* On fait primer le chemin d'importance */ + if (path_i == 'M' || (islower(path_i) && isupper(path_o))) + sel_path = path_o; + else + sel_path = path_i; + + //printf(" ++>> DIR :: '%c' vs '%c' => '%c'\n", path[pos], path_o, sel_path); + + parent = gtk_widget_get_parent(base); + create_panel_division(parent, item->widget, item->name, base, NULL, sel_path); + + } + + + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* PLACEMENTS DES DIFFERENTS PANNEAUX */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Prépare le terrain pour l'affichage central. * +* * +* Retour : Composant de support sur lequel tout va se placer. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *init_panels2(void) +{ + GtkWidget *result; /* Support à retourner */ + + result = qck_create_padded_alignment(0, 0, 0, 0); + gtk_widget_show(result); + + _support = result; + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Charge les principaux panneaux de l'éditeur. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void load_main_panels(void) +{ + GPanelItem *item; /* Panneau de base à charger */ + + item = create_log_panel(); + g_panel_item_dock(item); + + item = create_symbols_panel(); + g_panel_item_dock(item); + +} diff --git a/src/gui/panels/panel.h b/src/gui/panels/panel.h new file mode 100644 index 0000000..afdce93 --- /dev/null +++ b/src/gui/panels/panel.h @@ -0,0 +1,73 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * panel.h - prototypes pour la gestion des éléments réactifs spécifiques aux panneaux + * + * Copyright (C) 2009-2012 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 + */ + + +#ifndef _GUI_PANELS_PANEL_H +#define _GUI_PANELS_PANEL_H + + +#include "../editem.h" + + + +#define G_TYPE_PANEL_ITEM g_panel_item_get_type() +#define G_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_panel_item_get_type(), GPanelItem)) +#define G_IS_PANEL_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_panel_item_get_type())) +#define G_PANEL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_PANEL_ITEM, GPanelItemClass)) +#define G_IS_PANEL_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_PANEL_ITEM)) +#define G_PANEL_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_PANEL_ITEM, GPanelItemClass)) + + +/* Elément réactif pour panneaux de l'éditeur (instance) */ +typedef struct _GPanelItem GPanelItem; + +/* Elément réactif pour panneaux de l'éditeur (classe) */ +typedef struct _GPanelItemClass GPanelItemClass; + + +/* Indique le type défini pour un élément destiné à un panneau. */ +GType g_panel_item_get_type(void); + +/* Crée un élément de panneau réactif. */ +GEditorItem *g_panel_item_new(const char *, const char *, GtkWidget *, const char *); + +/* Recherche un panneau à partir de son nom court. */ +GPanelItem *g_panel_item_get(const char *); + +/* Place un panneau dans l'ensemble affiché. */ +void g_panel_item_dock(GPanelItem *); + + + +/* ----------------------- PLACEMENTS DES DIFFERENTS PANNEAUX ----------------------- */ + + +/* Prépare le terrain pour l'affichage central. */ +GtkWidget *init_panels2(void); + +/* Charge les principaux panneaux de l'éditeur. */ +void load_main_panels(void); + + + +#endif /* _GUI_PANELS_PANEL_H */ diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c new file mode 100644 index 0000000..bac2152 --- /dev/null +++ b/src/gui/panels/symbols.c @@ -0,0 +1,734 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * symbols.c - panneau d'affichage des symboles + * + * Copyright (C) 2008-2012 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 "symbols.h" + + +#include + + +#include "panel-int.h" +#include "../../format/format.h" +#include "../../gtkext/easygtk.h" +#include "../../gtkext/support.h" + + + +/* -------------------------- PARTIE PRINCIPALE DU PANNEAU -------------------------- */ + + +/* Panneau d'aperçu de graphiques (instance) */ +struct _GSymbolsPanel +{ + GPanelItem parent; /* A laisser en premier */ + + GtkTreeView *treeview; /* Composant d'affichage */ + GtkTreeStore *store; /* Modèle de gestion */ + + GOpenidaBinary *binary; /* Binaire à prendre en compte */ + +}; + + +/* Panneau d'aperçu de graphiques (classe) */ +struct _GSymbolsPanelClass +{ + GPanelItemClass parent; /* A laisser en premier */ + +}; + + +/* Colonnes de la liste des symboles */ +typedef enum _SymbolsColumn +{ + SBC_ADDRESS, /* Adresse mémoire du symbole */ + + SBC_ICON, /* Image de représentation */ + SBC_NAME, /* Désignation humaine */ + + SBC_EXPAND, /* Affichage des classes */ + + SBC_COUNT /* Nombre de colonnes */ + +} SymbolsColumn; + + +/* Initialise la classe des panneaux d'aperçu de graphiques. */ +static void g_symbols_panel_class_init(GSymbolsPanelClass *); + +/* Initialise une instance de panneau d'aperçu de graphiques. */ +static void g_symbols_panel_init(GSymbolsPanel *); + +/* Réagit au changement de sélection des symboles. */ +static void on_symbols_selection_change(GtkTreeSelection *, GSymbolsPanel *); + +/* Réagit à un changement d'affichage principal de contenu. */ +void change_symbols_panel_current_binary(GSymbolsPanel *, GOpenidaBinary *); + + + +/* ------------------------- AFFICHAGE A L'AIDE D'UNE LISTE ------------------------- */ + + +/* Réagit à un changement d'affichage principal de contenu. */ +static void reload_symbols_for_new_list_view(GSymbolsPanel *); + + + +/* -------------------------- AFFICHAGE SOUS FORME D'ARBRE -------------------------- */ + + +/* S'assure qu'un noeud donné existe bien. */ +static GtkTreeIter ensure_symbol_node_exist(GtkTreeStore *, GtkTreeIter *, const char *); + +/* Détermine le point d'insertion parent d'une routine. */ +static bool find_parent_for_routine(GtkTreeStore *, const GBinRoutine *, GtkTreeIter *); + +/* Réagit à un changement d'affichage principal de contenu. */ +static void reload_symbols_for_new_tree_view(GSymbolsPanel *); + +/* Réagit à une nouvelle demande de réorganisation. */ +static void reorganize_symbols_tree_view(GtkToolButton *, GObject *); + +/* Fait en sorte que toutes les classes soient affichées. */ +static gboolean show_all_classes_in_tree_view(GtkTreeModel *, GtkTreePath *, GtkTreeIter *, GtkTreeView *); + +/* Réagit à une demande de nouvelle forme d'affichage. */ +static void modify_types_in_symbols_tree_view(GtkToggleToolButton *, GObject *); + + + +/* ---------------------------------------------------------------------------------- */ +/* PARTIE PRINCIPALE DU PANNEAU */ +/* ---------------------------------------------------------------------------------- */ + + +/* Indique le type définit pour un panneau d'aperçu de graphiques. */ +G_DEFINE_TYPE(GSymbolsPanel, g_symbols_panel, G_TYPE_PANEL_ITEM); + + +/****************************************************************************** +* * +* Paramètres : klass = classe à initialiser. * +* * +* Description : Initialise la classe des panneaux d'aperçu de graphiques. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_symbols_panel_class_init(GSymbolsPanelClass *klass) +{ + +} + + +/****************************************************************************** +* * +* Paramètres : panel = instance à initialiser. * +* * +* Description : Initialise une instance de panneau d'aperçu de graphiques. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_symbols_panel_init(GSymbolsPanel *panel) +{ + GEditorItem *base; /* Version basique d'instance */ + GObject *ref; /* Espace de référencement */ + GtkTooltips *tooltips; /* Affichage des bulles d'aide */ + GtkWidget *toolbar; /* Barre d'outils */ + GtkWidget *button; /* Bouton de cette même barre */ + GtkWidget *separator; /* Barre de séparation vert. */ + GtkWidget *scrollwnd; /* Support défilant */ + GtkWidget *treeview; /* Affichage de la liste */ + GtkCellRenderer *renderer; /* Moteur de rendu de colonne */ + GtkTreeViewColumn *column; /* Colonne de la liste */ + GtkTreeSelection *select; /* Sélection dans la liste */ + + base = G_EDITOR_ITEM(panel); + + base->widget = gtk_vbox_new(FALSE, 0); + gtk_widget_show(base->widget); + + ref = G_OBJECT(base->widget); + g_object_set_data(ref, "panel", panel); + + /* Barre d'outils supérieure */ + + tooltips = gtk_tooltips_new(); + + toolbar = gtk_toolbar_new(); + gtk_widget_show(toolbar); + gtk_box_pack_start(GTK_BOX(base->widget), toolbar, FALSE, FALSE, 0); + + //group = gtk_tool_item_group_new(_("View")); + //gtk_widget_show(group); + //gtk_container_add(GTK_CONTAINER(toolbar), group); + + button = qck_create_toggle_tool_button(ref, "list", "tbutton_list_view.png", G_CALLBACK(NULL), NULL); + gtk_container_add(GTK_CONTAINER(toolbar), button); + //gtk_tool_item_group_insert(GTK_TOOL_ITEM_GROUP(group), GTK_TOOL_ITEM(button), -1); + + button = qck_create_toggle_tool_button(ref, "tree", "tbutton_tree_view.png", G_CALLBACK(NULL), NULL); + gtk_container_add(GTK_CONTAINER(toolbar), button); + gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(button), TRUE); + + + //gtk_tool_item_group_insert(GTK_TOOL_ITEM_GROUP(group), GTK_TOOL_ITEM(button), -1); + + + + separator = qck_create_tool_separator(NULL, NULL); + gtk_container_add(GTK_CONTAINER(toolbar), separator); + + button = qck_create_tool_button(ref, "collapse", "tbutton_collapse.png", G_CALLBACK(reorganize_symbols_tree_view), ref); + gtk_container_add(GTK_CONTAINER(toolbar), button); + + button = qck_create_tool_button(ref, "expand", "tbutton_expand.png", G_CALLBACK(reorganize_symbols_tree_view), ref); + gtk_container_add(GTK_CONTAINER(toolbar), button); + + button = qck_create_tool_button(ref, "classes", "symbol_class_classic.png", G_CALLBACK(reorganize_symbols_tree_view), ref); + gtk_container_add(GTK_CONTAINER(toolbar), button); + + separator = qck_create_tool_separator(NULL, NULL); + gtk_container_add(GTK_CONTAINER(toolbar), separator); + + button = qck_create_toggle_tool_button(ref, "namespace", "tbutton_namespace.png", G_CALLBACK(modify_types_in_symbols_tree_view), ref); + gtk_container_add(GTK_CONTAINER(toolbar), button); + + /* Liste arborescente ou linéaire */ + + scrollwnd = gtk_scrolled_window_new(NULL, NULL); + gtk_widget_show(scrollwnd); + gtk_box_pack_start(GTK_BOX(base->widget), scrollwnd, TRUE, TRUE, 0); + + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwnd), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwnd), GTK_SHADOW_IN); + + panel->store = gtk_tree_store_new(SBC_COUNT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN); + + treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(panel->store)); + gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); + gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(treeview), TRUE); + gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); + + panel->treeview = GTK_TREE_VIEW(treeview); + + gtk_widget_show(treeview); + gtk_container_add(GTK_CONTAINER(scrollwnd), treeview); + + g_object_unref(G_OBJECT(panel->store)); + + /* + column = gtk_tree_view_column_new(); + gtk_tree_view_column_set_visible(column, FALSE); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); + */ + + renderer = gtk_cell_renderer_text_new(); + column = gtk_tree_view_column_new_with_attributes("Address", renderer, "text", SBC_ADDRESS, NULL); + //gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + //gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); + + column = gtk_tree_view_column_new(); + gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); + + renderer = gtk_cell_renderer_pixbuf_new(); + //column = gtk_tree_view_column_new_with_attributes("Icon", renderer, "pixbuf", SBC_ICON, NULL); + gtk_tree_view_column_pack_start(column, renderer, FALSE); + gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", SBC_ICON); + + renderer = gtk_cell_renderer_text_new(); + //column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", SBC_NAME, NULL); + gtk_tree_view_column_pack_end(column, renderer, TRUE); + gtk_tree_view_column_add_attribute(column, renderer, "text", SBC_NAME); + //gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); + //gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); + + select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); + gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); + g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_symbols_selection_change), panel); + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Crée un panneau d'affichage des symboles. * +* * +* Retour : Adresse de la structure mise en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GEditorItem *g_symbols_panel_new(void) +{ + GEditorItem *result; /* Structure à retourner */ + + result = g_object_new(G_TYPE_SYMBOLS_PANEL, NULL); + + g_panel_item_init_ext(G_PANEL_ITEM(result), PANEL_SYMBOL_ID, _("Binary symbols"), + G_EDITOR_ITEM(result)->widget, "e"); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : - * +* * +* Description : Construit et intègre un panneau d'affichage des symboles. * +* * +* Retour : Adresse du panneau mis en place. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GPanelItem *create_symbols_panel(void) +{ + GEditorItem *result; /* Elément réactif à renvoyer */ + + result = g_symbols_panel_new(); + + /* Enregistre correctement le tout */ + result->update_binary = (update_item_binary_fc)change_symbols_panel_current_binary; + register_editor_item(result); + + return G_PANEL_ITEM(result); + +} + + +/****************************************************************************** +* * +* Paramètres : selection = sélection modifiée. * +* panel = structure contenant les informations maîtresses. * +* * +* Description : Réagit au changement de sélection des symboles. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void on_symbols_selection_change(GtkTreeSelection *selection, GSymbolsPanel *panel) +{ + GtkTreeIter iter; /* Point de sélection */ + GtkTreeModel *model; /* Modèle de gestion */ + gchar *string; /* Chaîne sélectionnée */ + vmpa_t address; /* Adresse à rejoindre */ + return; + if (gtk_tree_selection_get_selected(selection, &model, &iter)) + { + gtk_tree_model_get(model, &iter, SBC_ADDRESS, &string, -1); + address = strtoll(string, NULL, 16); /* FIXME */ + g_free(string); + + /* FIXME */ + //gtk_bin_view_scroll_to_address(panel->binview, address); + + } + +} + + +/****************************************************************************** +* * +* Paramètres : panel = panneau à mettre à jour. * +* binary = nouvelle instance de binaire analysé. * +* * +* Description : Réagit à un changement d'affichage principal de contenu. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void change_symbols_panel_current_binary(GSymbolsPanel *panel, GOpenidaBinary *binary) +{ + GtkToggleToolButton *button; /* Mode de représentation */ + + if (panel->binary != NULL) + g_object_unref(G_OBJECT(panel->binary)); + + panel->binary = binary; + g_object_ref(G_OBJECT(binary)); + + gtk_tree_store_clear(panel->store); + + button = g_object_get_data(G_OBJECT(G_EDITOR_ITEM(panel)->widget), "list"); + + if (gtk_toggle_tool_button_get_active(button)) + reload_symbols_for_new_list_view(panel); + else + reload_symbols_for_new_tree_view(panel); + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* AFFICHAGE A L'AIDE D'UNE LISTE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : panel = panneau à mettre à jour. * +* * +* Description : Réagit à un changement d'affichage principal de contenu. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void reload_symbols_for_new_list_view(GSymbolsPanel *panel) +{ + GExeFormat *format; /* Format associé au binaire */ + GBinRoutine **routines; /* Liste des routines trouvées */ + size_t routines_count; /* Nombre de ces routines */ + GArchProcessor *proc; /* Architecture utilisée */ + size_t i; /* Boucle de parcours */ + vmpa_t address; /* Adresse associée au symbole */ + char tmp[VMPA_MAX_SIZE]; /* Version humainement lisible */ + GtkTreeIter iter; /* Point d'insertion */ + + format = g_openida_binary_get_format(panel->binary); + + routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); + qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare); + + if (routines != NULL) + { + proc = get_arch_processor_from_format(format); + + for (i = 0; i < routines_count; i++) + { + address = g_binary_routine_get_address(routines[i]); + vmpa_to_string(address, g_arch_processor_get_memory_size(proc), tmp); + + gtk_tree_store_append(panel->store, &iter, NULL); + gtk_tree_store_set(panel->store, &iter, + SBC_ADDRESS, tmp, + SBC_NAME, g_binary_routine_to_string(routines[i]), + -1); + + } + + } + +} + + + +/* ---------------------------------------------------------------------------------- */ +/* AFFICHAGE SOUS FORME D'ARBRE */ +/* ---------------------------------------------------------------------------------- */ + + +/****************************************************************************** +* * +* Paramètres : store = gestion des différents éléments insérés. * +* parent = point d'insertion parent à retrouver. [OUT] * +* name = nom du noeud ciblé. * +* * +* Description : S'assure qu'un noeud donné existe bien. * +* * +* Retour : Point d'insertion prochain. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static GtkTreeIter ensure_symbol_node_exist(GtkTreeStore *store, GtkTreeIter *parent, const char *name) +{ + bool found; /* Bilan des recherches */ + GtkTreeIter iter; /* Boucle de parcours */ + gchar *string; /* Chaîne sélectionnée */ + GdkPixbuf *pixbuf; /* Icone pour l'élément inséré */ + + found = false; + + if (gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, parent)) + do + { + gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, SBC_NAME, &string, -1); + found = (strcmp(string, name) == 0); + g_free(string); + + if (found) break; + + } + while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)); + + if (!found) + { + pixbuf = get_pixbuf_from_file("symbol_package.png"); + + gtk_tree_store_append(store, &iter, parent); + gtk_tree_store_set(store, &iter, + SBC_ICON, pixbuf, + SBC_NAME, name, + -1); + + } + + return iter; + +} + + +/****************************************************************************** +* * +* Paramètres : store = gestion des différents éléments insérés. * +* routine = routine à intégrer. * +* parent = point d'insertion parent à constituer. * +* * +* Description : Détermine le point d'insertion parent d'une routine. * +* * +* Retour : true si le point n'est pas la racine, false sinon. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static bool find_parent_for_routine(GtkTreeStore *store, const GBinRoutine *routine, GtkTreeIter *parent) +{ + GOpenidaType *namespace; /* Espace d'appartenance */ + char *string; /* Conversion en chaîne */ + char *iter; /* Boucle de parcours */ + char *token; /* Partie de texte isolée */ + char *saveptr; /* Ctx. interne de découpage */ + + namespace = g_binary_routine_get_namespace(routine); + if (namespace == NULL) return false; + + string = g_openida_type_to_string(namespace); + + for (iter = string; ; iter = NULL) + { + token = strtok_r(iter, "::", &saveptr); + if (token == NULL) break; + + *parent = ensure_symbol_node_exist(store, (iter == string ? NULL : parent), token); + + } + + return true; + +} + + +/****************************************************************************** +* * +* Paramètres : panel = panneau à mettre à jour. * +* * +* Description : Réagit à un changement d'affichage principal de contenu. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel) +{ + GExeFormat *format; /* Format associé au binaire */ + GBinRoutine **routines; /* Liste des routines trouvées */ + size_t routines_count; /* Nombre de ces routines */ + GArchProcessor *proc; /* Architecture utilisée */ + Routine2StringOptions options; /* Options de rendu */ + GtkToggleToolButton *button; /* Mode de représentation */ + size_t i; /* Boucle de parcours */ + vmpa_t address; /* Adresse associée au symbole */ + char tmp[VMPA_MAX_SIZE]; /* Version humainement lisible */ + GtkTreeIter parent; /* Point d'insertion parent */ + GtkTreeIter iter; /* Point d'insertion */ + GdkPixbuf *pixbuf; /* Icone pour l'élément inséré */ + + format = g_openida_binary_get_format(panel->binary); + + routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); + qsort(routines, routines_count, sizeof(GBinRoutine *), (__compar_fn_t)g_binary_routine_rcompare); + + if (routines != NULL) + { + proc = get_arch_processor_from_format(format); + + options = 0; + + button = g_object_get_data(G_OBJECT(G_EDITOR_ITEM(panel)->widget), "namespace"); + + if (gtk_toggle_tool_button_get_active(button)) + options |= RSO_LONG_TYPE; + + for (i = 0; i < routines_count; i++) + { + address = g_binary_routine_get_address(routines[i]); + vmpa_to_string(address, g_arch_processor_get_memory_size(proc), tmp); + + if (find_parent_for_routine(panel->store, routines[i], &parent)) + { + pixbuf = get_pixbuf_from_file("symbol_class_classic.png"); + + gtk_tree_store_set(panel->store, &parent, + SBC_ICON, pixbuf, + SBC_EXPAND, TRUE, + -1); + + gtk_tree_store_append(panel->store, &iter, &parent); + + } + else + gtk_tree_store_append(panel->store, &iter, NULL); + + pixbuf = get_pixbuf_from_file("symbol_routine_classic.png"); + + gtk_tree_store_set(panel->store, &iter, + SBC_ICON, pixbuf, + SBC_NAME, _g_binary_routine_to_string(routines[i], options), + -1); + + if (pixbuf != NULL) + g_object_unref(G_OBJECT(pixbuf)); + + + } + + } + +} + + +/****************************************************************************** +* * +* Paramètres : button = bouton concerné par l'action. * +* ref = espace de référencement des composants. * +* * +* Description : Réagit à une nouvelle demande de réorganisation. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void reorganize_symbols_tree_view(GtkToolButton *button, GObject *ref) +{ + GSymbolsPanel *panel; /* Données du panneau */ + + panel = (GSymbolsPanel *)g_object_get_data(ref, "panel"); + + if (g_object_get_data(ref, "collapse") == button) + gtk_tree_view_collapse_all(panel->treeview); + + else if (g_object_get_data(ref, "expand") == button) + gtk_tree_view_expand_all(panel->treeview); + + else + gtk_tree_model_foreach(GTK_TREE_MODEL(panel->store), + (GtkTreeModelForeachFunc)show_all_classes_in_tree_view, + panel->treeview); + +} + + +/****************************************************************************** +* * +* Paramètres : model = modèle de gestion des éléments. * +* path = chemin d'accès à l'élément courant. * +* iter = itérateur courant. * +* treeview = arborescence à manipuler ici. * +* * +* Description : Fait en sorte que toutes les classes soient affichées. * +* * +* Retour : FALSE pour continuer le parcours. * +* * +* Remarques : - * +* * +******************************************************************************/ + +static gboolean show_all_classes_in_tree_view(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *treeview) +{ + gboolean expand; /* Besoin en intervention */ + GtkTreePath *tmp; /* Copie pour modification */ + + gtk_tree_model_get(model, iter, SBC_EXPAND, &expand, -1); + + if (expand) + { + tmp = gtk_tree_path_copy(path); + + if (gtk_tree_path_up(tmp)) + gtk_tree_view_expand_to_path(treeview, tmp); + + gtk_tree_path_free(tmp); + + } + + return FALSE; + +} + + +/****************************************************************************** +* * +* Paramètres : button = bouton concerné par l'action. * +* ref = espace de référencement des composants. * +* * +* Description : Réagit à une demande de nouvelle forme d'affichage. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void modify_types_in_symbols_tree_view(GtkToggleToolButton *button, GObject *ref) +{ + GSymbolsPanel *panel; /* Données du panneau */ + + panel = (GSymbolsPanel *)g_object_get_data(ref, "panel"); + + change_symbols_panel_current_binary(panel, panel->binary); + +} diff --git a/src/gui/panels/symbols.h b/src/gui/panels/symbols.h new file mode 100644 index 0000000..72801d8 --- /dev/null +++ b/src/gui/panels/symbols.h @@ -0,0 +1,65 @@ + +/* OpenIDA - Outil d'analyse de fichiers binaires + * symbols.h - prototypes pour le panneau d'affichage des symboles + * + * Copyright (C) 2008-2012 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 + */ + + +#ifndef _GUI_PANELS_SYMBOLS_H +#define _GUI_PANELS_SYMBOLS_H + + +#include + + +#include "panel.h" + + + +#define PANEL_SYMBOL_ID _("Symboles") + + +#define G_TYPE_SYMBOLS_PANEL g_symbols_panel_get_type() +#define G_SYMBOLS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_symbols_panel_get_type(), GSymbolsPanel)) +#define G_IS_SYMBOLS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_symbols_panel_get_type())) +#define G_SYMBOLS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SYMBOLS_PANEL, GSymbolsPanelClass)) +#define G_IS_SYMBOLS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SYMBOLS_PANEL)) +#define G_SYMBOLS_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SYMBOLS_PANEL, GSymbolsPanelClass)) + + +/* Panneau d'affichage des symboles (instance) */ +typedef struct _GSymbolsPanel GSymbolsPanel; + +/* Panneau d'affichage des symboles (classe) */ +typedef struct _GSymbolsPanelClass GSymbolsPanelClass; + + +/* Indique le type définit pour un panneau d'affichage des symboles. */ +GType g_symbols_panel_get_type(void); + +/* Crée un panneau d'affichage des symboles. */ +GEditorItem *g_symbols_panel_new(void); + +/* Construit et intègre un panneau d'affichage des symboles. */ +GPanelItem *create_symbols_panel(void); + + + +#endif /* _GUI_PANELS_SYMBOLS_H */ diff --git a/src/panels/Makefile.am b/src/panels/Makefile.am index 0db863a..4d24b93 100755 --- a/src/panels/Makefile.am +++ b/src/panels/Makefile.am @@ -4,12 +4,10 @@ noinst_LTLIBRARIES = libpanels.la libpanels_la_SOURCES = \ breaks.h breaks.c \ glimpse.h glimpse.c \ - log.h log.c \ panel-int.h \ panel.h panel.c \ registers.h registers.c \ - strings.h strings.c \ - symbols.h symbols.c + strings.h strings.c libpanels_la_LDFLAGS = diff --git a/src/panels/log.c b/src/panels/log.c deleted file mode 100644 index fdbda1d..0000000 --- a/src/panels/log.c +++ /dev/null @@ -1,244 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * log.c - panneau d'affichage des messages système - * - * Copyright (C) 2009-2011 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 "log.h" - - -#include -#include -#include - - -#include "panel.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; - - -#define _(str) str - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Construit le panneau d'affichage des messages système. * -* * -* Retour : Adresse du panneau mis en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GtkWidget *build_log_panel(void) -{ - GtkWidget *result; /* Panneau à retourner */ - GtkTreeStore *store; /* Modèle de gestion */ - GtkWidget *treeview; /* Affichage de la liste */ - GtkCellRenderer *renderer; /* Moteur de rendu de colonne */ - GtkTreeViewColumn *column; /* Colonne de la liste */ - - result = gtk_scrolled_window_new(NULL, NULL); - gtk_widget_show(result); - - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(result), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(result), GTK_SHADOW_IN); - - store = gtk_tree_store_new(LGC_COUNT, G_TYPE_STRING, G_TYPE_STRING); - g_object_set_data(G_OBJECT(result), "store", store); - - treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(store)); - g_object_set_data(G_OBJECT(result), "treeview", treeview); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); - gtk_widget_show(treeview); - gtk_container_add(GTK_CONTAINER(result), treeview); - - g_object_unref(G_OBJECT(store)); - - column = gtk_tree_view_column_new(); - gtk_tree_view_column_set_visible(column, FALSE); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); - - column = gtk_tree_view_column_new(); - - renderer = gtk_cell_renderer_pixbuf_new(); - gtk_tree_view_column_pack_start(column, renderer, FALSE); - gtk_tree_view_column_add_attribute(column, renderer, "stock-id", LGC_PICTURE); - - renderer = gtk_cell_renderer_text_new(); - gtk_tree_view_column_pack_start(column, renderer, TRUE); - gtk_tree_view_column_add_attribute(column, renderer, "text", LGC_STRING); - - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - - return result; - -} - - -/****************************************************************************** -* * -* Paramètres : type = espèce du message à ajouter. * -* msg = message à faire apparaître à l'écran. * -* * -* Description : Affiche un message dans le journal des messages système. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void log_simple_message(LogMessageType type, const char *msg) -{ - GtkWidget *panel; /* Panneau à traiter */ - GtkTreeStore *store; /* Modèle de gestion */ - GtkTreeIter iter; /* Point d'insertion */ - GtkTreeView *treeview; /* Affichage de la liste */ - GtkTreePath *path; /* Chemin d'accès à la ligne */ - - panel = get_panel(PNT_LOG); - store = g_object_get_data(G_OBJECT(panel), "store"); - - gtk_tree_store_append(store, &iter, NULL); - - switch (type) - { - case LMT_INFO: - gtk_tree_store_set(store, &iter, - LGC_PICTURE, "gtk-info", - LGC_STRING, msg, - -1); - break; - - case LMT_BAD_BINARY: - gtk_tree_store_set(store, &iter, - LGC_PICTURE, "gtk-dialog-warning", - LGC_STRING, msg, - -1); - break; - - case LMT_PROCESS: - gtk_tree_store_set(store, &iter, - LGC_PICTURE, "gtk-execute", - LGC_STRING, msg, - -1); - break; - - case LMT_ERROR: - gtk_tree_store_set(store, &iter, - LGC_PICTURE, "gtk-dialog-error", - LGC_STRING, msg, - -1); - break; - - case LMT_WARNING: - gtk_tree_store_set(store, &iter, - LGC_PICTURE, "gtk-dialog-warning", - LGC_STRING, msg, - -1); - break; - - default: - gtk_tree_store_set(store, &iter, - LGC_STRING, msg, - -1); - break; - - } - - treeview = GTK_TREE_VIEW(g_object_get_data(G_OBJECT(panel), "treeview")); - path = gtk_tree_model_get_path(GTK_TREE_MODEL(store), &iter); - - gtk_tree_view_scroll_to_cell(treeview, path, NULL, FALSE, 0.0, 0.0); - - gtk_tree_path_free(path); - -} - - -/****************************************************************************** -* * -* Paramètres : type = espèce du message à ajouter. * -* fmt = format du message à faire apparaître à l'écran. * -* ... = éventuels arguments venant compléter le message. * -* * -* Description : Affiche un message dans le journal des messages système. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void log_variadic_message(LogMessageType type, const char *fmt, ...) -{ - size_t len; /* Taille tampon disponible */ - char *buffer; /* Tampon du msg reconstitué */ - int ret; /* Bilan d'une impression */ - char *ptr; /* Nouvelle allocation */ - va_list ap; /* Liste d'arguments variable */ - - len = 100; - buffer = calloc(len, sizeof(char)); - - while (buffer != NULL) - { - va_start(ap, fmt); - ret = vsnprintf(buffer, len, fmt, ap); - va_end(ap); - - if (ret >= 0 && ret < len) break; - - else - { - if (ret > -1) len += 1; /* glibc 2.1 */ - else len *= 2; /* glibc 2.0 */ - - if ((ptr = realloc(buffer, len)) == NULL) - { - free(buffer); - buffer = NULL; - } - else buffer = ptr; - - } - - } - - log_simple_message(type, buffer); - - free(buffer); - -} diff --git a/src/panels/log.h b/src/panels/log.h deleted file mode 100644 index 1d46edd..0000000 --- a/src/panels/log.h +++ /dev/null @@ -1,58 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * log.h - prototypes pour le panneau d'affichage des messages système - * - * Copyright (C) 2009-2011 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 - */ - - -#ifndef _PANEL_LOG_H -#define _PANEL_LOG_H - - -#include - - - -/* Type de messages disponibles */ -typedef enum _LogMessageType -{ - LMT_INFO, /* Information sur l'exécution */ - LMT_BAD_BINARY, /* Binaire malformé */ - LMT_PROCESS, /* Début de tâche quelconque */ - LMT_ERROR, /* Erreur de traitement */ - LMT_WARNING, /* Avertissment à remonter */ - - LMT_COUNT - -} LogMessageType; - - -/* Construit le panneau d'affichage des messages système. */ -GtkWidget *build_log_panel(void); - -/* Affiche un message dans le journal des messages système. */ -void log_simple_message(LogMessageType, const char *); - -/* Affiche un message dans le journal des messages système. */ -void log_variadic_message(LogMessageType, const char *, ...); - - - -#endif /* _PANEL_LOG_H */ diff --git a/src/panels/panel.c b/src/panels/panel.c index 53fab8f..5922fe5 100644 --- a/src/panels/panel.c +++ b/src/panels/panel.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * panels.h - gestion des différents panneaux * - * Copyright (C) 2009-2010 Cyrille Bagard + * Copyright (C) 2009-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -28,7 +28,6 @@ #include "breaks.h" #include "glimpse.h" #include "panel-int.h" -#include "symbols.h" #include "../gtkext/gtkdockpanel.h" @@ -147,8 +146,8 @@ void init_internal_panels(void) panel = g_breaks_panel_new(); panels_list_add_tail(panel, &panels_list); - panel = g_symbols_panel_new(); - panels_list_add_tail(panel, &panels_list); + //panel = g_symbols_panel_new(); + //panels_list_add_tail(panel, &panels_list); panel = g_glimpse_panel_new(); panels_list_add_tail(panel, &panels_list); @@ -234,7 +233,6 @@ void notify_panels_of_view_change(GtkViewPanel *panel, bool same) -#include "log.h" #include "registers.h" #include "strings.h" @@ -258,7 +256,7 @@ static GtkWidget *panel_list[PNT_COUNT]; void init_panels(GObject *ref) { - panel_list[PNT_LOG] = build_log_panel(); + //panel_list[PNT_LOG] = build_log_panel(); panel_list[PNT_REGISTERS] = build_registers_panel(); panel_list[PNT_STRINGS] = build_strings_panel(ref); diff --git a/src/panels/symbols.c b/src/panels/symbols.c deleted file mode 100644 index d54e05e..0000000 --- a/src/panels/symbols.c +++ /dev/null @@ -1,718 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * symbols.c - panneau d'affichage des symboles - * - * Copyright (C) 2008-2010 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 "symbols.h" - - -#include - - -#include "panel-int.h" -#include "../format/format.h" -#include "../gtkext/easygtk.h" -#include "../gtkext/support.h" - - - -#define _(str) str - - - -/* -------------------------- PARTIE PRINCIPALE DU PANNEAU -------------------------- */ - - -/* Panneau d'aperçu de graphiques (instance) */ -struct _GSymbolsPanel -{ - GEditorPanel parent; /* A laisser en premier */ - - GtkTreeView *treeview; /* Composant d'affichage */ - GtkTreeStore *store; /* Modèle de gestion */ - - GtkViewPanel *view; /* Affichage à faire défiler */ - -}; - - -/* Panneau d'aperçu de graphiques (classe) */ -struct _GSymbolsPanelClass -{ - GEditorPanelClass parent; /* A laisser en premier */ - -}; - - -/* Colonnes de la liste des symboles */ -typedef enum _SymbolsColumn -{ - SBC_ADDRESS, /* Adresse mémoire du symbole */ - - SBC_ICON, /* Image de représentation */ - SBC_NAME, /* Désignation humaine */ - - SBC_EXPAND, /* Affichage des classes */ - - SBC_COUNT /* Nombre de colonnes */ - -} SymbolsColumn; - - -/* Initialise la classe des panneaux d'aperçu de graphiques. */ -static void g_symbols_panel_class_init(GSymbolsPanelClass *); - -/* Initialise une instance de panneau d'aperçu de graphiques. */ -static void g_symbols_panel_init(GSymbolsPanel *); - -/* Réagit au changement de sélection des symboles. */ -static void on_symbols_selection_change(GtkTreeSelection *, GSymbolsPanel *); - -/* Réagit à un changement d'affichage principal de contenu. */ -static void reload_symbols_for_new_view(GSymbolsPanel *, GtkViewPanel *, bool); - - - -/* ------------------------- AFFICHAGE A L'AIDE D'UNE LISTE ------------------------- */ - - -/* Réagit à un changement d'affichage principal de contenu. */ -static void reload_symbols_for_new_list_view(GSymbolsPanel *); - - - -/* -------------------------- AFFICHAGE SOUS FORME D'ARBRE -------------------------- */ - - -/* S'assure qu'un noeud donné existe bien. */ -static GtkTreeIter ensure_symbol_node_exist(GtkTreeStore *, GtkTreeIter *, const char *); - -/* Détermine le point d'insertion parent d'une routine. */ -static bool find_parent_for_routine(GtkTreeStore *, const GBinRoutine *, GtkTreeIter *); - -/* Réagit à un changement d'affichage principal de contenu. */ -static void reload_symbols_for_new_tree_view(GSymbolsPanel *); - -/* Réagit à une nouvelle demande de réorganisation. */ -static void reorganize_symbols_tree_view(GtkToolButton *, GObject *); - -/* Fait en sorte que toutes les classes soient affichées. */ -static gboolean show_all_classes_in_tree_view(GtkTreeModel *, GtkTreePath *, GtkTreeIter *, GtkTreeView *); - -/* Réagit à une demande de nouvelle forme d'affichage. */ -static void modify_types_in_symbols_tree_view(GtkToggleToolButton *, GObject *); - - - -/* ---------------------------------------------------------------------------------- */ -/* PARTIE PRINCIPALE DU PANNEAU */ -/* ---------------------------------------------------------------------------------- */ - - -/* Indique le type définit pour un panneau d'aperçu de graphiques. */ -G_DEFINE_TYPE(GSymbolsPanel, g_symbols_panel, G_TYPE_EDITOR_PANEL); - - -/****************************************************************************** -* * -* Paramètres : klass = classe à initialiser. * -* * -* Description : Initialise la classe des panneaux d'aperçu de graphiques. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_symbols_panel_class_init(GSymbolsPanelClass *klass) -{ - -} - - -/****************************************************************************** -* * -* Paramètres : panel = instance à initialiser. * -* * -* Description : Initialise une instance de panneau d'aperçu de graphiques. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void g_symbols_panel_init(GSymbolsPanel *panel) -{ - GEditorPanel *base; /* Version basique d'instance */ - GObject *ref; /* Espace de référencement */ - GtkTooltips *tooltips; /* Affichage des bulles d'aide */ - GtkWidget *toolbar; /* Barre d'outils */ - GtkWidget *button; /* Bouton de cette même barre */ - GtkWidget *separator; /* Barre de séparation vert. */ - GtkWidget *scrollwnd; /* Support défilant */ - GtkWidget *treeview; /* Affichage de la liste */ - GtkCellRenderer *renderer; /* Moteur de rendu de colonne */ - GtkTreeViewColumn *column; /* Colonne de la liste */ - GtkTreeSelection *select; /* Sélection dans la liste */ - - base = G_EDITOR_PANEL(panel); - - base->name = _("Symbols"); - base->reload_view = (reload_for_new_view_fc)reload_symbols_for_new_view; - - base->widget = gtk_vbox_new(FALSE, 0); - gtk_widget_show(base->widget); - - ref = G_OBJECT(base->widget); - g_object_set_data(ref, "panel", panel); - - /* Barre d'outils supérieure */ - - tooltips = gtk_tooltips_new(); - - toolbar = gtk_toolbar_new(); - gtk_widget_show(toolbar); - gtk_box_pack_start(GTK_BOX(base->widget), toolbar, FALSE, FALSE, 0); - - //group = gtk_tool_item_group_new(_("View")); - //gtk_widget_show(group); - //gtk_container_add(GTK_CONTAINER(toolbar), group); - - button = qck_create_toggle_tool_button(ref, "list", "tbutton_list_view.png", G_CALLBACK(NULL), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), button); - //gtk_tool_item_group_insert(GTK_TOOL_ITEM_GROUP(group), GTK_TOOL_ITEM(button), -1); - - button = qck_create_toggle_tool_button(ref, "tree", "tbutton_tree_view.png", G_CALLBACK(NULL), NULL); - gtk_container_add(GTK_CONTAINER(toolbar), button); - gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(button), TRUE); - - - //gtk_tool_item_group_insert(GTK_TOOL_ITEM_GROUP(group), GTK_TOOL_ITEM(button), -1); - - - - separator = qck_create_tool_separator(NULL, NULL); - gtk_container_add(GTK_CONTAINER(toolbar), separator); - - button = qck_create_tool_button(ref, "collapse", "tbutton_collapse.png", G_CALLBACK(reorganize_symbols_tree_view), ref); - gtk_container_add(GTK_CONTAINER(toolbar), button); - - button = qck_create_tool_button(ref, "expand", "tbutton_expand.png", G_CALLBACK(reorganize_symbols_tree_view), ref); - gtk_container_add(GTK_CONTAINER(toolbar), button); - - button = qck_create_tool_button(ref, "classes", "symbol_class_classic.png", G_CALLBACK(reorganize_symbols_tree_view), ref); - gtk_container_add(GTK_CONTAINER(toolbar), button); - - separator = qck_create_tool_separator(NULL, NULL); - gtk_container_add(GTK_CONTAINER(toolbar), separator); - - button = qck_create_toggle_tool_button(ref, "namespace", "tbutton_namespace.png", G_CALLBACK(modify_types_in_symbols_tree_view), ref); - gtk_container_add(GTK_CONTAINER(toolbar), button); - - /* Liste arborescente ou linéaire */ - - scrollwnd = gtk_scrolled_window_new(NULL, NULL); - gtk_widget_show(scrollwnd); - gtk_box_pack_start(GTK_BOX(base->widget), scrollwnd, TRUE, TRUE, 0); - - gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollwnd), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(scrollwnd), GTK_SHADOW_IN); - - panel->store = gtk_tree_store_new(SBC_COUNT, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN); - - treeview = gtk_tree_view_new_with_model(GTK_TREE_MODEL(panel->store)); - gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(treeview), FALSE); - gtk_tree_view_set_enable_tree_lines(GTK_TREE_VIEW(treeview), TRUE); - gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(treeview), TRUE); - - panel->treeview = GTK_TREE_VIEW(treeview); - - gtk_widget_show(treeview); - gtk_container_add(GTK_CONTAINER(scrollwnd), treeview); - - g_object_unref(G_OBJECT(panel->store)); - - /* - column = gtk_tree_view_column_new(); - gtk_tree_view_column_set_visible(column, FALSE); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); - */ - - renderer = gtk_cell_renderer_text_new(); - column = gtk_tree_view_column_new_with_attributes("Address", renderer, "text", SBC_ADDRESS, NULL); - //gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - //gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); - - column = gtk_tree_view_column_new(); - gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); - - renderer = gtk_cell_renderer_pixbuf_new(); - //column = gtk_tree_view_column_new_with_attributes("Icon", renderer, "pixbuf", SBC_ICON, NULL); - gtk_tree_view_column_pack_start(column, renderer, FALSE); - gtk_tree_view_column_add_attribute(column, renderer, "pixbuf", SBC_ICON); - - renderer = gtk_cell_renderer_text_new(); - //column = gtk_tree_view_column_new_with_attributes("Name", renderer, "text", SBC_NAME, NULL); - gtk_tree_view_column_pack_end(column, renderer, TRUE); - gtk_tree_view_column_add_attribute(column, renderer, "text", SBC_NAME); - //gtk_tree_view_append_column(GTK_TREE_VIEW(treeview), column); - //gtk_tree_view_set_expander_column(GTK_TREE_VIEW(treeview), column); - - select = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview)); - gtk_tree_selection_set_mode(select, GTK_SELECTION_SINGLE); - g_signal_connect(G_OBJECT(select), "changed", G_CALLBACK(on_symbols_selection_change), panel); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Crée un panneau d'aperçu de graphiques. * -* * -* Retour : Adresse de la structure mise en place. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GEditorPanel *g_symbols_panel_new(void) -{ - GEditorPanel *result; /* Structure à retourner */ - - result = g_object_new(G_TYPE_SYMBOLS_PANEL, NULL); - - return G_EDITOR_PANEL(result); - -} - - -/****************************************************************************** -* * -* Paramètres : selection = sélection modifiée. * -* panel = structure contenant les informations maîtresses. * -* * -* Description : Réagit au changement de sélection des symboles. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void on_symbols_selection_change(GtkTreeSelection *selection, GSymbolsPanel *panel) -{ - GtkTreeIter iter; /* Point de sélection */ - GtkTreeModel *model; /* Modèle de gestion */ - gchar *string; /* Chaîne sélectionnée */ - vmpa_t address; /* Adresse à rejoindre */ - return; - if (gtk_tree_selection_get_selected(selection, &model, &iter)) - { - gtk_tree_model_get(model, &iter, SBC_ADDRESS, &string, -1); - address = strtoll(string, NULL, 16); /* FIXME */ - g_free(string); - - /* FIXME */ - //gtk_bin_view_scroll_to_address(panel->binview, address); - - } - -} - - -/****************************************************************************** -* * -* Paramètres : panel = panneau à mettre à jour. * -* view = nouvelle visualisation de désassemblage. * -* same = changement de binaire ou de vue ? * -* * -* Description : Réagit à un changement d'affichage principal de contenu. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void reload_symbols_for_new_view(GSymbolsPanel *panel, GtkViewPanel *view, bool same) -{ - GtkToggleToolButton *button; /* Mode de représentation */ - - if (panel->view != NULL) - g_object_unref(G_OBJECT(panel->view)); - - panel->view = view; - g_object_ref(G_OBJECT(view)); - - if (same) return; - - gtk_tree_store_clear(panel->store); - - button = g_object_get_data(G_OBJECT(G_EDITOR_PANEL(panel)->widget), "list"); - - if (gtk_toggle_tool_button_get_active(button)) - reload_symbols_for_new_list_view(panel); - else - reload_symbols_for_new_tree_view(panel); - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* AFFICHAGE A L'AIDE D'UNE LISTE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : panel = panneau à mettre à jour. * -* * -* Description : Réagit à un changement d'affichage principal de contenu. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void reload_symbols_for_new_list_view(GSymbolsPanel *panel) -{ - GOpenidaBinary *binary; /* Binaire en cours d'édition */ - GExeFormat *format; /* Format associé au binaire */ - GBinRoutine **routines; /* Liste des routines trouvées */ - size_t routines_count; /* Nombre de ces routines */ - GArchProcessor *proc; /* Architecture utilisée */ - size_t i; /* Boucle de parcours */ - vmpa_t address; /* Adresse associée au symbole */ - char tmp[VMPA_MAX_SIZE]; /* Version humainement lisible */ - GtkTreeIter iter; /* Point d'insertion */ - - binary = gtk_view_panel_get_binary(panel->view); - format = g_openida_binary_get_format(binary); - - routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); - qsort(routines, routines_count, sizeof(GBinRoutine *), g_binary_routine_rcompare); - - if (routines != NULL) - { - proc = get_arch_processor_from_format(format); - - for (i = 0; i < routines_count; i++) - { - address = g_binary_routine_get_address(routines[i]); - vmpa_to_string(address, g_arch_processor_get_memory_size(proc), tmp); - - gtk_tree_store_append(panel->store, &iter, NULL); - gtk_tree_store_set(panel->store, &iter, - SBC_ADDRESS, tmp, - SBC_NAME, g_binary_routine_to_string(routines[i]), - -1); - - } - - } - -} - - - -/* ---------------------------------------------------------------------------------- */ -/* AFFICHAGE SOUS FORME D'ARBRE */ -/* ---------------------------------------------------------------------------------- */ - - -/****************************************************************************** -* * -* Paramètres : store = gestion des différents éléments insérés. * -* parent = point d'insertion parent à retrouver. [OUT] * -* name = nom du noeud ciblé. * -* * -* Description : S'assure qu'un noeud donné existe bien. * -* * -* Retour : Point d'insertion prochain. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static GtkTreeIter ensure_symbol_node_exist(GtkTreeStore *store, GtkTreeIter *parent, const char *name) -{ - bool found; /* Bilan des recherches */ - GtkTreeIter iter; /* Boucle de parcours */ - gchar *string; /* Chaîne sélectionnée */ - GdkPixbuf *pixbuf; /* Icone pour l'élément inséré */ - - found = false; - - if (gtk_tree_model_iter_children(GTK_TREE_MODEL(store), &iter, parent)) - do - { - gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, SBC_NAME, &string, -1); - found = (strcmp(string, name) == 0); - g_free(string); - - if (found) break; - - } - while (gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)); - - if (!found) - { - pixbuf = get_pixbuf_from_file("symbol_package.png"); - - gtk_tree_store_append(store, &iter, parent); - gtk_tree_store_set(store, &iter, - SBC_ICON, pixbuf, - SBC_NAME, name, - -1); - - } - - return iter; - -} - - -/****************************************************************************** -* * -* Paramètres : store = gestion des différents éléments insérés. * -* routine = routine à intégrer. * -* parent = point d'insertion parent à constituer. * -* * -* Description : Détermine le point d'insertion parent d'une routine. * -* * -* Retour : true si le point n'est pas la racine, false sinon. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static bool find_parent_for_routine(GtkTreeStore *store, const GBinRoutine *routine, GtkTreeIter *parent) -{ - GOpenidaType *namespace; /* Espace d'appartenance */ - char *string; /* Conversion en chaîne */ - char *iter; /* Boucle de parcours */ - char *token; /* Partie de texte isolée */ - char *saveptr; /* Ctx. interne de découpage */ - - namespace = g_binary_routine_get_namespace(routine); - if (namespace == NULL) return false; - - string = g_openida_type_to_string(namespace); - - for (iter = string; ; iter = NULL) - { - token = strtok_r(iter, "::", &saveptr); - if (token == NULL) break; - - *parent = ensure_symbol_node_exist(store, (iter == string ? NULL : parent), token); - - } - - return true; - -} - - -/****************************************************************************** -* * -* Paramètres : panel = panneau à mettre à jour. * -* * -* Description : Réagit à un changement d'affichage principal de contenu. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void reload_symbols_for_new_tree_view(GSymbolsPanel *panel) -{ - GOpenidaBinary *binary; /* Binaire en cours d'édition */ - GExeFormat *format; /* Format associé au binaire */ - GBinRoutine **routines; /* Liste des routines trouvées */ - size_t routines_count; /* Nombre de ces routines */ - GArchProcessor *proc; /* Architecture utilisée */ - Routine2StringOptions options; /* Options de rendu */ - GtkToggleToolButton *button; /* Mode de représentation */ - size_t i; /* Boucle de parcours */ - vmpa_t address; /* Adresse associée au symbole */ - char tmp[VMPA_MAX_SIZE]; /* Version humainement lisible */ - GtkTreeIter parent; /* Point d'insertion parent */ - GtkTreeIter iter; /* Point d'insertion */ - GdkPixbuf *pixbuf; /* Icone pour l'élément inséré */ - - binary = gtk_view_panel_get_binary(panel->view); - format = g_openida_binary_get_format(binary); - - routines = g_binary_format_get_routines(G_BIN_FORMAT(format), &routines_count); - qsort(routines, routines_count, sizeof(GBinRoutine *), g_binary_routine_rcompare); - - if (routines != NULL) - { - proc = get_arch_processor_from_format(format); - - options = 0; - - button = g_object_get_data(G_OBJECT(G_EDITOR_PANEL(panel)->widget), "namespace"); - - if (gtk_toggle_tool_button_get_active(button)) - options |= RSO_LONG_TYPE; - - for (i = 0; i < routines_count; i++) - { - address = g_binary_routine_get_address(routines[i]); - vmpa_to_string(address, g_arch_processor_get_memory_size(proc), tmp); - - if (find_parent_for_routine(panel->store, routines[i], &parent)) - { - pixbuf = get_pixbuf_from_file("symbol_class_classic.png"); - - gtk_tree_store_set(panel->store, &parent, - SBC_ICON, pixbuf, - SBC_EXPAND, TRUE, - -1); - - gtk_tree_store_append(panel->store, &iter, &parent); - - } - else - gtk_tree_store_append(panel->store, &iter, NULL); - - pixbuf = get_pixbuf_from_file("symbol_routine_classic.png"); - - gtk_tree_store_set(panel->store, &iter, - SBC_ICON, pixbuf, - SBC_NAME, _g_binary_routine_to_string(routines[i], options), - -1); - - if (pixbuf != NULL) - g_object_unref(G_OBJECT(pixbuf)); - - - } - - } - -} - - -/****************************************************************************** -* * -* Paramètres : button = bouton concerné par l'action. * -* ref = espace de référencement des composants. * -* * -* Description : Réagit à une nouvelle demande de réorganisation. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void reorganize_symbols_tree_view(GtkToolButton *button, GObject *ref) -{ - GSymbolsPanel *panel; /* Données du panneau */ - - panel = (GSymbolsPanel *)g_object_get_data(ref, "panel"); - - if (g_object_get_data(ref, "collapse") == button) - gtk_tree_view_collapse_all(panel->treeview); - - else if (g_object_get_data(ref, "expand") == button) - gtk_tree_view_expand_all(panel->treeview); - - else - gtk_tree_model_foreach(GTK_TREE_MODEL(panel->store), - (GtkTreeModelForeachFunc)show_all_classes_in_tree_view, - panel->treeview); - -} - - -/****************************************************************************** -* * -* Paramètres : model = modèle de gestion des éléments. * -* path = chemin d'accès à l'élément courant. * -* iter = itérateur courant. * -* treeview = arborescence à manipuler ici. * -* * -* Description : Fait en sorte que toutes les classes soient affichées. * -* * -* Retour : FALSE pour continuer le parcours. * -* * -* Remarques : - * -* * -******************************************************************************/ - -static gboolean show_all_classes_in_tree_view(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *treeview) -{ - gboolean expand; /* Besoin en intervention */ - GtkTreePath *tmp; /* Copie pour modification */ - - gtk_tree_model_get(model, iter, SBC_EXPAND, &expand, -1); - - if (expand) - { - tmp = gtk_tree_path_copy(path); - - if (gtk_tree_path_up(tmp)) - gtk_tree_view_expand_to_path(treeview, tmp); - - gtk_tree_path_free(tmp); - - } - - return FALSE; - -} - - -/****************************************************************************** -* * -* Paramètres : button = bouton concerné par l'action. * -* ref = espace de référencement des composants. * -* * -* Description : Réagit à une demande de nouvelle forme d'affichage. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -static void modify_types_in_symbols_tree_view(GtkToggleToolButton *button, GObject *ref) -{ - GSymbolsPanel *panel; /* Données du panneau */ - - panel = (GSymbolsPanel *)g_object_get_data(ref, "panel"); - - reload_symbols_for_new_view(panel, panel->view, false); - -} diff --git a/src/panels/symbols.h b/src/panels/symbols.h deleted file mode 100644 index d9f8b38..0000000 --- a/src/panels/symbols.h +++ /dev/null @@ -1,59 +0,0 @@ - -/* OpenIDA - Outil d'analyse de fichiers binaires - * pan_symbols.h - prototypes pour le panneau d'affichage des symboles - * - * Copyright (C) 2008-2010 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 - */ - - -#ifndef _PAN_SYMBOLS_H -#define _PAN_SYMBOLS_H - - -#include - - -#include "panel.h" - - - -#define G_TYPE_SYMBOLS_PANEL g_symbols_panel_get_type() -#define G_SYMBOLS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_symbols_panel_get_type(), GSymbolsPanel)) -#define G_IS_SYMBOLS_PANEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_symbols_panel_get_type())) -#define G_SYMBOLS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_SYMBOLS_PANEL, GSymbolsPanelClass)) -#define G_IS_SYMBOLS_PANEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_SYMBOLS_PANEL)) -#define G_SYMBOLS_PANEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_SYMBOLS_PANEL, GSymbolsPanelClass)) - - -/* Panneau d'affichage des symboles (instance) */ -typedef struct _GSymbolsPanel GSymbolsPanel; - -/* Panneau d'affichage des symboles (classe) */ -typedef struct _GSymbolsPanelClass GSymbolsPanelClass; - - -/* Indique le type définit pour un panneau d'affichage des symboles. */ -GType g_symbols_panel_get_type(void); - -/* Crée un panneau d'affichage des symboles. */ -GEditorPanel *g_symbols_panel_new(void); - - - -#endif /* _PAN_SYMBOLS_H */ diff --git a/src/project.c b/src/project.c index 85368c6..652721b 100644 --- a/src/project.c +++ b/src/project.c @@ -2,7 +2,7 @@ /* OpenIDA - Outil d'analyse de fichiers binaires * project.c - gestion d'un groupe de fichiers binaires * - * Copyright (C) 2008-2011 Cyrille Bagard + * Copyright (C) 2008-2012 Cyrille Bagard * * This file is part of OpenIDA. * @@ -36,6 +36,7 @@ #include "gtkext/gtkgraphview.h" #include "gtkext/gtksourceview.h" #include "gtkext/gtkviewpanel.h" +#include "gui/panels/panel.h" #include "panels/panel.h" @@ -500,9 +501,9 @@ void detach_binary_to_openida_project(openida_project *project, GOpenidaBinary * size_t i; /* Boucle de parcours */ dpanel = GTK_DOCK_PANEL(g_object_get_data(project->ref, "binpanel")); - ditem = gtk_dock_panel_get_item_from_binary(project, binary); + //ditem = gtk_dock_panel_get_item_from_binary(project, binary); FIXME !! - gtk_dock_panel_remove_item(dpanel, ditem); + //gtk_dock_panel_remove_item(dpanel, ditem); for (i = 0; i < project->binaries_count; i++) if (project->binaries[i]->binary == binary) break; @@ -840,7 +841,7 @@ void display_new_binary_of_openida_project(GOpenidaBinary *binary, openida_proje GtkDockPanel *dpanel; /* Support de panneaux */ GtkWidget *view; /* Affichage du code binaire */ char *title; /* Titre associé au binaire */ - GDockItem *ditem; /* Panneau avec ses infos. */ + GEditorItem *item; /* Panneau avec ses infos. */ index = attach_binary_to_openida_project(project, binary); @@ -852,9 +853,8 @@ void display_new_binary_of_openida_project(GOpenidaBinary *binary, openida_proje gdk_threads_enter(); - ditem = g_dock_item_new(strrchr(title, '/') + 1, view); - g_dock_item_set_desc(ditem, title); - gtk_dock_panel_add_item(dpanel, ditem); + item = g_panel_item_new(strrchr(title, G_DIR_SEPARATOR) + 1, title, view, "M"); + g_panel_item_dock(G_PANEL_ITEM(item)); gdk_flush (); gdk_threads_leave(); -- cgit v0.11.2-87-g4458