diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-09 08:51:20 -0800 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-11-09 08:57:06 -0800 |
commit | c51b105526b7722d7d29d6111f4afd80a5e7c27b (patch) | |
tree | ea40da4a59556e30f94bb0ace6b5dbd7fa3ba4f8 /equipment.c | |
parent | 8e6bdc4f94eec68ab88cfc031c2358acd0a34b3b (diff) | |
download | subsurface-c51b105526b7722d7d29d6111f4afd80a5e7c27b.tar.gz |
Add "enable" button for manual pressure setting
This grays out the pressure settings in the cylinder editing widget if
the pressure data has been taken from the samples. You can still
manually override the data, but you now need to enable that manual
override explicitly.
This makes the semantics of editing start/end pressures of dives with
pressure sample data a bit more intuitive, I think.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'equipment.c')
-rw-r--r-- | equipment.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/equipment.c b/equipment.c index 2e0e71a68..19abbe672 100644 --- a/equipment.c +++ b/equipment.c @@ -46,7 +46,7 @@ struct cylinder_widget { GtkWidget *hbox; GtkComboBox *description; GtkSpinButton *size, *pressure; - GtkWidget *start, *end; + GtkWidget *start, *end, *pressure_button; GtkWidget *o2, *gasmix_button; }; @@ -101,11 +101,24 @@ static void set_cylinder_type_spinbuttons(struct cylinder_widget *cylinder, int static void set_cylinder_pressure_spinbuttons(struct cylinder_widget *cylinder, cylinder_t *cyl) { + int set; + unsigned int start, end; double pressure; - convert_pressure(cyl->start.mbar, &pressure); + start = cyl->start.mbar; + end = cyl->end.mbar; + set = start || end; + if (!set) { + start = cyl->sample_start.mbar; + end = cyl->sample_end.mbar; + } + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cylinder->pressure_button), set); + gtk_widget_set_sensitive(cylinder->start, set); + gtk_widget_set_sensitive(cylinder->end, set); + + convert_pressure(start, &pressure); gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->start), pressure); - convert_pressure(cyl->end.mbar, &pressure); + convert_pressure(end, &pressure); gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->end), pressure); } @@ -405,6 +418,8 @@ static void record_cylinder_changes(cylinder_t *cyl, struct cylinder_widget *cyl pressure = gtk_spin_button_get_value(cylinder->pressure); start = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->start)); end = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->end)); + if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cylinder->pressure_button))) + start = end = 0; o2 = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->o2))*10 + 0.5; if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button))) o2 = 0; @@ -496,6 +511,16 @@ static void nitrox_cb(GtkToggleButton *button, gpointer data) gtk_widget_set_sensitive(cylinder->o2, state); } +static void pressure_cb(GtkToggleButton *button, gpointer data) +{ + struct cylinder_widget *cylinder = data; + int state; + + state = gtk_toggle_button_get_active(button); + gtk_widget_set_sensitive(cylinder->start, state); + gtk_widget_set_sensitive(cylinder->end, state); +} + static gboolean completion_cb(GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, struct cylinder_widget *cylinder) { const char *desc; @@ -559,6 +584,10 @@ static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, G hbox = gtk_hbox_new(FALSE, 3); gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); + cylinder->pressure_button = gtk_check_button_new(); + gtk_box_pack_start(GTK_BOX(hbox), cylinder->pressure_button, FALSE, FALSE, 3); + g_signal_connect(cylinder->pressure_button, "toggled", G_CALLBACK(pressure_cb), cylinder); + widget = create_spinbutton(hbox, "Start Pressure", 0, 5000, 1); cylinder->start = widget; |