blob: 6186515eff97280919ad9d9353a4d363ff43d69b [file] [log] [blame]
Stephen M. Cameronff1f3282012-02-24 08:17:30 +01001/*
2 * gfio - gui front end for fio - the flexible io tester
3 *
4 * Copyright (C) 2012 Stephen M. Cameron <stephenmcameron@gmail.com>
5 *
6 * The license below covers all files distributed with fio unless otherwise
7 * noted in the file itself.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 *
22 */
Stephen M. Cameron8232e282012-02-24 08:17:31 +010023#include <locale.h>
Stephen M. Cameron60f6b332012-02-24 08:17:32 +010024#include <malloc.h>
Stephen M. Cameron8232e282012-02-24 08:17:31 +010025
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +010026#include <glib.h>
Stephen M. Cameronff1f3282012-02-24 08:17:30 +010027#include <gtk/gtk.h>
28
Stephen M. Cameron8232e282012-02-24 08:17:31 +010029#include "fio.h"
30
Stephen M. Cameronf3074002012-02-24 08:17:30 +010031#define ARRAYSIZE(x) (sizeof((x)) / (sizeof((x)[0])))
32
33typedef void (*clickfunction)(GtkWidget *widget, gpointer data);
34
35static void quit_clicked(GtkWidget *widget, gpointer data);
36static void start_job_clicked(GtkWidget *widget, gpointer data);
37
38static struct button_spec {
39 const char *buttontext;
40 clickfunction f;
41 const char *tooltiptext;
42} buttonspeclist[] = {
43#define START_JOB_BUTTON 0
44 { "Start Job",
45 start_job_clicked,
46 "Send current fio job to fio server to be executed" },
Stephen M. Cameronf3074002012-02-24 08:17:30 +010047};
48
Stephen M. Cameronff1f3282012-02-24 08:17:30 +010049struct gui {
50 GtkWidget *window;
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +010051 GtkWidget *vbox;
Stephen M. Cameronc36f98d2012-02-24 08:17:32 +010052 GtkWidget *topvbox;
53 GtkWidget *topalign;
54 GtkWidget *bottomalign;
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +010055 GtkWidget *thread_status_pb;
Stephen M. Cameronf3074002012-02-24 08:17:30 +010056 GtkWidget *buttonbox;
57 GtkWidget *button[ARRAYSIZE(buttonspeclist)];
Stephen M. Cameron45032dd2012-02-24 08:17:31 +010058 GtkWidget *hostname_hbox;
59 GtkWidget *hostname_label;
60 GtkWidget *hostname_entry;
61 GtkWidget *port_label;
62 GtkWidget *port_entry;
63 GtkWidget *hostname_combo_box; /* ipv4, ipv6 or socket */
Stephen M. Cameron736f2df2012-02-24 08:17:32 +010064 GtkWidget *scrolled_window;
65 GtkWidget *textview;
Jens Axboe0420ba62012-02-29 11:16:52 +010066 GtkWidget *error_info_bar;
67 GtkWidget *error_label;
Stephen M. Cameron736f2df2012-02-24 08:17:32 +010068 GtkTextBuffer *text;
Stephen M. Cameron25927252012-02-24 08:17:31 +010069 pthread_t t;
Jens Axboe0420ba62012-02-29 11:16:52 +010070
71 void *cookie;
72 int nr_job_files;
73 char **job_files;
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +010074} ui;
Stephen M. Cameronff1f3282012-02-24 08:17:30 +010075
Stephen M. Camerona1820202012-02-24 08:17:31 +010076static void gfio_text_op(struct fio_client *client,
77 FILE *f, __u16 pdu_len, const char *buf)
78{
Stephen M. Cameron736f2df2012-02-24 08:17:32 +010079 GtkTextBuffer *buffer;
80 GtkTextIter end;
81
82 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui.textview));
83 gdk_threads_enter();
84 gtk_text_buffer_get_end_iter(buffer, &end);
85 gtk_text_buffer_insert(buffer, &end, buf, -1);
86 gdk_threads_leave();
87 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(ui.textview),
88 &end, 0.0, FALSE, 0.0,0.0);
Stephen M. Camerona1820202012-02-24 08:17:31 +010089}
90
91static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd)
92{
93 printf("gfio_disk_util_op called\n");
94 fio_client_ops.disk_util(client, cmd);
95}
96
97static void gfio_thread_status_op(struct fio_net_cmd *cmd)
98{
99 printf("gfio_thread_status_op called\n");
100 fio_client_ops.thread_status(cmd);
101}
102
103static void gfio_group_stats_op(struct fio_net_cmd *cmd)
104{
105 printf("gfio_group_stats_op called\n");
106 fio_client_ops.group_stats(cmd);
107}
108
109static void gfio_eta_op(struct fio_client *client, struct fio_net_cmd *cmd)
110{
Stephen M. Camerona1820202012-02-24 08:17:31 +0100111 fio_client_ops.eta(client, cmd);
112}
113
114static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
115{
116 printf("gfio_probe_op called\n");
117 fio_client_ops.probe(client, cmd);
118}
119
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +0100120static void gfio_update_thread_status(char *status_message, double perc)
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +0100121{
122 static char message[100];
123 const char *m = message;
124
125 strncpy(message, status_message, sizeof(message) - 1);
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +0100126 gtk_progress_bar_set_text(
127 GTK_PROGRESS_BAR(ui.thread_status_pb), m);
128 gtk_progress_bar_set_fraction(
129 GTK_PROGRESS_BAR(ui.thread_status_pb), perc / 100.0);
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +0100130 gdk_threads_enter();
131 gtk_widget_queue_draw(ui.window);
132 gdk_threads_leave();
133}
134
Stephen M. Camerona1820202012-02-24 08:17:31 +0100135struct client_ops gfio_client_ops = {
Jens Axboe0420ba62012-02-29 11:16:52 +0100136 .text_op = gfio_text_op,
137 .disk_util = gfio_disk_util_op,
138 .thread_status = gfio_thread_status_op,
139 .group_stats = gfio_group_stats_op,
140 .eta = gfio_eta_op,
141 .probe = gfio_probe_op,
142 .thread_status_display = gfio_update_thread_status,
Stephen M. Camerona1820202012-02-24 08:17:31 +0100143};
144
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100145static void quit_clicked(__attribute__((unused)) GtkWidget *widget,
146 __attribute__((unused)) gpointer data)
147{
148 gtk_main_quit();
149}
150
Stephen M. Cameron25927252012-02-24 08:17:31 +0100151static void *job_thread(void *arg)
Stephen M. Cameronf3074002012-02-24 08:17:30 +0100152{
Stephen M. Cameron25927252012-02-24 08:17:31 +0100153 struct gui *ui = arg;
154
155 fio_handle_clients(&gfio_client_ops);
156 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1);
157 return NULL;
158}
159
Jens Axboe0420ba62012-02-29 11:16:52 +0100160static int send_job_files(struct gui *ui)
Stephen M. Cameron60f6b332012-02-24 08:17:32 +0100161{
Jens Axboe0420ba62012-02-29 11:16:52 +0100162 int i, ret;
Stephen M. Cameron60f6b332012-02-24 08:17:32 +0100163
Jens Axboe0420ba62012-02-29 11:16:52 +0100164 for (i = 0; i < ui->nr_job_files; i++) {
165 ret = fio_clients_send_ini(ui->job_files[i]);
166 free(ui->job_files[i]);
167 ui->job_files[i] = NULL;
168 if (ret)
169 return ret;
170 }
171
172 return 0;
Stephen M. Cameron60f6b332012-02-24 08:17:32 +0100173}
174
Stephen M. Cameron25927252012-02-24 08:17:31 +0100175static void start_job_thread(pthread_t *t, struct gui *ui)
176{
Jens Axboe0420ba62012-02-29 11:16:52 +0100177 fio_clients_connect();
178
179 if (send_job_files(ui)) {
Stephen M. Cameron60f6b332012-02-24 08:17:32 +0100180 printf("Yeah, I didn't really like those options too much.\n");
Stephen M. Cameron60f6b332012-02-24 08:17:32 +0100181 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1);
182 return;
183 }
Jens Axboe0420ba62012-02-29 11:16:52 +0100184
Stephen M. Cameron25927252012-02-24 08:17:31 +0100185 pthread_create(t, NULL, job_thread, ui);
186}
187
188static void start_job_clicked(__attribute__((unused)) GtkWidget *widget,
189 gpointer data)
190{
191 struct gui *ui = data;
192
Stephen M. Cameronf3074002012-02-24 08:17:30 +0100193 printf("Start job button was clicked.\n");
Stephen M. Cameron25927252012-02-24 08:17:31 +0100194 gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 0);
195 start_job_thread(&ui->t, ui);
Stephen M. Cameronf3074002012-02-24 08:17:30 +0100196}
197
198static void add_button(struct gui *ui, int i, GtkWidget *buttonbox,
199 struct button_spec *buttonspec)
200{
201 ui->button[i] = gtk_button_new_with_label(buttonspec->buttontext);
202 g_signal_connect(ui->button[i], "clicked", G_CALLBACK (buttonspec->f), ui);
203 gtk_box_pack_start(GTK_BOX (ui->buttonbox), ui->button[i], TRUE, TRUE, 0);
204 gtk_widget_set_tooltip_text(ui->button[i], buttonspeclist[i].tooltiptext);
205}
206
207static void add_buttons(struct gui *ui,
208 struct button_spec *buttonlist,
209 int nbuttons)
210{
211 int i;
212
Stephen M. Cameronf3074002012-02-24 08:17:30 +0100213 for (i = 0; i < nbuttons; i++)
214 add_button(ui, i, ui->buttonbox, &buttonlist[i]);
215}
216
Jens Axboe0420ba62012-02-29 11:16:52 +0100217static void on_info_bar_response(GtkWidget *widget, gint response,
218 gpointer data)
219{
220 if (response == GTK_RESPONSE_OK) {
221 gtk_widget_destroy(widget);
222 ui.error_info_bar = NULL;
223 }
224}
225
226void report_error(GError* error)
227{
228 if (ui.error_info_bar == NULL) {
229 ui.error_info_bar = gtk_info_bar_new_with_buttons(GTK_STOCK_OK,
230 GTK_RESPONSE_OK,
231 NULL);
232 g_signal_connect(ui.error_info_bar, "response", G_CALLBACK(on_info_bar_response), NULL);
233 gtk_info_bar_set_message_type(GTK_INFO_BAR(ui.error_info_bar),
234 GTK_MESSAGE_ERROR);
235
236 ui.error_label = gtk_label_new(error->message);
237 GtkWidget *container = gtk_info_bar_get_content_area(GTK_INFO_BAR(ui.error_info_bar));
238 gtk_container_add(GTK_CONTAINER(container), ui.error_label);
239
240 gtk_box_pack_start(GTK_BOX(ui.vbox), ui.error_info_bar, FALSE, FALSE, 0);
241 gtk_widget_show_all(ui.vbox);
242 } else {
243 char buffer[256];
244 snprintf(buffer, sizeof(buffer), "Failed to open file.");
245 gtk_label_set(GTK_LABEL(ui.error_label), buffer);
246 }
247}
248
249static void file_open(GtkWidget *w, gpointer data)
250{
251 GtkWidget *dialog;
252 GSList *filenames, *fn_glist;
253 GtkFileFilter *filter;
254
255 dialog = gtk_file_chooser_dialog_new("Open File",
256 GTK_WINDOW(ui.window),
257 GTK_FILE_CHOOSER_ACTION_OPEN,
258 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
259 GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
260 NULL);
261 gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE);
262
263 filter = gtk_file_filter_new();
264 gtk_file_filter_add_pattern(filter, "*.fio");
265 gtk_file_filter_add_pattern(filter, "*.job");
266 gtk_file_filter_add_mime_type(filter, "text/fio");
267 gtk_file_filter_set_name(filter, "Fio job file");
268 gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
269
270 if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
271 gtk_widget_destroy(dialog);
272 return;
273 }
274
275 fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog));
276 filenames = fn_glist;
277 while (filenames != NULL) {
278 const char *hostname;
279
280 ui.job_files = realloc(ui.job_files, (ui.nr_job_files + 1) * sizeof(char *));
281 ui.job_files[ui.nr_job_files] = strdup(filenames->data);
282 ui.nr_job_files++;
283
284 hostname = gtk_entry_get_text(GTK_ENTRY(ui.hostname_entry));
285 fio_client_add(hostname, &ui.cookie);
286#if 0
287 if (error) {
288 report_error(error);
289 g_error_free(error);
290 error = NULL;
291 }
292#endif
293
294 g_free(filenames->data);
295 filenames = g_slist_next(filenames);
296 }
297 g_slist_free(fn_glist);
298 gtk_widget_destroy(dialog);
299}
300
301static void file_save(GtkWidget *w, gpointer data)
302{
303 GtkWidget *dialog;
304
305 dialog = gtk_file_chooser_dialog_new("Save File",
306 GTK_WINDOW(ui.window),
307 GTK_FILE_CHOOSER_ACTION_SAVE,
308 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
309 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
310 NULL);
311
312 gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE);
313 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document");
314
315 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
316 char *filename;
317
318 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
319 // save_job_file(filename);
320 g_free(filename);
321 }
322 gtk_widget_destroy(dialog);
323}
324
325static void about_dialog(GtkWidget *w, gpointer data)
326{
327 gtk_show_about_dialog(NULL,
328 "program-name", "gfio",
329 "comments", "Gtk2 UI for fio",
330 "license", "GPLv2",
331 "version", fio_version_string,
332 "copyright", "Jens Axboe <axboe@kernel.dk> 2012",
333 "logo-icon-name", "fio",
334 /* Must be last: */
335 NULL, NULL,
336 NULL);
337}
338
339static GtkActionEntry menu_items[] = {
340 { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
341 { "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL},
342 { "OpenFile", GTK_STOCK_OPEN, NULL, "<Control>O", NULL, G_CALLBACK(file_open) },
343 { "SaveFile", GTK_STOCK_SAVE, NULL, "<Control>S", NULL, G_CALLBACK(file_save) },
344 { "Quit", GTK_STOCK_QUIT, NULL, "<Control>Q", NULL, G_CALLBACK(quit_clicked) },
345 { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) },
346};
347static gint nmenu_items = sizeof (menu_items) / sizeof(menu_items[0]);
348
349static const gchar *ui_string = " \
350 <ui> \
351 <menubar name=\"MainMenu\"> \
352 <menu name=\"FileMenu\" action=\"FileMenuAction\"> \
353 <menuitem name=\"Open\" action=\"OpenFile\" /> \
354 <menuitem name=\"Save\" action=\"SaveFile\" /> \
355 <separator name=\"Separator\"/> \
356 <menuitem name=\"Quit\" action=\"Quit\" /> \
357 </menu> \
358 <menu name=\"Help\" action=\"HelpMenuAction\"> \
359 <menuitem name=\"About\" action=\"About\" /> \
360 </menu> \
361 </menubar> \
362 </ui> \
363";
364
365static GtkWidget *get_menubar_menu(GtkWidget *window, GtkUIManager *ui_manager)
366{
367 GtkActionGroup *action_group = gtk_action_group_new("Menu");
368 GError *error = 0;
369
370 action_group = gtk_action_group_new("Menu");
371 gtk_action_group_add_actions(action_group, menu_items, nmenu_items, 0);
372
373 gtk_ui_manager_insert_action_group(ui_manager, action_group, 0);
374 gtk_ui_manager_add_ui_from_string(GTK_UI_MANAGER(ui_manager), ui_string, -1, &error);
375
376 gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui_manager));
377 return gtk_ui_manager_get_widget(ui_manager, "/MainMenu");
378}
379
380void gfio_ui_setup(GtkSettings *settings, GtkWidget *menubar,
381 GtkWidget *vbox, GtkUIManager *ui_manager)
382{
383 gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0);
384}
385
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100386static void init_ui(int *argc, char **argv[], struct gui *ui)
387{
Stephen M. Cameron45032dd2012-02-24 08:17:31 +0100388 GList *hostname_type_list = NULL;
389 char portnum[20];
Jens Axboe0420ba62012-02-29 11:16:52 +0100390 GtkSettings *settings;
391 GtkUIManager *uimanager;
392 GtkWidget *menu;
393
394 memset(ui, 0, sizeof(*ui));
Stephen M. Cameron45032dd2012-02-24 08:17:31 +0100395
Stephen M. Cameron2839f0c2012-02-24 08:17:31 +0100396 /* Magical g*thread incantation, you just need this thread stuff.
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +0100397 * Without it, the update that happens in gfio_update_thread_status
Stephen M. Cameron2839f0c2012-02-24 08:17:31 +0100398 * doesn't really happen in a timely fashion, you need expose events
399 */
400 if (!g_thread_supported ())
401 g_thread_init(NULL);
402 gdk_threads_init();
403
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100404 gtk_init(argc, argv);
Jens Axboe0420ba62012-02-29 11:16:52 +0100405 settings = gtk_settings_get_default();
406 gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "gfio setting");
407 g_type_init();
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100408
409 ui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
410 gtk_window_set_title(GTK_WINDOW(ui->window), "fio");
411 gtk_window_set_default_size(GTK_WINDOW(ui->window), 700, 500);
412
Jens Axboe0420ba62012-02-29 11:16:52 +0100413 g_signal_connect(ui->window, "delete-event", G_CALLBACK(quit_clicked), NULL);
414 g_signal_connect(ui->window, "destroy", G_CALLBACK(quit_clicked), NULL);
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100415
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +0100416 ui->vbox = gtk_vbox_new(FALSE, 0);
417 gtk_container_add(GTK_CONTAINER (ui->window), ui->vbox);
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +0100418
Jens Axboe0420ba62012-02-29 11:16:52 +0100419 uimanager = gtk_ui_manager_new();
420 menu = get_menubar_menu(ui->window, uimanager);
421 gfio_ui_setup(settings, menu, ui->vbox, uimanager);
422
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +0100423 /*
Stephen M. Cameronc36f98d2012-02-24 08:17:32 +0100424 * Set up alignments for widgets at the top of ui,
425 * align top left, expand horizontally but not vertically
426 */
427 ui->topalign = gtk_alignment_new(0, 0, 1, 0);
428 ui->topvbox = gtk_vbox_new(FALSE, 0);
429 gtk_container_add(GTK_CONTAINER(ui->topalign), ui->topvbox);
Stephen M. Camerone1645342012-02-24 08:17:32 +0100430 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->topalign, FALSE, FALSE, 0);
Stephen M. Cameronc36f98d2012-02-24 08:17:32 +0100431
432 /*
Stephen M. Cameron45032dd2012-02-24 08:17:31 +0100433 * Set up hostname label + entry, port label + entry,
434 */
435 ui->hostname_hbox = gtk_hbox_new(FALSE, 0);
436 ui->hostname_label = gtk_label_new("Host:");
437 ui->hostname_entry = gtk_entry_new();
438 gtk_entry_set_text(GTK_ENTRY(ui->hostname_entry), "localhost");
439 ui->port_label = gtk_label_new("Port:");
440 ui->port_entry = gtk_entry_new();
441 snprintf(portnum, sizeof(portnum) - 1, "%d", FIO_NET_PORT);
442 gtk_entry_set_text(GTK_ENTRY(ui->port_entry), (gchar *) portnum);
443
444 /*
445 * Set up combo box for address type
446 */
447 ui->hostname_combo_box = gtk_combo_new();
Jens Axboe0420ba62012-02-29 11:16:52 +0100448 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(ui->hostname_combo_box)->entry), "IPv4");
Stephen M. Cameron45032dd2012-02-24 08:17:31 +0100449 hostname_type_list = g_list_append(hostname_type_list, (gpointer) "IPv4");
450 hostname_type_list = g_list_append(hostname_type_list, (gpointer) "local socket");
451 hostname_type_list = g_list_append(hostname_type_list, (gpointer) "IPv6");
Jens Axboe0420ba62012-02-29 11:16:52 +0100452 gtk_combo_set_popdown_strings(GTK_COMBO(ui->hostname_combo_box), hostname_type_list);
Stephen M. Cameron45032dd2012-02-24 08:17:31 +0100453 g_list_free(hostname_type_list);
454
455 gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->hostname_label);
456 gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->hostname_entry);
457 gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->port_label);
458 gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->port_entry);
459 gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->hostname_combo_box);
Stephen M. Cameronc36f98d2012-02-24 08:17:32 +0100460 gtk_container_add(GTK_CONTAINER (ui->topvbox), ui->hostname_hbox);
Stephen M. Cameron45032dd2012-02-24 08:17:31 +0100461
462 /*
Stephen M. Cameron04cc6b72012-02-24 08:17:31 +0100463 * Set up thread status progress bar
464 */
465 ui->thread_status_pb = gtk_progress_bar_new();
466 gtk_progress_bar_set_fraction(
467 GTK_PROGRESS_BAR(ui->thread_status_pb), 0.0);
468 gtk_progress_bar_set_text(
469 GTK_PROGRESS_BAR(ui->thread_status_pb), "No jobs running");
Stephen M. Cameronc36f98d2012-02-24 08:17:32 +0100470 gtk_container_add(GTK_CONTAINER (ui->topvbox), ui->thread_status_pb);
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +0100471
Stephen M. Cameron736f2df2012-02-24 08:17:32 +0100472 /*
473 * Add a text box for text op messages
474 */
475 ui->textview = gtk_text_view_new();
476 ui->text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui->textview));
477 gtk_text_buffer_set_text(ui->text, "", -1);
478 gtk_text_view_set_editable(GTK_TEXT_VIEW(ui->textview), FALSE);
479 gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(ui->textview), FALSE);
480 ui->scrolled_window = gtk_scrolled_window_new(NULL, NULL);
481 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ui->scrolled_window),
482 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
483 gtk_container_add(GTK_CONTAINER(ui->scrolled_window), ui->textview);
Stephen M. Camerone1645342012-02-24 08:17:32 +0100484 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->scrolled_window,
485 TRUE, TRUE, 0);
Stephen M. Cameron736f2df2012-02-24 08:17:32 +0100486
Stephen M. Cameronc36f98d2012-02-24 08:17:32 +0100487 /*
488 * Set up alignments for widgets at the bottom of ui,
489 * align bottom left, expand horizontally but not vertically
490 */
491 ui->bottomalign = gtk_alignment_new(0, 1, 1, 0);
492 ui->buttonbox = gtk_hbox_new(FALSE, 0);
493 gtk_container_add(GTK_CONTAINER(ui->bottomalign), ui->buttonbox);
Stephen M. Camerone1645342012-02-24 08:17:32 +0100494 gtk_box_pack_start(GTK_BOX(ui->vbox), ui->bottomalign,
495 FALSE, FALSE, 0);
Stephen M. Cameronc36f98d2012-02-24 08:17:32 +0100496
Stephen M. Cameronf3074002012-02-24 08:17:30 +0100497 add_buttons(ui, buttonspeclist, ARRAYSIZE(buttonspeclist));
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100498 gtk_widget_show_all(ui->window);
499}
500
Stephen M. Cameron8232e282012-02-24 08:17:31 +0100501int main(int argc, char *argv[], char *envp[])
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100502{
Stephen M. Cameron8232e282012-02-24 08:17:31 +0100503 if (initialize_fio(envp))
504 return 1;
Jens Axboe0420ba62012-02-29 11:16:52 +0100505 if (fio_init_options())
506 return 1;
Stephen M. Camerona1820202012-02-24 08:17:31 +0100507
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100508 init_ui(&argc, &argv, &ui);
Stephen M. Cameron5b7573a2012-02-24 08:17:31 +0100509
Stephen M. Cameron2839f0c2012-02-24 08:17:31 +0100510 gdk_threads_enter();
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100511 gtk_main();
Stephen M. Cameron2839f0c2012-02-24 08:17:31 +0100512 gdk_threads_leave();
Stephen M. Cameronff1f3282012-02-24 08:17:30 +0100513 return 0;
514}