diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2009-06-13 14:05:50 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2009-06-13 14:05:50 (GMT) |
commit | ecb9ecc486049fe3bec6ecaeeb27f08f67bf0ef0 (patch) | |
tree | c4d84575960583ad61981adef6ed8f958ef9d817 /src/project.c | |
parent | fc8324b66dee0abf0a5e5e3cc570e1aed96b80c8 (diff) |
Made the GUI offer to change the view of the current analyzed binary.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@73 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/project.c')
-rw-r--r-- | src/project.c | 156 |
1 files changed, 147 insertions, 9 deletions
diff --git a/src/project.c b/src/project.c index 20ec7c3..dc1efd1 100644 --- a/src/project.c +++ b/src/project.c @@ -33,6 +33,28 @@ #include "xdg.h" #include "xml.h" #include "gtkext/easygtk.h" +#include "gtkext/gtkblockview.h" +#include "gtkext/gtkgraphview.h" + + + + +/* Conservation d'un binaire chargé */ +typedef struct _loaded_binary +{ + openida_binary *binary; /* Binaire en question */ + + GtkWidget *views[BVW_COUNT]; /* Composants pour l'affichage */ + +} loaded_binary; + + +/* Met en place un nouveau binaire pour un projet. */ +loaded_binary *load_openida_binary(openida_binary *); + +/* Fournit un support d'affichage donné pour un binaire chargé. */ +GtkWidget *get_loaded_binary_view(const loaded_binary *, BinaryView); + @@ -42,7 +64,7 @@ struct openida_project { char *filename; /* Lieu d'enregistrement */ - openida_binary **binaries; /* Fichiers binaires associés */ + loaded_binary **binaries; /* Fichiers binaires associés */ size_t binaries_count; /* Nombre de ces fichiers */ @@ -55,6 +77,93 @@ struct openida_project +/****************************************************************************** +* * +* Paramètres : binary = binaire chargé à encadrer. * +* * +* Description : Met en place un nouveau binaire pour un projet. * +* * +* Retour : Adresse de la structure intermédiaire ou NULL si aucune (!). * +* * +* Remarques : - * +* * +******************************************************************************/ + +loaded_binary *load_openida_binary(openida_binary *binary) +{ + loaded_binary *result; /* Structure à renvoyer */ + BinaryView i; /* Boucle de parcours */ + GtkWidget *scrolledwindow; /* Surface d'exposition */ + GtkWidget *view; /* Affichage du binaire */ + + result = (loaded_binary *)calloc(1, sizeof(loaded_binary)); + + result->binary = binary; + + for (i = 0; i < BVW_COUNT; i++) + { + scrolledwindow = qck_create_scrolled_window(NULL, NULL); + + switch (i) + { + default: /* GCC ! */ + case BVW_BLOCK: + view = gtk_block_view_new(); + break; + case BVW_GRAPH: + view = gtk_graph_view_new(); + break; + } + + if (i == 0) + gtk_block_view_set_rendering_lines(GTK_BLOCK_VIEW(view), get_openida_binary_lines(binary)); + + gtk_widget_show(view); + + gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scrolledwindow), view); + + result->views[i] = scrolledwindow; + + } + + return result; + +} + + + + + + + + +/****************************************************************************** +* * +* Paramètres : binary = binaire chargé et encadré. * +* view = type d'affichage requis. * +* * +* Description : Fournit un support d'affichage donné pour un binaire chargé. * +* * +* Retour : Composant GTK dédié à un affichage particulier. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *get_loaded_binary_view(const loaded_binary *binary, BinaryView view) +{ + return binary->views[view]; + +} + + + + + + + + + /****************************************************************************** * * @@ -277,15 +386,10 @@ bool write_openida_project_to_xml(openida_project *project, const char *filename void attach_binary_to_openida_project(openida_project *project, openida_binary *binary) { - project->binaries = (openida_binary **)realloc(project->binaries, - ++project->binaries_count * sizeof(openida_binary *)); - - - - - - project->binaries[project->binaries_count - 1] = binary; + project->binaries = (loaded_binary **)realloc(project->binaries, + ++project->binaries_count * sizeof(loaded_binary *)); + project->binaries[project->binaries_count - 1] = load_openida_binary(binary); } @@ -305,6 +409,7 @@ void attach_binary_to_openida_project(openida_project *project, openida_binary * void detach_binary_to_openida_project(openida_project *project, openida_binary *binary) { +#if 0 size_t i; /* Boucle de parcours */ for (i = 0; i < project->binaries_count; i++) @@ -315,6 +420,39 @@ void detach_binary_to_openida_project(openida_project *project, openida_binary * project->binaries = (openida_binary **)realloc(project->binaries, --project->binaries_count * sizeof(openida_binary *)); +#endif +} + + +/****************************************************************************** +* * +* Paramètres : project = projet à consulter. * +* binary = binaire chargé, encadré et concerné. * +* view = type d'affichage requis. * +* * +* Description : Fournit un support d'affichage donné pour un binaire chargé. * +* * +* Retour : Composant GTK dédié à un affichage particulier. * +* * +* Remarques : - * +* * +******************************************************************************/ + +GtkWidget *get_view_for_openida_project_binary(const openida_project *project, const openida_binary *binary, BinaryView view) +{ + GtkWidget *result; /* Composant GTK à retourner */ + size_t i; /* Boucle de parcours */ + + result = NULL; + + for (i = 0; i < project->binaries_count; i++) + if (project->binaries[i]->binary == binary) + { + result = get_loaded_binary_view(project->binaries[i], view); + break; + } + + return result; } |