summaryrefslogtreecommitdiffstats
path: root/divelist.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-23 21:57:28 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-09-23 21:57:28 -0700
commitbe418458dbf4299ef289b2790ac36e3efa3b5261 (patch)
tree6867b015b11d323407955c5845b1461faec8bc18 /divelist.c
parentc6140c6e21aeff4c6e27e67bee407a1c3f552b18 (diff)
downloadsubsurface-be418458dbf4299ef289b2790ac36e3efa3b5261.tar.gz
Add "merge selected dives" to dive list popup menu
This is fairly straight forward. What I dislike is the check for the magic number of "14 indeces". I'm sure there's a better way to tell if more than one dive is selected... Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'divelist.c')
-rw-r--r--divelist.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/divelist.c b/divelist.c
index 6e3fc598e..baf0428e0 100644
--- a/divelist.c
+++ b/divelist.c
@@ -25,7 +25,7 @@
* void clear_trip_indexes(void)
* void delete_single_dive(int idx)
* void add_single_dive(int idx, struct dive *dive)
- * void merge_dive_index(int i, struct dive *a)
+ * void merge_two_dives(struct dive *a, struct dive *b)
* void select_dive(int idx)
* void deselect_dive(int idx)
* void mark_divelist_changed(int changed)
@@ -916,22 +916,24 @@ void add_single_dive(int idx, struct dive *dive)
}
}
-void merge_dive_index(int i, struct dive *a)
+struct dive *merge_two_dives(struct dive *a, struct dive *b)
{
- struct dive *b = get_dive(i+1);
struct dive *res;
+ int i,j;
+ if (!a || !b)
+ return NULL;
+ i = get_index_for_dive(a);
+ j = get_index_for_dive(b);
res = merge_dives(a, b, b->when - a->when, FALSE);
if (!res)
- return;
+ return NULL;
add_single_dive(i, res);
delete_single_dive(i+1);
- delete_single_dive(i+1);
-#if USE_GTK_UI
- dive_list_update_dives();
-#endif
+ delete_single_dive(j);
mark_divelist_changed(TRUE);
+ return res;
}
void select_dive(int idx)