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;
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)
106 convert_pressure(cyl->start.mbar, &pressure);
107 gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->start), pressure);
108 convert_pressure(cyl->end.mbar, &pressure);
109 gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->end), pressure);
113 * The gtk_tree_model_foreach() interface is bad. It could have
114 * returned whether the callback ever returned true
116 static GtkTreeIter *found_match = NULL;
117 static GtkTreeIter match_iter;
119 static gboolean match_cylinder(GtkTreeModel *model,
126 const char *desc = data;
128 gtk_tree_model_get(model, iter, 0, &name, -1);
129 match = !strcmp(desc, name);
133 found_match = &match_iter;
138 static int get_active_cylinder(GtkComboBox *combo_box, GtkTreeIter *iter)
142 if (gtk_combo_box_get_active_iter(combo_box, iter))
145 desc = gtk_combo_box_get_active_text(combo_box);
148 gtk_tree_model_foreach(GTK_TREE_MODEL(cylinder_model), match_cylinder, (void *)desc);
154 *iter = *found_match;
155 gtk_combo_box_set_active_iter(combo_box, iter);
159 static void cylinder_cb(GtkComboBox *combo_box, gpointer data)
162 GtkTreeModel *model = gtk_combo_box_get_model(combo_box);
164 struct cylinder_widget *cylinder = data;
165 cylinder_t *cyl = current_dive->cylinder + cylinder->index;
167 /* Did the user set it to some non-standard value? */
168 if (!get_active_cylinder(combo_box, &iter)) {
169 cylinder->changed = 1;
174 * We get "change" signal callbacks just because we set
175 * the description by hand. Whatever. So ignore them if
178 if (!cylinder->changed && cyl->type.description) {
180 char *desc = gtk_combo_box_get_active_text(combo_box);
182 same = !strcmp(desc, cyl->type.description);
187 cylinder->changed = 1;
189 gtk_tree_model_get(model, &iter,
194 set_cylinder_type_spinbuttons(cylinder, ml, mbar);
197 static GtkTreeIter *add_cylinder_type(const char *desc, int ml, int mbar, GtkTreeIter *iter)
201 /* Don't even bother adding stuff without a size */
206 model = GTK_TREE_MODEL(cylinder_model);
207 gtk_tree_model_foreach(model, match_cylinder, (void *)desc);
210 GtkListStore *store = GTK_LIST_STORE(model);
212 gtk_list_store_append(store, iter);
213 gtk_list_store_set(store, iter,
224 * When adding a dive, we'll add all the pre-existing cylinder
225 * information from that dive to our cylinder model.
227 void add_cylinder_description(cylinder_type_t *type)
231 unsigned int size, workp;
233 desc = type->description;
236 size = type->size.mliter;
237 workp = type->workingpressure.mbar;
238 add_cylinder_type(desc, size, workp, &iter);
241 static void add_cylinder(struct cylinder_widget *cylinder, const char *desc, int ml, int mbar)
243 GtkTreeIter iter, *match;
245 cylinder->name = desc;
246 match = add_cylinder_type(desc, ml, mbar, &iter);
248 gtk_combo_box_set_active_iter(cylinder->description, match);
251 static void show_cylinder(cylinder_t *cyl, struct cylinder_widget *cylinder)
257 /* Don't show uninitialized cylinder widgets */
258 if (!cylinder->description)
261 desc = cyl->type.description;
264 ml = cyl->type.size.mliter;
265 mbar = cyl->type.workingpressure.mbar;
266 add_cylinder(cylinder, desc, ml, mbar);
268 set_cylinder_type_spinbuttons(cylinder,
269 cyl->type.size.mliter, cyl->type.workingpressure.mbar);
270 set_cylinder_pressure_spinbuttons(cylinder, cyl);
271 o2 = cyl->gasmix.o2.permille / 10.0;
272 gtk_widget_set_sensitive(cylinder->o2, !!o2);
273 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button), !!o2);
276 gtk_spin_button_set_value(GTK_SPIN_BUTTON(cylinder->o2), o2);
279 static int cyl_nothing(cylinder_t *cyl)
281 return !cyl->type.size.mliter &&
282 !cyl->type.workingpressure.mbar &&
283 !cyl->type.description &&
284 !cyl->gasmix.o2.permille &&
285 !cyl->gasmix.he.permille &&
286 !cyl->sample_start.mbar &&
287 !cyl->sample_end.mbar &&
292 static void set_one_cylinder(int index, cylinder_t *cyl, GtkListStore *model, GtkTreeIter *iter)
294 unsigned int start, end;
296 start = cyl->start.mbar ? : cyl->sample_start.mbar;
297 end = cyl->end.mbar ? : cyl->sample_end.mbar;
298 gtk_list_store_set(model, iter,
299 CYL_DESC, cyl->type.description ? : "",
300 CYL_SIZE, cyl->type.size.mliter,
301 CYL_WORKP, cyl->type.workingpressure.mbar,
304 CYL_O2, cyl->gasmix.o2.permille,
305 CYL_HE, cyl->gasmix.he.permille,
309 void show_dive_equipment(struct dive *dive)
315 model = cylinder_list.model;
316 gtk_list_store_clear(model);
319 cylinder_t *cyl = &dive->cylinder[max-1];
321 if (!cyl_nothing(cyl))
325 cylinder_list.max_index = max;
327 gtk_widget_set_sensitive(cylinder_list.edit, 0);
328 gtk_widget_set_sensitive(cylinder_list.del, 0);
329 gtk_widget_set_sensitive(cylinder_list.add, max < MAX_CYLINDERS);
331 for (i = 0; i < max; i++) {
332 cylinder_t *cyl = dive->cylinder+i;
334 gtk_list_store_append(model, &iter);
335 set_one_cylinder(i, cyl, model, &iter);
339 static GtkWidget *create_spinbutton(GtkWidget *vbox, const char *name, double min, double max, double incr)
341 GtkWidget *frame, *hbox, *button;
343 frame = gtk_frame_new(name);
344 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, FALSE, 0);
346 hbox = gtk_hbox_new(FALSE, 3);
347 gtk_container_add(GTK_CONTAINER(frame), hbox);
349 button = gtk_spin_button_new_with_range(min, max, incr);
350 gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, FALSE, 0);
352 gtk_spin_button_set_update_policy(GTK_SPIN_BUTTON(button), GTK_UPDATE_IF_VALID);
357 static void fill_cylinder_info(struct cylinder_widget *cylinder, cylinder_t *cyl, const char *desc,
358 double volume, double pressure, double start, double end, int o2)
362 if (output_units.pressure == PSI) {
363 pressure = psi_to_bar(pressure);
364 start = psi_to_bar(start);
365 end = psi_to_bar(end);
368 if (pressure && output_units.volume == CUFT) {
369 volume = cuft_to_l(volume);
370 volume /= bar_to_atm(pressure);
373 ml = volume * 1000 + 0.5;
374 mbar = pressure * 1000 + 0.5;
378 cyl->type.description = desc;
379 cyl->type.size.mliter = ml;
380 cyl->type.workingpressure.mbar = mbar;
381 cyl->start.mbar = start * 1000 + 0.5;
382 cyl->end.mbar = end * 1000 + 0.5;
383 cyl->gasmix.o2.permille = o2;
386 * Also, insert it into the model if it doesn't already exist
388 add_cylinder(cylinder, desc, ml, mbar);
391 static void record_cylinder_changes(cylinder_t *cyl, struct cylinder_widget *cylinder)
395 double volume, pressure, start, end;
398 /* Ignore uninitialized cylinder widgets */
399 box = cylinder->description;
403 desc = gtk_combo_box_get_active_text(box);
404 volume = gtk_spin_button_get_value(cylinder->size);
405 pressure = gtk_spin_button_get_value(cylinder->pressure);
406 start = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->start));
407 end = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->end));
408 o2 = gtk_spin_button_get_value(GTK_SPIN_BUTTON(cylinder->o2))*10 + 0.5;
409 if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(cylinder->gasmix_button)))
411 fill_cylinder_info(cylinder, cyl, desc, volume, pressure, start, end, o2);
414 void flush_dive_equipment_changes(struct dive *dive)
416 /* We do nothing: we require the "Ok" button press */
420 * We hardcode the most common standard cylinders,
421 * we should pick up any other names from the dive
424 static struct tank_info {
426 int size; /* cuft if < 1000, otherwise mliter */
427 int psi; /* If zero, size is in mliter */
429 /* Need an empty entry for the no-cylinder case */
432 /* Size-only metric cylinders */
436 /* Most common AL cylinders */
437 { "AL50", 50, 3000 },
438 { "AL63", 63, 3000 },
439 { "AL72", 72, 3000 },
440 { "AL80", 80, 3000 },
441 { "AL100", 100, 3300 },
443 /* Somewhat common LP steel cylinders */
444 { "LP85", 85, 2640 },
445 { "LP95", 95, 2640 },
446 { "LP108", 108, 2640 },
447 { "LP121", 121, 2640 },
449 /* Somewhat common HP steel cylinders */
450 { "HP65", 65, 3442 },
451 { "HP80", 80, 3442 },
452 { "HP100", 100, 3442 },
453 { "HP119", 119, 3442 },
454 { "HP130", 130, 3442 },
456 /* We'll fill in more from the dive log dynamically */
460 static void fill_tank_list(GtkListStore *store)
463 struct tank_info *info = tank_info;
466 int size = info->size;
468 int mbar = 0, ml = size;
470 /* Is it in cuft and psi? */
472 double bar = psi_to_bar(psi);
473 double airvolume = cuft_to_l(size) * 1000.0;
474 double atm = bar_to_atm(bar);
476 ml = airvolume / atm + 0.5;
477 mbar = bar*1000 + 0.5;
480 gtk_list_store_append(store, &iter);
481 gtk_list_store_set(store, &iter,
490 static void nitrox_cb(GtkToggleButton *button, gpointer data)
492 struct cylinder_widget *cylinder = data;
495 state = gtk_toggle_button_get_active(button);
496 gtk_widget_set_sensitive(cylinder->o2, state);
499 static gboolean completion_cb(GtkEntryCompletion *widget, GtkTreeModel *model, GtkTreeIter *iter, struct cylinder_widget *cylinder)
502 unsigned int ml, mbar;
504 gtk_tree_model_get(model, iter, CYL_DESC, &desc, CYL_SIZE, &ml, CYL_WORKP, &mbar, -1);
505 add_cylinder(cylinder, desc, ml, mbar);
509 static void cylinder_activate_cb(GtkComboBox *combo_box, gpointer data)
511 struct cylinder_widget *cylinder = data;
512 cylinder_cb(cylinder->description, data);
515 static void cylinder_widget(GtkWidget *vbox, struct cylinder_widget *cylinder, GtkListStore *model)
517 GtkWidget *frame, *hbox;
519 GtkEntryCompletion *completion;
523 * Cylinder type: description, size and
526 frame = gtk_frame_new("Cylinder");
528 hbox = gtk_hbox_new(FALSE, 3);
529 gtk_container_add(GTK_CONTAINER(frame), hbox);
531 widget = gtk_combo_box_entry_new_with_model(GTK_TREE_MODEL(model), 0);
532 gtk_box_pack_start(GTK_BOX(hbox), widget, FALSE, TRUE, 0);
534 cylinder->description = GTK_COMBO_BOX(widget);
535 g_signal_connect(widget, "changed", G_CALLBACK(cylinder_cb), cylinder);
537 entry = GTK_ENTRY(GTK_BIN(widget)->child);
538 g_signal_connect(entry, "activate", G_CALLBACK(cylinder_activate_cb), cylinder);
540 completion = gtk_entry_completion_new();
541 gtk_entry_completion_set_text_column(completion, 0);
542 gtk_entry_completion_set_model(completion, GTK_TREE_MODEL(model));
543 g_signal_connect(completion, "match-selected", G_CALLBACK(completion_cb), cylinder);
544 gtk_entry_set_completion(entry, completion);
546 hbox = gtk_hbox_new(FALSE, 3);
547 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
548 gtk_box_pack_start(GTK_BOX(hbox), frame, FALSE, TRUE, 0);
550 widget = create_spinbutton(hbox, "Size", 0, 300, 0.1);
551 cylinder->size = GTK_SPIN_BUTTON(widget);
553 widget = create_spinbutton(hbox, "Pressure", 0, 5000, 1);
554 cylinder->pressure = GTK_SPIN_BUTTON(widget);
557 * Cylinder start/end pressures
559 hbox = gtk_hbox_new(FALSE, 3);
560 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
562 widget = create_spinbutton(hbox, "Start Pressure", 0, 5000, 1);
563 cylinder->start = widget;
565 widget = create_spinbutton(hbox, "End Pressure", 0, 5000, 1);
566 cylinder->end = widget;
569 * Cylinder gas mix: Air, Nitrox or Trimix
571 hbox = gtk_hbox_new(FALSE, 3);
572 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
574 widget = create_spinbutton(hbox, "Nitrox", 21, 100, 0.1);
575 cylinder->o2 = widget;
576 cylinder->gasmix_button = gtk_check_button_new();
577 gtk_box_pack_start(GTK_BOX(gtk_widget_get_parent(cylinder->o2)),
578 cylinder->gasmix_button, FALSE, FALSE, 3);
579 g_signal_connect(cylinder->gasmix_button, "toggled", G_CALLBACK(nitrox_cb), cylinder);
581 gtk_spin_button_set_range(GTK_SPIN_BUTTON(cylinder->o2), 21.0, 100.0);
584 static int edit_cylinder_dialog(int index, cylinder_t *cyl)
587 GtkWidget *dialog, *vbox;
588 struct cylinder_widget cylinder;
591 cylinder.index = index;
592 cylinder.changed = 0;
597 *cyl = dive->cylinder[index];
599 dialog = gtk_dialog_new_with_buttons("Cylinder",
600 GTK_WINDOW(main_window),
601 GTK_DIALOG_DESTROY_WITH_PARENT,
602 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
603 GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
606 vbox = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
607 cylinder_widget(vbox, &cylinder, cylinder_model);
609 show_cylinder(cyl, &cylinder);
611 gtk_widget_show_all(dialog);
612 success = gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT;
614 record_cylinder_changes(cyl, &cylinder);
615 dive->cylinder[index] = *cyl;
616 mark_divelist_changed(TRUE);
617 flush_divelist(dive);
620 gtk_widget_destroy(dialog);
625 static int get_model_index(GtkListStore *model, GtkTreeIter *iter)
630 path = gtk_tree_model_get_path(GTK_TREE_MODEL(model), iter);
631 p = gtk_tree_path_get_indices(path);
633 gtk_tree_path_free(path);
637 static void edit_cb(GtkButton *button, gpointer data)
641 GtkListStore *model = cylinder_list.model;
642 GtkTreeSelection *selection;
645 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
647 /* Nothing selected? This shouldn't happen, since the button should be inactive */
648 if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
651 index = get_model_index(model, &iter);
652 if (!edit_cylinder_dialog(index, &cyl))
655 set_one_cylinder(index, &cyl, model, &iter);
659 static void add_cb(GtkButton *button, gpointer data)
661 int index = cylinder_list.max_index;
663 GtkListStore *model = cylinder_list.model;
664 GtkTreeSelection *selection;
667 if (!edit_cylinder_dialog(index, &cyl))
670 gtk_list_store_append(model, &iter);
671 set_one_cylinder(index, &cyl, model, &iter);
673 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
674 gtk_tree_selection_select_iter(selection, &iter);
676 cylinder_list.max_index++;
677 gtk_widget_set_sensitive(cylinder_list.add, cylinder_list.max_index < MAX_CYLINDERS);
680 static void del_cb(GtkButton *button, gpointer data)
684 GtkListStore *model = cylinder_list.model;
685 GtkTreeSelection *selection;
689 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(cylinder_list.tree_view));
691 /* Nothing selected? This shouldn't happen, since the button should be inactive */
692 if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
695 index = get_model_index(model, &iter);
700 cyl = dive->cylinder + index;
701 nr = cylinder_list.max_index - index - 1;
703 gtk_list_store_remove(model, &iter);
705 cylinder_list.max_index--;
706 memmove(cyl, cyl+1, nr*sizeof(*cyl));
707 memset(cyl+nr, 0, sizeof(*cyl));
709 mark_divelist_changed(TRUE);
710 flush_divelist(dive);
712 gtk_widget_set_sensitive(cylinder_list.edit, 0);
713 gtk_widget_set_sensitive(cylinder_list.del, 0);
714 gtk_widget_set_sensitive(cylinder_list.add, 1);
717 static GtkListStore *create_tank_size_model(void)
721 model = gtk_list_store_new(3,
722 G_TYPE_STRING, /* Tank name */
723 G_TYPE_INT, /* Tank size in mliter */
724 G_TYPE_INT, /* Tank working pressure in mbar */
727 fill_tank_list(model);
731 static void size_data_func(GtkTreeViewColumn *col,
732 GtkCellRenderer *renderer,
738 double size, pressure;
741 gtk_tree_model_get(model, iter, CYL_SIZE, &ml, CYL_WORKP, &mbar, -1);
742 convert_volume_pressure(ml, mbar, &size, &pressure);
744 snprintf(buffer, sizeof(buffer), "%.1f", size);
746 strcpy(buffer, "unkn");
747 g_object_set(renderer, "text", buffer, NULL);
750 static void pressure_data_func(GtkTreeViewColumn *col,
751 GtkCellRenderer *renderer,
756 int index = (long)data;
761 gtk_tree_model_get(model, iter, index, &mbar, -1);
762 decimals = convert_pressure(mbar, &pressure);
764 snprintf(buffer, sizeof(buffer), "%.*f", decimals, pressure);
767 g_object_set(renderer, "text", buffer, NULL);
770 static void percentage_data_func(GtkTreeViewColumn *col,
771 GtkCellRenderer *renderer,
776 int index = (long)data;
780 gtk_tree_model_get(model, iter, index, &permille, -1);
782 snprintf(buffer, sizeof(buffer), "%.1f%%", permille / 10.0);
785 g_object_set(renderer, "text", buffer, NULL);
788 static void selection_cb(GtkTreeSelection *selection, GtkTreeModel *model)
793 selected = gtk_tree_selection_get_selected(selection, NULL, &iter);
794 gtk_widget_set_sensitive(cylinder_list.edit, selected);
795 gtk_widget_set_sensitive(cylinder_list.del, selected);
798 static void row_activated_cb(GtkTreeView *tree_view,
800 GtkTreeViewColumn *column,
806 static GtkWidget *cylinder_list_create(void)
808 GtkWidget *tree_view;
809 GtkTreeSelection *selection;
812 model = gtk_list_store_new(CYL_COLUMNS,
813 G_TYPE_STRING, /* CYL_DESC: utf8 */
814 G_TYPE_INT, /* CYL_SIZE: mliter */
815 G_TYPE_INT, /* CYL_WORKP: mbar */
816 G_TYPE_INT, /* CYL_STARTP: mbar */
817 G_TYPE_INT, /* CYL_ENDP: mbar */
818 G_TYPE_INT, /* CYL_O2: permille */
819 G_TYPE_INT /* CYL_HE: permille */
821 cylinder_list.model = model;
822 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
823 g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), model);
825 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
826 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
827 g_signal_connect(selection, "changed", G_CALLBACK(selection_cb), model);
829 g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
830 "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
833 cylinder_list.desc = tree_view_column(tree_view, CYL_DESC, "Type", NULL, PANGO_ALIGN_LEFT, TRUE);
834 cylinder_list.size = tree_view_column(tree_view, CYL_SIZE, "Size", size_data_func, PANGO_ALIGN_RIGHT, TRUE);
835 cylinder_list.workp = tree_view_column(tree_view, CYL_WORKP, "MaxPress", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
836 cylinder_list.startp = tree_view_column(tree_view, CYL_STARTP, "Start", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
837 cylinder_list.endp = tree_view_column(tree_view, CYL_ENDP, "End", pressure_data_func, PANGO_ALIGN_RIGHT, TRUE);
838 cylinder_list.o2 = tree_view_column(tree_view, CYL_O2, "O" UTF8_SUBSCRIPT_2 "%", percentage_data_func, PANGO_ALIGN_RIGHT, TRUE);
839 cylinder_list.he = tree_view_column(tree_view, CYL_HE, "He%", percentage_data_func, PANGO_ALIGN_RIGHT, TRUE);
843 GtkWidget *equipment_widget(void)
845 GtkWidget *vbox, *hbox, *frame, *framebox;
846 GtkWidget *add, *del, *edit;
848 vbox = gtk_vbox_new(FALSE, 3);
851 * We create the cylinder size model at startup, since
852 * we're going to share it across all cylinders and all
853 * dives. So if you add a new cylinder type in one dive,
854 * it will show up when you edit the cylinder types for
857 cylinder_model = create_tank_size_model();
859 cylinder_list.tree_view = cylinder_list_create();
861 hbox = gtk_hbox_new(FALSE, 3);
862 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);
864 frame = gtk_frame_new("Cylinders");
865 gtk_box_pack_start(GTK_BOX(hbox), frame, TRUE, FALSE, 3);
867 framebox = gtk_vbox_new(FALSE, 3);
868 gtk_container_add(GTK_CONTAINER(frame), framebox);
870 hbox = gtk_hbox_new(FALSE, 3);
871 gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
873 gtk_box_pack_start(GTK_BOX(hbox), cylinder_list.tree_view, TRUE, FALSE, 3);
875 hbox = gtk_hbox_new(TRUE, 3);
876 gtk_box_pack_start(GTK_BOX(framebox), hbox, TRUE, FALSE, 3);
878 edit = gtk_button_new_from_stock(GTK_STOCK_EDIT);
879 add = gtk_button_new_from_stock(GTK_STOCK_ADD);
880 del = gtk_button_new_from_stock(GTK_STOCK_DELETE);
881 gtk_box_pack_start(GTK_BOX(hbox), edit, FALSE, FALSE, 0);
882 gtk_box_pack_start(GTK_BOX(hbox), add, FALSE, FALSE, 0);
883 gtk_box_pack_start(GTK_BOX(hbox), del, FALSE, FALSE, 0);
885 cylinder_list.edit = edit;
886 cylinder_list.add = add;
887 cylinder_list.del = del;
889 g_signal_connect(edit, "clicked", G_CALLBACK(edit_cb), NULL);
890 g_signal_connect(add, "clicked", G_CALLBACK(add_cb), NULL);
891 g_signal_connect(del, "clicked", G_CALLBACK(del_cb), NULL);