diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-01-11 17:07:22 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-01-11 17:46:00 -0800 |
commit | 6a10700ca59e546c7a05688bdf5bffa388286bff (patch) | |
tree | 1cef21cc47580f1f64b0f186ebb712bca5b0cc24 /prefs.c | |
parent | 954290c70ba525cab4fefe83a3e82384ef01ba8c (diff) | |
download | subsurface-6a10700ca59e546c7a05688bdf5bffa388286bff.tar.gz |
Add default filename and divelist font to prefs structure
.. and add the usual logic to not save the default values.
This also simplifies the initial system-specific setup of both of these:
since we have defaults for all the preferences that get set up at
startup, we can just initialize those defaults to the system-specific
fonts then and there.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'prefs.c')
-rw-r--r-- | prefs.c | 26 |
1 files changed, 22 insertions, 4 deletions
@@ -1,3 +1,5 @@ +#include <string.h> + #include "dive.h" static void set_bool_conf(char *name, gboolean value, gboolean def) @@ -13,6 +15,16 @@ static void set_bool_conf(char *name, gboolean value, gboolean def) #define SAVE_UNIT(name, field, value) __SAVE_BOOLEAN(name, units.field, value) #define SAVE_BOOL(name, field) __SAVE_BOOLEAN(name, field, TRUE) +static void set_string_conf(char *name, const char *value, const char *def) +{ + if (!strcmp(value, def)) { + subsurface_unset_conf(name); + return; + } + subsurface_set_conf(name, value); +} +#define SAVE_STRING(name, field) set_string_conf(name, prefs.field, default_prefs.field) + /* We don't really save doubles */ static void save_double_conf(char *name, double _val, double _def) { @@ -63,7 +75,7 @@ void save_preferences(void) SAVE_BOOL("OTU", visible_cols.otu); SAVE_BOOL("MAXCNS", visible_cols.maxcns); - subsurface_set_conf("divelist_font", divelist_font); + SAVE_STRING("divelist_font", divelist_font); SAVE_BOOL("po2graph", pp_graphs.po2); SAVE_BOOL("pn2graph", pp_graphs.pn2); @@ -80,7 +92,7 @@ void save_preferences(void) SAVE_PERCENT("gflow", gflow); SAVE_PERCENT("gfhigh", gfhigh); - subsurface_set_conf("default_filename", default_filename); + SAVE_STRING("default_filename", default_filename); /* Flush the changes out to the system */ subsurface_flush_conf(); @@ -153,7 +165,13 @@ void load_preferences(void) free((void *)conf_value); } set_gf(prefs.gflow, prefs.gfhigh); - divelist_font = subsurface_get_conf("divelist_font"); - default_filename = subsurface_get_conf("default_filename"); + conf_value = subsurface_get_conf("divelist_font"); + if (conf_value) + prefs.divelist_font = conf_value; + + + conf_value = subsurface_get_conf("default_filename"); + if (conf_value) + prefs.default_filename = conf_value; } |