diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-09-20 15:31:39 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-09-20 15:35:43 -0700 |
commit | 529a72e6b496ef98702570ca944f415c09ac745c (patch) | |
tree | 2153c1b491256f3a93a450b89115349ddd5bc8b1 /divelist.c | |
parent | 7fa039994909cbbfc86d94ddea4a9c8867b0ed6c (diff) | |
download | subsurface-529a72e6b496ef98702570ca944f415c09ac745c.tar.gz |
Only select last dive by default if no other dives are selected
After deleting a dive the dive list is recreated. If there are still dives
selected we should select the last dive as well. If there isn't any dive
selected, then the last dive is as good a default as any, I guess.
Reported-by: "Lubomir I. Ivanov" <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/divelist.c b/divelist.c index 4f6808b1b..810b5be7c 100644 --- a/divelist.c +++ b/divelist.c @@ -1247,7 +1247,7 @@ static void fill_dive_list(void) DIVE_LOCATION, dive_trip->location, -1); update_dive_list_units(); - if (gtk_tree_model_get_iter_first(MODEL(dive_list), &iter)) { + if (amount_selected == 0 && gtk_tree_model_get_iter_first(MODEL(dive_list), &iter)) { GtkTreeSelection *selection; /* select the last dive (and make sure it's an actual dive that is selected) */ @@ -1876,18 +1876,21 @@ static void delete_dive_cb(GtkWidget *menuitem, GtkTreePath *path) for (i = idx; i < dive_table.nr - 1; i++) dive_table.dives[i] = dive_table.dives[i+1]; dive_table.nr--; + if (dive->selected) + amount_selected--; free(dive); + /* now make sure the correct dive list is displayed, the same + * dives stay selected and if necessary their trips are + * expanded. If no selected dives are left then fill_dive_list() + * (which gets called from dive_list_update_dives()) will once + * again select the last dive in the dive list */ dive_list_update_dives(); - /* now make sure the same dives stay selected and if necessary their trips are expanded - * also make sure that amount_selected stays consistent */ - amount_selected = 0; for_each_dive(i, dive) { if (dive->selected) { GtkTreePath *path = get_path_from(dive); if (MODEL(dive_list) == TREEMODEL(dive_list)) gtk_tree_view_expand_to_path(tree_view, path); gtk_tree_selection_select_path(selection, path); - amount_selected++; } } mark_divelist_changed(TRUE); |