X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=statistics.c;h=b9d2c3b95d19c57f96b2a353e274d9bb4304c301;hb=666538ec7739fe839623bd1b6f9f80ff884ad5a9;hp=3a260066a259d58c2305ace1255f88e7f829e66f;hpb=822b6409d752133090df24f5ca38f69656ff82b7;p=ext%2Fsubsurface.git diff --git a/statistics.c b/statistics.c index 3a26006..b9d2c3b 100644 --- a/statistics.c +++ b/statistics.c @@ -143,38 +143,21 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) } /* make sure we skip the selected summary entries */ -void process_selected_dives(GList *selected_dives, int *selectiontracker, GtkTreeModel *model) +void process_selected_dives(void) { - struct dive *dp; - unsigned int i, j; - int idx; - GtkTreeIter iter; - GtkTreePath *path; + struct dive *dive; + unsigned int i, nr; memset(&stats_selection, 0, sizeof(stats_selection)); - /* adjust amount_selected and remove negative index entries from list */ - for (i = 0, j = 0; j < amount_selected; ++i) { - GValue value = {0, }; - path = g_list_nth_data(selected_dives, i); - if (gtk_tree_model_get_iter(model, &iter, path)) { - gtk_tree_model_get_value(model, &iter, 0, &value); - idx = g_value_get_int(&value); - if (idx > 0) { - dp = get_dive(idx); - if (dp) { - selectiontracker[j] = idx; - process_dive(dp, &stats_selection); - j++; - continue; - } - } + nr = 0; + for_each_dive(i, dive) { + if (dive->selected) { + process_dive(dive, &stats_selection); + nr++; } - /* we didn't process it, so shorten the list */ - amount_selected--; } - /* record the actual number of dives selected */ - stats_selection.selection_size = amount_selected; + stats_selection.selection_size = nr; } static void set_label(GtkWidget *w, const char *fmt, ...) @@ -288,10 +271,7 @@ static void show_total_dive_stats(struct dive *dive) const char *unit; stats_t *stats_ptr; - if (amount_selected < 2) - stats_ptr = &stats; - else - stats_ptr = &stats_selection; + stats_ptr = &stats_selection; set_label(stats_w.selection_size, "%d", stats_ptr->selection_size); if (stats_ptr->min_temp) {