diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-09-03 20:51:09 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-09-03 20:51:09 -0700 |
commit | b9d74580d0ef68393934d5d651318254f006b786 (patch) | |
tree | 3b9a7e91c7c47c4a80d641801a97cf4b0b46f598 | |
parent | 70d254ab844ca5d4129eebdadd0b8729acd0d1e8 (diff) | |
download | subsurface-b9d74580d0ef68393934d5d651318254f006b786.tar.gz |
Add ability to merge trip with trip below
Miika suggested this - we should be able to merge with the trip below and
not just the trip above (oh, and call them "above/below" instead of
"previous").
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | divelist.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/divelist.c b/divelist.c index 90b3f693d..c73ac5b22 100644 --- a/divelist.c +++ b/divelist.c @@ -1517,9 +1517,9 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int { GtkWidget *menu, *menuitem, *image; char editlabel[] = "Edit dives"; - GtkTreePath *path, *prevpath; - GtkTreeIter iter, previter; - int idx, previdx; + GtkTreePath *path, *prevpath, *nextpath; + GtkTreeIter iter, previter, nextiter; + int idx, previdx, nextidx; struct dive *dive; if (!gtk_tree_view_get_path_at_pos(tree_view, event->x, event->y, &path, NULL, NULL, NULL)) @@ -1544,11 +1544,21 @@ static void popup_divelist_menu(GtkTreeView *tree_view, GtkTreeModel *model, int gtk_tree_model_get_iter(MODEL(dive_list), &previter, prevpath)) { gtk_tree_model_get(MODEL(dive_list), &previter, DIVE_INDEX, &previdx, -1); if (previdx < 0) { - menuitem = gtk_menu_item_new_with_label("Merge trip with previous"); + menuitem = gtk_menu_item_new_with_label("Merge trip with trip above"); g_signal_connect(menuitem, "activate", G_CALLBACK(merge_trips_cb), path); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); } } + nextpath = gtk_tree_path_copy(path); + gtk_tree_path_next(nextpath); + if (gtk_tree_model_get_iter(MODEL(dive_list), &nextiter, nextpath)) { + gtk_tree_model_get(MODEL(dive_list), &nextiter, DIVE_INDEX, &nextidx, -1); + if (nextidx < 0) { + menuitem = gtk_menu_item_new_with_label("Merge trip with trip below"); + g_signal_connect(menuitem, "activate", G_CALLBACK(merge_trips_cb), nextpath); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + } + } menuitem = gtk_menu_item_new_with_label("Remove Trip"); g_signal_connect(menuitem, "activate", G_CALLBACK(remove_trip_cb), path); gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); |