summaryrefslogtreecommitdiff
path: root/src/gui/panels/symbols.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/panels/symbols.c')
-rw-r--r--src/gui/panels/symbols.c185
1 files changed, 71 insertions, 114 deletions
diff --git a/src/gui/panels/symbols.c b/src/gui/panels/symbols.c
index fe295e0..fab82a9 100644
--- a/src/gui/panels/symbols.c
+++ b/src/gui/panels/symbols.c
@@ -62,8 +62,6 @@ struct _GSymbolsPanel
size_t count; /* Quantité de symboles utiles */
- regex_t *filter; /* Filtre appliqué ou NULL */
-
};
/* Panneau d'affichage des symboles (classe) */
@@ -92,10 +90,11 @@ typedef enum _SymbolsColumn
SBC_EXPAND, /* Affichage des classes */
SBC_MATCHED, /* Correspondance établie ? */
- SBC_MATCH_POINTS /* Nombre de demandeurs */
+ SBC_MATCH_POINTS, /* Nombre de demandeurs */
-} SymbolsColumn;
+ SBC_COUNT /* Nombre de colonnes */
+} SymbolsColumn;
/* Données utiles à la mise à jour */
@@ -109,7 +108,7 @@ static void g_symbols_panel_class_init(GSymbolsPanelClass *);
static void g_symbols_panel_init(GSymbolsPanel *);
/* Procède à l'initialisation de l'interface de mise à jour. */
-static void g_symbols_panel_interface_init(GUpdatablePanelInterface *);
+static void g_symbols_panel_updatable_interface_init(GUpdatablePanelInterface *);
/* Supprime toutes les références externes. */
static void g_symbols_panel_dispose(GSymbolsPanel *);
@@ -177,15 +176,9 @@ static void update_symbol_name_in_tree_view(const GSymbolsPanel *, GtkTreeStore
/* Démarre l'actualisation du filtrage des symboles. */
static void on_symbols_filter_changed(GtkSearchEntry *, GSymbolsPanel *);
-/* Met à jour l'affichage des noeuds en fonction des besoin. */
-static void update_symbol_visibility(GtkTreeStore *, GtkTreeIter *, bool);
-
/* Exécute un nouveau filtrage des symboles affichés. */
static void do_filtering_on_symbols(const GSymbolsPanel *, GtkStatusStack *, activity_id_t, symbols_update_data *);
-/* Détermine si un nom de symbole doit être filtré ou non. */
-static bool is_symbol_matching(const GSymbolsPanel *, const GBinSymbol *, regmatch_t *);
-
/* ---------------------- MECANISMES DE MISE A JOUR DE PANNEAU ---------------------- */
@@ -195,6 +188,8 @@ struct _symbols_update_data
{
size_t count; /* Qté d'inscriptions réalisées*/
+ regex_t *filter; /* Filtre appliqué ou NULL */
+
char **expanded; /* Chemins des noeuds ouverts */
size_t ecount; /* Nombre de ces chemins */
size_t eallocated; /* Espace alloué effectivement */
@@ -205,6 +200,9 @@ struct _symbols_update_data
#define EXPAND_ALLOC_RANGE 10
+/* Détermine si un nom de symbole doit être filtré ou non. */
+static bool is_symbol_matching(const symbols_update_data *, const GBinSymbol *, regmatch_t *);
+
/* Prépare une opération de mise à jour de panneau. */
static const char *g_symbols_panel_setup(const GSymbolsPanel *, unsigned int, size_t *, symbols_update_data **);
@@ -229,7 +227,7 @@ static void g_symbols_panel_clean_data(GUpdatablePanel *, unsigned int, symbols_
/* Indique le type définit pour un panneau d'affichage des symboles. */
G_DEFINE_TYPE_WITH_CODE(GSymbolsPanel, g_symbols_panel, G_TYPE_PANEL_ITEM,
- G_IMPLEMENT_INTERFACE(G_TYPE_UPDATABLE_PANEL, g_symbols_panel_interface_init));
+ G_IMPLEMENT_INTERFACE(G_TYPE_UPDATABLE_PANEL, g_symbols_panel_updatable_interface_init));
/******************************************************************************
@@ -248,8 +246,8 @@ static void g_symbols_panel_class_init(GSymbolsPanelClass *klass)
{
GObjectClass *object; /* Autre version de la classe */
GEditorItemClass *editem; /* Encore une autre vision... */
- gchar *filename; /* Chemin d'accès à utiliser */
GPanelItemClass *panel; /* Version parente de la classe*/
+ gchar *filename; /* Chemin d'accès à utiliser */
object = G_OBJECT_CLASS(klass);
@@ -260,6 +258,13 @@ static void g_symbols_panel_class_init(GSymbolsPanelClass *klass)
editem->update_binary = (update_item_binary_fc)change_symbols_panel_current_binary;
+ panel = G_PANEL_ITEM_CLASS(klass);
+
+ panel->unique = true;
+ panel->bindings = "<Shift>F3";
+
+ panel->gid = setup_tiny_global_work_group(1);
+
filename = find_pixmap_file("symbol_routine_classic.png");
assert(filename != NULL);
@@ -288,13 +293,6 @@ static void g_symbols_panel_class_init(GSymbolsPanelClass *klass)
g_free(filename);
- panel = G_PANEL_ITEM_CLASS(klass);
-
- panel->unique = true;
- panel->bindings = "<Shift>F3";
-
- panel->gid = setup_tiny_global_work_group(1);
-
}
@@ -315,8 +313,8 @@ static void g_symbols_panel_init(GSymbolsPanel *panel)
GEditorItem *base; /* Version basique d'instance */
GPanelItem *pitem; /* Version parente du panneau */
GtkBuilder *builder; /* Constructeur utilisé */
- GtkTreeView *treeview; /* Affichage de la liste */
GtkTreeModelFilter *filter; /* Filtre pour l'arborescence */
+ GtkTreeView *treeview; /* Affichage de la liste */
GtkCellRenderer *renderer; /* Moteur de rendu de colonne */
GtkTreeViewColumn *column; /* Colonne de la liste */
@@ -399,7 +397,7 @@ static void g_symbols_panel_init(GSymbolsPanel *panel)
* *
******************************************************************************/
-static void g_symbols_panel_interface_init(GUpdatablePanelInterface *iface)
+static void g_symbols_panel_updatable_interface_init(GUpdatablePanelInterface *iface)
{
iface->setup = (setup_updatable_cb)g_symbols_panel_setup;
iface->get_group = (get_updatable_group_cb)g_panel_item_get_group;
@@ -447,12 +445,6 @@ static void g_symbols_panel_dispose(GSymbolsPanel *panel)
static void g_symbols_panel_finalize(GSymbolsPanel *panel)
{
- if (panel->filter != NULL)
- {
- regfree(panel->filter);
- free(panel->filter);
- }
-
G_OBJECT_CLASS(g_symbols_panel_parent_class)->finalize(G_OBJECT(panel));
}
@@ -738,7 +730,7 @@ static void reload_symbols_for_new_list_view(const GSymbolsPanel *panel, GtkStat
const char *original; /* Etiquette brute d'origine */
char *name; /* Etiquette mise en relief */
const vmpa2t *addr; /* Localisation d'un symbole */
- char virt[VMPA_MAX_LEN]; /* Version humainement lisible */
+ VMPA_BUFFER(virt); /* Version humainement lisible */
GtkTreeIter iter; /* Point d'insertion */
builder = G_PANEL_ITEM(panel)->builder;
@@ -774,7 +766,7 @@ static void reload_symbols_for_new_list_view(const GSymbolsPanel *panel, GtkStat
if (icon == NULL)
goto rsfnlv_next;
- matched = is_symbol_matching(panel, symbol, &match);
+ matched = is_symbol_matching(data, symbol, &match);
original = g_binary_symbol_get_label(symbol);
@@ -798,7 +790,7 @@ static void reload_symbols_for_new_list_view(const GSymbolsPanel *panel, GtkStat
-1);
if (matched)
- update_symbol_visibility(store, &iter, true);
+ update_node_visibility(store, &iter, SBC_MATCHED, true);
data->count++;
@@ -809,6 +801,8 @@ static void reload_symbols_for_new_list_view(const GSymbolsPanel *panel, GtkStat
g_object_unref(G_OBJECT(symbol));
+ gtk_status_stack_update_activity_value(status, id, 1);
+
}
delete_symbol_iterator(siter);
@@ -1050,7 +1044,7 @@ static void reload_symbols_for_new_tree_view(const GSymbolsPanel *panel, GtkStat
if (icon == NULL)
goto rsfntv_next;
- matched = is_symbol_matching(panel, symbol, &match);
+ matched = is_symbol_matching(data, symbol, &match);
if (find_parent_for_symbol(panel, symbol, &parent, &match, &last))
{
@@ -1086,7 +1080,7 @@ static void reload_symbols_for_new_tree_view(const GSymbolsPanel *panel, GtkStat
-1);
if (matched)
- update_symbol_visibility(store, &iter, true);
+ update_node_visibility(store, &iter, SBC_MATCHED, true);
data->count++;
@@ -1097,6 +1091,8 @@ static void reload_symbols_for_new_tree_view(const GSymbolsPanel *panel, GtkStat
g_object_unref(G_OBJECT(symbol));
+ gtk_status_stack_update_activity_value(status, id, 1);
+
}
delete_symbol_iterator(siter);
@@ -1310,7 +1306,7 @@ static void update_symbol_name_in_tree_view(const GSymbolsPanel *panel, GtkTreeS
static void on_symbols_filter_changed(GtkSearchEntry *entry, GSymbolsPanel *panel)
{
- update_regex_on_search_entry_changed(entry, &panel->filter);
+ update_regex_on_search_entry_changed(entry, &G_PANEL_ITEM(panel)->filter);
run_panel_update(G_UPDATABLE_PANEL(panel), PUI_1);
@@ -1319,68 +1315,6 @@ static void on_symbols_filter_changed(GtkSearchEntry *entry, GSymbolsPanel *pane
/******************************************************************************
* *
-* Paramètres : store = organisation des données sous forme arborescente. *
-* iter = position du noeud courant à traiter. *
-* show = visibilité à obtenir pour le noeud final. *
-* *
-* Description : Met à jour l'affichage des noeuds en fonction des besoin. *
-* *
-* Retour : - *
-* *
-* Remarques : - *
-* *
-******************************************************************************/
-
-static void update_symbol_visibility(GtkTreeStore *store, GtkTreeIter *iter, bool show)
-{
- GtkTreeModel *model; /* Autre vision du gestionnaire*/
- guint points; /* Compteur de besoins */
- GtkTreeIter parent; /* Position de noeuf parent */
- gboolean further; /* Poursuite de remontée */
-
- model = GTK_TREE_MODEL(store);
-
- /* Enumération des besoins */
-
- gtk_tree_model_get(model, iter, SBC_MATCH_POINTS, &points, -1);
-
- if (show)
- points++;
-
- else
- {
- assert(points > 0);
- points--;
- }
-
- gtk_tree_store_set(store, iter, SBC_MATCH_POINTS, points, -1);
-
- /* Adaptation de l'affichage */
-
- if (show)
- {
- if (points == 1)
- gtk_tree_store_set(store, iter, SBC_MATCHED, true, -1);
- }
-
- else
- {
- if (points == 0)
- gtk_tree_store_set(store, iter, SBC_MATCHED, false, -1);
- }
-
- /* Eventuel étage supérieur */
-
- further = gtk_tree_model_iter_parent(model, &parent, iter);
-
- if (further)
- update_symbol_visibility(store, &parent, show);
-
-}
-
-
-/******************************************************************************
-* *
* Paramètres : panel = panneau assurant l'affichage des symboles. *
* status = barre de statut à tenir informée. *
* id = identifiant pour le suivi de la progression. *
@@ -1413,30 +1347,34 @@ static void do_filtering_on_symbols(const GSymbolsPanel *panel, GtkStatusStack *
if (symbol != NULL)
{
- matched = is_symbol_matching(panel, symbol, &match);
+ matched = is_symbol_matching(data, symbol, &match);
+
+ if (matched)
+ {
+ if (*as_list)
+ update_symbol_name_in_list_view(store, iter, &match);
+ else
+ update_symbol_name_in_tree_view(panel, store, symbol, &match);
+ }
gtk_tree_model_get(model, iter, SBC_MATCHED, &shown, -1);
if (!matched)
{
if (shown)
- update_symbol_visibility(store, iter, false);
+ update_node_visibility(store, iter, SBC_MATCHED, false);
}
else
{
- if (*as_list)
- update_symbol_name_in_list_view(store, iter, &match);
- else
- update_symbol_name_in_tree_view(panel, store, symbol, &match);
-
if (!shown)
- update_symbol_visibility(store, iter, true);
-
+ update_node_visibility(store, iter, SBC_MATCHED, true);
}
g_object_unref(G_OBJECT(symbol));
+ gtk_status_stack_update_activity_value(status, id, 1);
+
}
return FALSE;
@@ -1456,9 +1394,15 @@ static void do_filtering_on_symbols(const GSymbolsPanel *panel, GtkStatusStack *
}
+
+/* ---------------------------------------------------------------------------------- */
+/* MECANISMES DE MISE A JOUR DE PANNEAU */
+/* ---------------------------------------------------------------------------------- */
+
+
/******************************************************************************
* *
-* Paramètres : panel = panneau assurant l'affichage des symboles. *
+* Paramètres : data = données complémentaire à manipuler. *
* symbol = symbole à traiter. *
* match = récupération des trouvailles. [OUT] *
* *
@@ -1470,7 +1414,7 @@ static void do_filtering_on_symbols(const GSymbolsPanel *panel, GtkStatusStack *
* *
******************************************************************************/
-static bool is_symbol_matching(const GSymbolsPanel *panel, const GBinSymbol *symbol, regmatch_t *match)
+static bool is_symbol_matching(const symbols_update_data *data, const GBinSymbol *symbol, regmatch_t *match)
{
bool result; /* Bilan à retourner */
#ifndef NDEBUG
@@ -1485,19 +1429,13 @@ static bool is_symbol_matching(const GSymbolsPanel *panel, const GBinSymbol *sym
#endif
- result = is_content_matching(panel->filter, g_binary_symbol_get_label(symbol), match);
+ result = is_content_matching(data->filter, g_binary_symbol_get_label(symbol), match);
return result;
}
-
-/* ---------------------------------------------------------------------------------- */
-/* MECANISMES DE MISE A JOUR DE PANNEAU */
-/* ---------------------------------------------------------------------------------- */
-
-
/******************************************************************************
* *
* Paramètres : panel = panneau ciblé par une mise à jour. *
@@ -1517,6 +1455,7 @@ static const char *g_symbols_panel_setup(const GSymbolsPanel *panel, unsigned in
{
const char *result; /* Message à retourner */
GBinFormat *format; /* Format du binaire */
+ int ret; /* Bilan de mise en place */
GtkBuilder *builder; /* Constructeur utilisé */
GtkTreeView *treeview; /* Arborescence graphique */
@@ -1556,6 +1495,18 @@ static const char *g_symbols_panel_setup(const GSymbolsPanel *panel, unsigned in
}
+ if (G_PANEL_ITEM(panel)->filter != NULL)
+ {
+ (*data)->filter = (regex_t *)malloc(sizeof(regex_t));
+
+ ret = regcomp((*data)->filter, G_PANEL_ITEM(panel)->filter, REG_EXTENDED | REG_ICASE);
+ assert(ret == 0);
+
+ }
+
+ else
+ (*data)->filter = NULL;
+
/* Mémorisation de tous les noeuds ouverts */
builder = G_PANEL_ITEM(panel)->builder;
@@ -1742,6 +1693,12 @@ static void g_symbols_panel_clean_data(GUpdatablePanel *panel, unsigned int uid,
{
size_t i; /* Boucle de parcours */
+ if (data->filter != NULL)
+ {
+ regfree(data->filter);
+ free(data->filter);
+ }
+
for (i = 0; i < data->ecount; i++)
g_free(data->expanded[i]);