Store the user's unit preferences in git storage

Save and load a usually unused copy of the preferences with the units that
were active the last time the dive list was saved to git storage (this
isn't used in XML files); storing the unit preferences in the data file is
usually pointless (that's a setting of the software, not a property of the
data), but it's a great hint of what the user might expect to see when
creating a backend service that visualizes the dive list without
Subsurface running - so this is basically a functionality for the core
library that Subsurface itself doesn't use but that another consumer of
the library (like an HTML exporter) will need.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-16 20:28:42 -07:00
parent 7cf3ebc2f7
commit ff4b5478b5
6 changed files with 75 additions and 3 deletions

View file

@ -727,6 +727,12 @@ static void parse_trip_notes(char *line, struct membuffer *str, void *_trip)
static void parse_settings_autogroup(char *line, struct membuffer *str, void *_unused)
{ set_autogroup(1); }
static void parse_settings_units(char *line, struct membuffer *str, void *unused)
{
if (line)
set_informational_units(line);
}
static void parse_settings_userid(char *line, struct membuffer *str, void *_unused)
{
if (line) {
@ -895,7 +901,7 @@ static void trip_parser(char *line, struct membuffer *str, void *_trip)
static struct keyword_action settings_action[] = {
#undef D
#define D(x) { #x, parse_settings_ ## x }
D(autogroup), D(divecomputerid), D(subsurface), D(userid), D(version),
D(autogroup), D(divecomputerid), D(subsurface), D(units), D(userid), D(version),
};
static void settings_parser(char *line, struct membuffer *str, void *_unused)