Move global variables covered by Preferences into one structure

Now we can simply remember the state of all the preferences at the
beginning of preferences_dialog() and restore them if the user presses
'Cancel'.

Fixes #21

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2012-12-10 09:20:57 -08:00
parent 54919c1c4e
commit 92c0d8c516
10 changed files with 191 additions and 176 deletions

27
dive.h
View file

@ -390,9 +390,32 @@ struct units {
enum { KG, LBS } weight;
};
extern const struct units SI_units, IMPERIAL_units;
extern struct units input_units, output_units;
/*
* We're going to default to SI units for input. Yes,
* technically the SI unit for pressure is Pascal, but
* we default to bar (10^5 pascal), which people
* actually use. Similarly, C instead of Kelvin.
* And kg instead of g.
*/
#define SI_UNITS { \
.length = METERS, \
.volume = LITER, \
.pressure = BAR, \
.temperature = CELSIUS, \
.weight = KG \
}
#define IMPERIAL_UNITS { \
.length = FEET, \
.volume = CUFT, \
.pressure = PSI, \
.temperature = FAHRENHEIT, \
.weight = LBS \
}
extern const struct units SI_units, IMPERIAL_units;
extern struct units input_units;
extern struct units *get_output_units(void);
extern int verbose;
struct dive_table {