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, *start, *end;
49 GtkWidget *o2, *gasmix_button;
52 /* we want bar - so let's not use our unit functions */
53 static int convert_pressure(int mbar, double *p)
58 if (output_units.pressure == PSI) {
59 pressure = mbar_to_PSI(mbar);
62 pressure = mbar / 1000.0;
69 static int convert_volume_pressure(int ml, int mbar, double *v, double *p)
72 double volume, pressure;
76 if (output_units.volume == CUFT) {
77 volume = ml_to_cuft(ml);
78 volume *= bar_to_atm(mbar / 1000.0);
81 if (output_units.pressure == PSI) {
82 pressure = mbar_to_PSI(mbar);
85 pressure = mbar / 1000.0;
92 static void set_cylinder_type_spinbuttons(struct cylinder_widget *cylinder, int ml, int mbar)
94 double volume, pressure;
96 convert_volume_pressure(ml, mbar, &volume, &pressure);
97 gtk_spin_button_set_value(cylinder->size, volume);
98 gtk_spin_button_set_value(cylinder->pressure, pressure);
101 static void set_cylinder_pressure_spinbuttons(struct cylinder_widget *cylinder, cylinder_t *cyl)
105 convert_pressure(cyl->start.mbar, &pressure);
106 gtk_spin_button_set_value(cylinder->start, pressure);
107 convert_pressure(cyl->end.mbar, &pressure);
108 gtk_spin_button_set_value(cylinder->end, pressure);
112 * The gtk_tree_model_foreach() interface is bad. It could have
113 * returned whether the callback ever returned true
115 static GtkTreeIter *found_match = NULL;
116 static GtkTreeIter match_iter;
118 static gboolean match_cylinder(GtkTreeModel *model,
125 const char *desc = data;
127 gtk_tree_model_get(model, iter, 0, &name, -1);
128 match = !strcmp(desc, name);
132 found_match = &match_iter;
137 static int get_active_cylinder(GtkComboBox *combo_box, GtkTreeIter *iter)
141 if (gtk_combo_box_get_active_iter(combo_box, iter))
144 desc = gtk_combo_box_get_active_text(combo_box);
147 gtk_tree_model_foreach(GTK_TREE_MODEL(cylinder_model), match_cylinder, (void *)desc);
153 *iter = *found_match;
154 gtk_combo_box_set_active_iter(combo_box, iter);
158 static void cylinder_cb(GtkComboBox *combo_box, gpointer data)
161 GtkTreeModel *model = gtk_combo_box_get_model(combo_box);
163 struct cylinder_widget *cylinder = data;
164 cylinder_t *cyl = current_dive->cylinder + cylinder->index;
166 /* Did the user set it to some non-standard value? */
167 if (!get_active_cylinder(combo_box, &iter)) {
168 cylinder->changed = 1;
173 * We get "change" signal callbacks just because we set
174 * the description by hand. Whatever. So ignore them if
177 if (!cylinder->changed && cyl->type.description) {
179 char *desc = gtk_combo_box_get_active_text(combo_box);
181 same = !strcmp(desc, cyl->type.description);
186 cylinder->changed = 1;
188 gtk_tree_model_get(model, &iter,
193 set_cylinder_type_spinbuttons(cylinder, ml, mbar);
196 static GtkTreeIter *add_cylinder_type(const char *desc, int ml, int mbar, GtkTreeIter *iter)
200 /* Don't even bother adding stuff without a size */
205 model = GTK_TREE_MODEL(cylinder_model);
206 gtk_tree_model_foreach(model, match_cylinder, (void *)desc);
209 GtkListStore *store = GTK_LIST_STORE(model);
211 gtk_list_store_append(store, iter);
212 gtk_list_store_set(store, iter,
223 * When adding a dive, we'll add all the pre-existing cylinder
224 * information from that dive to our cylinder model.
226 void add_cylinder_description(cylinder_type_t *type)
230 unsigned int size, workp;
232 desc = type->description;
235 size = type->size.mliter;
236 workp = type->workingpressure.mbar;
237 add_cylinder_type(desc, size, workp, &iter);
240 static void add_cylinder(struct cylinder_widget *cylinder, const char *desc, int ml, int mbar)
242 GtkTreeIter iter, *match;
244 cylinder->name = desc;
245 match = add_cylinder_type(desc, ml, mbar, &iter);
247 gtk_combo_box_set_active_iter(cylinder->description, match);
250 static void show_cylinder(cylinder_t *cyl, struct cylinder_widget *cylinder)
256 /* Don't show uninitialized cylinder widgets */
257 if (!cylinder->description)
260 desc = cyl->type.description;
263 ml = cyl->type.size.mliter;
264 mbar = cyl->type.workingpressure.mbar;
265 add_cylinder(cylinder, desc, ml, mbar);
267 set_cylinder_type_spinbuttons(cylinder,
268 cyl->type.size.mliter, cyl->type.workingpressure.mbar);
269 set_cylinder_pressure_spinbuttons(cylinder, cyl);
270 o2 = cyl->gasmix.o2.permille / 10.0;
271 gtk_widget_set_sensitive(cylinder->o2, !!o2);
272 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button), !!o2);
275 gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->o2), o2);
278 static int cyl_nothing(cylinder_t *cyl)
280 return !cyl->type.size.mliter &&
281 !cyl->type.workingpressure.mbar &&
282 !cyl->type.description &&
283 !cyl->gasmix.o2.permille &&
284 !cyl->gasmix.he.permille &&
285 !cyl->sample_start.mbar &&
286 !cyl->sample_end.mbar &&
291 static void set_one_cylinder(int index, cylinder_t *cyl, GtkListStore *model, GtkTreeIter *iter)
293 unsigned int start, end;
295 start = cyl->start.mbar ? : cyl->sample_start.mbar;
296 end = cyl->end.mbar ? : cyl->sample_end.mbar;
297 gtk_list_store_set(model, iter,
298 CYL_DESC, cyl->type.description ? : "",
299 CYL_SIZE, cyl->type.size.mliter,
300 CYL_WORKP, cyl->type.workingpressure.mbar,
303 CYL_O2, cyl->gasmix.o2.permille,
304 CYL_HE, cyl->gasmix.he.permille,
308 void show_dive_equipment(struct dive *dive)
314 model = cylinder_list.model;
315 gtk_list_store_clear(model);
318 cylinder_t *cyl = &dive->cylinder[max-1];
320 if (!cyl_nothing(cyl))
324 cylinder_list.max_index = max;
326 gtk_widget_set_sensitive(cylinder_list.edit, 0);
327 gtk_widget_set_sensitive(cylinder_list.del, 0);
328 gtk_widget_set_sensitive(cylinder_list.add, max < MAX_CYLINDERS);
330 for (i = 0; i < max; i++) {
331 cylinder_t *cyl = dive->cylinder+i;
333 gtk_list_store_append(model, &iter);
334 set_one_cylinder(i, cyl, model, &iter);
338 static GtkWidget *create_spinbutton(GtkWidget *vbox, const char *name, double min, double max, double incr)
340 GtkWidget *frame, *hbox, *button;
342 frame = gtk_frame_new(name);
343 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, FALSE, 0);
345 hbox = gtk_hbox_new(FALSE, 3);
346 gtk_container_add(GTK_CONTAINER(frame), hbox);
348 button = gtk_spin_button_new_with_range(min, max, incr);
349 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 0);
351 gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(button), GTK_UPDATE_IF_VALID);
356 static void fill_cylinder_info(struct cylinder_widget *cylinder, cylinder_t *cyl, const char *desc,
357 double volume, double pressure, double start, double end, int o2)
361 if (output_units.pressure == PSI) {
362 pressure = psi_to_bar(pressure);
363 start = psi_to_bar(start);
364 end = psi_to_bar(end);
367 if (pressure && output_units.volume == CUFT) {
368 volume = cuft_to_l(volume);
369 volume /= bar_to_atm(pressure);
372 ml = volume * 1000 + 0.5;
373 mbar = pressure * 1000 + 0.5;
377 cyl->type.description = desc;
378 cyl->type.size.mliter = ml;
379 cyl->type.workingpressure.mbar = mbar;
380 cyl->start.mbar = start * 1000 + 0.5;
381 cyl->end.mbar = end * 1000 + 0.5;
382 cyl->gasmix.o2.permille = o2;
385 * Also, insert it into the model if it doesn't already exist
387 add_cylinder(cylinder, desc, ml, mbar);
390 static void record_cylinder_changes(cylinder_t *cyl, struct cylinder_widget *cylinder)
394 double volume, pressure, start, end;
397 /* Ignore uninitialized cylinder widgets */
398 box = cylinder->description;
402 desc = gtk_combo_box_get_active_text(box);
403 volume = gtk_spin_button_get_value(cylinder->size);
404 pressure = gtk_spin_button_get_value(cylinder->pressure);
405 start = gtk_spin_button_get_value(cylinder->start);
406 end = gtk_spin_button_get_value(cylinder->end);
407 o2 = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->o2))*10 + 0.5;
408 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button)))
410 fill_cylinder_info(cylinder, cyl, desc, volume, pressure, start, end, o2);
413 void flush_dive_equipment_changes(struct dive *dive)
415 /* We do nothing: we require the "Ok" button press */
419 * We hardcode the most common standard cylinders,
420 * we should pick up any other names from the dive
423 static struct tank_info {
425 int size; /* cuft if < 1000, otherwise mliter */
426 int psi; /* If zero, size is in mliter */
428 /* Need an empty entry for the no-cylinder case */
431 /* Size-only metric cylinders */
435 /* Most common AL cylinders */
436 { "AL50", 50, 3000 },
437 { "AL63", 63, 3000 },
438 { "AL72", 72, 3000 },
439 { "AL80", 80, 3000 },
440 { "AL100", 100, 3300 },
442 /* Somewhat common LP steel cylinders */
443 { "LP85", 85, 2640 },
444 { "LP95", 95, 2640 },
445 { "LP108", 108, 2640 },
446 { "LP121", 121, 2640 },
448 /* Somewhat common HP steel cylinders */
449 { "HP65", 65, 3442 },
450 { "HP80", 80, 3442 },
451 { "HP100", 100, 3442 },
452 { "HP119", 119, 3442 },
453 { "HP130", 130, 3442 },
455 /* We'll fill in more from the dive log dynamically */
459 static void fill_tank_list(GtkListStore *store)
462 struct tank_info *info = tank_info;
465 int size = info->size;
467 int mbar = 0, ml = size;
469 /* Is it in cuft and psi? */
471 double bar = psi_to_bar(psi);
472 double airvolume = cuft_to_l(size) * 1000.0;
473 double atm = bar_to_atm(bar);
475 ml = airvolume / atm + 0.5;
476 mbar = bar*1000 + 0.5;
479 gtk_list_store_append(store, &iter);
480 gtk_list_store_set(store, &iter,
489 static void nitrox_cb(GtkToggleButton *button, gpointer data)
491 struct cylinder_widget *cylinder = data;
494 state = gtk_toggle_button_get_active(button);
495 gtk_widget_set_sensitive(cylinder->o2, state);
498 static gboolean completion_cb(GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, struct cylinder_widget *cylinder)
501 unsigned int ml, mbar;
503 gtk_tree_model_get(model, iter, CYL_DESC, &desc, CYL_SIZE, &ml, CYL_WORKP, &mbar, -1);
504 add_cylinder(cylinder, desc, ml, mbar);
508 static void cylinder_activate_cb(GtkComboBox *combo_box, gpointer data)
510 struct cylinder_widget *cylinder = data;
511 cylinder_cb(cylinder->description, data);
514 static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, GtkListStore *model)
516 GtkWidget *frame, *hbox;
518 GtkEntryCompletion *completion;
522 * Cylinder type: description, size and
525 frame = gtk_frame_new("Cylinder");
527 hbox = gtk_hbox_new(FALSE, 3);
528 gtk_container_add(GTK_CONTAINER(frame), hbox);
530 widget = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
531 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
533 cylinder->description = GTK_COMBO_BOX(widget);
534 g_signal_connect(widget, "changed", G_CALLBACK(cylinder_cb), cylinder);
536 entry = GTK_ENTRY(GTK_BIN(widget)->child);
537 g_signal_connect(entry, "activate", G_CALLBACK(cylinder_activate_cb), cylinder);
539 completion = gtk_entry_completion_new();
540 gtk_entry_completion_set_text_column(completion, 0);
541 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(model));
542 g_signal_connect(completion, "match-selected", G_CALLBACK(completion_cb), cylinder);
543 gtk_entry_set_completion(entry, completion);
545 hbox = gtk_hbox_new(FALSE, 3);
546 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
547 gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
549 widget = create_spinbutton(hbox, "Size", 0, 300, 0.1);
550 cylinder->size = GTK_SPIN_BUTTON(widget);
552 widget = create_spinbutton(hbox, "Pressure", 0, 5000, 1);
553 cylinder->pressure = GTK_SPIN_BUTTON(widget);
556 * Cylinder start/end pressures
558 hbox = gtk_hbox_new(FALSE, 3);
559 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
561 widget = create_spinbutton(hbox, "Start Pressure", 0, 5000, 1);
562 cylinder->start = GTK_SPIN_BUTTON(widget);
564 widget = create_spinbutton(hbox, "End Pressure", 0, 5000, 1);
565 cylinder->end = GTK_SPIN_BUTTON(widget);
568 * Cylinder gas mix: Air, Nitrox or Trimix
570 hbox = gtk_hbox_new(FALSE, 3);
571 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
573 widget = create_spinbutton(hbox, "Nitrox", 21, 100, 0.1);
574 cylinder->o2 = widget;
575 cylinder->gasmix_button = gtk_check_button_new();
576 gtk_box_pack_start(GTK_BOX(gtk_widget_get_parent(cylinder->o2)),
577 cylinder->gasmix_button, FALSE, FALSE, 3);
578 g_signal_connect(cylinder->gasmix_button, "toggled", G_CALLBACK(nitrox_cb), cylinder);
580 gtk_spin_button_set_range(GTK_SPIN_BUTTON(cylinder->o2), 21.0, 100.0);
583 static int edit_cylinder_dialog(int index, cylinder_t *cyl)
586 GtkWidget *dialog, *vbox;
587 struct cylinder_widget cylinder;
590 cylinder.index = index;
591 cylinder.changed = 0;
596 *cyl = dive->cylinder[index];
598 dialog = gtk_dialog_new_with_buttons("Cylinder",
599 GTK_WINDOW(main_window),
600 GTK_DIALOG_DESTROY_WITH_PARENT,
601 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
602 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
605 vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
606 cylinder_widget(vbox, &cylinder, cylinder_model);
608 show_cylinder(cyl, &cylinder);
610 gtk_widget_show_all(dialog);
611 success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
613 record_cylinder_changes(cyl, &cylinder);
614 dive->cylinder[index] = *cyl;
615 mark_divelist_changed(TRUE);
616 flush_divelist(dive);
619 gtk_widget_destroy(dialog);
624 static int get_model_index(GtkListStore *model, GtkTreeIter *iter)
629 path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), iter);
630 p = gtk_tree_path_get_indices(path);
632 gtk_tree_path_free(path);
636 static void edit_cb(GtkButton *button, gpointer data)
640 GtkListStore *model = cylinder_list.model;
641 GtkTreeSelection *selection;
644 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
646 /* Nothing selected? This shouldn't happen, since the button should be inactive */
647 if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
650 index = get_model_index(model, &iter);
651 if (!edit_cylinder_dialog(index, &cyl))
654 set_one_cylinder(index, &cyl, model, &iter);
658 static void add_cb(GtkButton *button, gpointer data)
660 int index = cylinder_list.max_index;
662 GtkListStore *model = cylinder_list.model;
663 GtkTreeSelection *selection;
666 if (!edit_cylinder_dialog(index, &cyl))
669 gtk_list_store_append(model, &iter);
670 set_one_cylinder(index, &cyl, model, &iter);
672 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
673 gtk_tree_selection_select_iter(selection, &iter);
675 cylinder_list.max_index++;
676 gtk_widget_set_sensitive(cylinder_list.add, cylinder_list.max_index < MAX_CYLINDERS);
679 static void del_cb(GtkButton *button, gpointer data)
683 GtkListStore *model = cylinder_list.model;
684 GtkTreeSelection *selection;
688 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
690 /* Nothing selected? This shouldn't happen, since the button should be inactive */
691 if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
694 index = get_model_index(model, &iter);
699 cyl = dive->cylinder + index;
700 nr = cylinder_list.max_index - index - 1;
702 gtk_list_store_remove(model, &iter);
704 cylinder_list.max_index--;
705 memmove(cyl, cyl+1, nr*sizeof(*cyl));
706 memset(cyl+nr, 0, sizeof(*cyl));
708 mark_divelist_changed(TRUE);
709 flush_divelist(dive);
711 gtk_widget_set_sensitive(cylinder_list.edit, 0);
712 gtk_widget_set_sensitive(cylinder_list.del, 0);
713 gtk_widget_set_sensitive(cylinder_list.add, 1);
716 static GtkListStore *create_tank_size_model(void)
720 model = gtk_list_store_new(3,
721 G_TYPE_STRING, /* Tank name */
722 G_TYPE_INT, /* Tank size in mliter */
723 G_TYPE_INT, /* Tank working pressure in mbar */
726 fill_tank_list(model);
730 static void size_data_func(GtkTreeViewColumn *col,
731 GtkCellRenderer *renderer,
737 double size, pressure;
740 gtk_tree_model_get(model, iter, CYL_SIZE, &ml, CYL_WORKP, &mbar, -1);
741 convert_volume_pressure(ml, mbar, &size, &pressure);
743 snprintf(buffer, sizeof(buffer), "%.1f", size);
745 strcpy(buffer, "unkn");
746 g_object_set(renderer, "text", buffer, NULL);
749 static void pressure_data_func(GtkTreeViewColumn *col,
750 GtkCellRenderer *renderer,
755 int index = (long)data;
760 gtk_tree_model_get(model, iter, index, &mbar, -1);
761 decimals = convert_pressure(mbar, &pressure);
763 snprintf(buffer, sizeof(buffer), "%.*f", decimals, pressure);
766 g_object_set(renderer, "text", buffer, NULL);
769 static void percentage_data_func(GtkTreeViewColumn *col,
770 GtkCellRenderer *renderer,
775 int index = (long)data;
779 gtk_tree_model_get(model, iter, index, &permille, -1);
781 snprintf(buffer, sizeof(buffer), "%.1f%%", permille / 10.0);
784 g_object_set(renderer, "text", buffer, NULL);
787 static void selection_cb(GtkTreeSelection *selection, GtkTreeModel *model)
792 selected = gtk_tree_selection_get_selected(selection, NULL, &iter);
793 gtk_widget_set_sensitive(cylinder_list.edit, selected);
794 gtk_widget_set_sensitive(cylinder_list.del, selected);
797 static void row_activated_cb(GtkTreeView *tree_view,
799 GtkTreeViewColumn *column,
805 static GtkWidget *cylinder_list_create(void)
807 GtkWidget *tree_view;
808 GtkTreeSelection *selection;
811 model = gtk_list_store_new(CYL_COLUMNS,
812 G_TYPE_STRING, /* CYL_DESC: utf8 */
813 G_TYPE_INT, /* CYL_SIZE: mliter */
814 G_TYPE_INT, /* CYL_WORKP: mbar */
815 G_TYPE_INT, /* CYL_STARTP: mbar */
816 G_TYPE_INT, /* CYL_ENDP: mbar */
817 G_TYPE_INT, /* CYL_O2: permille */
818 G_TYPE_INT /* CYL_HE: permille */
820 cylinder_list.model = model;
821 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
822 g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), model);
824 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
825 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
826 g_signal_connect(selection, "changed", G_CALLBACK(selection_cb), model);
828 g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
829 "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
832 cylinder_list.desc = tree_view_column(tree_view, CYL_DESC, "Type", NULL, PANGO_ALIGN_LEFT, TRUE);
833 cylinder_list.size = tree_view_column(tree_view, CYL_SIZE, "Size", size_data_func, PANGO_ALIGN_RIGHT, TRUE);
834 cylinder_list.workp = tree_view_column(tree_view, CYL_WORKP, "MaxPress", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
835 cylinder_list.startp = tree_view_column(tree_view, CYL_STARTP, "Start", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
836 cylinder_list.endp = tree_view_column(tree_view, CYL_ENDP, "End", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
837 cylinder_list.o2 = tree_view_column(tree_view, CYL_O2, "O" UTF8_SUBSCRIPT_2 "%", percentage_data_func, PANGO_ALIGN_RIGHT, TRUE);
838 cylinder_list.he = tree_view_column(tree_view, CYL_HE, "He%", percentage_data_func, PANGO_ALIGN_RIGHT, TRUE);
842 GtkWidget *equipment_widget(void)
844 GtkWidget *vbox, *hbox, *frame, *framebox;
845 GtkWidget *add, *del, *edit;
847 vbox = gtk_vbox_new(FALSE, 3);
850 * We create the cylinder size model at startup, since
851 * we're going to share it across all cylinders and all
852 * dives. So if you add a new cylinder type in one dive,
853 * it will show up when you edit the cylinder types for
856 cylinder_model = create_tank_size_model();
858 cylinder_list.tree_view = cylinder_list_create();
860 hbox = gtk_hbox_new(FALSE, 3);
861 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
863 frame = gtk_frame_new("Cylinders");
864 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, FALSE, 3);
866 framebox = gtk_vbox_new(FALSE, 3);
867 gtk_container_add(GTK_CONTAINER(frame), framebox);
869 hbox = gtk_hbox_new(FALSE, 3);
870 gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
872 gtk_box_pack_start(GTK_BOX(hbox), cylinder_list.tree_view, TRUE, FALSE, 3);
874 hbox = gtk_hbox_new(TRUE, 3);
875 gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
877 edit = gtk_button_new_from_stock(GTK_STOCK_EDIT);
878 add = gtk_button_new_from_stock(GTK_STOCK_ADD);
879 del = gtk_button_new_from_stock(GTK_STOCK_DELETE);
880 gtk_box_pack_start(GTK_BOX(hbox), edit, FALSE, FALSE, 0);
881 gtk_box_pack_start(GTK_BOX(hbox), add, FALSE, FALSE, 0);
882 gtk_box_pack_start(GTK_BOX(hbox), del, FALSE, FALSE, 0);
884 cylinder_list.edit = edit;
885 cylinder_list.add = add;
886 cylinder_list.del = del;
888 g_signal_connect(edit, "clicked", G_CALLBACK(edit_cb), NULL);
889 g_signal_connect(add, "clicked", G_CALLBACK(add_cb), NULL);
890 g_signal_connect(del, "clicked", G_CALLBACK(del_cb), NULL);