summaryrefslogtreecommitdiffstats
path: root/gtk-gui.c
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-03-23 21:07:53 -0700
committerGravatar Linus Torvalds <torvalds@linux-foundation.org>2012-03-23 21:07:53 -0700
commit81fddfa67e779c8d378eee4c57fd9f201e15f96f (patch)
tree94fa92476642bcbfbcc334a5a7516cc20fbba4f2 /gtk-gui.c
parenta738108549371f62a29ef4f4fd005ffcccc84b19 (diff)
parent854bd0269c05adc56caf9667fd68f676520a2941 (diff)
downloadsubsurface-81fddfa67e779c8d378eee4c57fd9f201e15f96f.tar.gz
Merge branch 'weight' of git://subsurface.hohndel.org/subsurface
Pull weight management from Dirk Hohndel: "This is the fifth or sixth version of this code, I'm begining to lose track. I still struggle with the balance between code duplication and unnecessary indirectness and complexity. Maybe I'm just not finding the right level of abstraction. Maybe I'm just trying too hard. The code here is reasonably well tested. Works for me :-) It can import DivingLog xml files with weight systems and correctly parses those. It obviously can read and write weight systems in its own file format. It adds a KG/lbs unit default (and correctly stores that). The thing I still worry about is the code in equipment.c. You'll see that I tried to abstract things in a way that weight systems and cylinders share quite a bit of code - but there's more very similar code that isn't shared as my attempts to do so turned into ugly and hard to read code. It always felt like trying to write C++ in C..." * 'weight' of git://subsurface.hohndel.org/subsurface: Add weight system tracking Fix up some trivial conflicts due to various renaming of globals and simplification in function interfaces.
Diffstat (limited to 'gtk-gui.c')
-rw-r--r--gtk-gui.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/gtk-gui.c b/gtk-gui.c
index 402e91a6e..7d0e95c43 100644
--- a/gtk-gui.c
+++ b/gtk-gui.c
@@ -296,6 +296,8 @@ UNITCALLBACK(set_liter, volume, LITER)
UNITCALLBACK(set_cuft, volume, CUFT)
UNITCALLBACK(set_celsius, temperature, CELSIUS)
UNITCALLBACK(set_fahrenheit, temperature, FAHRENHEIT)
+UNITCALLBACK(set_kg, weight, KG)
+UNITCALLBACK(set_lbs, weight, LBS)
#define OPTIONCALLBACK(name, option) \
static void name(GtkWidget *w, gpointer data) \
@@ -357,6 +359,11 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
"Fahrenheit", set_fahrenheit, (output_units.temperature == FAHRENHEIT),
NULL);
+ create_radio(box, "Weight:",
+ "kg", set_kg, (output_units.weight == KG),
+ "lbs", set_lbs, (output_units.weight == LBS),
+ NULL);
+
frame = gtk_frame_new("Columns");
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), frame, FALSE, FALSE, 5);
@@ -409,6 +416,7 @@ static void preferences_dialog(GtkWidget *w, gpointer data)
subsurface_set_conf("psi", PREF_BOOL, BOOL_TO_PTR(output_units.pressure == PSI));
subsurface_set_conf("cuft", PREF_BOOL, BOOL_TO_PTR(output_units.volume == CUFT));
subsurface_set_conf("fahrenheit", PREF_BOOL, BOOL_TO_PTR(output_units.temperature == FAHRENHEIT));
+ subsurface_set_conf("lbs", PREF_BOOL, BOOL_TO_PTR(output_units.weight == LBS));
subsurface_set_conf("TEMPERATURE", PREF_BOOL, BOOL_TO_PTR(visible_cols.temperature));
subsurface_set_conf("CYLINDER", PREF_BOOL, BOOL_TO_PTR(visible_cols.cylinder));
subsurface_set_conf("NITROX", PREF_BOOL, BOOL_TO_PTR(visible_cols.nitrox));
@@ -670,6 +678,8 @@ void init_ui(int *argcp, char ***argvp)
output_units.volume = CUFT;
if (subsurface_get_conf("fahrenheit", PREF_BOOL))
output_units.temperature = FAHRENHEIT;
+ if (subsurface_get_conf("lbs", PREF_BOOL))
+ output_units.weight = LBS;
/* an unset key is FALSE - all these are hidden by default */
visible_cols.cylinder = PTR_TO_BOOL(subsurface_get_conf("CYLINDER", PREF_BOOL));
visible_cols.temperature = PTR_TO_BOOL(subsurface_get_conf("TEMPERATURE", PREF_BOOL));