diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-22 17:18:58 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-10-22 17:22:13 +0300 |
commit | 567c945714e0f627b8b7fe638d925b91b8397a9a (patch) | |
tree | d215335ce70dd1a405055c05d9b18300de445069 | |
parent | abaed4c2756e8c79f4f529bb960b037adedff3bb (diff) | |
download | subsurface-567c945714e0f627b8b7fe638d925b91b8397a9a.tar.gz |
Fix the reading of the cylinder start/end pressure from cylinder models
The cylinder model doesn't contain the start/end pressures, they just
contain the cylinder type information. So trying to read the start and
end pressure from the cylinder model change callback is totally bogus.
We need to set the start/end pressures from the cylinder info when we
create the cylinder widget, and not touch them when the type changes.
So split up the "set_cylinder_spinbuttons()" function in two: one that
sets the type information, and one that sets the start/end pressure.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | equipment.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/equipment.c b/equipment.c index 5ff8f0fe6..690064390 100644 --- a/equipment.c +++ b/equipment.c @@ -87,13 +87,18 @@ static int convert_volume_pressure(int ml, int mbar, double *v, double *p) return decimals; } -static void set_cylinder_spinbuttons(struct cylinder_widget *cylinder, int ml, int mbar, int start, int end) +static void set_cylinder_type_spinbuttons(struct cylinder_widget *cylinder, int ml, int mbar) { double volume, pressure; convert_volume_pressure(ml, mbar, &volume, &pressure); gtk_spin_button_set_value(cylinder->size, volume); gtk_spin_button_set_value(cylinder->pressure, pressure); +} + +static void set_cylinder_pressure_spinbuttons(struct cylinder_widget *cylinder, int start, int end) +{ + double pressure; convert_pressure(start, &pressure); gtk_spin_button_set_value(cylinder->start, pressure); @@ -105,7 +110,7 @@ static void cylinder_cb(GtkComboBox *combo_box, gpointer data) { GtkTreeIter iter; GtkTreeModel *model = gtk_combo_box_get_model(combo_box); - int ml, mbar, start, end; + int ml, mbar; struct cylinder_widget *cylinder = data; cylinder_t *cyl = current_dive->cylinder + cylinder->index; @@ -134,11 +139,9 @@ static void cylinder_cb(GtkComboBox *combo_box, gpointer data) gtk_tree_model_get(model, &iter, CYL_SIZE, &ml, CYL_WORKP, &mbar, - CYL_STARTP, &start, - CYL_ENDP, &end, -1); - set_cylinder_spinbuttons(cylinder, ml, mbar, start, end); + set_cylinder_type_spinbuttons(cylinder, ml, mbar); } /* @@ -205,8 +208,9 @@ static void show_cylinder(cylinder_t *cyl, struct cylinder_widget *cylinder) mbar = cyl->type.workingpressure.mbar; add_cylinder(cylinder, desc, ml, mbar); - set_cylinder_spinbuttons(cylinder, - cyl->type.size.mliter, cyl->type.workingpressure.mbar, + set_cylinder_type_spinbuttons(cylinder, + cyl->type.size.mliter, cyl->type.workingpressure.mbar); + set_cylinder_pressure_spinbuttons(cylinder, cyl->start.mbar, cyl->end.mbar); o2 = cyl->gasmix.o2.permille / 10.0; gtk_widget_set_sensitive(cylinder->o2, !!o2); |