From f6e56cebfa878dd32a2405fd0c916a40140a1ff0 Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 16 Jul 2018 22:11:21 +0200 Subject: Applied a new GUI update with the new loaded panels features. --- plugins/pychrysalide/gui/editem.c | 84 +++++------ plugins/ropgadgets/select.c | 6 +- src/analysis/db/items/move.c | 3 +- src/analysis/loaded.c | 6 + src/analysis/loaded.h | 5 + src/glibext/gbinarycursor.c | 60 +++++++- src/glibext/gbinarycursor.h | 4 +- src/glibext/glinecursor-int.h | 7 +- src/glibext/glinecursor.c | 23 ++- src/glibext/glinecursor.h | 11 +- src/glibext/gloadedpanel-int.h | 7 + src/glibext/gloadedpanel.c | 34 +++++ src/glibext/gloadedpanel.h | 14 ++ src/gtkext/gtkbufferdisplay.c | 5 +- src/gtkext/gtkdisplaypanel-int.h | 4 - src/gtkext/gtkdisplaypanel.c | 213 ++++++++++++---------------- src/gtkext/gtkdisplaypanel.h | 22 +-- src/gtkext/gtkgraphdisplay.c | 2 +- src/gui/core/global.c | 103 +++----------- src/gui/core/global.h | 22 ++- src/gui/core/items.c | 158 ++++++--------------- src/gui/core/items.h | 10 +- src/gui/editem-int.h | 28 ++-- src/gui/editem.c | 116 ++++++++++++++- src/gui/editem.h | 29 ++-- src/gui/editor.c | 25 ++-- src/gui/menus/binary.c | 32 ++--- src/gui/menus/binary.h | 6 +- src/gui/menus/edition.c | 289 +++++++++++++++++++++++++------------- src/gui/menus/edition.h | 7 +- src/gui/menus/menubar.c | 69 ++++----- src/gui/menus/view.c | 14 +- src/gui/menus/view.h | 6 +- src/gui/panels/bintree.c | 18 ++- src/gui/panels/bookmarks.c | 35 ++++- src/gui/panels/errors.c | 18 ++- src/gui/panels/glance.c | 50 ++++--- src/gui/panels/history.c | 19 ++- src/gui/panels/panel-int.h | 1 + src/gui/panels/strings.c | 25 ++-- src/gui/panels/symbols.c | 38 +++-- src/gui/status.c | 52 +++---- src/gui/tb/portions.c | 33 +++-- 43 files changed, 975 insertions(+), 738 deletions(-) diff --git a/plugins/pychrysalide/gui/editem.c b/plugins/pychrysalide/gui/editem.c index 91f5246..8fd2c17 100644 --- a/plugins/pychrysalide/gui/editem.c +++ b/plugins/pychrysalide/gui/editem.c @@ -40,22 +40,22 @@ /* Réagit à un changement du binaire courant. */ -static void _update_editor_item_for_binary_python_wrapper(GEditorItem *, GLoadedBinary *); +static void _change_editor_item_content_python_wrapper(GEditorItem *, GLoadedContent *, GLoadedContent *); /* Réagit à un changement de vue. */ -static void _update_editor_item_for_view_python_wrapper(GEditorItem *, GtkDisplayPanel *); +static void _change_editor_item_view_python_wrapper(GEditorItem *, GLoadedPanel *, GLoadedPanel *); /* Réagit à un changement de contenu. */ -static void _update_editor_item_for_view_content_python_wrapper(GEditorItem *, GtkDisplayPanel *); +static void _update_editor_item_view_python_wrapper(GEditorItem *, GLoadedPanel *); -/* Réagit à un changement du binaire courant. */ -static PyObject *py_editor_item_update_for_binary(PyObject *, PyObject *); +/* Réagit à un changement de contenu chargé en cours d'analyse. */ +static PyObject *py_editor_item_change_content(PyObject *, PyObject *); -/* Réagit à un changement d'affichage principal de contenu. */ -static PyObject *py_editor_item_update_for_view(PyObject *, PyObject *); +/* Réagit à un changement de vue du contenu en cours d'analyse. */ +static PyObject *py_editor_item_change_view(PyObject *, PyObject *); -/* Réagit à un changement d'affichage principal de contenu. */ -static PyObject *py_editor_item_update_for_content(PyObject *, PyObject *); +/* Réagit à une modification de la vue du contenu analysé. */ +static PyObject *py_editor_item_update_view(PyObject *, PyObject *); /* Procède à l'enregistrement d'un élément reactif de l'éditeur. */ static PyObject *py_editor_item_register(PyObject *, PyObject *); @@ -64,8 +64,9 @@ static PyObject *py_editor_item_register(PyObject *, PyObject *); /****************************************************************************** * * -* Paramètres : item = élément à actualiser. * -* binary = nouvelle instance de binaire analysé. * +* Paramètres : item = élément à actualiser. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * * Description : Réagit à un changement du binaire courant. * * * @@ -75,7 +76,7 @@ static PyObject *py_editor_item_register(PyObject *, PyObject *); * * ******************************************************************************/ -static void _update_editor_item_for_binary_python_wrapper(GEditorItem *item, GLoadedBinary *binary) +static void _change_editor_item_content_python_wrapper(GEditorItem *item, GLoadedContent *old, GLoadedContent *new) { PyObject *target; /* Version Python de l'élément */ PyObject *args; /* Arguments pour l'appel */ @@ -92,10 +93,11 @@ static void _update_editor_item_for_binary_python_wrapper(GEditorItem *item, GLo */ target = pygobject_new(G_OBJECT(item)); - args = PyTuple_New(1); - PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(binary))); + args = PyTuple_New(2); + PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(old))); + PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(new))); - value = run_python_method(target, "update_for_binary", args); + value = run_python_method(target, "change_content", args); Py_XDECREF(value); Py_DECREF(args); @@ -106,8 +108,9 @@ static void _update_editor_item_for_binary_python_wrapper(GEditorItem *item, GLo /****************************************************************************** * * -* Paramètres : item = élément à actualiser. * -* panel = nouveau panneau d'affichage actif. * +* Paramètres : item = élément à actualiser. * +* old = ancienne vue du contenu chargé analysé. * +* new = nouvelle vue du contenu chargé analysé. * * * * Description : Réagit à un changement de vue. * * * @@ -117,7 +120,7 @@ static void _update_editor_item_for_binary_python_wrapper(GEditorItem *item, GLo * * ******************************************************************************/ -static void _update_editor_item_for_view_python_wrapper(GEditorItem *item, GtkDisplayPanel *panel) +static void _change_editor_item_view_python_wrapper(GEditorItem *item, GLoadedPanel *old, GLoadedPanel *new) { PyObject *target; /* Version Python de l'élément */ PyObject *args; /* Arguments pour l'appel */ @@ -134,10 +137,11 @@ static void _update_editor_item_for_view_python_wrapper(GEditorItem *item, GtkDi */ target = pygobject_new(G_OBJECT(item)); - args = PyTuple_New(1); - PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(panel))); + args = PyTuple_New(2); + PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(old))); + PyTuple_SetItem(args, 1, pygobject_new(G_OBJECT(new))); - value = run_python_method(target, "update_for_view", args); + value = run_python_method(target, "change_view", args); Py_XDECREF(value); Py_DECREF(args); @@ -149,7 +153,7 @@ static void _update_editor_item_for_view_python_wrapper(GEditorItem *item, GtkDi /****************************************************************************** * * * Paramètres : item = élément à actualiser. * -* panel = nouveau panneau d'affichage actif. * +* panel = vue du contenu chargé analysé modifiée. * * * * Description : Réagit à un changement de contenu. * * * @@ -159,7 +163,7 @@ static void _update_editor_item_for_view_python_wrapper(GEditorItem *item, GtkDi * * ******************************************************************************/ -static void _update_editor_item_for_view_content_python_wrapper(GEditorItem *item, GtkDisplayPanel *panel) +static void _update_editor_item_view_python_wrapper(GEditorItem *item, GLoadedPanel *panel) { PyObject *target; /* Version Python de l'élément */ PyObject *args; /* Arguments pour l'appel */ @@ -179,7 +183,7 @@ static void _update_editor_item_for_view_content_python_wrapper(GEditorItem *ite args = PyTuple_New(1); PyTuple_SetItem(args, 0, pygobject_new(G_OBJECT(panel))); - value = run_python_method(target, "update_for_content", args); + value = run_python_method(target, "update_view", args); Py_XDECREF(value); Py_DECREF(args); @@ -193,7 +197,7 @@ static void _update_editor_item_for_view_content_python_wrapper(GEditorItem *ite * Paramètres : self = classe représentant un binaire. * * args = arguments fournis à l'appel. * * * -* Description : Réagit à un changement du binaire courant. * +* Description : Réagit à un changement de contenu chargé en cours d'analyse. * * * * Retour : - * * * @@ -201,7 +205,7 @@ static void _update_editor_item_for_view_content_python_wrapper(GEditorItem *ite * * ******************************************************************************/ -static PyObject *py_editor_item_update_for_binary(PyObject *self, PyObject *args) +static PyObject *py_editor_item_change_content(PyObject *self, PyObject *args) { Py_RETURN_NONE; @@ -213,7 +217,7 @@ static PyObject *py_editor_item_update_for_binary(PyObject *self, PyObject *args * Paramètres : self = classe représentant un binaire. * * args = arguments fournis à l'appel. * * * -* Description : Réagit à un changement d'affichage principal de contenu. * +* Description : Réagit à un changement de vue du contenu en cours d'analyse. * * * * Retour : - * * * @@ -221,7 +225,7 @@ static PyObject *py_editor_item_update_for_binary(PyObject *self, PyObject *args * * ******************************************************************************/ -static PyObject *py_editor_item_update_for_view(PyObject *self, PyObject *args) +static PyObject *py_editor_item_change_view(PyObject *self, PyObject *args) { Py_RETURN_NONE; @@ -233,7 +237,7 @@ static PyObject *py_editor_item_update_for_view(PyObject *self, PyObject *args) * Paramètres : self = classe représentant un binaire. * * args = arguments fournis à l'appel. * * * -* Description : Réagit à un changement d'affichage principal de contenu. * +* Description : Réagit à une modification de la vue du contenu analysé. * * * * Retour : - * * * @@ -241,7 +245,7 @@ static PyObject *py_editor_item_update_for_view(PyObject *self, PyObject *args) * * ******************************************************************************/ -static PyObject *py_editor_item_update_for_content(PyObject *self, PyObject *args) +static PyObject *py_editor_item_update_view(PyObject *self, PyObject *args) { Py_RETURN_NONE; @@ -263,16 +267,16 @@ static PyObject *py_editor_item_update_for_content(PyObject *self, PyObject *arg static PyObject *py_editor_item_register(PyObject *self, PyObject *args) { - GEditorItem *item; /* Version GLib de l'élément */ + //GEditorItem *item; /* Version GLib de l'élément */ - item = G_EDITOR_ITEM(pygobject_get(self)); + //item = G_EDITOR_ITEM(pygobject_get(self)); - //item->update_binary = _update_editor_item_for_binary_python_wrapper; - //item->update_view = _update_editor_item_for_view_python_wrapper; - //item->update_content = _update_editor_item_for_view_content_python_wrapper; + //item->update_binary = _change_editor_item_content_python_wrapper; + //item->update_view = _change_editor_item_view_python_wrapper; + //item->update_content = _update_editor_item_view_python_wrapper; Py_INCREF(self); - register_editor_item(item); + //register_editor_item(item); Py_RETURN_NONE; @@ -295,17 +299,17 @@ PyTypeObject *get_python_editor_item_type(void) { static PyMethodDef py_editor_item_methods[] = { { - "update_for_binary", (PyCFunction)py_editor_item_update_for_binary, + "change_content", (PyCFunction)py_editor_item_change_content, METH_VARARGS, - "Called by Chrysalide on each binary change, if the item is registered." + "Called by Chrysalide on each content change, if the item is registered." }, { - "update_for_view", (PyCFunction)py_editor_item_update_for_view, + "change_view", (PyCFunction)py_editor_item_change_view, METH_VARARGS, "Called by Chrysalide on each view change, if the item is registered." }, { - "update_for_content", (PyCFunction)py_editor_item_update_for_content, + "update_view", (PyCFunction)py_editor_item_update_view, METH_VARARGS, "Called by Chrysalide on each view content change, if the item is registered." }, diff --git a/plugins/ropgadgets/select.c b/plugins/ropgadgets/select.c index 9f1b69e..e8ee8c3 100644 --- a/plugins/ropgadgets/select.c +++ b/plugins/ropgadgets/select.c @@ -503,7 +503,7 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref) { GtkWidget *result; /* Composant à retourner */ GStudyProject *project; /* Projet courant */ - GLoadedBinary *current; /* Binaire actif courant */ + GLoadedContent *current; /* Contenu actif courant */ gint selected; /* Indice à sélectionner */ GtkListStore *store; /* Modèle de gestion en liste */ GLoadedContent **contents; /* Liste de contenus chargés */ @@ -517,7 +517,7 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref) project = get_current_project(); - current = get_current_binary(); + current = get_current_content(); /* Constitution d'une liste de binaires courants */ @@ -541,7 +541,7 @@ static GtkWidget *load_and_populate_current_project_binaries(GObject *ref) CPB_FILENAME, g_loaded_binary_get_name(binary, true), -1); - if (binary == current) + if (binary == (GLoadedBinary *)current) selected = i; } diff --git a/src/analysis/db/items/move.c b/src/analysis/db/items/move.c index 5653649..1b1d5d2 100644 --- a/src/analysis/db/items/move.c +++ b/src/analysis/db/items/move.c @@ -38,7 +38,6 @@ #include "../../../gui/core/global.h" #include "../../../glibext/gbinarycursor.h" #include "../../../glibext/gloadedpanel.h" -#include "../../../gtkext/gtkdisplaypanel.h" // REMME @@ -444,7 +443,7 @@ static bool g_db_move_run(const GDbMove *move, GLineCursor *cursor) gboolean do_move_in_main_loop(move_params *p) { - gtk_display_panel_scroll_to_cursor(p->panel, p->cursor, SPT_CENTER); + g_loaded_panel_scroll_to_cursor(p->panel, p->cursor, SPT_CENTER, true); return G_SOURCE_REMOVE; diff --git a/src/analysis/loaded.c b/src/analysis/loaded.c index 5dd96a8..e65cb38 100644 --- a/src/analysis/loaded.c +++ b/src/analysis/loaded.c @@ -369,6 +369,12 @@ const char *g_loaded_content_describe(const GLoadedContent *content, bool full) } + +/* ---------------------------------------------------------------------------------- */ +/* GESTION DYNAMIQUE DES VUES */ +/* ---------------------------------------------------------------------------------- */ + + /****************************************************************************** * * * Paramètres : content = contenu chargé à consulter. * diff --git a/src/analysis/loaded.h b/src/analysis/loaded.h index 643e170..344d102 100644 --- a/src/analysis/loaded.h +++ b/src/analysis/loaded.h @@ -78,6 +78,11 @@ bool g_loaded_content_analyze_and_wait(GLoadedContent *); /* Fournit le désignation associée à l'élément chargé. */ const char *g_loaded_content_describe(const GLoadedContent *, bool); + + +/* --------------------------- GESTION DYNAMIQUE DES VUES --------------------------- */ + + /* Détermine le nombre de vues disponibles pour un contenu. */ unsigned int g_loaded_content_count_views(const GLoadedContent *); diff --git a/src/glibext/gbinarycursor.c b/src/glibext/gbinarycursor.c index 0c2a197..ee9eb5f 100644 --- a/src/glibext/gbinarycursor.c +++ b/src/glibext/gbinarycursor.c @@ -24,6 +24,9 @@ #include "gbinarycursor.h" +#include + + #include "glinecursor-int.h" @@ -66,12 +69,15 @@ static GLineCursor *g_binary_cursor_duplicate(const GBinaryCursor *); /* Compare deux suivis d'emplacements. */ static int g_binary_cursor_compare(const GBinaryCursor *, const GBinaryCursor *); -/* Détermine si un suivi d'emplacement est valide ou non. */ +/* Détermine si la position de suivi est pertinente ou non. */ static bool g_binary_cursor_is_valid(const GBinaryCursor *); /* Construit une étiquette de représentation d'un suivi. */ static char *g_binary_cursor_build_label(const GBinaryCursor *); +/* Affiche une position dans une barre de statut. */ +static void g_binary_cursor_show_status(const GBinaryCursor *, GtkStatusStack *, GLoadedContent *); + /* ---------------------- ENCADREMENT DES TRANSFERTS DE DONEES ---------------------- */ @@ -133,6 +139,7 @@ static void g_binary_cursor_class_init(GBinaryCursorClass *class) line->compare = (compare_cursor_fc)g_binary_cursor_compare; line->is_valid = (is_cursor_valid_fc)g_binary_cursor_is_valid; line->build_label = (build_cursor_label_fc)g_binary_cursor_build_label; + line->show_status = (show_cursor_status_fc)g_binary_cursor_show_status; line->serialize = (serialize_cursor_fc)g_binary_cursor_serialize; line->unserialize = (unserialize_cursor_fc)g_binary_cursor_unserialize; @@ -278,7 +285,7 @@ static int g_binary_cursor_compare(const GBinaryCursor *cursor, const GBinaryCur * * * Paramètres : cursor = suivi d'emplacement à consulter. * * * -* Description : Détermine si un suivi d'emplacement est valide ou non. * +* Description : Détermine si la position de suivi est pertinente ou non. * * * * Retour : Bilan de validité. * * * @@ -325,6 +332,51 @@ static char *g_binary_cursor_build_label(const GBinaryCursor *cursor) /****************************************************************************** * * +* Paramètres : cursor = emplacement du curseur à afficher. * +* stack = pile de statuts à mettre à jour. * +* content = contenu contenant le curseur à représenter. * +* * +* Description : Affiche une position dans une barre de statut. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void g_binary_cursor_show_status(const GBinaryCursor *cursor, GtkStatusStack *stack, GLoadedContent *content) +{ + GLoadedBinary *binary; /* Binaire chargé et analysé */ + GArchProcessor *proc; /* Architecture du binaire */ + GArchInstruction *instr; /* Instruction présente */ + + if (g_binary_cursor_is_valid(cursor)) + { + assert(G_IS_LOADED_BINARY(content)); + + binary = G_LOADED_BINARY(content); + + proc = g_loaded_binary_get_processor(binary); + + instr = _g_arch_processor_find_instr_by_address(proc, &cursor->addr, true); + assert(instr != NULL); + + gtk_status_stack_update_current_instruction(stack, binary, instr); + + g_object_unref(G_OBJECT(instr)); + + g_object_unref(G_OBJECT(proc)); + + } + + else + gtk_status_stack_reset_current_instruction(stack); + +} + + +/****************************************************************************** +* * * Paramètres : cursor = suivi de positions à mettre à jour. * * addr = emplacement dans le binaire visé. * * * @@ -348,7 +400,7 @@ void g_binary_cursor_update(GBinaryCursor *cursor, const vmpa2t *addr) * Paramètres : cursor = suivi de positions à consulter. * * addr = emplacement dans le binaire visé. [OUT] * * * -* Description : Transmet la position suivi dans un panneau de chargement. * +* Description : Transmet la position de suivi dans un panneau de chargement. * * * * Retour : - * * * @@ -356,7 +408,7 @@ void g_binary_cursor_update(GBinaryCursor *cursor, const vmpa2t *addr) * * ******************************************************************************/ -void g_binary_cursor_get_info(GBinaryCursor *cursor, vmpa2t *addr) +void g_binary_cursor_get_info(const GBinaryCursor *cursor, vmpa2t *addr) { copy_vmpa(addr, &cursor->addr); diff --git a/src/glibext/gbinarycursor.h b/src/glibext/gbinarycursor.h index 9846c59..63a6f1b 100644 --- a/src/glibext/gbinarycursor.h +++ b/src/glibext/gbinarycursor.h @@ -60,8 +60,8 @@ GLineCursor *g_binary_cursor_new(void); /* Met à jour la position suivi dans un panneau de chargement. */ void g_binary_cursor_update(GBinaryCursor *, const vmpa2t *); -/* Transmet la position suivi dans un panneau de chargement. */ -void g_binary_cursor_get_info(GBinaryCursor *, vmpa2t *); +/* Transmet la position de suivi dans un panneau de chargement. */ +void g_binary_cursor_get_info(const GBinaryCursor *, vmpa2t *); diff --git a/src/glibext/glinecursor-int.h b/src/glibext/glinecursor-int.h index b38e22e..18ec147 100644 --- a/src/glibext/glinecursor-int.h +++ b/src/glibext/glinecursor-int.h @@ -26,6 +26,7 @@ #include "glinecursor.h" +#include "../gtkext/gtkstatusstack.h" @@ -35,12 +36,15 @@ typedef GLineCursor * (* duplicate_cursor_fc) (const GLineCursor *); /* Compare deux suivis d'emplacements. */ typedef int (* compare_cursor_fc) (const GLineCursor *, const GLineCursor *); -/* Détermine si un suivi d'emplacement est valide ou non. */ +/* Détermine si la position de suivi est pertinente ou non. */ typedef bool (* is_cursor_valid_fc) (const GLineCursor *); /* Construit une étiquette de représentation d'un suivi. */ typedef char * (* build_cursor_label_fc) (const GLineCursor *); +/* Affiche une position dans une barre de statut. */ +typedef void (* show_cursor_status_fc) (const GLineCursor *, GtkStatusStack *, GLoadedContent *); + /* Exporte la définition d'un emplacement dans un flux réseau. */ typedef bool (* serialize_cursor_fc) (const GLineCursor *, packed_buffer *); @@ -76,6 +80,7 @@ struct _GLineCursorClass compare_cursor_fc compare; /* Comparaison d'emplacements */ is_cursor_valid_fc is_valid; /* Certificat de validité */ build_cursor_label_fc build_label; /* Obtention d'une étiquette */ + show_cursor_status_fc show_status; /* Affichage dans une barre */ serialize_cursor_fc serialize; /* Sauvegarde d'un emplacement */ unserialize_cursor_fc unserialize; /* Chargement d'un emplacement */ diff --git a/src/glibext/glinecursor.c b/src/glibext/glinecursor.c index 0245ebd..64521f4 100644 --- a/src/glibext/glinecursor.c +++ b/src/glibext/glinecursor.c @@ -190,7 +190,7 @@ int g_line_cursor_compare(const GLineCursor *cursor, const GLineCursor *other) * * * Paramètres : cursor = suivi d'emplacement à consulter. * * * -* Description : Détermine si un suivi d'emplacement est valide ou non. * +* Description : Détermine si la position de suivi est pertinente ou non. * * * * Retour : Bilan de validité. * * * @@ -232,6 +232,27 @@ char *g_line_cursor_build_label(const GLineCursor *cursor) } +/****************************************************************************** +* * +* Paramètres : cursor = emplacement du curseur à afficher. * +* stack = pile de statuts à mettre à jour. * +* content = contenu contenant le curseur à représenter. * +* * +* Description : Affiche une position dans une barre de statut. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_line_cursor_show_status(const GLineCursor *cursor, GtkStatusStack *stack, GLoadedContent *content) +{ + G_LINE_CURSOR_GET_CLASS(cursor)->show_status(cursor, stack, content); + +} + + /* ---------------------------------------------------------------------------------- */ /* ENCADREMENT DES TRANSFERTS DE DONEES */ diff --git a/src/glibext/glinecursor.h b/src/glibext/glinecursor.h index d9c16c4..1cf8d47 100644 --- a/src/glibext/glinecursor.h +++ b/src/glibext/glinecursor.h @@ -29,11 +29,17 @@ #include +#include "../analysis/loaded.h" #include "../common/packed.h" #include "../common/sqlite.h" +/* Depuis ../gtkext/gtkstatusstack.h : abstration d'une gestion de barre de statut (instance) */ +typedef struct _GtkStatusStack GtkStatusStack; + + + /* ----------------------- FONCTIONNALITES D'UN SUIVI DE BASE ----------------------- */ @@ -61,12 +67,15 @@ GLineCursor *g_line_cursor_duplicate(const GLineCursor *); /* Compare deux suivis d'emplacements. */ int g_line_cursor_compare(const GLineCursor *, const GLineCursor *); -/* Détermine si un suivi d'emplacement est valide ou non. */ +/* Détermine si la position de suivi est pertinente ou non. */ bool g_line_cursor_is_valid(const GLineCursor *); /* Construit une étiquette de représentation d'un suivi. */ char *g_line_cursor_build_label(const GLineCursor *); +/* Affiche une position dans une barre de statut. */ +void g_line_cursor_show_status(const GLineCursor *, GtkStatusStack *, GLoadedContent *); + /* ---------------------- ENCADREMENT DES TRANSFERTS DE DONEES ---------------------- */ diff --git a/src/glibext/gloadedpanel-int.h b/src/glibext/gloadedpanel-int.h index dbe9c0c..36a1437 100644 --- a/src/glibext/gloadedpanel-int.h +++ b/src/glibext/gloadedpanel-int.h @@ -41,6 +41,9 @@ typedef GLineCursor * (* get_loaded_cursor_fc) (const GLoadedPanel *); /* Définit le position courante dans un panneau de chargement. */ typedef void (* set_loaded_cursor_fc) (GLoadedPanel *, const GLineCursor *); +/* S'assure qu'un emplacement donné est visible à l'écran. */ +typedef void (* scroll_loaded_to_cursor_fc) (GLoadedPanel *, const GLineCursor *, ScrollPositionTweak, bool); + /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ typedef void (* cache_loaded_glance_fc) (GLoadedPanel *, cairo_t *, const GtkAllocation *, double); @@ -50,17 +53,21 @@ struct _GLoadedPanelIface { GTypeInterface base_iface; /* A laisser en premier */ + /* Méthodes virtuelles */ + set_loaded_panel_content_fc set_content;/* Définition du contenu */ get_loaded_panel_content_fc get_content;/* Récupération du contenu */ get_loaded_cursor_fc get_cursor; /* Fourniture d'une position */ set_loaded_cursor_fc set_cursor; /* Application d'une position */ + scroll_loaded_to_cursor_fc scroll; /* Défilement de la vue */ cache_loaded_glance_fc cache_glance; /* Cache de la mignature */ /* Signaux */ void (* move_request) (GLoadedPanel *, const GLineCursor *, gboolean); + void (* cursor_moved) (GLoadedPanel *, const GLineCursor *); }; diff --git a/src/glibext/gloadedpanel.c b/src/glibext/gloadedpanel.c index 8bf750a..ead34b7 100644 --- a/src/glibext/gloadedpanel.c +++ b/src/glibext/gloadedpanel.c @@ -60,6 +60,14 @@ static void g_loaded_panel_default_init(GLoadedPanelInterface *iface) g_cclosure_user_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2, G_TYPE_LINE_CURSOR, G_TYPE_BOOLEAN); + g_signal_new("cursor-moved", + G_TYPE_LOADED_PANEL, + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET(GLoadedPanelIface, cursor_moved), + NULL, NULL, + g_cclosure_marshal_VOID__OBJECT, + G_TYPE_NONE, 1, G_TYPE_LINE_CURSOR); + } @@ -188,6 +196,32 @@ void g_loaded_panel_request_move(GLoadedPanel *panel, const GLineCursor *cursor, /****************************************************************************** * * +* Paramètres : panel = composant GTK à manipuler. * +* cursor = emplacement à présenter à l'écran. * +* tweak = adaptation finale à effectuer. * +* move = doit-on déplacer le curseur à l'adresse indiquée ? * +* * +* Description : S'assure qu'un emplacement donné est visible à l'écran. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_loaded_panel_scroll_to_cursor(GLoadedPanel *panel, const GLineCursor *cursor, ScrollPositionTweak tweak, bool move) +{ + GLoadedPanelIface *iface; /* Interface utilisée */ + + iface = G_LOADED_PANEL_GET_IFACE(panel); + + iface->scroll(panel, cursor, tweak, move); + +} + + +/****************************************************************************** +* * * Paramètres : panel = composant GTK à manipuler. * * cairo = assistant pour la création de rendus. * * area = taille de la surface réduite à disposition. * diff --git a/src/glibext/gloadedpanel.h b/src/glibext/gloadedpanel.h index ffdb35b..50ea058 100644 --- a/src/glibext/gloadedpanel.h +++ b/src/glibext/gloadedpanel.h @@ -26,6 +26,7 @@ #include +#include #include @@ -67,6 +68,19 @@ void g_loaded_panel_set_cursor(GLoadedPanel *, const GLineCursor *); /* Demande à qui veut répondre un déplacement du curseur. */ void g_loaded_panel_request_move(GLoadedPanel *, const GLineCursor *, gboolean); +/* Adaptation d'une position sur une surface */ +typedef enum _ScrollPositionTweak +{ + SPT_RAW, /* Aucun ajustement */ + SPT_TOP, /* Le plus haut possible */ + SPT_CENTER, /* Au centre de la surface */ + SPT_BOTTOM /* Le plus bas possible */ + +} ScrollPositionTweak; + +/* S'assure qu'un emplacement donné est visible à l'écran. */ +void g_loaded_panel_scroll_to_cursor(GLoadedPanel *, const GLineCursor *, ScrollPositionTweak, bool); + /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ void g_loaded_panel_cache_glance(GLoadedPanel *, cairo_t *, const GtkAllocation *, double); diff --git a/src/gtkext/gtkbufferdisplay.c b/src/gtkext/gtkbufferdisplay.c index ff651c8..4a2c814 100644 --- a/src/gtkext/gtkbufferdisplay.c +++ b/src/gtkext/gtkbufferdisplay.c @@ -521,7 +521,7 @@ static gboolean gtk_buffer_display_key_press(GtkWidget *widget, GdkEventKey *eve if (status) { gtk_buffer_display_relocate_caret(display, &area, cursor); - _gtk_display_panel_scroll_to_cursor(panel, cursor, SPT_RAW, false); + g_loaded_panel_scroll_to_cursor(G_LOADED_PANEL(panel), cursor, SPT_RAW, false); } else g_signal_emit_by_name(display, "reach-limit", dir); @@ -1038,7 +1038,8 @@ static void gtk_buffer_display_restart_caret_blinking(GtkBufferDisplay *display) } - g_signal_emit_by_name(display, "caret-moved", &display->caret_addr); + if (display->cursor != NULL) + g_signal_emit_by_name(display, "cursor-moved", display->cursor); } diff --git a/src/gtkext/gtkdisplaypanel-int.h b/src/gtkext/gtkdisplaypanel-int.h index fa67dbd..cf0335a 100644 --- a/src/gtkext/gtkdisplaypanel-int.h +++ b/src/gtkext/gtkdisplaypanel-int.h @@ -114,10 +114,6 @@ struct _GtkDisplayPanelClass set_cursor_fc set_cursor; /* Application d'une position */ cache_glance_fc cache_glance; /* Cache de la mignature */ - /* Signaux */ - - void (* caret_moved) (GtkDisplayPanel *, const vmpa2t *); - }; /* Propriétés propres au composant d'affichage */ diff --git a/src/gtkext/gtkdisplaypanel.c b/src/gtkext/gtkdisplaypanel.c index 15d257f..24436ca 100644 --- a/src/gtkext/gtkdisplaypanel.c +++ b/src/gtkext/gtkdisplaypanel.c @@ -105,6 +105,9 @@ static GLineCursor *gtk_display_panel_get_cursor(const GtkDisplayPanel *); /* Définit le position courante dans un panneau de chargement. */ static void gtk_display_panel_set_cursor(GtkDisplayPanel *, const GLineCursor *); +/* S'assure qu'un emplacement donné est visible à l'écran. */ +static void gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *, const GLineCursor *, ScrollPositionTweak, bool); + /* Place en cache un rendu destiné à l'aperçu graphique rapide. */ static void gtk_display_panel_cache_glance(GtkDisplayPanel *, cairo_t *, const GtkAllocation *, double); @@ -155,14 +158,6 @@ static void gtk_display_panel_class_init(GtkDisplayPanelClass *class) panel_class->compute_inc = gtk_display_panel_compute_scroll_inc; - g_signal_new("caret-moved", - GTK_TYPE_DISPLAY_PANEL, - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET(GtkDisplayPanelClass, caret_moved), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - } @@ -205,6 +200,7 @@ static void gtk_display_panel_loaded_interface_init(GLoadedPanelInterface *iface iface->get_cursor = (get_loaded_cursor_fc)gtk_display_panel_get_cursor; iface->set_cursor = (set_loaded_cursor_fc)gtk_display_panel_set_cursor; + iface->scroll = (scroll_loaded_to_cursor_fc)gtk_display_panel_scroll_to_cursor; iface->cache_glance = (cache_loaded_glance_fc)gtk_display_panel_cache_glance; @@ -843,36 +839,6 @@ static void on_view_panel_binary_display_change(GLoadedBinary *binary, BinaryVie * * * Paramètres : panel = composant GTK à consulter. * * * -* Description : Fournit le binaire associé à la représentation. * -* * -* Retour : Représentation de contenu binaire. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GLoadedBinary *gtk_display_panel_get_binary(const GtkDisplayPanel *panel) -{ - g_object_ref(G_OBJECT(panel->binary)); - - return panel->binary; - -} - - - - - - - - - - - -/****************************************************************************** -* * -* Paramètres : panel = composant GTK à consulter. * -* * * Description : Indique la position courante du curseur. * * * * Retour : Emplacement courant du curseur ou NULL si aucun. * @@ -924,90 +890,6 @@ GObject *gtk_display_panel_get_active_object(const GtkDisplayPanel *panel) /****************************************************************************** * * -* Paramètres : panel = composant GTK à manipuler. * -* cursor = emplacement à présenter à l'écran. * -* tweak = adaptation finale à effectuer. * -* move = doit-on déplacer le curseur à l'adresse indiquée ? * -* * -* Description : S'assure qu'une adresse donnée est visible à l'écran. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void _gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *panel, const GLineCursor *cursor, ScrollPositionTweak tweak, bool move) -{ - GtkWidget *parent; /* Support parent à valider */ - gint x; /* Abscisse à garantir */ - gint y; /* Ordonnée à garantir */ - GtkWidget *viewport; /* Parent avec défilement */ - GtkAdjustment *adj; /* Défilement à mettre à jour */ - gdouble step_inc; /* Valeur d'un petit pas */ - gdouble page_size; /* Taille de l'affichage */ - double value; /* Valeur courante */ - - /** - * Si une vue partielle se déplace via cette fonction, il faut potentiellement - * rediriger l'appel vers la vue en graphiques parente. - */ - - parent = gtk_widget_get_parent(GTK_WIDGET(panel)); - parent = gtk_widget_get_parent(GTK_WIDGET(parent)); - - if (GTK_IS_DISPLAY_PANEL(parent)) - panel = GTK_DISPLAY_PANEL(parent); - - /* - if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->define != NULL) - GTK_DISPLAY_PANEL_GET_CLASS(panel)->define(panel, addr); - */ - - if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, cursor, &x, &y, tweak)) - { - viewport = gtk_widget_get_parent(GTK_WIDGET(panel)); - - /* Eventuel défilement horizontal */ - - g_object_get(G_OBJECT(viewport), "hadjustment", &adj, NULL); - - step_inc = gtk_adjustment_get_step_increment(adj); - page_size = gtk_adjustment_get_page_size(adj); - value = gtk_adjustment_get_value(adj); - - if (x < value) - gtk_adjustment_set_value(adj, x); - - else if ((x + step_inc) > (value + page_size)) - gtk_adjustment_set_value(adj, x + step_inc - page_size); - - /* Eventuel défilement vertical */ - - g_object_get(G_OBJECT(viewport), "vadjustment", &adj, NULL); - - step_inc = gtk_adjustment_get_step_increment(adj); - page_size = gtk_adjustment_get_page_size(adj); - value = gtk_adjustment_get_value(adj); - - if (y < value || tweak != SPT_RAW) - gtk_adjustment_set_value(adj, y); - - else if ((y + step_inc) > (value + page_size)) - gtk_adjustment_set_value(adj, y + step_inc - page_size); - - /* Déplacement du curseur */ - - if (move && GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, cursor, &x, &y, SPT_RAW)) - GTK_DISPLAY_PANEL_GET_CLASS(panel)->move_caret_to(panel, x, y); - - } - -} - - -/****************************************************************************** -* * * Paramètres : panel = composant GTK à manipuler. * * addr = adresse à présenter à l'écran. * * * @@ -1159,6 +1041,9 @@ static GLoadedContent *gtk_display_panel_get_content(const GtkDisplayPanel *pane result = G_LOADED_CONTENT(panel->binary); + if (result != NULL) + g_object_ref(G_OBJECT(result)); + return result; } @@ -1209,6 +1094,90 @@ static void gtk_display_panel_set_cursor(GtkDisplayPanel *panel, const GLineCurs /****************************************************************************** * * +* Paramètres : panel = composant GTK à manipuler. * +* cursor = emplacement à présenter à l'écran. * +* tweak = adaptation finale à effectuer. * +* move = doit-on déplacer le curseur à l'adresse indiquée ? * +* * +* Description : S'assure qu'un emplacement donné est visible à l'écran. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *panel, const GLineCursor *cursor, ScrollPositionTweak tweak, bool move) +{ + GtkWidget *parent; /* Support parent à valider */ + gint x; /* Abscisse à garantir */ + gint y; /* Ordonnée à garantir */ + GtkWidget *viewport; /* Parent avec défilement */ + GtkAdjustment *adj; /* Défilement à mettre à jour */ + gdouble step_inc; /* Valeur d'un petit pas */ + gdouble page_size; /* Taille de l'affichage */ + double value; /* Valeur courante */ + + /** + * Si une vue partielle se déplace via cette fonction, il faut potentiellement + * rediriger l'appel vers la vue en graphiques parente. + */ + + parent = gtk_widget_get_parent(GTK_WIDGET(panel)); + parent = gtk_widget_get_parent(GTK_WIDGET(parent)); + + if (GTK_IS_DISPLAY_PANEL(parent)) + panel = GTK_DISPLAY_PANEL(parent); + + /* + if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->define != NULL) + GTK_DISPLAY_PANEL_GET_CLASS(panel)->define(panel, addr); + */ + + if (GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, cursor, &x, &y, tweak)) + { + viewport = gtk_widget_get_parent(GTK_WIDGET(panel)); + + /* Eventuel défilement horizontal */ + + g_object_get(G_OBJECT(viewport), "hadjustment", &adj, NULL); + + step_inc = gtk_adjustment_get_step_increment(adj); + page_size = gtk_adjustment_get_page_size(adj); + value = gtk_adjustment_get_value(adj); + + if (x < value) + gtk_adjustment_set_value(adj, x); + + else if ((x + step_inc) > (value + page_size)) + gtk_adjustment_set_value(adj, x + step_inc - page_size); + + /* Eventuel défilement vertical */ + + g_object_get(G_OBJECT(viewport), "vadjustment", &adj, NULL); + + step_inc = gtk_adjustment_get_step_increment(adj); + page_size = gtk_adjustment_get_page_size(adj); + value = gtk_adjustment_get_value(adj); + + if (y < value || tweak != SPT_RAW) + gtk_adjustment_set_value(adj, y); + + else if ((y + step_inc) > (value + page_size)) + gtk_adjustment_set_value(adj, y + step_inc - page_size); + + /* Déplacement du curseur */ + + if (move && GTK_DISPLAY_PANEL_GET_CLASS(panel)->get_coordinates(panel, cursor, &x, &y, SPT_RAW)) + GTK_DISPLAY_PANEL_GET_CLASS(panel)->move_caret_to(panel, x, y); + + } + +} + + +/****************************************************************************** +* * * Paramètres : panel = composant GTK à manipuler. * * cairo = assistant pour la création de rendus. * * area = taille de la surface réduite à disposition. * diff --git a/src/gtkext/gtkdisplaypanel.h b/src/gtkext/gtkdisplaypanel.h index c060c39..b336799 100644 --- a/src/gtkext/gtkdisplaypanel.h +++ b/src/gtkext/gtkdisplaypanel.h @@ -30,6 +30,7 @@ #include "../analysis/binary.h" #include "../glibext/glinecursor.h" +#include "../glibext/gloadedpanel.h" @@ -60,33 +61,12 @@ void gtk_display_panel_set_addresses_display(GtkDisplayPanel *, bool); /* Définit si le code doit apparaître dans le rendu. */ void gtk_display_panel_set_code_display(GtkDisplayPanel *, bool); -/* Fournit le binaire associé à la représentation. */ -GLoadedBinary *gtk_display_panel_get_binary(const GtkDisplayPanel *); - - - - -/* Adaptation d'une position sur une surface */ -typedef enum _ScrollPositionTweak -{ - SPT_RAW, /* Aucun ajustement */ - SPT_TOP, /* Le plus haut possible */ - SPT_CENTER, /* Au centre de la surface */ - SPT_BOTTOM /* Le plus bas possible */ - -} ScrollPositionTweak; - /* Indique la position courante du curseur. */ const vmpa2t *gtk_display_panel_get_caret_location(const GtkDisplayPanel *); /* Fournit l'élément actif lié à la position courante. */ GObject *gtk_display_panel_get_active_object(const GtkDisplayPanel *); -/* S'assure qu'une adresse donnée est visible à l'écran. */ -void _gtk_display_panel_scroll_to_cursor(GtkDisplayPanel *, const GLineCursor *, ScrollPositionTweak, bool); - -#define gtk_display_panel_scroll_to_cursor(p, c, t) _gtk_display_panel_scroll_to_cursor(p, c, t, true) - /* Demande à qui veut répondre un déplacement du curseur. */ void gtk_display_panel_request_move(GtkDisplayPanel *, const vmpa2t *); diff --git a/src/gtkext/gtkgraphdisplay.c b/src/gtkext/gtkgraphdisplay.c index 0fe86ef..7721a44 100644 --- a/src/gtkext/gtkgraphdisplay.c +++ b/src/gtkext/gtkgraphdisplay.c @@ -698,7 +698,7 @@ static void gtk_graph_display_define_main_address(GtkGraphDisplay *display, cons ggddma_done: - change_editor_items_current_view_content(G_LOADED_PANEL(display)); + update_editor_items_current_view(G_LOADED_PANEL(display)); g_object_unref(G_OBJECT(format)); diff --git a/src/gui/core/global.c b/src/gui/core/global.c index 89a2d90..30dc174 100644 --- a/src/gui/core/global.c +++ b/src/gui/core/global.c @@ -31,21 +31,16 @@ static GtkWindow *_editor = NULL; /* Barre de statut principale */ static GtkStatusStack *_status = NULL; -/* Binaire en cours d'étude ou NULL */ -static GLoadedBinary *_current_binary = NULL; +/* Contenu en cours d'étude ou NULL */ +static GLoadedContent *_current_content = NULL; -G_LOCK_DEFINE_STATIC(_cb_mutex); +G_LOCK_DEFINE_STATIC(_cc_mutex); /* Suivi du panneau d'affichage courant ou NULL */ static GLoadedPanel *_current_view = NULL; G_LOCK_DEFINE_STATIC(_cv_mutex); -/* Suivi des changements de position ou NULL */ -static GObject *_caret_instance = NULL; - -G_LOCK_DEFINE_STATIC(_ci_mutex); - /****************************************************************************** @@ -145,9 +140,9 @@ GtkStatusStack *get_global_status(void) /****************************************************************************** * * -* Paramètres : binary = instance de binaire chargé. * +* Paramètres : content = instance de contenu chargé. * * * -* Description : Définit le binaire actif en cours d'étude. * +* Description : Définit le contenu actif en cours d'étude. * * * * Retour : - * * * @@ -155,16 +150,16 @@ GtkStatusStack *get_global_status(void) * * ******************************************************************************/ -void set_current_binary(GLoadedBinary *binary) +void set_current_content(GLoadedContent *content) { - G_LOCK(_cb_mutex); + G_LOCK(_cc_mutex); - if (_current_binary != NULL) - g_object_unref(G_OBJECT(_current_binary)); + if (_current_content != NULL) + g_object_unref(G_OBJECT(_current_content)); - _current_binary = binary; + _current_content = content; - G_UNLOCK(_cb_mutex); + G_UNLOCK(_cc_mutex); } @@ -173,26 +168,26 @@ void set_current_binary(GLoadedBinary *binary) * * * Paramètres : - * * * -* Description : Fournit le binaire actif en cours d'étude. * +* Description : Fournit le contenu actif en cours d'étude. * * * -* Retour : Instance courante de binaire étudié ou NULL. * +* Retour : Instance courante de contenu étudié ou NULL. * * * * Remarques : - * * * ******************************************************************************/ -GLoadedBinary *get_current_binary(void) +GLoadedContent *get_current_content(void) { - GLoadedBinary *result; /* Instance à retourner */ + GLoadedContent *result; /* Instance à retourner */ - G_LOCK(_cb_mutex); + G_LOCK(_cc_mutex); - result = _current_binary; + result = _current_content; if (result != NULL) g_object_ref(G_OBJECT(result)); - G_UNLOCK(_cb_mutex); + G_UNLOCK(_cc_mutex); return result; @@ -201,9 +196,9 @@ GLoadedBinary *get_current_binary(void) /****************************************************************************** * * -* Paramètres : view = représentation courante de binaire. * +* Paramètres : view = représentation courante de contenu. * * * -* Description : Définit l'affichage de binaire courant. * +* Description : Définit l'affichage de contenu courant. * * * * Retour : - * * * @@ -229,7 +224,7 @@ void set_current_view(GLoadedPanel *view) * * * Paramètres : - * * * -* Description : Fournit l'affichage de binaire courant. * +* Description : Fournit l'affichage de contenu courant. * * * * Retour : Instance en place ou NULL si aucune. * * * @@ -253,59 +248,3 @@ GLoadedPanel *get_current_view(void) return result; } - - -/****************************************************************************** -* * -* Paramètres : caret = instance graphique à mémoriser. * -* * -* Description : Définit le support contenant la position active. * -* * -* Retour : - * -* * -* Remarques : - * -* * -******************************************************************************/ - -void set_caret_instance(GObject *caret) -{ - G_LOCK(_ci_mutex); - - if (_caret_instance != NULL) - g_object_unref(_caret_instance); - - _caret_instance = caret; - - G_UNLOCK(_ci_mutex); - -} - - -/****************************************************************************** -* * -* Paramètres : - * -* * -* Description : Fournit le support contenant la position active. * -* * -* Retour : Instance en place ou NULL si aucune. * -* * -* Remarques : - * -* * -******************************************************************************/ - -GObject *get_caret_instance(void) -{ - GObject *result; /* Instance à retourner */ - - G_LOCK(_ci_mutex); - - result = _caret_instance; - - if (result != NULL) - g_object_ref(result); - - G_UNLOCK(_ci_mutex); - - return result; - -} diff --git a/src/gui/core/global.h b/src/gui/core/global.h index 5e9d902..ee66399 100644 --- a/src/gui/core/global.h +++ b/src/gui/core/global.h @@ -1,5 +1,5 @@ -/* Chrysalide - Outil d'analyse de fichiers binaires +/* Chrysalide - Outil d'analyse de fichiers contenus * global.h - prototypes pour la conservation de variables globales à vocation graphique * * Copyright (C) 2016-2017 Cyrille Bagard @@ -25,7 +25,7 @@ #define _GUI_CORE_GLOBAL_H -#include "../../analysis/binary.h" +#include "../../analysis/loaded.h" #include "../../glibext/gloadedpanel.h" #include "../../gtkext/gtkstatusstack.h" @@ -46,24 +46,18 @@ void set_global_status(GtkStatusStack *); /* Fournit l'adresse de la barre de statut principale. */ GtkStatusStack *get_global_status(void); -/* Définit le binaire actif en cours d'étude. */ -void set_current_binary(GLoadedBinary *); +/* Définit le contenu actif en cours d'étude. */ +void set_current_content(GLoadedContent *); -/* Fournit le binaire actif en cours d'étude. */ -GLoadedBinary *get_current_binary(void); +/* Fournit le contenu actif en cours d'étude. */ +GLoadedContent *get_current_content(void); -/* Définit l'affichage de binaire courant. */ +/* Définit l'affichage de contenu courant. */ void set_current_view(GLoadedPanel *); -/* Fournit l'affichage de binaire courant. */ +/* Fournit l'affichage de contenu courant. */ GLoadedPanel *get_current_view(void); -/* Définit le support contenant la position active. */ -void set_caret_instance(GObject *); - -/* Fournit le support contenant la position active. */ -GObject *get_caret_instance(void); - #endif /* _GUI_CORE_GLOBAL_H */ diff --git a/src/gui/core/items.c b/src/gui/core/items.c index a25d1b9..ad2de2c 100644 --- a/src/gui/core/items.c +++ b/src/gui/core/items.c @@ -34,14 +34,11 @@ static GEditorItem *_editem_list = NULL; -/* Suit les changements de focus des panneaux d'affichage. */ -static gboolean notify_view_panel_focus_change(GLoadedPanel *, GdkEventFocus *, gpointer); - /* Lance une procédure de déplacement de la position courante. */ static void start_moving_to_cursor_in_loaded_panel(GLoadedPanel *, const GLineCursor *, gboolean, gpointer); /* Suit les changements de position dans du code d'assembleur. */ -static void track_caret_address_on_view_panel(GtkDisplayPanel *, const vmpa2t *, gpointer); +static void track_cursor_on_view_panel(GLoadedPanel *, const GLineCursor *, gpointer); @@ -66,9 +63,9 @@ void register_editor_item(GEditorItem *item) /****************************************************************************** * * -* Paramètres : binary = nouvelle instance de binaire analysé. * +* Paramètres : content = nouvelle instance de contenu analysé. * * * -* Description : Lance une actualisation du fait d'un changement de binaire. * +* Description : Lance une actualisation du fait d'un changement de contenu. * * * * Retour : - * * * @@ -76,49 +73,26 @@ void register_editor_item(GEditorItem *item) * * ******************************************************************************/ -void change_editor_items_current_binary(GLoadedBinary *binary) +void change_editor_items_current_content(GLoadedContent *content) { + GLoadedContent *old; /* Ancien contenu */ GEditorItem *iter; /* Boucle de parcours */ - GEditorItemClass *klass; /* Classe correspondante */ - set_current_binary(binary); + old = get_current_content(); - editem_list_for_each(iter, _editem_list) + if (content != old) { - klass = G_EDITOR_ITEM_GET_CLASS(iter); - - if (klass->update_binary != NULL) - klass->update_binary(iter, binary); - - } - -} - - -/****************************************************************************** -* * -* Paramètres : panel = composant d'affichage concerné par l'opération. * -* event = informations liées à l'événement. * -* unused = adresse non utilisée ici. * -* * -* Description : Suit les changements de focus des panneaux d'affichage. * -* * -* Retour : FALSE pour continuer la propagation. * -* * -* Remarques : - * -* * -******************************************************************************/ + set_current_content(content); -static gboolean notify_view_panel_focus_change(GLoadedPanel *panel, GdkEventFocus *event, gpointer unused) -{ - GEditorItem *iter; /* Boucle de parcours */ + editem_list_for_each(iter, _editem_list) + { + g_editor_item_change_content(iter, old, content); + } - editem_list_for_each(iter, _editem_list) - { - notify_focus_change_for_editor_item(iter, event->in ? panel : NULL); } - return FALSE; + if (old != NULL) + g_object_unref(G_OBJECT(old)); } @@ -157,7 +131,7 @@ static void start_moving_to_cursor_in_loaded_panel(GLoadedPanel *panel, const GL } else - gtk_display_panel_scroll_to_cursor(panel, cursor, SPT_CENTER); + g_loaded_panel_scroll_to_cursor(panel, cursor, SPT_CENTER, true); if (src != NULL) g_object_unref(G_OBJECT(src)); @@ -168,7 +142,7 @@ static void start_moving_to_cursor_in_loaded_panel(GLoadedPanel *panel, const GL /****************************************************************************** * * * Paramètres : panel = composant d'affichage parcouru. * -* addr = nouvelle adresse du curseur courant. * +* cursor = nouvel emplacement du curseur courant. * * unused = adresse non utilisée ici. * * * * Description : Suit les changements de position dans du code d'assembleur. * @@ -179,18 +153,13 @@ static void start_moving_to_cursor_in_loaded_panel(GLoadedPanel *panel, const GL * * ******************************************************************************/ -static void track_caret_address_on_view_panel(GtkDisplayPanel *panel, const vmpa2t *addr, gpointer unused) +static void track_cursor_on_view_panel(GLoadedPanel *panel, const GLineCursor *cursor, gpointer unused) { GEditorItem *iter; /* Boucle de parcours */ - GEditorItemClass *klass; /* Classe correspondante */ editem_list_for_each(iter, _editem_list) { - klass = G_EDITOR_ITEM_GET_CLASS(iter); - - if (klass->track_caret != NULL) - klass->track_caret(iter, panel, addr); - + g_editor_item_track_cursor(iter, panel, cursor); } } @@ -210,59 +179,32 @@ static void track_caret_address_on_view_panel(GtkDisplayPanel *panel, const vmpa void change_editor_items_current_view(GLoadedPanel *panel) { - GLoadedPanel *view; /* Affichage actif */ + GLoadedPanel *old; /* Ancien affichage */ GEditorItem *iter; /* Boucle de parcours */ - GEditorItemClass *klass; /* Classe correspondante */ - GObject *caret; /* Support du curseur actif */ /* Suivi des affichages */ - view = get_current_view(); + old = get_current_view(); - if (view != NULL) + if (panel != old) { - g_signal_handlers_disconnect_by_func(view, G_CALLBACK(notify_view_panel_focus_change), NULL); - g_signal_handlers_disconnect_by_func(view, G_CALLBACK(notify_view_panel_focus_change), NULL); + set_current_view(panel); - g_object_unref(view); - - } - - set_current_view(panel); - - editem_list_for_each(iter, _editem_list) - { - klass = G_EDITOR_ITEM_GET_CLASS(iter); - - if (klass->update_view != NULL) - klass->update_view(iter, panel); - - } - - if (panel != NULL) - { - g_signal_connect(panel, "focus-in-event", G_CALLBACK(notify_view_panel_focus_change), NULL); - g_signal_connect(panel, "focus-out-event", G_CALLBACK(notify_view_panel_focus_change), NULL); - } + editem_list_for_each(iter, _editem_list) + { + g_editor_item_change_view(iter, old, panel); + } - /* Suivi du curseur */ + /* Suivi du curseur */ - if (GTK_IS_DISPLAY_PANEL(panel)) - { - caret = get_caret_instance(); - - if (caret != NULL) + if (old != NULL) { - g_signal_handlers_disconnect_by_func(caret, + g_signal_handlers_disconnect_by_func(old, G_CALLBACK(start_moving_to_cursor_in_loaded_panel), NULL); - g_signal_handlers_disconnect_by_func(caret, - G_CALLBACK(track_caret_address_on_view_panel), + g_signal_handlers_disconnect_by_func(old, + G_CALLBACK(track_cursor_on_view_panel), NULL); - - set_caret_instance(NULL); - g_object_unref(caret); - } if (panel != NULL) @@ -271,19 +213,16 @@ void change_editor_items_current_view(GLoadedPanel *panel) G_CALLBACK(start_moving_to_cursor_in_loaded_panel), NULL); - g_signal_connect(panel, "caret-moved", - G_CALLBACK(track_caret_address_on_view_panel), + g_signal_connect(panel, "cursor-moved", + G_CALLBACK(track_cursor_on_view_panel), NULL); - - caret = G_OBJECT(panel); - - g_object_ref(caret); - set_caret_instance(caret); - } } + if (old != NULL) + g_object_unref(G_OBJECT(old)); + } @@ -299,18 +238,13 @@ void change_editor_items_current_view(GLoadedPanel *panel) * * ******************************************************************************/ -void change_editor_items_current_view_content(GLoadedPanel *panel) +void update_editor_items_current_view(GLoadedPanel *panel) { GEditorItem *iter; /* Boucle de parcours */ - GEditorItemClass *klass; /* Classe correspondante */ editem_list_for_each(iter, _editem_list) { - klass = G_EDITOR_ITEM_GET_CLASS(iter); - - if (klass->update_content != NULL) - klass->update_content(iter, panel); - + g_editor_item_update_view(iter, panel); } } @@ -318,9 +252,9 @@ void change_editor_items_current_view_content(GLoadedPanel *panel) /****************************************************************************** * * -* Paramètres : binary = binaire contenant l'adresse à représenter. * -* addr = adresse mémoire à mettre en avant. * -* source = composant à l'origine du changement. * +* Paramètres : content = contenu contenant le curseur à représenter. * +* cursor = nouvel emplacement du curseur courant. * +* source = composant à l'origine du changement. * * * * Description : Concentre l'attention de l'ensemble sur une adresse donnée. * * * @@ -330,18 +264,14 @@ void change_editor_items_current_view_content(GLoadedPanel *panel) * * ******************************************************************************/ -void focus_address_in_editor_items(GLoadedBinary *binary, const vmpa2t *addr, GEditorItem *source) +void focus_cursor_in_editor_items(GLoadedContent *content, const GLineCursor *cursor, GEditorItem *source) { GEditorItem *iter; /* Boucle de parcours */ - GEditorItemClass *klass; /* Classe correspondante */ editem_list_for_each(iter, _editem_list) { - klass = G_EDITOR_ITEM_GET_CLASS(iter); - - if (klass->focus_addr != NULL && iter != source) - klass->focus_addr(iter, binary, addr); - + if (iter != source) + g_editor_item_focus_cursor(iter, content, cursor); } } diff --git a/src/gui/core/items.h b/src/gui/core/items.h index a738ac9..86350c7 100644 --- a/src/gui/core/items.h +++ b/src/gui/core/items.h @@ -26,7 +26,7 @@ #include "../editem.h" -#include "../../analysis/binary.h" +#include "../../analysis/loaded.h" #include "../../analysis/project.h" #include "../../glibext/gloadedpanel.h" @@ -35,17 +35,17 @@ /* Procède à l'enregistrement d'un élément reactif de l'éditeur. */ void register_editor_item(GEditorItem *); -/* Lance une actualisation du fait d'un changement de binaire. */ -void change_editor_items_current_binary(GLoadedBinary *); +/* Lance une actualisation du fait d'un changement de contenu. */ +void change_editor_items_current_content(GLoadedContent *); /* Lance une actualisation du fait d'un changement de vue. */ void change_editor_items_current_view(GLoadedPanel *); /* Lance une actualisation du fait d'un changement de contenu. */ -void change_editor_items_current_view_content(GLoadedPanel *); +void update_editor_items_current_view(GLoadedPanel *); /* Concentre l'attention de l'ensemble sur une adresse donnée. */ -void focus_address_in_editor_items(GLoadedBinary *, const vmpa2t *, GEditorItem *); +void focus_cursor_in_editor_items(GLoadedContent *, const GLineCursor *, GEditorItem *); /* Lance une actualisation relative à l'étendue du projet. */ void update_project_area(GStudyProject *); diff --git a/src/gui/editem-int.h b/src/gui/editem-int.h index 801e54c..744a55f 100644 --- a/src/gui/editem-int.h +++ b/src/gui/editem-int.h @@ -34,24 +34,23 @@ #include "../analysis/project.h" #include "../common/dllist.h" -#include "../gtkext/gtkdisplaypanel.h" -/* Réagit à un changement du binaire courant. */ -typedef void (* update_item_binary_fc) (GEditorItem *, GLoadedBinary *); +/* Réagit à un changement de contenu chargé en cours d'analyse. */ +typedef void (* change_item_content_fc) (GEditorItem *, GLoadedContent *, GLoadedContent *); -/* Réagit à un changement d'affichage principal de contenu. */ -typedef void (* update_item_view_fc) (GEditorItem *, GLoadedPanel *); +/* Réagit à un changement de vue du contenu en cours d'analyse. */ +typedef void (* change_item_view_fc) (GEditorItem *, GLoadedPanel *, GLoadedPanel *); -/* Réagit à un changement de focus des panneaux d'affichage. */ -typedef void (* notify_focus_change_fc) (GEditorItem *, GLoadedPanel *); +/* Réagit à une modification de la vue du contenu analysé. */ +typedef void (* update_item_view_fc) (GEditorItem *, GLoadedPanel *); /* Suit les changements de position dans du code d'assembleur. */ -typedef void (* track_caret_in_view_fc) (GEditorItem *, GtkDisplayPanel *, const vmpa2t *); +typedef void (* track_cursor_in_view_fc) (GEditorItem *, GLoadedPanel *, const GLineCursor *); /* Concentre l'attention de l'ensemble sur une adresse donnée. */ -typedef void (* focus_addr_fc) (GEditorItem *, GLoadedBinary *, const vmpa2t *); +typedef void (* focus_cursor_fc) (GEditorItem *, GLoadedContent *, const GLineCursor *); /* Lance une actualisation relative à l'étendue du projet. */ typedef void (* update_project_fc) (GEditorItem *, GStudyProject *); @@ -77,12 +76,11 @@ struct _GEditorItemClass { GObjectClass parent; /* A laisser en premier */ - update_item_binary_fc update_binary; /* Changement de binaire */ - update_item_view_fc update_view; /* Rechargement dû à une vue */ - update_item_view_fc update_content; /* Rechargement dû à un contenu*/ - notify_focus_change_fc notify_focus; /* Gain ou perte de focus */ - track_caret_in_view_fc track_caret; /* Suivi des positions */ - focus_addr_fc focus_addr; /* Prête attention à une addr. */ + change_item_content_fc change_content; /* Changement de contenu */ + change_item_view_fc change_view; /* Rechargement dû à une vue */ + update_item_view_fc update_view; /* Rechargement dû à évolutions*/ + track_cursor_in_view_fc track_cursor; /* Suivi des positions */ + focus_cursor_fc focus_cursor; /* Prête attention à une addr. */ update_project_fc update_project; /* Actualisation des binaires */ }; diff --git a/src/gui/editem.c b/src/gui/editem.c index bf3dfa6..ef7cb30 100644 --- a/src/gui/editem.c +++ b/src/gui/editem.c @@ -136,10 +136,114 @@ GtkWidget *g_editor_item_get_widget(const GEditorItem *item) /****************************************************************************** * * -* Paramètres : bar = instance à actualiser. * -* panel = composant d'affichage concerné par l'opération. * +* Paramètres : item = instance à consulter. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * +* * +* Description : Réagit à un changement de contenu chargé en cours d'analyse. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_editor_item_change_content(GEditorItem *item, GLoadedContent *old, GLoadedContent *new) +{ + GEditorItemClass *klass; /* Classe correspondante */ + + klass = G_EDITOR_ITEM_GET_CLASS(item); + + if (klass->change_content != NULL) + klass->change_content(item, old, new); + +} + + +/****************************************************************************** +* * +* Paramètres : item = instance à consulter. * +* old = ancienne vue du contenu chargé analysé. * +* new = nouvelle vue du contenu chargé analysé. * +* * +* Description : Réagit à un changement de vue du contenu en cours d'analyse. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_editor_item_change_view(GEditorItem *item, GLoadedPanel *old, GLoadedPanel *new) +{ + GEditorItemClass *klass; /* Classe correspondante */ + + klass = G_EDITOR_ITEM_GET_CLASS(item); + + if (klass->change_view != NULL) + klass->change_view(item, old, new); + +} + + +/****************************************************************************** +* * +* Paramètres : item = instance à consulter. * +* panel = vue du contenu chargé analysé modifiée. * +* * +* Description : Réagit à une modification de la vue du contenu analysé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_editor_item_update_view(GEditorItem *item, GLoadedPanel *panel) +{ + GEditorItemClass *klass; /* Classe correspondante */ + + klass = G_EDITOR_ITEM_GET_CLASS(item); + + if (klass->update_view != NULL) + klass->update_view(item, panel); + +} + + +/****************************************************************************** +* * +* Paramètres : item = instance à consulter. * +* panel = composant d'affichage parcouru. * +* cursor = nouvel emplacement du curseur courant. * +* * +* Description : Réagit à une modification de la vue du contenu analysé. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void g_editor_item_track_cursor(GEditorItem *item, GLoadedPanel *panel, const GLineCursor *cursor) +{ + GEditorItemClass *klass; /* Classe correspondante */ + + klass = G_EDITOR_ITEM_GET_CLASS(item); + + if (klass->track_cursor != NULL) + klass->track_cursor(item, panel, cursor); + +} + + +/****************************************************************************** +* * +* Paramètres : item = instance à consulter. * +* content = contenu contenant le curseur à représenter. * +* cursor = nouvel emplacement du curseur courant. * * * -* Description : Réagit à un changement de focus des panneaux d'affichage. * +* Description : Réagit à une modification de la vue du contenu analysé. * * * * Retour : - * * * @@ -147,13 +251,13 @@ GtkWidget *g_editor_item_get_widget(const GEditorItem *item) * * ******************************************************************************/ -void notify_focus_change_for_editor_item(GEditorItem *item, GLoadedPanel *panel) +void g_editor_item_focus_cursor(GEditorItem *item, GLoadedContent *content, const GLineCursor *cursor) { GEditorItemClass *klass; /* Classe correspondante */ klass = G_EDITOR_ITEM_GET_CLASS(item); - if (klass->notify_focus != NULL) - klass->notify_focus(item, panel); + if (klass->focus_cursor != NULL) + klass->focus_cursor(item, content, cursor); } diff --git a/src/gui/editem.h b/src/gui/editem.h index f102d5c..5adc288 100644 --- a/src/gui/editem.h +++ b/src/gui/editem.h @@ -30,16 +30,17 @@ #include +#include "../analysis/loaded.h" #include "../glibext/gloadedpanel.h" -#define G_TYPE_EDITOR_ITEM g_editor_item_get_type() -#define G_EDITOR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_editor_item_get_type(), GEditorItem)) -#define G_IS_EDITOR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_editor_item_get_type())) -#define G_EDITOR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), G_TYPE_EDITOR_ITEM, GEditorItemClass)) -#define G_IS_EDITOR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), G_TYPE_EDITOR_ITEM)) -#define G_EDITOR_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_EDITOR_ITEM, GEditorItemClass)) +#define G_TYPE_EDITOR_ITEM g_editor_item_get_type() +#define G_EDITOR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_editor_item_get_type(), GEditorItem)) +#define G_IS_EDITOR_ITEM(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_editor_item_get_type())) +#define G_EDITOR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), g_editor_item_get_type(), GEditorItemClass)) +#define G_IS_EDITOR_ITEM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), g_editor_item_get_type())) +#define G_EDITOR_ITEM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), g_editor_item_get_type(), GEditorItemClass)) /* Elément réactif quelconque de l'éditeur (instance) */ @@ -61,8 +62,20 @@ const char *g_editor_item_get_name(const GEditorItem *); /* Fournit le composant GTK associé à l'élément réactif. */ GtkWidget *g_editor_item_get_widget(const GEditorItem *); -/* Réagit à un changement de focus des panneaux d'affichage. */ -void notify_focus_change_for_editor_item(GEditorItem *, GLoadedPanel *); +/* Réagit à un changement de contenu chargé en cours d'analyse. */ +void g_editor_item_change_content(GEditorItem *, GLoadedContent *, GLoadedContent *); + +/* Réagit à un changement de vue du contenu en cours d'analyse. */ +void g_editor_item_change_view(GEditorItem *, GLoadedPanel *, GLoadedPanel *); + +/* Réagit à une modification de la vue du contenu analysé. */ +void g_editor_item_update_view(GEditorItem *, GLoadedPanel *); + +/* Réagit à une modification de la vue du contenu analysé. */ +void g_editor_item_track_cursor(GEditorItem *, GLoadedPanel *, const GLineCursor *); + +/* Réagit à une modification de la vue du contenu analysé. */ +void g_editor_item_focus_cursor(GEditorItem *, GLoadedContent *, const GLineCursor *); diff --git a/src/gui/editor.c b/src/gui/editor.c index d63b3a9..3b8497c 100644 --- a/src/gui/editor.c +++ b/src/gui/editor.c @@ -389,7 +389,8 @@ GtkWidget *create_editor(void) register_project_change_notification(notify_editor_project_change); - change_editor_items_current_binary(NULL); + change_editor_items_current_content(NULL); + change_editor_items_current_view(NULL); @@ -1374,8 +1375,8 @@ void on_panel_item_undock_request(GPanelItem *panel, gpointer unused) static void on_dock_item_switch(GtkDockStation *station, GtkWidget *widget, gpointer unused) { - GLoadedBinary *old_binary; /* Ancien binaire édité */ - GLoadedBinary *binary; /* Binaire en cours d'édition */ + GLoadedPanel *panel; /* Vue du contenu chargé */ + GLoadedContent *content; /* Contenu en cours d'édition */ if (GTK_IS_SCROLLED_WINDOW(widget)) widget = gtk_bin_get_child(GTK_BIN(widget)); @@ -1383,23 +1384,17 @@ static void on_dock_item_switch(GtkDockStation *station, GtkWidget *widget, gpoi if (GTK_IS_VIEWPORT(widget)) widget = gtk_bin_get_child(GTK_BIN(widget)); - if (GTK_IS_DISPLAY_PANEL(widget)) + if (G_IS_LOADED_PANEL(widget)) { - /* Changement de binaire ? */ + panel = G_LOADED_PANEL(widget); - old_binary = get_current_binary(); - binary = gtk_display_panel_get_binary(GTK_DISPLAY_PANEL(widget)); + content = g_loaded_panel_get_content(panel); - if (old_binary != binary) - change_editor_items_current_binary(binary); - else - g_object_unref(G_OBJECT(binary)); + change_editor_items_current_content(content); - if (old_binary != NULL) - g_object_unref(G_OBJECT(old_binary)); + g_object_unref(G_OBJECT(content)); - g_object_ref(G_OBJECT(widget)); - change_editor_items_current_view(G_LOADED_PANEL(widget)); + change_editor_items_current_view(panel); } diff --git a/src/gui/menus/binary.c b/src/gui/menus/binary.c index b7be1b9..1360011 100644 --- a/src/gui/menus/binary.c +++ b/src/gui/menus/binary.c @@ -34,6 +34,7 @@ #include "../dialogs/gotox.h" #include "../dialogs/storage.h" #include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkdisplaypanel.h" @@ -106,10 +107,9 @@ GtkWidget *build_menu_binary(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *ba /****************************************************************************** * * -* Paramètres : ref = espace de référencements à consulter. * -* panel = panneau d'affichage actif ou NULL si aucun. * +* Paramètres : new = nouveau contenu chargé à analyser. * * * -* Description : Met à jour les accès du menu "Binaire" selon le contenu. * +* Description : Réagit à un changement d'affichage principal de contenu. * * * * Retour : - * * * @@ -117,14 +117,17 @@ GtkWidget *build_menu_binary(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *ba * * ******************************************************************************/ -void update_access_in_menu_binary(GObject *ref, GtkDisplayPanel *panel) +void update_access_for_content_in_menu_binary(GLoadedContent *new) { + GObject *ref; /* Espace de référencements */ gboolean access; /* Accès à déterminer */ GtkWidget *item; /* Elément de menu à traiter */ /* Préliminaire */ - access = (panel != NULL); + ref = get_global_ref(); + + access = G_IS_LOADED_BINARY(new); /* Menus */ @@ -155,19 +158,14 @@ void update_access_in_menu_binary(GObject *ref, GtkDisplayPanel *panel) static void mcb_binary_entry_points(GtkMenuItem *menuitem, GMenuBar *bar) { - GEditorItem *item; /* Elément d'éditeur graphique */ - GObject *ref; /* Espace de référencements */ GLoadedBinary *binary; /* Binaire présenté à l'écran */ GtkWidget *dialog; /* Boîte de dialogue à montrer */ vmpa2t *addr; /* Adresse de destination */ GLoadedPanel *panel; /* Afficheur effectif de code */ - item = G_EDITOR_ITEM(bar); + binary = G_LOADED_BINARY(get_current_content()); - ref = g_editor_item_get_global_ref(item); - binary = get_current_binary(); - - dialog = create_gotox_dialog_for_entry_points(GTK_WINDOW(ref), binary); + dialog = create_gotox_dialog_for_entry_points(get_editor_window(), binary); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { @@ -226,14 +224,12 @@ static void mcb_binary_attach_debugger(GtkMenuItem *menuitem, GMenuBar *bar) static void mcb_binary_storage(GtkMenuItem *menuitem, GMenuBar *bar) { GLoadedBinary *binary; /* Edition courante */ - GObject *ref; /* Espace de référencements */ GtkBuilder *builder; /* Constructeur utilisé */ GtkWidget *dialog; /* Boîte de dialogue à montrer */ - binary = get_current_binary(); - ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(bar)); + binary = G_LOADED_BINARY(get_current_content()); - dialog = create_storage_dialog(binary, GTK_WINDOW(ref), &builder); + dialog = create_storage_dialog(binary, get_editor_window(), &builder); gtk_dialog_run(GTK_DIALOG(dialog)); @@ -263,9 +259,9 @@ static void mcb_binary_export(GtkMenuItem *menuitem, GMenuBar *bar) { GLoadedBinary *binary; /* Edition courante */ - binary = get_current_binary(); + binary = G_LOADED_BINARY(get_current_content()); - run_export_assistant(binary, GTK_WINDOW(G_EDITOR_ITEM(bar)->ref)); + run_export_assistant(binary, get_editor_window()); g_object_unref(G_OBJECT(binary)); diff --git a/src/gui/menus/binary.h b/src/gui/menus/binary.h index a66fe26..45140b6 100644 --- a/src/gui/menus/binary.h +++ b/src/gui/menus/binary.h @@ -30,15 +30,15 @@ #include "menubar.h" -#include "../../gtkext/gtkdisplaypanel.h" +#include "../../analysis/loaded.h" /* Construit le menu "Binaire". */ GtkWidget *build_menu_binary(GObject *, GtkAccelGroup *, GMenuBar *); -/* Met à jour les accès du menu "Binaire" selon le contenu. */ -void update_access_in_menu_binary(GObject *, GtkDisplayPanel *); +/* Réagit à un changement d'affichage principal de contenu. */ +void update_access_for_content_in_menu_binary(GLoadedContent *); diff --git a/src/gui/menus/edition.c b/src/gui/menus/edition.c index 08745b6..4a24d33 100644 --- a/src/gui/menus/edition.c +++ b/src/gui/menus/edition.c @@ -37,7 +37,11 @@ #include "../dialogs/gotox.h" #include "../../analysis/db/items/switcher.h" #include "../../arch/target.h" +#include "../../glibext/gbinarycursor.h" #include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkblockdisplay.h" +#include "../../gtkext/gtkdisplaypanel.h" +#include "../../gtkext/gtkgraphdisplay.h" @@ -103,14 +107,20 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b menubar = qck_create_menu(GTK_MENU_ITEM(result)); - submenuitem = qck_create_menu_item(NULL, NULL, _("Go to address..."), + /* Déplacements ciblés */ + + submenuitem = qck_create_menu_item(ref, "mnu_edit_goto", _("Go to address..."), G_CALLBACK(mcb_edition_goto), bar); add_accelerator_to_menu_item(submenuitem, "G", accgroup); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + /* Séparation */ + submenuitem = qck_create_menu_separator(); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); + /* Bascule des opérandes numériques */ + submenuitem = qck_create_menu_item(NULL, NULL, _("Numeric operand"), NULL, NULL); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); @@ -153,7 +163,7 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b submenuitem = qck_create_menu_separator(); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - /* Déplacements */ + /* Suivi de cibles */ submenuitem = qck_create_menu_item(ref, "mnu_edit_go_back", _("Go back"), G_CALLBACK(mcb_edition_go_back), bar); @@ -182,12 +192,12 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b deepmenubar = qck_create_menu(GTK_MENU_ITEM(submenuitem)); - deepmenuitem = qck_create_menu_item(NULL, NULL, _("Toggle at current location"), + deepmenuitem = qck_create_menu_item(ref, "mnu_edit_toggle_bmark", _("Toggle at current location"), G_CALLBACK(mcb_edition_bookmarks_toggle), bar); add_accelerator_to_menu_item(deepmenuitem, "D", accgroup); gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); - deepmenuitem = qck_create_menu_item(NULL, NULL, _("Delete all bookmarks"), + deepmenuitem = qck_create_menu_item(ref, "mnu_edit_delete_bmarks", _("Delete all bookmarks"), G_CALLBACK(mcb_edition_bookmarks_delete_all), bar); gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); @@ -198,22 +208,22 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b deepmenubar = qck_create_menu(GTK_MENU_ITEM(submenuitem)); - deepmenuitem = qck_create_menu_item(NULL, NULL, _("Enter a comment..."), + deepmenuitem = qck_create_menu_item(ref, "mnu_edit_enter_comment", _("Enter a comment..."), G_CALLBACK(mcb_edition_comment_enter), bar); add_accelerator_to_menu_item(deepmenuitem, "semicolon", accgroup); gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); - deepmenuitem = qck_create_menu_item(NULL, NULL, _("Enter a repeatable comment..."), + deepmenuitem = qck_create_menu_item(ref, "mnu_edit_enter_rep_comment", _("Enter a repeatable comment..."), G_CALLBACK(mcb_edition_comment_enter_repeatable), bar); add_accelerator_to_menu_item(deepmenuitem, "colon", accgroup); gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); - deepmenuitem = qck_create_menu_item(NULL, NULL, _("Enter a comment in the previous line..."), + deepmenuitem = qck_create_menu_item(ref, "mnu_edit_enter_prev", _("Enter a comment in the previous line..."), G_CALLBACK(mcb_edition_comment_enter_previous), bar); add_accelerator_to_menu_item(deepmenuitem, "Insert", accgroup); gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); - deepmenuitem = qck_create_menu_item(NULL, NULL, _("Enter a comment in the next line..."), + deepmenuitem = qck_create_menu_item(ref, "mnu_edit_enter_next", _("Enter a comment in the next line..."), G_CALLBACK(mcb_edition_comment_enter_next), bar); add_accelerator_to_menu_item(deepmenuitem, "Insert", accgroup); gtk_container_add(GTK_CONTAINER(deepmenubar), deepmenuitem); @@ -225,9 +235,96 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b /****************************************************************************** * * -* Paramètres : ref = espace de référencements à consulter. * -* panel = panneau d'affichage actif ou NULL si aucun. * -* addr = nouvelle adresse du curseur courant. * +* Paramètres : new = nouvelle vue du contenu chargé analysé. * +* * +* Description : Lance une actualisation du fait d'un changement de support. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +void update_access_for_view_in_menu_edition(GLoadedPanel *new) +{ + GObject *ref; /* Espace de référencements */ + gboolean access; /* Accès à déterminer */ + GtkWidget *item; /* Elément de menu à traiter */ + + ref = get_global_ref(); + + /* Déplacements ciblés */ + + access = GTK_IS_BLOCK_DISPLAY(new) || GTK_IS_GRAPH_DISPLAY(new); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_goto")); + gtk_widget_set_sensitive(item, access); + + /* Bascule des opérandes numériques */ + + access = GTK_IS_BLOCK_DISPLAY(new) || GTK_IS_GRAPH_DISPLAY(new); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_hex")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_dec")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_oct")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_bin")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_switch_def")); + gtk_widget_set_sensitive(item, access); + + /* Suivi de cibles */ + + access = GTK_IS_BLOCK_DISPLAY(new) || GTK_IS_GRAPH_DISPLAY(new); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_go_back")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_follow_ref")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_list_xrefs")); + gtk_widget_set_sensitive(item, access); + + /* Signets */ + + access = GTK_IS_BLOCK_DISPLAY(new) || GTK_IS_GRAPH_DISPLAY(new); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_toggle_bmark")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_delete_bmarks")); + gtk_widget_set_sensitive(item, access); + + /* Commentaires */ + + access = GTK_IS_BLOCK_DISPLAY(new) || GTK_IS_GRAPH_DISPLAY(new); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_enter_comment")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_enter_rep_comment")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_enter_prev")); + gtk_widget_set_sensitive(item, access); + + item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_enter_next")); + gtk_widget_set_sensitive(item, access); + +} + + +/****************************************************************************** +* * +* Paramètres : panel = vue d'affichage active ou NULL si aucune. * +* cursor = suivi des positions à consulter. * * * * Description : Met à jour les accès du menu "Edition" selon une position. * * * @@ -237,19 +334,35 @@ GtkWidget *build_menu_edition(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *b * * ******************************************************************************/ -void update_access_in_menu_edition(GObject *ref, GtkDisplayPanel *panel, const vmpa2t *addr) +void update_access_for_cursor_in_menu_edition(GLoadedPanel *panel, const GLineCursor *cursor) { + GObject *ref; /* Espace de référencements */ GObject *creator; /* Créateur à l'orgine du seg. */ gboolean access; /* Accès à déterminer */ GtkWidget *item; /* Elément de menu à traiter */ + ref = get_global_ref(); + /* Préliminaire */ - if (panel == NULL || addr == NULL) - creator = NULL; + /** + * Seuls les affichages de blocs (en graphique ou non) distribuent ce + * genre de curseur. Donc on valide dans le même temps la nature de la vue. + */ + + if (G_IS_BINARY_CURSOR(cursor)) + { + assert(GTK_IS_BLOCK_DISPLAY(panel) || GTK_IS_GRAPH_DISPLAY(panel)); + + if (g_line_cursor_is_valid(cursor)) + creator = gtk_display_panel_get_active_object(GTK_DISPLAY_PANEL(panel)); + else + cursor = NULL; + + } else - creator = gtk_display_panel_get_active_object(panel); + creator = NULL; /* Bascule des opérandes numériques */ @@ -277,14 +390,15 @@ void update_access_in_menu_edition(GObject *ref, GtkDisplayPanel *panel, const v item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_follow_ref")); gtk_widget_set_sensitive(item, access); - access = (addr != NULL);; + access = g_line_cursor_is_valid(cursor); item = GTK_WIDGET(g_object_get_data(ref, "mnu_edit_list_xrefs")); gtk_widget_set_sensitive(item, access); /* Nettoyage et sortie finale */ - if (creator != NULL) g_object_unref(G_OBJECT(creator)); + if (creator != NULL) + g_object_unref(G_OBJECT(creator)); } @@ -317,9 +431,9 @@ static void mcb_edition_goto(GtkMenuItem *menuitem, GMenuBar *bar) addr = get_address_from_goto_dialog(dialog); panel = get_current_view(); + assert(GTK_IS_BLOCK_DISPLAY(panel) || GTK_IS_GRAPH_DISPLAY(panel)); - if (GTK_IS_DISPLAY_PANEL(panel)) - gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), addr); + gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), addr); g_object_unref(G_OBJECT(panel)); @@ -359,32 +473,29 @@ static void mcb_edition_switch_numeric_operand(GtkMenuItem *menuitem, gpointer u display = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(menuitem), "kind_of_switch")); panel = get_current_view(); + assert(GTK_IS_BLOCK_DISPLAY(panel) || GTK_IS_GRAPH_DISPLAY(panel)); - if (GTK_IS_DISPLAY_PANEL(panel)) - { - creator = gtk_display_panel_get_active_object(GTK_DISPLAY_PANEL(panel)); - assert(G_IS_IMM_OPERAND(creator)); + creator = gtk_display_panel_get_active_object(GTK_DISPLAY_PANEL(panel)); + assert(G_IS_IMM_OPERAND(creator)); - addr = gtk_display_panel_get_caret_location(GTK_DISPLAY_PANEL(panel)); + addr = gtk_display_panel_get_caret_location(GTK_DISPLAY_PANEL(panel)); - binary = get_current_binary(); - proc = g_loaded_binary_get_processor(binary); + binary = G_LOADED_BINARY(get_current_content()); + proc = g_loaded_binary_get_processor(binary); - instr = g_arch_processor_find_instr_by_address(proc, addr); - assert(instr != NULL); + instr = g_arch_processor_find_instr_by_address(proc, addr); + assert(instr != NULL); - switcher = g_db_switcher_new(instr, G_IMM_OPERAND(creator), display); + switcher = g_db_switcher_new(instr, G_IMM_OPERAND(creator), display); - g_object_unref(G_OBJECT(instr)); + g_object_unref(G_OBJECT(instr)); - g_loaded_binary_add_to_collection(binary, G_DB_ITEM(switcher)); + g_loaded_binary_add_to_collection(binary, G_DB_ITEM(switcher)); - g_object_unref(G_OBJECT(proc)); - g_object_unref(G_OBJECT(binary)); - - g_object_unref(creator); + g_object_unref(G_OBJECT(proc)); + g_object_unref(G_OBJECT(binary)); - } + g_object_unref(creator); g_object_unref(G_OBJECT(panel)); @@ -432,35 +543,32 @@ static void mcb_edition_follow_ref(GtkMenuItem *menuitem, gpointer unused) virt_t virt; /* Adresse virtuelle */ panel = get_current_view(); + assert(GTK_IS_BLOCK_DISPLAY(panel) || GTK_IS_GRAPH_DISPLAY(panel)); - if (GTK_IS_DISPLAY_PANEL(panel)) - { - creator = gtk_display_panel_get_active_object(GTK_DISPLAY_PANEL(panel)); - assert(creator != NULL); + creator = gtk_display_panel_get_active_object(GTK_DISPLAY_PANEL(panel)); + assert(creator != NULL); - defined = false; + defined = false; - if (G_IS_TARGET_OPERAND(creator)) - { - g_target_operand_get_addr(G_TARGET_OPERAND(creator), &addr); - defined = true; - } + if (G_IS_TARGET_OPERAND(creator)) + { + g_target_operand_get_addr(G_TARGET_OPERAND(creator), &addr); + defined = true; + } - else if (G_IS_IMM_OPERAND(creator)) + else if (G_IS_IMM_OPERAND(creator)) + { + if (g_imm_operand_to_virt_t(G_IMM_OPERAND(creator), &virt)) { - if (g_imm_operand_to_virt_t(G_IMM_OPERAND(creator), &virt)) - { - init_vmpa(&addr, VMPA_NO_PHYSICAL, virt); - defined = true; - } + init_vmpa(&addr, VMPA_NO_PHYSICAL, virt); + defined = true; } + } - if (defined) - gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), &addr); + if (defined) + gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), &addr); - g_object_unref(creator); - - } + g_object_unref(creator); g_object_unref(G_OBJECT(panel)); @@ -492,51 +600,48 @@ static void mcb_edition_list_xrefs(GtkMenuItem *menuitem, GMenuBar *bar) vmpa2t *dest; /* Adresse de destination */ panel = get_current_view(); + assert(GTK_IS_BLOCK_DISPLAY(panel) || GTK_IS_GRAPH_DISPLAY(panel)); - if (GTK_IS_DISPLAY_PANEL(panel)) - { - addr = gtk_display_panel_get_caret_location(GTK_DISPLAY_PANEL(panel)); - - binary = get_current_binary(); - proc = g_loaded_binary_get_processor(binary); - - /** - * On ne peut pas se reposer sur l'espace couvert par une ligne, car il peut - * être de taille nulle (cas d'une étiquette, par exemple), à la différence - * de la taille d'une instruction. - * - * Il faut ainsi être plus souple, et se baser sur l'espace couvert par - * une ligne mais sur l'adresse uniquement. - */ - instr = g_arch_processor_find_instr_by_address(proc, addr); - - if (instr != NULL) - { - ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(bar)); + addr = gtk_display_panel_get_caret_location(GTK_DISPLAY_PANEL(panel)); - dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), binary, instr, true); + binary = G_LOADED_BINARY(get_current_content()); + proc = g_loaded_binary_get_processor(binary); - if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) - { - dest = get_address_from_gotox_dialog(dialog); + /** + * On ne peut pas se reposer sur l'espace couvert par une ligne, car il peut + * être de taille nulle (cas d'une étiquette, par exemple), à la différence + * de la taille d'une instruction. + * + * Il faut ainsi être plus souple, et se baser sur l'espace couvert par + * une ligne mais sur l'adresse uniquement. + */ + instr = g_arch_processor_find_instr_by_address(proc, addr); - gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), dest); + if (instr != NULL) + { + ref = g_editor_item_get_global_ref(G_EDITOR_ITEM(bar)); - delete_vmpa(dest); + dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), binary, instr, true); - } + if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) + { + dest = get_address_from_gotox_dialog(dialog); - gtk_widget_destroy(dialog); + gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), dest); - g_object_unref(G_OBJECT(instr)); + delete_vmpa(dest); } - g_object_unref(G_OBJECT(proc)); - g_object_unref(G_OBJECT(binary)); + gtk_widget_destroy(dialog); + + g_object_unref(G_OBJECT(instr)); } + g_object_unref(G_OBJECT(proc)); + g_object_unref(G_OBJECT(binary)); + g_object_unref(G_OBJECT(panel)); } @@ -570,15 +675,13 @@ static void mcb_edition_bookmarks_toggle(GtkMenuItem *menuitem, GMenuBar *bar) /* Détermination de l'adresse visée */ panel = get_current_view(); - - if (!GTK_IS_DISPLAY_PANEL(panel)) - goto done_with_panel; + assert(GTK_IS_BLOCK_DISPLAY(panel) || GTK_IS_GRAPH_DISPLAY(panel)); curloc = gtk_display_panel_get_caret_location(GTK_DISPLAY_PANEL(panel)); /* Accès à la collection */ - binary = get_current_binary(); + binary = G_LOADED_BINARY(get_current_content()); collec = g_loaded_binary_find_collection(binary, DBF_BOOKMARKS); /** @@ -636,8 +739,6 @@ static void mcb_edition_bookmarks_toggle(GtkMenuItem *menuitem, GMenuBar *bar) g_object_unref(G_OBJECT(collec)); g_object_unref(G_OBJECT(binary)); - done_with_panel: - g_object_unref(G_OBJECT(panel)); } diff --git a/src/gui/menus/edition.h b/src/gui/menus/edition.h index f863568..a49e320 100644 --- a/src/gui/menus/edition.h +++ b/src/gui/menus/edition.h @@ -30,15 +30,18 @@ #include "menubar.h" -#include "../../gtkext/gtkdisplaypanel.h" +#include "../../glibext/gloadedpanel.h" /* Construit le menu "Edition". */ GtkWidget *build_menu_edition(GObject *, GtkAccelGroup *, GMenuBar *); +/* Lance une actualisation du fait d'un changement de support. */ +void update_access_for_view_in_menu_edition(GLoadedPanel *); + /* Met à jour les accès du menu "Edition" selon une position. */ -void update_access_in_menu_edition(GObject *, GtkDisplayPanel *, const vmpa2t *); +void update_access_for_cursor_in_menu_edition(GLoadedPanel *, const GLineCursor *); diff --git a/src/gui/menus/menubar.c b/src/gui/menus/menubar.c index 989d964..7bc7e85 100644 --- a/src/gui/menus/menubar.c +++ b/src/gui/menus/menubar.c @@ -76,14 +76,14 @@ static void g_menu_bar_dispose(GMenuBar *); /* Procède à la libération totale de la mémoire. */ static void g_menu_bar_finalize(GMenuBar *); -/* Lance une actualisation du fait d'un changement de vue. */ -static void update_menu_bar_for_view(GMenuBar *, GtkDisplayPanel *); +/* Réagit à un changement d'affichage principal de contenu. */ +static void change_menubar_current_content(GMenuBar *, GLoadedContent *, GLoadedContent *); -/* Réagit à un changement de focus des panneaux d'affichage. */ -static void notify_focus_change_for_menu_bar(GMenuBar *, GtkDisplayPanel *); +/* Lance une actualisation du fait d'un changement de support. */ +static void change_menubar_current_view(GMenuBar *, GLoadedPanel *, GLoadedPanel *); /* Met à jour les accès aux menus en fonction de la position. */ -static void track_caret_address_for_menu_bar(GMenuBar *, GtkDisplayPanel *, const vmpa2t *); +static void track_caret_address_for_menu_bar(GMenuBar *, GLoadedPanel *, const GLineCursor *); /* Lance une actualisation relative à l'étendue du projet. */ static void update_menu_bar_for_project(GMenuBar *, GStudyProject *); @@ -118,9 +118,9 @@ static void g_menu_bar_class_init(GMenuBarClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_view = (update_item_view_fc)update_menu_bar_for_view; - editem->notify_focus = (notify_focus_change_fc)notify_focus_change_for_menu_bar; - editem->track_caret = (track_caret_in_view_fc)track_caret_address_for_menu_bar; + editem->change_content = (change_item_content_fc)change_menubar_current_content; + editem->change_view = (change_item_view_fc)change_menubar_current_view; + editem->track_cursor = (track_cursor_in_view_fc)track_caret_address_for_menu_bar; editem->update_project = (update_project_fc)update_menu_bar_for_project; } @@ -264,10 +264,6 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup) result->help = build_menu_help(ref, accgroup); gtk_container_add(GTK_CONTAINER(item->widget), result->help); - /* Finalisation générique */ - - notify_focus_change_for_menu_bar(result, NULL); - return G_EDITOR_ITEM(result); } @@ -275,10 +271,11 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup) /****************************************************************************** * * -* Paramètres : bar = barre de menus à actualiser. * -* panel = nouveau panneau d'affichage actif. * +* Paramètres : bar = barre de menus à mettre à jour. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * -* Description : Lance une actualisation du fait d'un changement de vue. * +* Description : Réagit à un changement d'affichage principal de contenu. * * * * Retour : - * * * @@ -286,19 +283,20 @@ GEditorItem *g_menu_bar_new(GObject *ref, GtkAccelGroup *accgroup) * * ******************************************************************************/ -static void update_menu_bar_for_view(GMenuBar *bar, GtkDisplayPanel *panel) +static void change_menubar_current_content(GMenuBar *bar, GLoadedContent *old, GLoadedContent *new) { - update_menu_view_for_view(bar->view, panel, bar); + update_access_for_content_in_menu_binary(new); } /****************************************************************************** * * -* Paramètres : bar = barre de menus à actualiser. * -* panel = composant d'affichage concerné par l'opération. * +* Paramètres : bar = barre de menus à mettre à jour. * +* old = ancienne vue du contenu chargé analysé. * +* new = nouvelle vue du contenu chargé analysé. * * * -* Description : Réagit à un changement de focus des panneaux d'affichage. * +* Description : Lance une actualisation du fait d'un changement de support. * * * * Retour : - * * * @@ -306,23 +304,12 @@ static void update_menu_bar_for_view(GMenuBar *bar, GtkDisplayPanel *panel) * * ******************************************************************************/ -static void notify_focus_change_for_menu_bar(GMenuBar *bar, GtkDisplayPanel *panel) +static void change_menubar_current_view(GMenuBar *bar, GLoadedPanel *old, GLoadedPanel *new) { - const vmpa2t *addr; /* Position courante */ - GEditorItem *item; /* Autre version de l'élément */ - - if (panel != NULL) - addr = gtk_display_panel_get_caret_location(panel); - else - addr = NULL; - - item = G_EDITOR_ITEM(bar); - - update_access_in_menu_edition(item->ref, panel, addr); + update_access_for_view_in_menu_edition(new); - update_access_in_menu_view(item->ref, panel); - - update_access_in_menu_binary(item->ref, panel); + rebuild_menu_view(bar->view, new, bar); + update_access_for_view_in_menu_view(G_EDITOR_ITEM(bar)->ref, new); } @@ -330,8 +317,8 @@ static void notify_focus_change_for_menu_bar(GMenuBar *bar, GtkDisplayPanel *pan /****************************************************************************** * * * Paramètres : bar = barre de menus à actualiser. * -* panel = panneau d'affichage actif ou NULL si aucun. * -* addr = nouvelle adresse du curseur courant. * +* panel = composant d'affichage parcouru. * +* cursor = nouvel emplacement du curseur courant. * * * * Description : Met à jour les accès aux menus en fonction de la position. * * * @@ -341,13 +328,9 @@ static void notify_focus_change_for_menu_bar(GMenuBar *bar, GtkDisplayPanel *pan * * ******************************************************************************/ -static void track_caret_address_for_menu_bar(GMenuBar *bar, GtkDisplayPanel *panel, const vmpa2t *addr) +static void track_caret_address_for_menu_bar(GMenuBar *bar, GLoadedPanel *panel, const GLineCursor *cursor) { - GEditorItem *item; /* Autre version de l'élément */ - - item = G_EDITOR_ITEM(bar); - - update_access_in_menu_edition(item->ref, panel, addr); + update_access_for_cursor_in_menu_edition(panel, cursor); } diff --git a/src/gui/menus/view.c b/src/gui/menus/view.c index dfbf152..f0e7450 100644 --- a/src/gui/menus/view.c +++ b/src/gui/menus/view.c @@ -105,7 +105,7 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) qck_create_menu(GTK_MENU_ITEM(submenuitem)); - /* - */ + /* Séparation */ submenuitem = qck_create_menu_separator(); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); @@ -138,7 +138,7 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) add_accelerator_to_menu_item(submenuitem, "Tab", accgroup); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - /* - */ + /* Séparation */ submenuitem = qck_create_menu_separator(); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); @@ -160,7 +160,7 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) g_object_set_data(G_OBJECT(submenuitem), "kind_of_opt", GUINT_TO_POINTER(BLC_BINARY)); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); - /* - */ + /* Séparation */ submenuitem = qck_create_menu_separator(); gtk_container_add(GTK_CONTAINER(menubar), submenuitem); @@ -191,7 +191,7 @@ GtkWidget *build_menu_view(GObject *ref, GtkAccelGroup *accgroup, GMenuBar *bar) * * ******************************************************************************/ -void update_menu_view_for_view(GtkWidget *widget, GtkDisplayPanel *panel, GMenuBar *bar) +void rebuild_menu_view(GtkWidget *widget, GLoadedPanel *panel, GMenuBar *bar) { GObject *ref; /* Espace de référencements */ GtkRadioMenuItem *item; /* Elément de menu arbitraire */ @@ -246,9 +246,9 @@ void update_menu_view_for_view(GtkWidget *widget, GtkDisplayPanel *panel, GMenuB g_slist_foreach(radios, (GFunc)reconnect_display_radio, NULL); - /* - */ + /* Séparation */ - content = g_loaded_panel_get_content(G_LOADED_PANEL(panel)); + content = g_loaded_panel_get_content(panel); view_index = g_loaded_content_get_view_index(content, GTK_WIDGET(panel)); @@ -305,7 +305,7 @@ void update_menu_view_for_view(GtkWidget *widget, GtkDisplayPanel *panel, GMenuB * * ******************************************************************************/ -void update_access_in_menu_view(GObject *ref, GtkDisplayPanel *panel) +void update_access_for_view_in_menu_view(GObject *ref, GLoadedPanel *panel) { gboolean access; /* Accès à déterminer */ GtkWidget *item; /* Elément de menu à traiter */ diff --git a/src/gui/menus/view.h b/src/gui/menus/view.h index d42bbc6..5216bcb 100644 --- a/src/gui/menus/view.h +++ b/src/gui/menus/view.h @@ -30,7 +30,7 @@ #include "menubar.h" -#include "../../gtkext/gtkdisplaypanel.h" +#include "../../glibext/gloadedpanel.h" @@ -38,10 +38,10 @@ GtkWidget *build_menu_view(GObject *, GtkAccelGroup *, GMenuBar *); /* Lance une actualisation du fait d'un changement de vue. */ -void update_menu_view_for_view(GtkWidget *, GtkDisplayPanel *, GMenuBar *); +void rebuild_menu_view(GtkWidget *, GLoadedPanel *, GMenuBar *); /* Met à jour les accès du menu "Affichage" selon le contenu. */ -void update_access_in_menu_view(GObject *, GtkDisplayPanel *); +void update_access_for_view_in_menu_view(GObject *, GLoadedPanel *); diff --git a/src/gui/panels/bintree.c b/src/gui/panels/bintree.c index ecb18fe..5c8a19e 100644 --- a/src/gui/panels/bintree.c +++ b/src/gui/panels/bintree.c @@ -37,6 +37,7 @@ #include "updating-int.h" #include "../core/global.h" #include "../../core/queue.h" +#include "../../gtkext/gtkdisplaypanel.h" #include "../../gtkext/tmgt.h" @@ -118,7 +119,7 @@ static void on_depth_spin_value_changed(GtkSpinButton *, const GBintreePanel *); static void on_bintree_selection_changed(GtkTreeSelection *, gpointer); /* Réagit à un changement d'affichage principal de contenu. */ -static void change_bintree_panel_current_binary(GBintreePanel *, GLoadedBinary *); +static void change_bintree_panel_current_content(GBintreePanel *, GLoadedContent *, GLoadedContent *); @@ -230,7 +231,7 @@ static void g_bintree_panel_class_init(GBintreePanelClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_binary = (update_item_binary_fc)change_bintree_panel_current_binary; + editem->change_content = (change_item_content_fc)change_bintree_panel_current_content; panel = G_PANEL_ITEM_CLASS(klass); @@ -520,8 +521,9 @@ static void on_bintree_selection_changed(GtkTreeSelection *selection, gpointer u /****************************************************************************** * * -* Paramètres : panel = panneau à mettre à jour. * -* binary = nouvelle instance de binaire analysé. * +* Paramètres : panel = panneau à mettre à jour. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * * Description : Réagit à un changement d'affichage principal de contenu. * * * @@ -531,11 +533,17 @@ static void on_bintree_selection_changed(GtkTreeSelection *selection, gpointer u * * ******************************************************************************/ -static void change_bintree_panel_current_binary(GBintreePanel *panel, GLoadedBinary *binary) +static void change_bintree_panel_current_content(GBintreePanel *panel, GLoadedContent *old, GLoadedContent *new) { + GLoadedBinary *binary; /* Autre version de l'instance */ GtkBuilder *builder; /* Constructeur utilisé */ GtkTreeStore *store; /* Modèle de gestion */ + if (G_IS_LOADED_BINARY(new)) + binary = G_LOADED_BINARY(new); + else + binary = NULL; + /* Basculement du binaire utilisé */ if (panel->binary != NULL) diff --git a/src/gui/panels/bookmarks.c b/src/gui/panels/bookmarks.c index fd8af25..3c1e719 100644 --- a/src/gui/panels/bookmarks.c +++ b/src/gui/panels/bookmarks.c @@ -46,6 +46,7 @@ #include "../../glibext/chrysamarshal.h" #include "../../glibext/signal.h" #include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkdisplaypanel.h" #include "../../gtkext/gtkdockable-int.h" @@ -106,6 +107,8 @@ static void g_bookmarks_panel_dispose(GBookmarksPanel *); /* Procède à la libération totale de la mémoire. */ static void g_bookmarks_panel_finalize(GBookmarksPanel *); +/* Réagit à un changement d'affichage principal de contenu. */ +static void change_bookmarks_panel_current_content(GBookmarksPanel *, GLoadedContent *, GLoadedContent *); /* ------------------------- AFFICHAGE A L'AIDE D'UNE LISTE ------------------------- */ @@ -208,7 +211,7 @@ static void g_bookmarks_panel_class_init(GBookmarksPanelClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_binary = (update_item_binary_fc)reload_bookmarks_into_treeview; + editem->change_content = (change_item_content_fc)change_bookmarks_panel_current_content; panel = G_PANEL_ITEM_CLASS(klass); @@ -426,6 +429,34 @@ GPanelItem *g_bookmarks_panel_new(void) } +/****************************************************************************** +* * +* Paramètres : panel = panneau à mettre à jour. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * +* * +* Description : Réagit à un changement d'affichage principal de contenu. * +* * +* Retour : - * +* * +* Remarques : - * +* * +******************************************************************************/ + +static void change_bookmarks_panel_current_content(GBookmarksPanel *panel, GLoadedContent *old, GLoadedContent *new) +{ + GLoadedBinary *binary; /* Autre version de l'instance */ + + if (G_IS_LOADED_BINARY(new)) + binary = G_LOADED_BINARY(new); + else + binary = NULL; + + reload_bookmarks_into_treeview(panel, binary); + +} + + /* ---------------------------------------------------------------------------------- */ /* AFFICHAGE A L'AIDE D'UNE LISTE */ @@ -955,7 +986,7 @@ static void on_param_value_edited(GtkCellRendererText *renderer, gchar *path, gc static void update_filtered_bookmarks(GBookmarksPanel *panel) { - //reload_bookmarks_into_treeview(panel, panel->binary); + reload_bookmarks_into_treeview(panel, panel->binary); } diff --git a/src/gui/panels/errors.c b/src/gui/panels/errors.c index 5873ad5..fa86a84 100644 --- a/src/gui/panels/errors.c +++ b/src/gui/panels/errors.c @@ -41,6 +41,7 @@ #include "../../core/queue.h" #include "../../format/format.h" #include "../../glibext/signal.h" +#include "../../gtkext/gtkdisplaypanel.h" @@ -137,7 +138,7 @@ static void g_error_panel_finalize(GErrorPanel *); static gint sort_errors_in_panel(GtkTreeModel *, GtkTreeIter *, GtkTreeIter *, gpointer); /* Réagit à un changement d'affichage principal de contenu. */ -static void update_panel_with_binary_errors(GErrorPanel *, GLoadedBinary *); +static void change_error_panel_current_content(GErrorPanel *, GLoadedContent *, GLoadedContent *); /* Effectue la mise à jour du contenu du panneau d'erreurs. */ static void update_error_panel(const GErrorPanel *, GtkStatusStack *, activity_id_t, error_update_data *); @@ -218,7 +219,7 @@ static void g_error_panel_class_init(GErrorPanelClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_binary = (update_item_binary_fc)update_panel_with_binary_errors; + editem->change_content = (change_item_content_fc)change_error_panel_current_content; filename = find_pixmap_file("error_file.png"); assert(filename != NULL); @@ -465,8 +466,9 @@ static gint sort_errors_in_panel(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIte /****************************************************************************** * * -* Paramètres : panel = panneau à mettre à jour. * -* binary = nouvelle instance de binaire analysé. * +* Paramètres : panel = panneau à mettre à jour. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * * Description : Réagit à un changement d'affichage principal de contenu. * * * @@ -476,11 +478,17 @@ static gint sort_errors_in_panel(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIte * * ******************************************************************************/ -static void update_panel_with_binary_errors(GErrorPanel *panel, GLoadedBinary *binary) +static void change_error_panel_current_content(GErrorPanel *panel, GLoadedContent *old, GLoadedContent *new) { + GLoadedBinary *binary; /* Autre version de l'instance */ GtkBuilder *builder; /* Constructeur utilisé */ GtkListStore *store; /* Modèle de gestion */ + if (G_IS_LOADED_BINARY(new)) + binary = G_LOADED_BINARY(new); + else + binary = NULL; + /* Réinitialisation */ if (panel->binary != NULL) diff --git a/src/gui/panels/glance.c b/src/gui/panels/glance.c index c58f3b6..0fb8f43 100644 --- a/src/gui/panels/glance.c +++ b/src/gui/panels/glance.c @@ -87,7 +87,7 @@ static void g_glance_panel_dispose(GGlancePanel *); static void g_glance_panel_finalize(GGlancePanel *); /* Lance une actualisation du fait d'un changement de support. */ -static void update_glance_panel_for_view(GGlancePanel *, GLoadedPanel *); +static void change_glance_panel_current_view(GGlancePanel *, GLoadedPanel *, GLoadedPanel *); /* Réagit à la préparation du défilement du support original. */ static void on_view_scroll_setup(GtkAdjustment *, GGlancePanel *); @@ -102,7 +102,7 @@ static void on_glance_resize(GtkWidget *, GdkRectangle *, GGlancePanel *); static void compute_glance_scale(GGlancePanel *); /* Lance une actualisation du fait d'un changement de vue. */ -static void update_glance_panel_for_view_content(GGlancePanel *, GLoadedPanel *); +static void update_glance_panel_view(GGlancePanel *, GLoadedPanel *); /* Met à jour l'affichage de l'aperçu rapide à présenter. */ static gboolean redraw_glance_area(GtkWidget *, cairo_t *, GGlancePanel *); @@ -147,8 +147,8 @@ static void g_glance_panel_class_init(GGlancePanelClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_view = (update_item_view_fc)update_glance_panel_for_view; - editem->update_content = (update_item_view_fc)update_glance_panel_for_view_content; + editem->change_view = (change_item_view_fc)change_glance_panel_current_view; + editem->update_view = (update_item_view_fc)update_glance_panel_view; theme = gtk_icon_theme_get_default(); @@ -282,7 +282,8 @@ GPanelItem *g_glance_panel_new(void) /****************************************************************************** * * * Paramètres : panel = panneau à actualiser. * -* view = nouveau panneau d'affichage actif. * +* old = ancienne vue du contenu chargé analysé. * +* new = nouvelle vue du contenu chargé analysé. * * * * Description : Lance une actualisation du fait d'un changement de support. * * * @@ -292,17 +293,17 @@ GPanelItem *g_glance_panel_new(void) * * ******************************************************************************/ -static void update_glance_panel_for_view(GGlancePanel *panel, GLoadedPanel *view) +static void change_glance_panel_current_view(GGlancePanel *panel, GLoadedPanel *old, GLoadedPanel *new) { GtkWidget *parent; /* Support défilant de la vue */ GtkAdjustment *adj; /* Gestionnaire du défilement */ if (panel->view != NULL) { - g_object_unref(panel->view); + g_object_unref(G_OBJECT(panel->view)); panel->view = NULL; - g_object_unref(panel->support); + g_object_unref(G_OBJECT(panel->support)); panel->support = NULL; if (panel->cache != NULL) @@ -318,22 +319,27 @@ static void update_glance_panel_for_view(GGlancePanel *panel, GLoadedPanel *view * de la fonction mcb_view_change_support(). */ - parent = gtk_widget_get_parent(GTK_WIDGET(view)); + parent = gtk_widget_get_parent(GTK_WIDGET(new)); if (!GTK_IS_SCROLLED_WINDOW(parent)) return; - panel->view = view; - g_object_ref(panel->view); + panel->view = new; + + if (panel->view != NULL) + { + g_object_ref(G_OBJECT(panel->view)); + + panel->support = GTK_SCROLLED_WINDOW(parent); + g_object_ref(G_OBJECT(panel->support)); - panel->support = GTK_SCROLLED_WINDOW(parent); - g_object_ref(panel->support); + adj = gtk_scrolled_window_get_hadjustment(panel->support); + g_signal_connect(G_OBJECT(adj), "changed", G_CALLBACK(on_view_scroll_setup), panel); + g_signal_connect(G_OBJECT(adj), "value-changed", G_CALLBACK(on_view_scrolled), panel); - adj = gtk_scrolled_window_get_hadjustment(panel->support); - g_signal_connect(G_OBJECT(adj), "changed", G_CALLBACK(on_view_scroll_setup), panel); - g_signal_connect(G_OBJECT(adj), "value-changed", G_CALLBACK(on_view_scrolled), panel); + adj = gtk_scrolled_window_get_vadjustment(panel->support); + g_signal_connect(G_OBJECT(adj), "changed", G_CALLBACK(on_view_scroll_setup), panel); + g_signal_connect(G_OBJECT(adj), "value-changed", G_CALLBACK(on_view_scrolled), panel); - adj = gtk_scrolled_window_get_vadjustment(panel->support); - g_signal_connect(G_OBJECT(adj), "changed", G_CALLBACK(on_view_scroll_setup), panel); - g_signal_connect(G_OBJECT(adj), "value-changed", G_CALLBACK(on_view_scrolled), panel); + } } @@ -368,7 +374,7 @@ static void on_view_scroll_setup(GtkAdjustment *adj, GGlancePanel *panel) on_view_scrolled(adj, panel); - update_glance_panel_for_view_content(panel, panel->view); + update_glance_panel_view(panel, panel->view); } @@ -426,7 +432,7 @@ static void on_glance_resize(GtkWidget *widget, GdkRectangle *allocation, GGlanc if (panel->view != NULL) { on_view_scroll_setup(NULL, panel); - update_glance_panel_for_view_content(panel, panel->view); + update_glance_panel_view(panel, panel->view); } } @@ -519,7 +525,7 @@ static void compute_glance_scale(GGlancePanel *panel) * * ******************************************************************************/ -static void update_glance_panel_for_view_content(GGlancePanel *panel, GLoadedPanel *view) +static void update_glance_panel_view(GGlancePanel *panel, GLoadedPanel *view) { cairo_t *cairo; /* Assistant pour le dessin */ GtkAllocation area; /* Dimension de la surface */ diff --git a/src/gui/panels/history.c b/src/gui/panels/history.c index c43534b..50e72da 100644 --- a/src/gui/panels/history.c +++ b/src/gui/panels/history.c @@ -33,7 +33,7 @@ #include "panel-int.h" -#include "../../analysis/db/collection.h" +#include "../../analysis/binary.h" #include "../../glibext/chrysamarshal.h" #include "../../glibext/signal.h" #include "../../gtkext/easygtk.h" @@ -87,7 +87,7 @@ static void g_history_panel_dispose(GHistoryPanel *); static void g_history_panel_finalize(GHistoryPanel *); /* Réagit à un changement d'affichage principal de contenu. */ -static void change_history_panel_current_binary(GHistoryPanel *, GLoadedBinary *); +static void change_history_panel_current_content(GHistoryPanel *, GLoadedContent *, GLoadedContent *); /* Réagit à une modification au sein d'une collection donnée. */ static void on_history_changed(GDbCollection *, DBAction, GDbItem *, GHistoryPanel *); @@ -137,7 +137,7 @@ static void g_history_panel_class_init(GHistoryPanelClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_binary = (update_item_binary_fc)change_history_panel_current_binary; + editem->change_content = (change_item_content_fc)change_history_panel_current_content; } @@ -326,8 +326,9 @@ GPanelItem *g_history_panel_new(void) /****************************************************************************** * * -* Paramètres : panel = panneau à mettre à jour. * -* binary = nouvelle instance de binaire analysé. * +* Paramètres : panel = panneau à mettre à jour. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * * Description : Réagit à un changement d'affichage principal de contenu. * * * @@ -337,8 +338,9 @@ GPanelItem *g_history_panel_new(void) * * ******************************************************************************/ -static void change_history_panel_current_binary(GHistoryPanel *panel, GLoadedBinary *binary) +static void change_history_panel_current_content(GHistoryPanel *panel, GLoadedContent *old, GLoadedContent *new) { + GLoadedBinary *binary; /* Autre version de l'instance */ GList *collections; /* Ensemble de collections */ GList *c; /* Boucle de parcours #1 */ GDbCollection *collec; /* Collection visée manipulée */ @@ -348,6 +350,11 @@ static void change_history_panel_current_binary(GHistoryPanel *panel, GLoadedBin GDbItem *item; /* Elément à intégrer */ GtkTreeIter iter; /* Point d'insertion */ + if (G_IS_LOADED_BINARY(new)) + binary = G_LOADED_BINARY(new); + else + binary = NULL; + /* Basculement du binaire utilisé */ if (panel->binary != NULL) diff --git a/src/gui/panels/panel-int.h b/src/gui/panels/panel-int.h index 3f5213d..4ea9182 100644 --- a/src/gui/panels/panel-int.h +++ b/src/gui/panels/panel-int.h @@ -34,6 +34,7 @@ #include "../editem-int.h" #include "../../common/dllist.h" +#include "../../glibext/delayed.h" diff --git a/src/gui/panels/strings.c b/src/gui/panels/strings.c index dacd14c..6e9324f 100644 --- a/src/gui/panels/strings.c +++ b/src/gui/panels/strings.c @@ -41,6 +41,7 @@ #include "../../format/format.h" #include "../../format/symiter.h" #include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkdisplaypanel.h" #include "../../gtkext/gtkdockable-int.h" #include "../../gtkext/tmgt.h" @@ -121,7 +122,7 @@ static gboolean on_key_pressed_over_strings(GtkTreeView *, GdkEventKey *, GStrin static void on_string_name_edited(GtkCellRendererText *, gchar *, gchar *, GtkTreeModel *); /* Réagit à un changement d'affichage principal de contenu. */ -static void change_strings_panel_current_binary(GStringsPanel *, GLoadedBinary *); +static void change_strings_panel_current_content(GStringsPanel *, GLoadedContent *, GLoadedContent *); @@ -249,7 +250,7 @@ static void g_strings_panel_class_init(GStringsPanelClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_binary = (update_item_binary_fc)change_strings_panel_current_binary; + editem->change_content = (change_item_content_fc)change_strings_panel_current_content; panel = G_PANEL_ITEM_CLASS(klass); @@ -641,8 +642,9 @@ static void on_string_name_edited(GtkCellRendererText *renderer, gchar *path, gc /****************************************************************************** * * -* Paramètres : panel = panneau à mettre à jour. * -* binary = nouvelle instance de binaire analysé. * +* Paramètres : panel = panneau à mettre à jour. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * * Description : Réagit à un changement d'affichage principal de contenu. * * * @@ -652,14 +654,20 @@ static void on_string_name_edited(GtkCellRendererText *renderer, gchar *path, gc * * ******************************************************************************/ -static void change_strings_panel_current_binary(GStringsPanel *panel, GLoadedBinary *binary) +static void change_strings_panel_current_content(GStringsPanel *panel, GLoadedContent *old, GLoadedContent *new) { + GLoadedBinary *binary; /* Autre version de l'instance */ GtkBuilder *builder; /* Constructeur utilisé */ GtkListStore *store; /* Modèle de gestion */ GtkTreeView *treeview; /* Affichage de la liste */ GtkTreeViewColumn *column; /* Colonne de la liste */ GArchProcessor *proc; /* Architecture du binaire */ + if (G_IS_LOADED_BINARY(new)) + binary = G_LOADED_BINARY(new); + else + binary = NULL; + /* Basculement du binaire utilisé */ if (panel->binary != NULL) @@ -1266,7 +1274,6 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa { GBinSymbol *symbol; /* Symbole sélectionné */ const mrange_t *range; /* Couverture en mémoire */ - GLoadedBinary *binary; /* Représentation binaire */ GArchProcessor *proc; /* Processeur de l'architecture*/ GArchInstruction *instr; /* Point de croisements */ GObject *ref; /* Espace de référencements */ @@ -1279,8 +1286,7 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa range = g_binary_symbol_get_range(symbol); - binary = get_current_binary(); - proc = g_loaded_binary_get_processor(binary); + proc = g_loaded_binary_get_processor(panel->binary); /** * Se rapporter aux commentaires de mcb_edition_list_xrefs() pour les questions @@ -1290,7 +1296,7 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa ref = G_OBJECT(get_editor_window());//g_editor_item_get_global_ref(G_EDITOR_ITEM(panel)); - dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), binary, instr, true); + dialog = create_gotox_dialog_for_cross_references(GTK_WINDOW(ref), panel->binary, instr, true); if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK) { @@ -1313,7 +1319,6 @@ static void mcb_strings_panel_find_refs(GtkMenuItem *menuitem, GStringsPanel *pa g_object_unref(G_OBJECT(instr)); g_object_unref(G_OBJECT(proc)); - g_object_unref(G_OBJECT(binary)); g_object_unref(G_OBJECT(symbol)); diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c index 0c88bce..414c4c7 100644 --- a/src/gui/panels/symbols.c +++ b/src/gui/panels/symbols.c @@ -45,6 +45,7 @@ #include "../../format/format.h" #include "../../format/symiter.h" #include "../../gtkext/easygtk.h" +#include "../../gtkext/gtkdisplaypanel.h" #include "../../gtkext/tmgt.h" @@ -126,7 +127,7 @@ static void on_symbols_tree_display_toggle(GtkToggleToolButton *, GSymbolsPanel static void on_symbols_selection_change(GtkTreeSelection *, gpointer); /* Réagit à un changement d'affichage principal de contenu. */ -static void change_symbols_panel_current_binary(GSymbolsPanel *, GLoadedBinary *); +static void change_symbols_panel_current_content(GSymbolsPanel *, GLoadedContent *, GLoadedContent *); /* Réagit à un changement d'affichage principal de contenu. */ static void reload_symbols_panel_content(const GSymbolsPanel *, GtkStatusStack *, activity_id_t, symbols_update_data *); @@ -256,7 +257,7 @@ static void g_symbols_panel_class_init(GSymbolsPanelClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->update_binary = (update_item_binary_fc)change_symbols_panel_current_binary; + editem->change_content = (change_item_content_fc)change_symbols_panel_current_content; panel = G_PANEL_ITEM_CLASS(klass); @@ -490,6 +491,7 @@ static void on_symbols_list_display_toggle(GtkToggleToolButton *button, GSymbols { GtkBuilder *builder; /* Constructeur utilisé */ GtkWidget *other; /* Autre bouton de la barre */ + GLoadedContent *content; /* Autre version du binaire */ if (gtk_toggle_tool_button_get_active(button)) { @@ -510,9 +512,12 @@ static void on_symbols_list_display_toggle(GtkToggleToolButton *button, GSymbols if (panel->binary != NULL) { - g_object_ref(G_OBJECT(panel->binary)); - change_symbols_panel_current_binary(panel, panel->binary); - g_object_unref(G_OBJECT(panel->binary)); + content = G_LOADED_CONTENT(panel->binary); + + g_object_ref(G_OBJECT(content)); + change_symbols_panel_current_content(panel, content, content); + g_object_unref(G_OBJECT(content)); + } } @@ -537,6 +542,7 @@ static void on_symbols_tree_display_toggle(GtkToggleToolButton *button, GSymbols { GtkBuilder *builder; /* Constructeur utilisé */ GtkWidget *other; /* Autre bouton de la barre */ + GLoadedContent *content; /* Autre version du binaire */ if (gtk_toggle_tool_button_get_active(button)) { @@ -557,9 +563,12 @@ static void on_symbols_tree_display_toggle(GtkToggleToolButton *button, GSymbols if (panel->binary != NULL) { - g_object_ref(G_OBJECT(panel->binary)); - change_symbols_panel_current_binary(panel, panel->binary); - g_object_unref(G_OBJECT(panel->binary)); + content = G_LOADED_CONTENT(panel->binary); + + g_object_ref(G_OBJECT(content)); + change_symbols_panel_current_content(panel, content, content); + g_object_unref(G_OBJECT(content)); + } } @@ -614,8 +623,9 @@ static void on_symbols_selection_change(GtkTreeSelection *selection, gpointer un /****************************************************************************** * * -* Paramètres : panel = panneau à mettre à jour. * -* binary = nouvelle instance de binaire analysé. * +* Paramètres : panel = panneau à mettre à jour. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * * Description : Réagit à un changement d'affichage principal de contenu. * * * @@ -625,11 +635,17 @@ static void on_symbols_selection_change(GtkTreeSelection *selection, gpointer un * * ******************************************************************************/ -static void change_symbols_panel_current_binary(GSymbolsPanel *panel, GLoadedBinary *binary) +static void change_symbols_panel_current_content(GSymbolsPanel *panel, GLoadedContent *old, GLoadedContent *new) { + GLoadedBinary *binary; /* Autre version de l'instance */ GtkBuilder *builder; /* Constructeur utilisé */ GtkTreeStore *store; /* Modèle de gestion */ + if (G_IS_LOADED_BINARY(new)) + binary = G_LOADED_BINARY(new); + else + binary = NULL; + /* Basculement du binaire utilisé */ if (panel->binary != NULL) diff --git a/src/gui/status.c b/src/gui/status.c index bd52310..645028e 100644 --- a/src/gui/status.c +++ b/src/gui/status.c @@ -70,10 +70,10 @@ static void g_status_info_dispose(GStatusInfo *); static void g_status_info_finalize(GStatusInfo *); /* Imprime la position du parcours courant dans le statut. */ -static void track_caret_address_for_status_info(GStatusInfo *, GtkBufferDisplay *, const vmpa2t *); +static void track_cursor_for_status_info(GStatusInfo *, GLoadedPanel *, const GLineCursor *); /* Concentre l'attention de l'ensemble sur une adresse donnée. */ -static void focus_address_in_status_info(GStatusInfo *, GLoadedBinary *, const vmpa2t *); +static void focus_cursor_in_status_info(GStatusInfo *, GLoadedContent *, const GLineCursor *); @@ -105,8 +105,8 @@ static void g_status_info_class_init(GStatusInfoClass *klass) editem = G_EDITOR_ITEM_CLASS(klass); - editem->track_caret = (track_caret_in_view_fc)track_caret_address_for_status_info; - editem->focus_addr = (focus_addr_fc)focus_address_in_status_info; + editem->track_cursor = (track_cursor_in_view_fc)track_cursor_for_status_info; + editem->focus_cursor = (focus_cursor_fc)focus_cursor_in_status_info; } @@ -208,9 +208,9 @@ GEditorItem *g_status_info_new(GObject *ref) /****************************************************************************** * * -* Paramètres : info = barre de statut présentant les informations. * -* display = composant d'affichage parcouru. * -* addr = nouvelle adresse du curseur courant. * +* Paramètres : info = barre de statut présentant les informations. * +* panel = composant d'affichage parcouru. * +* cursor = nouvel emplacement du curseur courant. * * * * Description : Imprime la position du parcours courant dans le statut. * * * @@ -220,24 +220,24 @@ GEditorItem *g_status_info_new(GObject *ref) * * ******************************************************************************/ -static void track_caret_address_for_status_info(GStatusInfo *info, GtkBufferDisplay *display, const vmpa2t *addr) +static void track_cursor_for_status_info(GStatusInfo *info, GLoadedPanel *panel, const GLineCursor *cursor) { - GLoadedBinary *binary; /* Binaire courant */ + GLoadedContent *content; /* Contenu courant */ - binary = get_current_binary(); + content = g_loaded_panel_get_content(panel); - focus_address_in_status_info(info, binary, addr); + focus_cursor_in_status_info(info, content, cursor); - g_object_unref(G_OBJECT(binary)); + g_object_unref(G_OBJECT(content)); } /****************************************************************************** * * -* Paramètres : info = composant réactif à mettre à jour. * -* binary = binaire contenant l'adresse à représenter. * -* addr = adresse mémoire à mettre en avant. * +* Paramètres : info = composant réactif à mettre à jour. * +* content = contenu contenant le curseur à représenter. * +* cursor = nouvel emplacement du curseur courant. * * * * Description : Concentre l'attention de l'ensemble sur une adresse donnée. * * * @@ -247,30 +247,12 @@ static void track_caret_address_for_status_info(GStatusInfo *info, GtkBufferDisp * * ******************************************************************************/ -static void focus_address_in_status_info(GStatusInfo *info, GLoadedBinary *binary, const vmpa2t *addr) +static void focus_cursor_in_status_info(GStatusInfo *info, GLoadedContent *content, const GLineCursor *cursor) { GEditorItem *item; /* Autre version de l'élément */ - GArchProcessor *proc; /* Architecture du binaire */ - GArchInstruction *instr; /* Instruction présente */ item = G_EDITOR_ITEM(info); - if (is_invalid_vmpa(addr)) - gtk_status_stack_reset_current_instruction(GTK_STATUS_STACK(item->widget)); - - else - { - proc = g_loaded_binary_get_processor(binary); - - instr = _g_arch_processor_find_instr_by_address(proc, addr, true); - assert(instr != NULL); - - gtk_status_stack_update_current_instruction(GTK_STATUS_STACK(item->widget), binary, instr); - - g_object_unref(G_OBJECT(instr)); - - g_object_unref(G_OBJECT(proc)); - - } + g_line_cursor_show_status(cursor, GTK_STATUS_STACK(item->widget), content); } diff --git a/src/gui/tb/portions.c b/src/gui/tb/portions.c index f60f83c..202cd43 100644 --- a/src/gui/tb/portions.c +++ b/src/gui/tb/portions.c @@ -32,7 +32,9 @@ #include "../core/global.h" #include "../core/items.h" #include "../../format/format.h" +#include "../../glibext/gbinarycursor.h" #include "../../gtkext/gtkbinarystrip.h" +#include "../../gtkext/gtkdisplaypanel.h" @@ -66,7 +68,7 @@ static void g_portions_tbitem_dispose(GPortionsTbItem *); static void g_portions_tbitem_finalize(GPortionsTbItem *); /* Réagit à un changement du binaire courant. */ -static void update_portions_item_binary(GEditorItem *, GLoadedBinary *); +static void change_portions_tbitem_current_content(GEditorItem *, GLoadedContent *, GLoadedContent *); /* Fait suivre un changement d'adresse dans la barre. */ static void track_address_on_binary_strip(GtkBinaryStrip *, GEditorItem *); @@ -100,7 +102,7 @@ static void g_portions_tbitem_class_init(GPortionsTbItemClass *klass) object->dispose = (GObjectFinalizeFunc/* ! */)g_portions_tbitem_dispose; object->finalize = (GObjectFinalizeFunc)g_portions_tbitem_finalize; - item->update_binary = update_portions_item_binary; + item->change_content = change_portions_tbitem_current_content; } @@ -204,8 +206,9 @@ GEditorItem *create_portions_tb_item(GObject *ref) /****************************************************************************** * * -* Paramètres : item = élément réactif sollicité. * -* binary = binaire chargé nouvellement affiché. * +* Paramètres : item = élément réactif sollicité. * +* old = ancien contenu chargé analysé. * +* new = nouveau contenu chargé à analyser. * * * * Description : Réagit à un changement du binaire courant. * * * @@ -215,10 +218,16 @@ GEditorItem *create_portions_tb_item(GObject *ref) * * ******************************************************************************/ -static void update_portions_item_binary(GEditorItem *item, GLoadedBinary *binary) +static void change_portions_tbitem_current_content(GEditorItem *item, GLoadedContent *old, GLoadedContent *new) { + GLoadedBinary *binary; /* Autre version de l'instance */ GtkBinaryStrip *strip; /* Bande pour binaire */ + if (G_IS_LOADED_BINARY(new)) + binary = G_LOADED_BINARY(new); + else + binary = NULL; + strip = GTK_BINARY_STRIP(g_object_get_data(G_OBJECT(item->widget), "strip")); gtk_binary_strip_attach(strip, binary); @@ -244,19 +253,25 @@ static void track_address_on_binary_strip(GtkBinaryStrip *strip, GEditorItem *it { const vmpa2t *addr; /* Nouvelle destination */ GLoadedPanel *panel; /* Afficheur effectif de code */ - GLoadedBinary *binary; /* Binaire chargé et actif */ + GLoadedContent *content; /* Contenu chargé et actif */ + GLineCursor *cursor; /* Emplacement à afficher */ addr = gtk_binary_strip_get_location(strip); panel = get_current_view(); - binary = get_current_binary(); + content = get_current_content(); if (GTK_IS_DISPLAY_PANEL(panel)) gtk_display_panel_request_move(GTK_DISPLAY_PANEL(panel), addr); - focus_address_in_editor_items(binary, addr, item); + cursor = g_binary_cursor_new(); + g_binary_cursor_update(G_BINARY_CURSOR(cursor), addr); + + focus_cursor_in_editor_items(content, cursor, item); + + g_object_unref(G_OBJECT(cursor)); - g_object_unref(G_OBJECT(binary)); + g_object_unref(G_OBJECT(content)); g_object_unref(G_OBJECT(panel)); } -- cgit v0.11.2-87-g4458