11 static struct tank_info {
13 int size; /* cuft or mliter depending on psi */
14 int psi; /* If zero, size is in mliter */
23 { "HP100", 100, 3442 },
24 { "HP119", 119, 3442 },
28 static void fill_tank_list(GtkListStore *store)
32 struct tank_info *info = tank_info;
35 int size = info->size;
37 int mbar = 0, ml = size;
39 /* Is it in cuft and psi? */
41 double bar = 0.0689475729 * psi;
42 double airvolume = 28316.8466 * size;
43 double atm = bar / 1.01325;
45 ml = airvolume / atm + 0.5;
46 mbar = bar*1000 + 0.5;
49 gtk_list_store_append(store, &iter);
50 gtk_list_store_set(store, &iter,
59 static void cylinder_widget(GtkWidget *box, int nr, GtkListStore *model)
61 GtkWidget *frame, *hbox, *size;
62 GtkCellRenderer *cell;
65 snprintf(buffer, sizeof(buffer), "Cylinder %d", nr);
66 frame = gtk_frame_new(buffer);
67 gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 0);
69 hbox = gtk_hbox_new(TRUE, 3);
70 gtk_container_add(GTK_CONTAINER(frame), hbox);
72 size = gtk_combo_box_new_with_model(GTK_TREE_MODEL(model));
73 cell = gtk_cell_renderer_text_new();
74 gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(size), cell, TRUE);
75 gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(size), cell, "text", 0, NULL );
77 gtk_box_pack_start(GTK_BOX(hbox), size, FALSE, FALSE, 0);
80 static GtkListStore *create_tank_size_model(void)
84 model = gtk_list_store_new(3,
85 G_TYPE_STRING, /* Tank name */
86 G_TYPE_INT, /* Tank size in mliter */
87 G_TYPE_INT, /* Tank working pressure in mbar */
90 fill_tank_list(model);
94 GtkWidget *cylinder_management_widget(void)
100 vbox = gtk_vbox_new(TRUE, 3);
102 model = create_tank_size_model();
103 for (i = 0; i < MAX_CYLINDERS; i++)
104 cylinder_widget(vbox, i, model);