+ cylinder_t *cyl = &dive->cylinder[0];
+ const char *desc = cyl->type.description;
+ GtkTreeModel *model = gtk_combo_box_get_model(cylinder_description);
+ double o2;
+
+ if (desc)
+ gtk_tree_model_foreach(model, match_cylinder, (gpointer)desc);
+ gtk_spin_button_set_value(cylinder_size,
+ cyl->type.size.mliter / 1000.0);
+ gtk_spin_button_set_value(cylinder_pressure,
+ cyl->type.workingpressure.mbar / 1000.0);
+ o2 = cyl->gasmix.o2.permille / 10.0;
+ if (!o2)
+ o2 = 21.0;
+ gtk_spin_button_set_value(nitrox_value, o2);
+}
+
+static GtkWidget *create_spinbutton(GtkWidget *vbox, const char *name, double min, double max, double incr)
+{
+ GtkWidget *frame, *button;
+
+ frame = gtk_frame_new(name);
+ gtk_container_add(GTK_CONTAINER(vbox), frame);
+
+ button = gtk_spin_button_new_with_range(min, max, incr);
+ gtk_container_add(GTK_CONTAINER(frame), button);
+
+ gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(button), GTK_UPDATE_IF_VALID);
+
+ return button;
+}
+
+static void fill_cylinder_info(cylinder_t *cyl, const char *desc, int mliter, int mbar, int o2)
+{
+ if (o2 < 211)
+ o2 = 0;
+ cyl->type.description = desc;
+ cyl->type.size.mliter = mliter;
+ cyl->type.workingpressure.mbar = mbar;
+ cyl->gasmix.o2.permille = o2;
+}
+
+static void record_cylinder_changes(struct dive *dive)
+{
+ const gchar *desc;
+ GtkComboBox *box = cylinder_description;
+ int volume, pressure, o2;
+
+ desc = gtk_combo_box_get_active_text(box);
+ volume = gtk_spin_button_get_value(cylinder_size) * 1000 + 0.5;
+ pressure = gtk_spin_button_get_value(cylinder_pressure) * 1000 + 0.5;
+ o2 = gtk_spin_button_get_value(nitrox_value)*10 + 0.5;
+ fill_cylinder_info(dive->cylinder+0, desc, volume, pressure, o2);