summaryrefslogtreecommitdiffstats
path: root/save-xml.c
diff options
context:
space:
mode:
authorGravatar Pierre-Yves Chibon <pingou@pingoured.fr>2013-02-01 09:28:33 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-02-02 00:10:14 +1100
commit20d3b5f71495adccf59d27095445a0d2e63b6a09 (patch)
tree15b34a49533609ff8ed19de8dd3f62d4752e4f10 /save-xml.c
parent60f9c338e9ddcc18495758ac7ad6926cce5af44d (diff)
downloadsubsurface-20d3b5f71495adccf59d27095445a0d2e63b6a09.tar.gz
Add 'Save As' entry to context menu shown when right clicking on a dive
Something which is nice especially when asked on the list to share an interesting dive is the possibility to save just some dives into a file. This commit adds to the context menu shown with right-click the 'Save As' entry. This entry allows to save selected dives. [Dirk Hohndel: clean up white space, commit message and remove unused variables] Signed-off-by: Pierre-Yves Chibon <pingou@pingoured.fr> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'save-xml.c')
-rw-r--r--save-xml.c36
1 files changed, 25 insertions, 11 deletions
diff --git a/save-xml.c b/save-xml.c
index 6e33cd5e6..b95a38028 100644
--- a/save-xml.c
+++ b/save-xml.c
@@ -536,6 +536,11 @@ static void save_device_info(FILE *f)
void save_dives(const char *filename)
{
+ save_dives_logic(filename, FALSE);
+}
+
+void save_dives_logic(const char *filename, const gboolean select_only)
+{
int i;
struct dive *dive;
dive_trip_t *trip;
@@ -561,21 +566,30 @@ void save_dives(const char *filename)
/* save the dives */
for_each_dive(i, dive) {
- trip = dive->divetrip;
- /* Bare dive without a trip? */
- if (!trip) {
+ if (select_only) {
+
+ if(!dive->selected)
+ continue;
save_dive(f, dive);
- continue;
- }
- /* Have we already seen this trip (and thus saved this dive?) */
- if (trip->index)
- continue;
+ } else {
+ trip = dive->divetrip;
+
+ /* Bare dive without a trip? */
+ if (!trip) {
+ save_dive(f, dive);
+ continue;
+ }
- /* We haven't seen this trip before - save it and all dives */
- trip->index = 1;
- save_trip(f, trip);
+ /* Have we already seen this trip (and thus saved this dive?) */
+ if (trip->index)
+ continue;
+
+ /* We haven't seen this trip before - save it and all dives */
+ trip->index = 1;
+ save_trip(f, trip);
+ }
}
fprintf(f, "</dives>\n</divelog>\n");
fclose(f);