+ model = gtk_list_store_new(2,
+ G_TYPE_STRING, /* Weightsystem description */
+ G_TYPE_INT, /* Weight in grams */
+ -1);
+
+ fill_ws_list(model);
+ return model;
+}
+
+static void size_data_func(GtkTreeViewColumn *col,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ int ml, mbar;
+ double size, pressure;
+ char buffer[10];
+
+ gtk_tree_model_get(model, iter, CYL_SIZE, &ml, CYL_WORKP, &mbar, -1);
+ convert_volume_pressure(ml, mbar, &size, &pressure);
+ if (size)
+ snprintf(buffer, sizeof(buffer), "%.1f", size);
+ else
+ strcpy(buffer, "unkn");
+ g_object_set(renderer, "text", buffer, NULL);
+}
+
+static void weight_data_func(GtkTreeViewColumn *col,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ int idx = (long)data;
+ int grams, decimals;
+ double value;
+ char buffer[10];
+
+ gtk_tree_model_get(model, iter, idx, &grams, -1);
+ decimals = convert_weight(grams, &value);
+ if (grams)
+ snprintf(buffer, sizeof(buffer), "%.*f", decimals, value);
+ else
+ strcpy(buffer, "unkn");
+ g_object_set(renderer, "text", buffer, NULL);
+}
+
+static void pressure_data_func(GtkTreeViewColumn *col,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ int index = (long)data;
+ int mbar, decimals;
+ double pressure;
+ char buffer[10];
+
+ gtk_tree_model_get(model, iter, index, &mbar, -1);
+ decimals = convert_pressure(mbar, &pressure);
+ if (mbar)
+ snprintf(buffer, sizeof(buffer), "%.*f", decimals, pressure);
+ else
+ *buffer = 0;
+ g_object_set(renderer, "text", buffer, NULL);
+}
+
+static void percentage_data_func(GtkTreeViewColumn *col,
+ GtkCellRenderer *renderer,
+ GtkTreeModel *model,
+ GtkTreeIter *iter,
+ gpointer data)
+{
+ int index = (long)data;
+ int permille;
+ char buffer[10];
+
+ gtk_tree_model_get(model, iter, index, &permille, -1);
+ if (permille)
+ snprintf(buffer, sizeof(buffer), "%.1f%%", permille / 10.0);
+ else
+ *buffer = 0;
+ g_object_set(renderer, "text", buffer, NULL);
+}
+
+static void selection_cb(GtkTreeSelection *selection, struct equipment_list *list)
+{
+ GtkTreeIter iter;
+ int selected;
+
+ selected = gtk_tree_selection_get_selected(selection, NULL, &iter);
+ gtk_widget_set_sensitive(list->edit, selected);
+ gtk_widget_set_sensitive(list->del, selected);
+}
+
+static void row_activated_cb(GtkTreeView *tree_view,
+ GtkTreePath *path,
+ GtkTreeViewColumn *column,
+ GtkTreeModel *model)
+{
+ edit_cb(NULL, tree_view);
+}
+
+GtkWidget *cylinder_list_widget(void)
+{
+ GtkListStore *model = cylinder_list.model;
+ GtkWidget *tree_view;
+ GtkTreeSelection *selection;
+
+ tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+ gtk_widget_set_can_focus(tree_view, FALSE);
+
+ g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), model);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
+ g_signal_connect(selection, "changed", G_CALLBACK(selection_cb), &cylinder_list);
+
+ g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
+ "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
+ NULL);
+
+ tree_view_column(tree_view, CYL_DESC, "Type", NULL, ALIGN_LEFT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_SIZE, "Size", size_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_WORKP, "MaxPress", pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_STARTP, "Start", pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_ENDP, "End", pressure_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_O2, "O" UTF8_SUBSCRIPT_2 "%", percentage_data_func, ALIGN_RIGHT | UNSORTABLE);
+ tree_view_column(tree_view, CYL_HE, "He%", percentage_data_func, ALIGN_RIGHT | UNSORTABLE);
+ return tree_view;
+}
+
+GtkWidget *weightsystem_list_widget(void)
+{
+ GtkListStore *model = weightsystem_list.model;
+ GtkWidget *tree_view;
+ GtkTreeSelection *selection;
+
+ tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
+ gtk_widget_set_can_focus(tree_view, FALSE);
+ g_signal_connect(tree_view, "row-activated", G_CALLBACK(row_activated_cb), model);
+
+ selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
+ gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
+ g_signal_connect(selection, "changed", G_CALLBACK(selection_cb), &weightsystem_list);
+
+ g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
+ "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH,
+ NULL);
+
+ tree_view_column(tree_view, WS_DESC, "Type", NULL, ALIGN_LEFT | UNSORTABLE);
+ tree_view_column(tree_view, WS_WEIGHT, "weight",
+ weight_data_func, ALIGN_RIGHT | UNSORTABLE);
+
+ return tree_view;
+}
+
+static GtkWidget *cylinder_list_create(void)
+{
+ GtkListStore *model;
+
+ model = gtk_list_store_new(CYL_COLUMNS,
+ G_TYPE_STRING, /* CYL_DESC: utf8 */
+ G_TYPE_INT, /* CYL_SIZE: mliter */
+ G_TYPE_INT, /* CYL_WORKP: mbar */
+ G_TYPE_INT, /* CYL_STARTP: mbar */
+ G_TYPE_INT, /* CYL_ENDP: mbar */
+ G_TYPE_INT, /* CYL_O2: permille */
+ G_TYPE_INT /* CYL_HE: permille */
+ );
+ cylinder_list.model = model;
+ return cylinder_list_widget();
+}
+
+static GtkWidget *weightsystem_list_create(void)
+{
+ GtkListStore *model;
+
+ model = gtk_list_store_new(WS_COLUMNS,
+ G_TYPE_STRING, /* WS_DESC: utf8 */
+ G_TYPE_INT /* WS_WEIGHT: grams */
+ );
+ weightsystem_list.model = model;
+ return weightsystem_list_widget();
+}
+
+GtkWidget *equipment_widget(void)
+{
+ GtkWidget *vbox, *hbox, *frame, *framebox, *tree_view;
+ GtkWidget *add, *del, *edit;
+