summaryrefslogtreecommitdiffstats
path: root/main.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2011-10-05 11:36:15 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2011-10-05 13:36:17 -0700
commitdbdd42b31f73ad8e8117d5b2a5b4ac4e061bf202 (patch)
treea569978161130384e345853a45624aeb2922d4df /main.c
parentc785ceaf4cb4032dafb832d27caba419d5be1adc (diff)
downloadsubsurface-dbdd42b31f73ad8e8117d5b2a5b4ac4e061bf202.tar.gz
Add XML file import back and treat open and import differently
Open (or adding a file name on the command line) means that this is just one of the files that you consider part of your dive history. So dives don't get automagically numbered and the dive_list is not considered "changed" just because another file was opened. Import (or adding a file on the command line after --import) means that you are importing the content of this file to your dive history. So if the imported file has un-numbered dives that are newer than everything else, those get correctly renumbered. And importing marks the dive_list as changed. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'main.c')
-rw-r--r--main.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/main.c b/main.c
index 642e07271..26d2eee22 100644
--- a/main.c
+++ b/main.c
@@ -101,7 +101,7 @@ static void try_to_renumber(struct dive *last, int preexisting)
* 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();
}
@@ -160,7 +162,7 @@ static void parse_argument(const char *arg)
if (strcmp(arg,"--import") == 0) {
/* mark the dives so far as the base,
* everything after is imported */
- report_dives();
+ report_dives(TRUE);
return;
}
/* fallthrough */
@@ -227,7 +229,7 @@ int main(int argc, char **argv)
}
}
- report_dives();
+ report_dives(FALSE);
run_ui();
return 0;