From 2141476200ac16213c9d567708c081857bf7eb8c Mon Sep 17 00:00:00 2001 From: Cyrille Bagard Date: Mon, 4 Jun 2018 23:29:51 +0200 Subject: Measured the number of binary portions to load. --- src/glibext/gbinportion.c | 39 +++++++++++++++++++++++++++++++++++++++ src/glibext/gbinportion.h | 3 +++ src/gui/panels/bintree.c | 12 +++++++++++- 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/glibext/gbinportion.c b/src/glibext/gbinportion.c index ff5ff7d..f99a7cc 100644 --- a/src/glibext/gbinportion.c +++ b/src/glibext/gbinportion.c @@ -1148,6 +1148,45 @@ static void g_binary_portion_print(GBinPortion *portion, GBufferLine *line, size /****************************************************************************** * * * Paramètres : portion = couche de portions à parcourir pour les recherches.* +* * +* Description : Compte le nombre de portions présentes dans une arborescence.* +* * +* Retour : Quantité de portions présentes. * +* * +* Remarques : - * +* * +******************************************************************************/ + +size_t g_binary_portion_count(const GBinPortion *portion) +{ + size_t result; /* Quantité à retourner */ + + + size_t measure_portion_size(const GBinPortion *root) + { + size_t count; /* Nombre de trouvailles */ + size_t i; /* Boucle de parcours */ + + count = 1; + + for (i = 0; i < root->count; i++) + count += measure_portion_size(root->subs[i]); + + return count; + + } + + + result = measure_portion_size(portion); + + return result; + +} + + +/****************************************************************************** +* * +* Paramètres : portion = couche de portions à parcourir pour les recherches.* * x = abscisse du point de recherche. * * area = étendue de portion mère, puis celle trouvée. [OUT] * * * diff --git a/src/glibext/gbinportion.h b/src/glibext/gbinportion.h index 581be68..5c8c363 100644 --- a/src/glibext/gbinportion.h +++ b/src/glibext/gbinportion.h @@ -144,6 +144,9 @@ bool g_binary_portion_visit(GBinPortion *, visit_portion_fc, void *); /* ------------------------ PARCOURS D'ENSEMBLES DE PORTIONS ------------------------ */ +/* Compte le nombre de portions présentes dans une arborescence. */ +size_t g_binary_portion_count(const GBinPortion *); + /* Recherche la portion présente à un point donné. */ GBinPortion *g_binary_portion_find_at_pos(GBinPortion *, gint, GdkRectangle *); diff --git a/src/gui/panels/bintree.c b/src/gui/panels/bintree.c index 642a71c..ecb18fe 100644 --- a/src/gui/panels/bintree.c +++ b/src/gui/panels/bintree.c @@ -166,6 +166,8 @@ struct _bintree_update_data const GBintreePanel *panel; /* Transfert de panneau */ GtkTreeIter *top; /* Transfert de racine */ + GtkStatusStack *status; /* Transfert de statut */ + activity_id_t id; /* Transfert d'activité */ }; @@ -623,6 +625,7 @@ static bool populate_tree_with_portion(GBinPortion *portion, GBinPortion *parent update_bintree_node(data, store, &iter, portion); + gtk_status_stack_update_activity_value(data->status, data->id, 1); } @@ -674,6 +677,7 @@ static void reload_portions_for_new_tree_view(const GBintreePanel *panel, GtkSta GtkTreeStore *store; /* Modèle de gestion */ GExeFormat *format; /* Format du binaire */ GBinPortion *portions; /* Couche première de portions */ + size_t count; /* Compteur de portions */ GtkTreeIter top; /* Racine de l'arborescence */ gint max_depth; /* Profondeur maximale */ GtkSpinButton *depth_spin; /* Bouton de variation */ @@ -689,6 +693,10 @@ static void reload_portions_for_new_tree_view(const GBintreePanel *panel, GtkSta portions = g_exe_format_get_portions(format); + count = g_binary_portion_count(portions); + + gtk_status_stack_extend_activity(status, id, count); + gtk_tree_store_append(store, &top, NULL); gtk_tree_store_set(store, &top, @@ -698,6 +706,8 @@ static void reload_portions_for_new_tree_view(const GBintreePanel *panel, GtkSta data->panel = panel; data->top = ⊤ + data->status = status; + data->id = id; g_binary_portion_visit(portions, (visit_portion_fc)populate_tree_with_portion, data); @@ -1060,7 +1070,7 @@ static const char *g_bintree_panel_setup(const GBintreePanel *panel, unsigned in { case PUI_0: - *count = 1; + *count = 0; (*data)->count = 0; result = _("Loading portions contained in the binary format..."); -- cgit v0.11.2-87-g4458