diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-10-08 17:56:51 +0900 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-10-09 16:32:05 +0900 |
commit | 856e10ddb27e6494eaa01b88f3ed3939e5258f21 (patch) | |
tree | 23b9dd1a5dd9dbcc1a1d2120f6062bca5d87d181 /divelist.c | |
parent | 14856aab4bb8511e12a073cd987c1fbf9d641274 (diff) | |
download | subsurface-856e10ddb27e6494eaa01b88f3ed3939e5258f21.tar.gz |
Add trip above adds all consecutive selected dives to the new trip
Before this commit we had the odd behavior that if we right clicked in the
middle of a group of selected dives, the trip was added above the dive we
clicked on, not above the group.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r-- | divelist.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/divelist.c b/divelist.c index 910b0c909..3272cdfdc 100644 --- a/divelist.c +++ b/divelist.c @@ -1632,6 +1632,21 @@ static void insert_trip_before_cb(GtkWidget *menuitem, GtkTreePath *path) GtkTreePath *next_path; dive = dive_from_path(path); + if (dive->selected) { + next_path = gtk_tree_path_copy(path); + for (;;) { + /* let's find the first dive in a block of selected dives */ + if (gtk_tree_path_prev(next_path)) { + next_dive = dive_from_path(next_path); + if (next_dive && next_dive->selected) { + path = gtk_tree_path_copy(next_path); + continue; + } + } + break; + } + } + /* now path points at the first selected dive in a consecutive block */ turn_dive_into_trip(path); /* if the dive was selected and the next dive was selected, too, * then all of them should be part of the new trip */ |