+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 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, GtkTreeModel *model)
+{
+ GtkTreeIter iter;
+ int selected;
+
+ selected = gtk_tree_selection_get_selected(selection, NULL, &iter);
+ gtk_widget_set_sensitive(cylinder_list.edit, selected);
+ gtk_widget_set_sensitive(cylinder_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), model);
+
+ 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;
+}
+
+static GtkWidget *cylinder_list_create(void)