+static void add_cylinder(struct cylinder_widget *cylinder, const char *desc, int ml, int mbar)
+{
+ GtkTreeModel *model;
+
+ found_match = 0;
+ model = gtk_combo_box_get_model(cylinder->description);
+ cylinder->name = desc;
+ gtk_tree_model_foreach(model, match_cylinder, cylinder);
+
+ if (!found_match) {
+ GtkListStore *store = GTK_LIST_STORE(model);
+ GtkTreeIter iter;
+
+ gtk_list_store_append(store, &iter);
+ gtk_list_store_set(store, &iter,
+ 0, desc,
+ 1, ml,
+ 2, mbar,
+ -1);
+ gtk_combo_box_set_active_iter(cylinder->description, &iter);
+ }
+}
+
+static void show_cylinder(cylinder_t *cyl, struct cylinder_widget *cylinder)
+{
+ const char *desc;
+ int ml, mbar;
+ double o2;
+
+ /* Don't show uninitialized cylinder widgets */
+ if (!cylinder->description)
+ return;
+
+ desc = cyl->type.description;
+ if (!desc)
+ desc = "";
+ ml = cyl->type.size.mliter;
+ mbar = cyl->type.workingpressure.mbar;
+ add_cylinder(cylinder, desc, ml, mbar);
+
+ set_cylinder_spinbuttons(cylinder, cyl->type.size.mliter, cyl->type.workingpressure.mbar);
+ o2 = cyl->gasmix.o2.permille / 10.0;
+ gtk_widget_set_sensitive(cylinder->o2, !!o2);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button), !!o2);
+ if (!o2)
+ o2 = 21.0;
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->o2), o2);
+}
+