+ widget = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
+ gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
+
+ cylinder->description = GTK_COMBO_BOX(widget);
+ g_signal_connect(widget, "changed", G_CALLBACK(cylinder_cb), cylinder);
+
+ hbox = gtk_hbox_new(FALSE, 3);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
+
+ widget = create_spinbutton(hbox, "Size", 0, 300, 0.1);
+ cylinder->size = GTK_SPIN_BUTTON(widget);
+
+ widget = create_spinbutton(hbox, "Pressure", 0, 5000, 1);
+ cylinder->pressure = GTK_SPIN_BUTTON(widget);
+
+ widget = create_spinbutton(hbox, "Nitrox", 21, 100, 0.1);
+ cylinder->o2 = widget;
+ cylinder->gasmix_button = gtk_check_button_new();
+ gtk_box_pack_start(GTK_BOX(gtk_widget_get_parent(cylinder->o2)),
+ cylinder->gasmix_button, FALSE, FALSE, 3);
+ g_signal_connect(cylinder->gasmix_button, "toggled", G_CALLBACK(nitrox_cb), cylinder);
+
+ gtk_spin_button_set_range(GTK_SPIN_BUTTON(cylinder->o2), 21.0, 100.0);
+}
+
+static int edit_cylinder_dialog(int index, cylinder_t *cyl)
+{
+ int success;
+ GtkWidget *dialog, *vbox;
+ struct cylinder_widget cylinder;
+ struct dive *dive;
+
+ cylinder.index = index;
+ cylinder.changed = 0;
+
+ dive = current_dive;
+ if (!dive)
+ return 0;
+ *cyl = dive->cylinder[index];
+
+ dialog = gtk_dialog_new_with_buttons("Cylinder",
+ GTK_WINDOW(main_window),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
+ NULL);
+
+ vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ cylinder_widget(vbox, &cylinder, cylinder_model);
+
+ show_cylinder(cyl, &cylinder);
+
+ gtk_widget_show_all(dialog);
+ success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
+ if (success) {
+ record_cylinder_changes(cyl, &cylinder);
+ dive->cylinder[index] = *cyl;
+ mark_divelist_changed(TRUE);
+ flush_divelist(dive);
+ }
+
+ gtk_widget_destroy(dialog);
+
+ return success;
+}
+
+static int get_model_index(GtkListStore *model, GtkTreeIter *iter)
+{
+ int *p, index;
+ GtkTreePath *path;
+
+ path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), iter);
+ p = gtk_tree_path_get_indices(path);
+ index = p ? *p : 0;
+ gtk_tree_path_free(path);
+ return index;
+}
+
+static void edit_cb(GtkButton *button, gpointer data)
+{
+ int index;
+ GtkTreeIter iter;
+ GtkListStore *model = cylinder_list.model;
+ GtkTreeSelection *selection;
+ cylinder_t cyl;
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));