From 856e10ddb27e6494eaa01b88f3ed3939e5258f21 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 8 Oct 2012 17:56:51 +0900 Subject: [PATCH] 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 --- divelist.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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 */