mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-29 05:30:41 +00:00
8dea49ffe2
The old code (on purpose) didn't try to differentiate "nonexisting boolean configuration" with "existing boolean configuration set to false", which is problematic if we optimize the saving to not save default preferences at all. Which this does. So in addition to the logic to know about default preferences, this has to change the interfaces for the PREF_BOOL reading code so that you can tell the difference between "no value" and "false". And since the previous calling convention was an abomination of doing pointer casting and having case-statements for the config types, change that while at it. Both from a usage perspective *and* from a back-end perspective it is actually much simpler to just have different functions for the string vs boolean config read/write versions. The OSX versions in particular end up being one-liners. (The GConf library is a nightmare, and doesn't seem to have any way to know whether a boolean value exists or not, so you have to read it as a GConfVal and then turn it into a gboolean rather than just get the "oh, it didn't exist" as an error value). Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
48 lines
1.2 KiB
C
48 lines
1.2 KiB
C
#ifndef PREF_H
|
|
#define PREF_H
|
|
|
|
typedef struct {
|
|
gboolean cylinder;
|
|
gboolean temperature;
|
|
gboolean totalweight;
|
|
gboolean suit;
|
|
gboolean nitrox;
|
|
gboolean sac;
|
|
gboolean otu;
|
|
gboolean maxcns;
|
|
} visible_cols_t;
|
|
|
|
typedef struct {
|
|
gboolean po2;
|
|
gboolean pn2;
|
|
gboolean phe;
|
|
double po2_threshold;
|
|
double pn2_threshold;
|
|
double phe_threshold;
|
|
} partial_pressure_graphs_t;
|
|
|
|
struct preferences {
|
|
struct units units;
|
|
visible_cols_t visible_cols;
|
|
partial_pressure_graphs_t pp_graphs;
|
|
gboolean profile_red_ceiling;
|
|
gboolean profile_calc_ceiling;
|
|
gboolean calc_ceiling_3m_incr;
|
|
double gflow;
|
|
double gfhigh;
|
|
};
|
|
|
|
extern struct preferences prefs, default_prefs;
|
|
|
|
#define PP_GRAPHS_ENABLED (prefs.pp_graphs.po2 || prefs.pp_graphs.pn2 || prefs.pp_graphs.phe)
|
|
|
|
extern void subsurface_open_conf(void);
|
|
extern void subsurface_set_conf(char *name, const char *value);
|
|
extern void subsurface_set_conf_bool(char *name, gboolean value);
|
|
extern void subsurface_unset_conf(char *name);
|
|
extern const void *subsurface_get_conf(char *name);
|
|
extern int subsurface_get_conf_bool(char *name);
|
|
extern void subsurface_flush_conf(void);
|
|
extern void subsurface_close_conf(void);
|
|
|
|
#endif /* PREF_H */
|