2 /* creates the UI for the equipment page -
3 * controlled through the following interfaces:
5 * void show_dive_equipment(struct dive *dive)
6 * void flush_dive_equipment_changes(struct dive *dive)
9 * GtkWidget *equipment_widget(void)
19 #include "display-gtk.h"
22 static GtkListStore *cylinder_model;
39 GtkWidget *edit, *add, *del;
40 GtkTreeViewColumn *desc, *size, *workp, *startp, *endp, *o2, *he;
43 struct cylinder_widget {
47 GtkComboBox *description;
48 GtkSpinButton *size, *pressure;
49 GtkWidget *start, *end, *pressure_button;
50 GtkWidget *o2, *gasmix_button;
53 /* we want bar - so let's not use our unit functions */
54 static int convert_pressure(int mbar, double *p)
59 if (output_units.pressure == PSI) {
60 pressure = mbar_to_PSI(mbar);
63 pressure = mbar / 1000.0;
70 static int convert_volume_pressure(int ml, int mbar, double *v, double *p)
73 double volume, pressure;
77 if (output_units.volume == CUFT) {
78 volume = ml_to_cuft(ml);
79 volume *= bar_to_atm(mbar / 1000.0);
82 if (output_units.pressure == PSI) {
83 pressure = mbar_to_PSI(mbar);
86 pressure = mbar / 1000.0;
93 static void set_cylinder_type_spinbuttons(struct cylinder_widget *cylinder, int ml, int mbar)
95 double volume, pressure;
97 convert_volume_pressure(ml, mbar, &volume, &pressure);
98 gtk_spin_button_set_value(cylinder->size, volume);
99 gtk_spin_button_set_value(cylinder->pressure, pressure);
102 static void set_cylinder_pressure_spinbuttons(struct cylinder_widget *cylinder, cylinder_t *cyl)
105 unsigned int start, end;
108 start = cyl->start.mbar;
112 start = cyl->sample_start.mbar;
113 end = cyl->sample_end.mbar;
115 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cylinder->pressure_button), set);
116 gtk_widget_set_sensitive(cylinder->start, set);
117 gtk_widget_set_sensitive(cylinder->end, set);
119 convert_pressure(start, &pressure);
120 gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->start), pressure);
121 convert_pressure(end, &pressure);
122 gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->end), pressure);
126 * The gtk_tree_model_foreach() interface is bad. It could have
127 * returned whether the callback ever returned true
129 static GtkTreeIter *found_match = NULL;
130 static GtkTreeIter match_iter;
132 static gboolean match_cylinder(GtkTreeModel *model,
139 const char *desc = data;
141 gtk_tree_model_get(model, iter, 0, &name, -1);
142 match = !strcmp(desc, name);
146 found_match = &match_iter;
151 static int get_active_cylinder(GtkComboBox *combo_box, GtkTreeIter *iter)
155 if (gtk_combo_box_get_active_iter(combo_box, iter))
158 desc = gtk_combo_box_get_active_text(combo_box);
161 gtk_tree_model_foreach(GTK_TREE_MODEL(cylinder_model), match_cylinder, (void *)desc);
167 *iter = *found_match;
168 gtk_combo_box_set_active_iter(combo_box, iter);
172 static void cylinder_cb(GtkComboBox *combo_box, gpointer data)
175 GtkTreeModel *model = gtk_combo_box_get_model(combo_box);
177 struct cylinder_widget *cylinder = data;
178 cylinder_t *cyl = current_dive->cylinder + cylinder->index;
180 /* Did the user set it to some non-standard value? */
181 if (!get_active_cylinder(combo_box, &iter)) {
182 cylinder->changed = 1;
187 * We get "change" signal callbacks just because we set
188 * the description by hand. Whatever. So ignore them if
191 if (!cylinder->changed && cyl->type.description) {
193 char *desc = gtk_combo_box_get_active_text(combo_box);
195 same = !strcmp(desc, cyl->type.description);
200 cylinder->changed = 1;
202 gtk_tree_model_get(model, &iter,
207 set_cylinder_type_spinbuttons(cylinder, ml, mbar);
210 static GtkTreeIter *add_cylinder_type(const char *desc, int ml, int mbar, GtkTreeIter *iter)
214 /* Don't even bother adding stuff without a size */
219 model = GTK_TREE_MODEL(cylinder_model);
220 gtk_tree_model_foreach(model, match_cylinder, (void *)desc);
223 GtkListStore *store = GTK_LIST_STORE(model);
225 gtk_list_store_append(store, iter);
226 gtk_list_store_set(store, iter,
237 * When adding a dive, we'll add all the pre-existing cylinder
238 * information from that dive to our cylinder model.
240 void add_cylinder_description(cylinder_type_t *type)
244 unsigned int size, workp;
246 desc = type->description;
249 size = type->size.mliter;
250 workp = type->workingpressure.mbar;
251 add_cylinder_type(desc, size, workp, &iter);
254 static void add_cylinder(struct cylinder_widget *cylinder, const char *desc, int ml, int mbar)
256 GtkTreeIter iter, *match;
258 cylinder->name = desc;
259 match = add_cylinder_type(desc, ml, mbar, &iter);
261 gtk_combo_box_set_active_iter(cylinder->description, match);
264 static void show_cylinder(cylinder_t *cyl, struct cylinder_widget *cylinder)
270 /* Don't show uninitialized cylinder widgets */
271 if (!cylinder->description)
274 desc = cyl->type.description;
277 ml = cyl->type.size.mliter;
278 mbar = cyl->type.workingpressure.mbar;
279 add_cylinder(cylinder, desc, ml, mbar);
281 set_cylinder_type_spinbuttons(cylinder,
282 cyl->type.size.mliter, cyl->type.workingpressure.mbar);
283 set_cylinder_pressure_spinbuttons(cylinder, cyl);
284 o2 = cyl->gasmix.o2.permille / 10.0;
285 gtk_widget_set_sensitive(cylinder->o2, !!o2);
286 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button), !!o2);
289 gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->o2), o2);
292 static int cyl_nothing(cylinder_t *cyl)
294 return !cyl->type.size.mliter &&
295 !cyl->type.workingpressure.mbar &&
296 !cyl->type.description &&
297 !cyl->gasmix.o2.permille &&
298 !cyl->gasmix.he.permille &&
299 !cyl->sample_start.mbar &&
300 !cyl->sample_end.mbar &&
305 static void set_one_cylinder(int index, cylinder_t *cyl, GtkListStore *model, GtkTreeIter *iter)
307 unsigned int start, end;
309 start = cyl->start.mbar ? : cyl->sample_start.mbar;
310 end = cyl->end.mbar ? : cyl->sample_end.mbar;
311 gtk_list_store_set(model, iter,
312 CYL_DESC, cyl->type.description ? : "",
313 CYL_SIZE, cyl->type.size.mliter,
314 CYL_WORKP, cyl->type.workingpressure.mbar,
317 CYL_O2, cyl->gasmix.o2.permille,
318 CYL_HE, cyl->gasmix.he.permille,
322 void show_dive_equipment(struct dive *dive)
328 model = cylinder_list.model;
329 gtk_list_store_clear(model);
332 cylinder_t *cyl = &dive->cylinder[max-1];
334 if (!cyl_nothing(cyl))
338 cylinder_list.max_index = max;
340 gtk_widget_set_sensitive(cylinder_list.edit, 0);
341 gtk_widget_set_sensitive(cylinder_list.del, 0);
342 gtk_widget_set_sensitive(cylinder_list.add, max < MAX_CYLINDERS);
344 for (i = 0; i < max; i++) {
345 cylinder_t *cyl = dive->cylinder+i;
347 gtk_list_store_append(model, &iter);
348 set_one_cylinder(i, cyl, model, &iter);
352 static GtkWidget *create_spinbutton(GtkWidget *vbox, const char *name, double min, double max, double incr)
354 GtkWidget *frame, *hbox, *button;
356 frame = gtk_frame_new(name);
357 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, FALSE, 0);
359 hbox = gtk_hbox_new(FALSE, 3);
360 gtk_container_add(GTK_CONTAINER(frame), hbox);
362 button = gtk_spin_button_new_with_range(min, max, incr);
363 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 0);
365 gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(button), GTK_UPDATE_IF_VALID);
370 static void fill_cylinder_info(struct cylinder_widget *cylinder, cylinder_t *cyl, const char *desc,
371 double volume, double pressure, double start, double end, int o2)
375 if (output_units.pressure == PSI) {
376 pressure = psi_to_bar(pressure);
377 start = psi_to_bar(start);
378 end = psi_to_bar(end);
381 if (pressure && output_units.volume == CUFT) {
382 volume = cuft_to_l(volume);
383 volume /= bar_to_atm(pressure);
386 ml = volume * 1000 + 0.5;
387 mbar = pressure * 1000 + 0.5;
391 cyl->type.description = desc;
392 cyl->type.size.mliter = ml;
393 cyl->type.workingpressure.mbar = mbar;
394 cyl->start.mbar = start * 1000 + 0.5;
395 cyl->end.mbar = end * 1000 + 0.5;
396 cyl->gasmix.o2.permille = o2;
399 * Also, insert it into the model if it doesn't already exist
401 add_cylinder(cylinder, desc, ml, mbar);
404 static void record_cylinder_changes(cylinder_t *cyl, struct cylinder_widget *cylinder)
408 double volume, pressure, start, end;
411 /* Ignore uninitialized cylinder widgets */
412 box = cylinder->description;
416 desc = gtk_combo_box_get_active_text(box);
417 volume = gtk_spin_button_get_value(cylinder->size);
418 pressure = gtk_spin_button_get_value(cylinder->pressure);
419 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cylinder->pressure_button))) {
420 start = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->start));
421 end = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->end));
425 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button)))
426 o2 = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->o2))*10 + 0.5;
429 fill_cylinder_info(cylinder, cyl, desc, volume, pressure, start, end, o2);
432 void flush_dive_equipment_changes(struct dive *dive)
434 /* We do nothing: we require the "Ok" button press */
438 * We hardcode the most common standard cylinders,
439 * we should pick up any other names from the dive
442 static struct tank_info {
444 int size; /* cuft if < 1000, otherwise mliter */
445 int psi; /* If zero, size is in mliter */
447 /* Need an empty entry for the no-cylinder case */
450 /* Size-only metric cylinders */
454 /* Most common AL cylinders */
455 { "AL50", 50, 3000 },
456 { "AL63", 63, 3000 },
457 { "AL72", 72, 3000 },
458 { "AL80", 80, 3000 },
459 { "AL100", 100, 3300 },
461 /* Somewhat common LP steel cylinders */
462 { "LP85", 85, 2640 },
463 { "LP95", 95, 2640 },
464 { "LP108", 108, 2640 },
465 { "LP121", 121, 2640 },
467 /* Somewhat common HP steel cylinders */
468 { "HP65", 65, 3442 },
469 { "HP80", 80, 3442 },
470 { "HP100", 100, 3442 },
471 { "HP119", 119, 3442 },
472 { "HP130", 130, 3442 },
474 /* We'll fill in more from the dive log dynamically */
478 static void fill_tank_list(GtkListStore *store)
481 struct tank_info *info = tank_info;
484 int size = info->size;
486 int mbar = 0, ml = size;
488 /* Is it in cuft and psi? */
490 double bar = psi_to_bar(psi);
491 double airvolume = cuft_to_l(size) * 1000.0;
492 double atm = bar_to_atm(bar);
494 ml = airvolume / atm + 0.5;
495 mbar = bar*1000 + 0.5;
498 gtk_list_store_append(store, &iter);
499 gtk_list_store_set(store, &iter,
508 static void nitrox_cb(GtkToggleButton *button, gpointer data)
510 struct cylinder_widget *cylinder = data;
513 state = gtk_toggle_button_get_active(button);
514 gtk_widget_set_sensitive(cylinder->o2, state);
517 static void pressure_cb(GtkToggleButton *button, gpointer data)
519 struct cylinder_widget *cylinder = data;
522 state = gtk_toggle_button_get_active(button);
523 gtk_widget_set_sensitive(cylinder->start, state);
524 gtk_widget_set_sensitive(cylinder->end, state);
527 static gboolean completion_cb(GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, struct cylinder_widget *cylinder)
530 unsigned int ml, mbar;
532 gtk_tree_model_get(model, iter, CYL_DESC, &desc, CYL_SIZE, &ml, CYL_WORKP, &mbar, -1);
533 add_cylinder(cylinder, desc, ml, mbar);
537 static void cylinder_activate_cb(GtkComboBox *combo_box, gpointer data)
539 struct cylinder_widget *cylinder = data;
540 cylinder_cb(cylinder->description, data);
543 static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, GtkListStore *model)
545 GtkWidget *frame, *hbox;
547 GtkEntryCompletion *completion;
551 * Cylinder type: description, size and
554 frame = gtk_frame_new("Cylinder");
556 hbox = gtk_hbox_new(FALSE, 3);
557 gtk_container_add(GTK_CONTAINER(frame), hbox);
559 widget = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
560 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
562 cylinder->description = GTK_COMBO_BOX(widget);
563 g_signal_connect(widget, "changed", G_CALLBACK(cylinder_cb), cylinder);
565 entry = GTK_ENTRY(GTK_BIN(widget)->child);
566 g_signal_connect(entry, "activate", G_CALLBACK(cylinder_activate_cb), cylinder);
568 completion = gtk_entry_completion_new();
569 gtk_entry_completion_set_text_column(completion, 0);
570 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(model));
571 g_signal_connect(completion, "match-selected", G_CALLBACK(completion_cb), cylinder);
572 gtk_entry_set_completion(entry, completion);
574 hbox = gtk_hbox_new(FALSE, 3);
575 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
576 gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
578 widget = create_spinbutton(hbox, "Size", 0, 300, 0.1);
579 cylinder->size = GTK_SPIN_BUTTON(widget);
581 widget = create_spinbutton(hbox, "Pressure", 0, 5000, 1);
582 cylinder->pressure = GTK_SPIN_BUTTON(widget);
585 * Cylinder start/end pressures
587 hbox = gtk_hbox_new(FALSE, 3);
588 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
590 cylinder->pressure_button = gtk_check_button_new();
591 gtk_box_pack_start(GTK_BOX(hbox), cylinder->pressure_button, FALSE, FALSE, 3);
592 g_signal_connect(cylinder->pressure_button, "toggled", G_CALLBACK(pressure_cb), cylinder);
594 widget = create_spinbutton(hbox, "Start Pressure", 0, 5000, 1);
595 cylinder->start = widget;
597 widget = create_spinbutton(hbox, "End Pressure", 0, 5000, 1);
598 cylinder->end = widget;
601 * Cylinder gas mix: Air, Nitrox or Trimix
603 hbox = gtk_hbox_new(FALSE, 3);
604 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
606 widget = create_spinbutton(hbox, "Nitrox", 21, 100, 0.1);
607 cylinder->o2 = widget;
608 cylinder->gasmix_button = gtk_check_button_new();
609 gtk_box_pack_start(GTK_BOX(gtk_widget_get_parent(cylinder->o2)),
610 cylinder->gasmix_button, FALSE, FALSE, 3);
611 g_signal_connect(cylinder->gasmix_button, "toggled", G_CALLBACK(nitrox_cb), cylinder);
613 gtk_spin_button_set_range(GTK_SPIN_BUTTON(cylinder->o2), 21.0, 100.0);
616 static int edit_cylinder_dialog(int index, cylinder_t *cyl)
619 GtkWidget *dialog, *vbox;
620 struct cylinder_widget cylinder;
623 cylinder.index = index;
624 cylinder.changed = 0;
629 *cyl = dive->cylinder[index];
631 dialog = gtk_dialog_new_with_buttons("Cylinder",
632 GTK_WINDOW(main_window),
633 GTK_DIALOG_DESTROY_WITH_PARENT,
634 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
635 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
638 vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
639 cylinder_widget(vbox, &cylinder, cylinder_model);
641 show_cylinder(cyl, &cylinder);
643 gtk_widget_show_all(dialog);
644 success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
646 record_cylinder_changes(cyl, &cylinder);
647 dive->cylinder[index] = *cyl;
648 mark_divelist_changed(TRUE);
649 update_cylinder_related_info(dive);
650 flush_divelist(dive);
653 gtk_widget_destroy(dialog);
658 static int get_model_index(GtkListStore *model, GtkTreeIter *iter)
663 path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), iter);
664 p = gtk_tree_path_get_indices(path);
666 gtk_tree_path_free(path);
670 static void edit_cb(GtkButton *button, gpointer data)
674 GtkListStore *model = cylinder_list.model;
675 GtkTreeSelection *selection;
678 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
680 /* Nothing selected? This shouldn't happen, since the button should be inactive */
681 if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
684 index = get_model_index(model, &iter);
685 if (!edit_cylinder_dialog(index, &cyl))
688 set_one_cylinder(index, &cyl, model, &iter);
692 static void add_cb(GtkButton *button, gpointer data)
694 int index = cylinder_list.max_index;
696 GtkListStore *model = cylinder_list.model;
697 GtkTreeSelection *selection;
700 if (!edit_cylinder_dialog(index, &cyl))
703 gtk_list_store_append(model, &iter);
704 set_one_cylinder(index, &cyl, model, &iter);
706 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
707 gtk_tree_selection_select_iter(selection, &iter);
709 cylinder_list.max_index++;
710 gtk_widget_set_sensitive(cylinder_list.add, cylinder_list.max_index < MAX_CYLINDERS);
713 static void del_cb(GtkButton *button, gpointer data)
717 GtkListStore *model = cylinder_list.model;
718 GtkTreeSelection *selection;
722 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
724 /* Nothing selected? This shouldn't happen, since the button should be inactive */
725 if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
728 index = get_model_index(model, &iter);
733 cyl = dive->cylinder + index;
734 nr = cylinder_list.max_index - index - 1;
736 gtk_list_store_remove(model, &iter);
738 cylinder_list.max_index--;
739 memmove(cyl, cyl+1, nr*sizeof(*cyl));
740 memset(cyl+nr, 0, sizeof(*cyl));
742 mark_divelist_changed(TRUE);
743 flush_divelist(dive);
745 gtk_widget_set_sensitive(cylinder_list.edit, 0);
746 gtk_widget_set_sensitive(cylinder_list.del, 0);
747 gtk_widget_set_sensitive(cylinder_list.add, 1);
750 static GtkListStore *create_tank_size_model(void)
754 model = gtk_list_store_new(3,
755 G_TYPE_STRING, /* Tank name */
756 G_TYPE_INT, /* Tank size in mliter */
757 G_TYPE_INT, /* Tank working pressure in mbar */
760 fill_tank_list(model);
764 static void size_data_func(GtkTreeViewColumn *col,
765 GtkCellRenderer *renderer,
771 double size, pressure;
774 gtk_tree_model_get(model, iter, CYL_SIZE, &ml, CYL_WORKP, &mbar, -1);
775 convert_volume_pressure(ml, mbar, &size, &pressure);
777 snprintf(buffer, sizeof(buffer), "%.1f", size);
779 strcpy(buffer, "unkn");
780 g_object_set(renderer, "text", buffer, NULL);
783 static void pressure_data_func(GtkTreeViewColumn *col,
784 GtkCellRenderer *renderer,
789 int index = (long)data;
794 gtk_tree_model_get(model, iter, index, &mbar, -1);
795 decimals = convert_pressure(mbar, &pressure);
797 snprintf(buffer, sizeof(buffer), "%.*f", decimals, pressure);
800 g_object_set(renderer, "text", buffer, NULL);
803 static void percentage_data_func(GtkTreeViewColumn *col,
804 GtkCellRenderer *renderer,
809 int index = (long)data;
813 gtk_tree_model_get(model, iter, index, &permille, -1);
815 snprintf(buffer, sizeof(buffer), "%.1f%%", permille / 10.0);
818 g_object_set(renderer, "text", buffer, NULL);
821 static void selection_cb(GtkTreeSelection *selection, GtkTreeModel *model)
826 selected = gtk_tree_selection_get_selected(selection, NULL, &iter);
827 gtk_widget_set_sensitive(cylinder_list.edit, selected);
828 gtk_widget_set_sensitive(cylinder_list.del, selected);
831 static void row_activated_cb(GtkTreeView *tree_view,
833 GtkTreeViewColumn *column,
839 static GtkWidget *cylinder_list_create(void)
841 GtkWidget *tree_view;
842 GtkTreeSelection *selection;
845 model = gtk_list_store_new(CYL_COLUMNS,
846 G_TYPE_STRING, /* CYL_DESC: utf8 */
847 G_TYPE_INT, /* CYL_SIZE: mliter */
848 G_TYPE_INT, /* CYL_WORKP: mbar */
849 G_TYPE_INT, /* CYL_STARTP: mbar */
850 G_TYPE_INT, /* CYL_ENDP: mbar */
851 G_TYPE_INT, /* CYL_O2: permille */
852 G_TYPE_INT /* CYL_HE: permille */
854 cylinder_list.model = model;
855 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
856 gtk_widget_set_can_focus(tree_view, FALSE);
857 g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), model);
859 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
860 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
861 g_signal_connect(selection, "changed", G_CALLBACK(selection_cb), model);
863 g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
864 "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
867 cylinder_list.desc = tree_view_column(tree_view, CYL_DESC, "Type", NULL, PANGO_ALIGN_LEFT, TRUE);
868 cylinder_list.size = tree_view_column(tree_view, CYL_SIZE, "Size", size_data_func, PANGO_ALIGN_RIGHT, TRUE);
869 cylinder_list.workp = tree_view_column(tree_view, CYL_WORKP, "MaxPress", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
870 cylinder_list.startp = tree_view_column(tree_view, CYL_STARTP, "Start", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
871 cylinder_list.endp = tree_view_column(tree_view, CYL_ENDP, "End", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
872 cylinder_list.o2 = tree_view_column(tree_view, CYL_O2, "O" UTF8_SUBSCRIPT_2 "%", percentage_data_func, PANGO_ALIGN_RIGHT, TRUE);
873 cylinder_list.he = tree_view_column(tree_view, CYL_HE, "He%", percentage_data_func, PANGO_ALIGN_RIGHT, TRUE);
877 GtkWidget *equipment_widget(void)
879 GtkWidget *vbox, *hbox, *frame, *framebox;
880 GtkWidget *add, *del, *edit;
882 vbox = gtk_vbox_new(FALSE, 3);
885 * We create the cylinder size model at startup, since
886 * we're going to share it across all cylinders and all
887 * dives. So if you add a new cylinder type in one dive,
888 * it will show up when you edit the cylinder types for
891 cylinder_model = create_tank_size_model();
893 cylinder_list.tree_view = cylinder_list_create();
895 hbox = gtk_hbox_new(FALSE, 3);
896 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
898 frame = gtk_frame_new("Cylinders");
899 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, FALSE, 3);
901 framebox = gtk_vbox_new(FALSE, 3);
902 gtk_container_add(GTK_CONTAINER(frame), framebox);
904 hbox = gtk_hbox_new(FALSE, 3);
905 gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
907 gtk_box_pack_start(GTK_BOX(hbox), cylinder_list.tree_view, TRUE, FALSE, 3);
909 hbox = gtk_hbox_new(TRUE, 3);
910 gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
912 edit = gtk_button_new_from_stock(GTK_STOCK_EDIT);
913 add = gtk_button_new_from_stock(GTK_STOCK_ADD);
914 del = gtk_button_new_from_stock(GTK_STOCK_DELETE);
915 gtk_box_pack_start(GTK_BOX(hbox), edit, FALSE, FALSE, 0);
916 gtk_box_pack_start(GTK_BOX(hbox), add, FALSE, FALSE, 0);
917 gtk_box_pack_start(GTK_BOX(hbox), del, FALSE, FALSE, 0);
919 cylinder_list.edit = edit;
920 cylinder_list.add = add;
921 cylinder_list.del = del;
923 g_signal_connect(edit, "clicked", G_CALLBACK(edit_cb), NULL);
924 g_signal_connect(add, "clicked", G_CALLBACK(add_cb), NULL);
925 g_signal_connect(del, "clicked", G_CALLBACK(del_cb), NULL);