diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-08-16 16:31:53 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-08-16 16:47:49 -0700 |
commit | 7cf0f6d5e19f57449078901a3730f9e40de3a012 (patch) | |
tree | c48f1e9b821a0e1274b99181b4eb8bfe6c39bca9 /statistics.c | |
parent | e6ecddfa3d17901847474b67b6121c0c8f56f078 (diff) | |
download | subsurface-7cf0f6d5e19f57449078901a3730f9e40de3a012.tar.gz |
Stop relying on gtk to track which dives are selected
We spend way too much effort trying to get gtk to manage the dives that
are selected. The straw that broke the camel's back is that gtk forces us
to expand any nodes that we want to select - so selecting a summary entry
for a dive trip forced us to expand all the dives in the dive trip. Which
as Linus pointed out really sucked from a user experience.
So instead we now completeley ignore gtk's weird idea of what is selected
and what isn't and simply track things ourselves. We still need to play
some games with gtk to make sure that the correct rows are SHOWN as
selected, but still, the overall code seems much cleaner.
This commit contains a bunch of debugging code that is ifdef'ed out -
this is extremely useful to make sure I didn't mess anything up, but
eventually I'll want to remove that again as it just looks ugly in the
code.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'statistics.c')
-rw-r--r-- | statistics.c | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/statistics.c b/statistics.c index 3a260066a..7ff2bfd01 100644 --- a/statistics.c +++ b/statistics.c @@ -146,34 +146,20 @@ static void process_all_dives(struct dive *dive, struct dive **prev_dive) void process_selected_dives(GList *selected_dives, int *selectiontracker, GtkTreeModel *model) { struct dive *dp; - unsigned int i, j; + unsigned int i; int idx; - GtkTreeIter iter; - GtkTreePath *path; 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; - } + for (i = 0; i < amount_selected; ++i) { + idx = selectiontracker[i]; + if (idx > 0) { + dp = get_dive(idx); + if (dp) { + process_dive(dp, &stats_selection); } } - /* we didn't process it, so shorten the list */ - amount_selected--; } - /* record the actual number of dives selected */ stats_selection.selection_size = amount_selected; } |