summaryrefslogtreecommitdiffstats
path: root/statistics.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-08-13 21:11:09 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-08-14 13:22:31 -0700
commit822b6409d752133090df24f5ca38f69656ff82b7 (patch)
tree008bc3dc6f12ff58dbbb4eba22ae91593c623db4 /statistics.c
parent5ba89c13ac09ee7649abf2d0c4514f9a83bb6c8b (diff)
downloadsubsurface-822b6409d752133090df24f5ca38f69656ff82b7.tar.gz
Fix selecting and unselecting summary items
The dive list now seems to behave intuitively. In order to do this we had to intercept the select function in addition to having a selection-changed callback. That way we can simulate the multi-level selection and unselection that was missing. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r--statistics.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/statistics.c b/statistics.c
index adfc9c77a..3a260066a 100644
--- a/statistics.c
+++ b/statistics.c
@@ -142,30 +142,39 @@ 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)
{
struct dive *dp;
- unsigned int i;
+ unsigned int i, j;
int idx;
GtkTreeIter iter;
GtkTreePath *path;
memset(&stats_selection, 0, sizeof(stats_selection));
- stats_selection.selection_size = amount_selected;
- for (i = 0; i < amount_selected; ++i) {
+ /* 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);
- dp = get_dive(idx);
- if (dp) {
- selectiontracker[i] = idx;
- process_dive(dp, &stats_selection);
+ if (idx > 0) {
+ dp = get_dive(idx);
+ if (dp) {
+ selectiontracker[j] = idx;
+ process_dive(dp, &stats_selection);
+ j++;
+ continue;
+ }
}
}
+ /* we didn't process it, so shorten the list */
+ amount_selected--;
}
+ /* record the actual number of dives selected */
+ stats_selection.selection_size = amount_selected;
}
static void set_label(GtkWidget *w, const char *fmt, ...)