mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 13:10:19 +00:00
Make "create trip above" also add on selected dives
This makes things more consistent with the merge with trip above option - if multiple dives are selected then the consecutive set of selected top level dives below the dive on which a user right-clicked are all added to the newly created trip. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
b49b081bb9
commit
42bff28e47
1 changed files with 28 additions and 9 deletions
37
divelist.c
37
divelist.c
|
@ -161,6 +161,17 @@ static GtkTreePath *get_path_from(struct dive *dive)
|
||||||
return path_match;
|
return path_match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct dive *dive_from_path(GtkTreePath *path)
|
||||||
|
{
|
||||||
|
GtkTreeIter iter;
|
||||||
|
int idx;
|
||||||
|
|
||||||
|
gtk_tree_model_get_iter(MODEL(dive_list), &iter, path);
|
||||||
|
gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);
|
||||||
|
return get_dive(idx);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure that if we expand a summary row that is selected, the children show
|
/* make sure that if we expand a summary row that is selected, the children show
|
||||||
up as selected, too */
|
up as selected, too */
|
||||||
void row_expanded_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
|
void row_expanded_cb(GtkTreeView *tree_view, GtkTreeIter *iter, GtkTreePath *path, gpointer data)
|
||||||
|
@ -1260,13 +1271,7 @@ void edit_selected_dives_cb(GtkWidget *menuitem, gpointer data)
|
||||||
|
|
||||||
void edit_dive_from_path_cb(GtkWidget *menuitem, GtkTreePath *path)
|
void edit_dive_from_path_cb(GtkWidget *menuitem, GtkTreePath *path)
|
||||||
{
|
{
|
||||||
GtkTreeIter iter;
|
struct dive *dive = dive_from_path(path);
|
||||||
int idx;
|
|
||||||
struct dive *dive;
|
|
||||||
|
|
||||||
gtk_tree_model_get_iter(MODEL(dive_list), &iter, path);
|
|
||||||
gtk_tree_model_get(MODEL(dive_list), &iter, DIVE_INDEX, &idx, -1);
|
|
||||||
dive = get_dive(idx);
|
|
||||||
|
|
||||||
edit_multi_dive_info(dive);
|
edit_multi_dive_info(dive);
|
||||||
}
|
}
|
||||||
|
@ -1503,10 +1508,24 @@ static void insert_trip_before(GtkTreePath *path)
|
||||||
static void insert_trip_before_cb(GtkWidget *menuitem, GtkTreePath *path)
|
static void insert_trip_before_cb(GtkWidget *menuitem, GtkTreePath *path)
|
||||||
{
|
{
|
||||||
/* is this splitting a trip or turning a dive into a trip? */
|
/* is this splitting a trip or turning a dive into a trip? */
|
||||||
if (gtk_tree_path_get_depth(path) == 2)
|
if (gtk_tree_path_get_depth(path) == 2) {
|
||||||
insert_trip_before(path);
|
insert_trip_before(path);
|
||||||
else
|
} else { /* this is a top level dive */
|
||||||
|
struct dive *dive, *next_dive;
|
||||||
|
GtkTreePath *next_path;
|
||||||
|
|
||||||
|
dive = dive_from_path(path);
|
||||||
turn_dive_into_trip(path);
|
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 */
|
||||||
|
if (dive->selected) {
|
||||||
|
next_path = gtk_tree_path_copy(path);
|
||||||
|
gtk_tree_path_next(next_path);
|
||||||
|
next_dive = dive_from_path(next_path);
|
||||||
|
if (next_dive && next_dive->selected)
|
||||||
|
merge_dive_into_trip_above_cb(menuitem, next_path);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_from_trip(GtkTreePath *path)
|
static void remove_from_trip(GtkTreePath *path)
|
||||||
|
|
Loading…
Reference in a new issue