summaryrefslogtreecommitdiffstats
path: root/parse-xml.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-01 17:29:38 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-01-01 17:29:38 -0800
commita58d470bad755c138a84b5516fa27bf74924e24c (patch)
tree6b902760a42bba3707dff08191c5d3f442074d29 /parse-xml.c
parent030d0c1294bf6c90c3a58e6678dc56760d197bcb (diff)
downloadsubsurface-a58d470bad755c138a84b5516fa27bf74924e24c.tar.gz
Remove autogroup from the preferences and store per file instead
Having two spots to toggle autogroup had always been a clear sign of insanity. The inconsistent ludicrous semantic of when we remembered the state of autogroup was even worse. This finally gets rid of that disaster and drops the autogroup setting from the preferences and makes it instead a per file property. When you save a file, it saves the state of the autogroup toggle. This seems much more useful - you may have files where you want to create trips by default. And others, where you don't. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'parse-xml.c')
-rw-r--r--parse-xml.c33
1 files changed, 28 insertions, 5 deletions
diff --git a/parse-xml.c b/parse-xml.c
index a256990b3..e7cb1a182 100644
--- a/parse-xml.c
+++ b/parse-xml.c
@@ -595,16 +595,29 @@ static void eventtime(char *buffer, void *_duration)
duration->seconds += cur_sample->time.seconds;
}
+static void try_to_match_autogroup(const char *name, char *buf)
+{
+ int len = strlen(name);
+ int autogroupvalue;
+
+ start_match("autogroup", name, buf);
+ if (MATCH(".autogroup.state", get_index, &autogroupvalue)) {
+ set_autogroup(autogroupvalue);
+ return;
+ }
+ nonmatch("autogroup", name, buf);
+}
+
static void try_to_fill_dc_settings(const char *name, char *buf)
{
int len = strlen(name);
start_match("divecomputerid", name, buf);
- if (MATCH(".model", utf8_string, &cur_settings.dc.model))
+ if (MATCH("divecomputerid.model", utf8_string, &cur_settings.dc.model))
return;
- if (MATCH(".deviceid", hex_value, &cur_settings.dc.deviceid))
+ if (MATCH("divecomputerid.deviceid", hex_value, &cur_settings.dc.deviceid))
return;
- if (MATCH(".nickname", utf8_string, &cur_settings.dc.nickname))
+ if (MATCH("divecomputerid.nickname", utf8_string, &cur_settings.dc.nickname))
return;
nonmatch("divecomputerid", name, buf);
@@ -1053,15 +1066,23 @@ static void reset_dc_settings(void)
cur_settings.dc.deviceid = 0;
}
-static void dc_settings_start(void)
+static void settings_start(void)
{
in_settings = TRUE;
+}
+
+static void settings_end(void)
+{
+ in_settings = FALSE;
+}
+
+static void dc_settings_start(void)
+{
reset_dc_settings();
}
static void dc_settings_end(void)
{
- in_settings = FALSE;
if (cur_settings.dc.model)
remember_dc(cur_settings.dc.model, cur_settings.dc.deviceid, cur_settings.dc.nickname, TRUE);
reset_dc_settings();
@@ -1218,6 +1239,7 @@ static void entry(const char *name, char *buf)
{
if (in_settings) {
try_to_fill_dc_settings(name, buf);
+ try_to_match_autogroup(name, buf);
return;
}
if (cur_event.active) {
@@ -1341,6 +1363,7 @@ static struct nesting {
void (*start)(void), (*end)(void);
} nesting[] = {
{ "divecomputerid", dc_settings_start, dc_settings_end },
+ { "settings", settings_start, settings_end },
{ "dive", dive_start, dive_end },
{ "Dive", dive_start, dive_end },
{ "trip", trip_start, trip_end },