+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;
+}
+