+static int cylinder_changed;
+static GtkComboBox *cylinder_description;
+static GtkSpinButton *cylinder_size, *cylinder_pressure, *nitrox_value;
+
+static void cylinder_cb(GtkComboBox *combo_box, gpointer data)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model = gtk_combo_box_get_model(combo_box);
+ GValue value1 = {0, }, value2 = {0,};
+ int volume, pressure;
+ cylinder_t *cyl = current_dive->cylinder + 0;
+
+ /* Did the user set it to some non-standard value? */
+ if (!gtk_combo_box_get_active_iter(combo_box, &iter)) {
+ cylinder_changed = 1;
+ return;
+ }
+
+ /*
+ * We get "change" signal callbacks just because we set
+ * the description by hand. Whatever. So ignore them if
+ * they are no-ops.
+ */
+ if (!cylinder_changed && cyl->type.description) {
+ int same;
+ char *desc = gtk_combo_box_get_active_text(combo_box);
+
+ same = !strcmp(desc, cyl->type.description);
+ g_free(desc);
+ if (same)
+ return;
+ }
+ cylinder_changed = 1;
+
+ gtk_tree_model_get_value(model, &iter, 1, &value1);
+ volume = g_value_get_int(&value1);
+ gtk_tree_model_get_value(model, &iter, 2, &value2);
+ pressure = g_value_get_int(&value2);
+
+ gtk_spin_button_set_value(cylinder_size,
+ volume / 1000.0);
+ gtk_spin_button_set_value(cylinder_pressure,
+ pressure / 1000.0);
+}