summaryrefslogtreecommitdiffstats
path: root/dive.c
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-10 09:20:57 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2012-12-10 10:26:06 -0800
commit92c0d8c5160232642571b52b66176594c796f21d (patch)
treed3b78a6deba3af0119b493dbfd0a8ec8c4a13304 /dive.c
parent54919c1c4ec94cd21150c5320fa0956d13df5904 (diff)
downloadsubsurface-92c0d8c5160232642571b52b66176594c796f21d.tar.gz
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>
Diffstat (limited to 'dive.c')
-rw-r--r--dive.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/dive.c b/dive.c
index d4e0217d7..b197c835f 100644
--- a/dive.c
+++ b/dive.c
@@ -34,8 +34,9 @@ int get_pressure_units(unsigned int mb, const char **units)
{
int pressure;
const char* unit;
+ struct units *output_units_p = get_output_units();
- switch (output_units.pressure) {
+ switch (output_units_p->pressure) {
case PASCAL:
pressure = mb * 100;
unit = _("pascal");
@@ -58,8 +59,9 @@ double get_temp_units(unsigned int mk, const char **units)
{
double deg;
const char *unit;
+ struct units *output_units_p = get_output_units();
- if (output_units.temperature == FAHRENHEIT) {
+ if (output_units_p->temperature == FAHRENHEIT) {
deg = mkelvin_to_F(mk);
unit = UTF8_DEGREE "F";
} else {
@@ -76,8 +78,9 @@ double get_volume_units(unsigned int ml, int *frac, const char **units)
int decimals;
double vol;
const char *unit;
+ struct units *output_units_p = get_output_units();
- switch (output_units.volume) {
+ switch (output_units_p->volume) {
case LITER:
vol = ml / 1000.0;
unit = _("l");
@@ -101,8 +104,9 @@ double get_depth_units(unsigned int mm, int *frac, const char **units)
int decimals;
double d;
const char *unit;
+ struct units *output_units_p = get_output_units();
- switch (output_units.length) {
+ switch (output_units_p->length) {
case METERS:
d = mm / 1000.0;
unit = _("m");
@@ -126,8 +130,9 @@ double get_weight_units(unsigned int grams, int *frac, const char **units)
int decimals;
double value;
const char* unit;
+ struct units *output_units_p = get_output_units();
- if (output_units.weight == LBS) {
+ if (output_units_p->weight == LBS) {
value = grams_to_lbs(grams);
unit = _("lbs");
decimals = 0;