]> git.tdb.fi Git - ext/subsurface.git/blobdiff - main.c
XSLT to transform JDiveLog to Subsurface format
[ext/subsurface.git] / main.c
diff --git a/main.c b/main.c
index a09bfe03a01099efebe11f7337df2838a775e3f3..f34e3ae51b3f3fa952bf69cb6373b1eefef788ca 100644 (file)
--- a/main.c
+++ b/main.c
@@ -4,16 +4,11 @@
 #include <stdlib.h>
 #include <time.h>
 
-#include <gconf/gconf-client.h>
-
 #include "dive.h"
 #include "divelist.h"
 
-GConfClient *gconf;
 struct units output_units;
 
-#define GCONF_NAME(x) "/apps/subsurface/" #x
-
 /* random helper functions, used here or elsewhere */
 static int sortfn(const void *_a, const void *_b)
 {
@@ -97,11 +92,16 @@ static void try_to_renumber(struct dive *last, int preexisting)
        }
 }
 
+/*
+ * track whether we switched to importing dives
+ */
+static gboolean imported = FALSE;
+
 /*
  * This doesn't really report anything at all. We just sort the
  * dives, the GUI does the reporting
  */
-void report_dives(void)
+void report_dives(gboolean imported)
 {
        int i;
        int preexisting = dive_table.preexisting;
@@ -135,13 +135,15 @@ void report_dives(void)
                i--;
        }
 
-       /* Was the previous dive table state numbered? */
-       if (last && last->number)
-               try_to_renumber(last, preexisting);
+       if (imported) {
+               /* Was the previous dive table state numbered? */
+               if (last && last->number)
+                       try_to_renumber(last, preexisting);
 
-       /* did we have dives in the table and added more? */
-       if (last && preexisting != dive_table.nr)
-               mark_divelist_changed(TRUE);
+               /* did we have dives in the table and added more? */
+               if (last && preexisting != dive_table.nr)
+                       mark_divelist_changed(TRUE);
+       }
        dive_table.preexisting = dive_table.nr;
        dive_list_update_dives();
 }
@@ -155,6 +157,16 @@ static void parse_argument(const char *arg)
                case 'v':
                        verbose++;
                        continue;
+               case '-':
+                       /* long options with -- */
+                       if (strcmp(arg,"--import") == 0) {
+                               /* mark the dives so far as the base,
+                                * everything after is imported */
+                               report_dives(FALSE);
+                               imported = TRUE;
+                               return;
+                       }
+                       /* fallthrough */
                default:
                        fprintf(stderr, "Bad argument '%s'\n", arg);
                        exit(1);
@@ -186,6 +198,7 @@ void renumber_dives(int nr)
        for (i = 0; i < dive_table.nr; i++) {
                struct dive *dive = dive_table.dives[i];
                dive->number = nr + i;
+               flush_divelist(dive);
        }
        mark_divelist_changed(TRUE);
 }
@@ -218,7 +231,7 @@ int main(int argc, char **argv)
                }
        }
 
-       report_dives();
+       report_dives(imported);
 
        run_ui();
        return 0;