Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 1 | /* |
| 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. Cameron | 8232e28 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 23 | #include <locale.h> |
Stephen M. Cameron | 60f6b33 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 24 | #include <malloc.h> |
Stephen M. Cameron | 8232e28 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 25 | |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 26 | #include <glib.h> |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 27 | #include <gtk/gtk.h> |
| 28 | |
Stephen M. Cameron | 8232e28 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 29 | #include "fio.h" |
| 30 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 31 | static void gfio_update_thread_status(char *status_message, double perc); |
| 32 | |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 33 | #define ARRAYSIZE(x) (sizeof((x)) / (sizeof((x)[0]))) |
| 34 | |
| 35 | typedef void (*clickfunction)(GtkWidget *widget, gpointer data); |
| 36 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 37 | static void connect_clicked(GtkWidget *widget, gpointer data); |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 38 | static void start_job_clicked(GtkWidget *widget, gpointer data); |
| 39 | |
| 40 | static struct button_spec { |
| 41 | const char *buttontext; |
| 42 | clickfunction f; |
| 43 | const char *tooltiptext; |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 44 | const int start_insensitive; |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 45 | } buttonspeclist[] = { |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 46 | #define CONNECT_BUTTON 0 |
| 47 | #define START_JOB_BUTTON 1 |
| 48 | { "Connect", connect_clicked, "Connect to host", 0 }, |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 49 | { "Start Job", |
| 50 | start_job_clicked, |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 51 | "Send current fio job to fio server to be executed", 1 }, |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 52 | }; |
| 53 | |
Jens Axboe | 843ad23 | 2012-02-29 11:44:53 +0100 | [diff] [blame] | 54 | struct probe_widget { |
| 55 | GtkWidget *hostname; |
| 56 | GtkWidget *os; |
| 57 | GtkWidget *arch; |
| 58 | GtkWidget *fio_ver; |
| 59 | }; |
| 60 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 61 | struct eta_widget { |
| 62 | GtkWidget *jobs; |
| 63 | GtkWidget *files; |
| 64 | GtkWidget *read_bw; |
| 65 | GtkWidget *read_iops; |
| 66 | GtkWidget *cr_bw; |
| 67 | GtkWidget *cr_iops; |
| 68 | GtkWidget *write_bw; |
| 69 | GtkWidget *write_iops; |
| 70 | GtkWidget *cw_bw; |
| 71 | GtkWidget *cw_iops; |
| 72 | }; |
| 73 | |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 74 | struct gui { |
| 75 | GtkWidget *window; |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 76 | GtkWidget *vbox; |
Stephen M. Cameron | c36f98d | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 77 | GtkWidget *topvbox; |
| 78 | GtkWidget *topalign; |
| 79 | GtkWidget *bottomalign; |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 80 | GtkWidget *thread_status_pb; |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 81 | GtkWidget *buttonbox; |
| 82 | GtkWidget *button[ARRAYSIZE(buttonspeclist)]; |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 83 | GtkWidget *hostname_hbox; |
| 84 | GtkWidget *hostname_label; |
| 85 | GtkWidget *hostname_entry; |
| 86 | GtkWidget *port_label; |
| 87 | GtkWidget *port_entry; |
| 88 | GtkWidget *hostname_combo_box; /* ipv4, ipv6 or socket */ |
Stephen M. Cameron | 736f2df | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 89 | GtkWidget *scrolled_window; |
| 90 | GtkWidget *textview; |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 91 | GtkWidget *error_info_bar; |
| 92 | GtkWidget *error_label; |
Stephen M. Cameron | 736f2df | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 93 | GtkTextBuffer *text; |
Jens Axboe | 843ad23 | 2012-02-29 11:44:53 +0100 | [diff] [blame] | 94 | struct probe_widget probe; |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 95 | struct eta_widget eta; |
Stephen M. Cameron | 2592725 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 96 | pthread_t t; |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 97 | |
| 98 | void *cookie; |
| 99 | int nr_job_files; |
| 100 | char **job_files; |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 101 | } ui; |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 102 | |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 103 | static void gfio_text_op(struct fio_client *client, |
| 104 | FILE *f, __u16 pdu_len, const char *buf) |
| 105 | { |
Stephen M. Cameron | 736f2df | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 106 | GtkTextBuffer *buffer; |
| 107 | GtkTextIter end; |
| 108 | |
| 109 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui.textview)); |
| 110 | gdk_threads_enter(); |
| 111 | gtk_text_buffer_get_end_iter(buffer, &end); |
| 112 | gtk_text_buffer_insert(buffer, &end, buf, -1); |
| 113 | gdk_threads_leave(); |
| 114 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(ui.textview), |
| 115 | &end, 0.0, FALSE, 0.0,0.0); |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 116 | } |
| 117 | |
| 118 | static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd) |
| 119 | { |
| 120 | printf("gfio_disk_util_op called\n"); |
| 121 | fio_client_ops.disk_util(client, cmd); |
| 122 | } |
| 123 | |
| 124 | static void gfio_thread_status_op(struct fio_net_cmd *cmd) |
| 125 | { |
| 126 | printf("gfio_thread_status_op called\n"); |
| 127 | fio_client_ops.thread_status(cmd); |
| 128 | } |
| 129 | |
| 130 | static void gfio_group_stats_op(struct fio_net_cmd *cmd) |
| 131 | { |
| 132 | printf("gfio_group_stats_op called\n"); |
| 133 | fio_client_ops.group_stats(cmd); |
| 134 | } |
| 135 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 136 | static void gfio_update_eta(struct jobs_eta *je) |
| 137 | { |
| 138 | static int eta_good; |
| 139 | char eta_str[128]; |
| 140 | char output[256]; |
| 141 | char tmp[32]; |
| 142 | double perc = 0.0; |
| 143 | int i2p = 0; |
| 144 | |
| 145 | eta_str[0] = '\0'; |
| 146 | output[0] = '\0'; |
| 147 | |
| 148 | if (je->eta_sec != INT_MAX && je->elapsed_sec) { |
| 149 | perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec); |
| 150 | eta_to_str(eta_str, je->eta_sec); |
| 151 | } |
| 152 | |
| 153 | sprintf(tmp, "%u", je->nr_running); |
| 154 | gtk_label_set_text(GTK_LABEL(ui.eta.jobs), tmp); |
| 155 | sprintf(tmp, "%u", je->files_open); |
| 156 | gtk_label_set_text(GTK_LABEL(ui.eta.files), tmp); |
| 157 | |
| 158 | #if 0 |
| 159 | if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) { |
| 160 | if (je->m_rate || je->t_rate) { |
| 161 | char *tr, *mr; |
| 162 | |
| 163 | mr = num2str(je->m_rate, 4, 0, i2p); |
| 164 | tr = num2str(je->t_rate, 4, 0, i2p); |
| 165 | gtk_label_set_text(GTK_LABEL(ui.eta. |
| 166 | p += sprintf(p, ", CR=%s/%s KB/s", tr, mr); |
| 167 | free(tr); |
| 168 | free(mr); |
| 169 | } else if (je->m_iops || je->t_iops) |
| 170 | p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops); |
| 171 | #else |
| 172 | gtk_label_set_text(GTK_LABEL(ui.eta.cr_bw), "---"); |
| 173 | gtk_label_set_text(GTK_LABEL(ui.eta.cr_iops), "---"); |
| 174 | gtk_label_set_text(GTK_LABEL(ui.eta.cw_bw), "---"); |
| 175 | gtk_label_set_text(GTK_LABEL(ui.eta.cw_iops), "---"); |
| 176 | #endif |
| 177 | |
| 178 | if (je->eta_sec != INT_MAX && je->nr_running) { |
| 179 | char *iops_str[2]; |
| 180 | char *rate_str[2]; |
| 181 | |
| 182 | if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running) |
| 183 | strcpy(output, "-.-% done"); |
| 184 | else { |
| 185 | eta_good = 1; |
| 186 | perc *= 100.0; |
| 187 | sprintf(output, "%3.1f%% done", perc); |
| 188 | } |
| 189 | |
| 190 | rate_str[0] = num2str(je->rate[0], 5, 10, i2p); |
| 191 | rate_str[1] = num2str(je->rate[1], 5, 10, i2p); |
| 192 | |
| 193 | iops_str[0] = num2str(je->iops[0], 4, 1, 0); |
| 194 | iops_str[1] = num2str(je->iops[1], 4, 1, 0); |
| 195 | |
| 196 | gtk_label_set_text(GTK_LABEL(ui.eta.read_bw), rate_str[0]); |
| 197 | gtk_label_set_text(GTK_LABEL(ui.eta.read_iops), iops_str[0]); |
| 198 | gtk_label_set_text(GTK_LABEL(ui.eta.write_bw), rate_str[1]); |
| 199 | gtk_label_set_text(GTK_LABEL(ui.eta.write_iops), iops_str[1]); |
| 200 | |
| 201 | free(rate_str[0]); |
| 202 | free(rate_str[1]); |
| 203 | free(iops_str[0]); |
| 204 | free(iops_str[1]); |
| 205 | } |
| 206 | |
| 207 | if (eta_str[0]) { |
| 208 | char *dst = output + strlen(output); |
| 209 | |
| 210 | sprintf(dst, " - %s", eta_str); |
| 211 | } |
| 212 | |
| 213 | gfio_update_thread_status(output, perc); |
| 214 | } |
| 215 | |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 216 | static void gfio_eta_op(struct fio_client *client, struct fio_net_cmd *cmd) |
| 217 | { |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 218 | struct jobs_eta *je = (struct jobs_eta *) cmd->payload; |
| 219 | struct client_eta *eta = (struct client_eta *) (uintptr_t) cmd->tag; |
| 220 | |
| 221 | client->eta_in_flight = NULL; |
| 222 | flist_del_init(&client->eta_list); |
| 223 | |
| 224 | fio_client_convert_jobs_eta(je); |
| 225 | fio_client_sum_jobs_eta(&eta->eta, je); |
| 226 | fio_client_dec_jobs_eta(eta, gfio_update_eta); |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 227 | } |
| 228 | |
| 229 | static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd) |
| 230 | { |
Jens Axboe | 843ad23 | 2012-02-29 11:44:53 +0100 | [diff] [blame] | 231 | struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload; |
| 232 | const char *os, *arch; |
| 233 | char buf[64]; |
| 234 | |
| 235 | os = fio_get_os_string(probe->os); |
| 236 | if (!os) |
| 237 | os = "unknown"; |
| 238 | |
| 239 | arch = fio_get_arch_string(probe->arch); |
| 240 | if (!arch) |
| 241 | os = "unknown"; |
| 242 | |
| 243 | if (!client->name) |
| 244 | client->name = strdup((char *) probe->hostname); |
| 245 | |
| 246 | gtk_label_set_text(GTK_LABEL(ui.probe.hostname), (char *) probe->hostname); |
| 247 | gtk_label_set_text(GTK_LABEL(ui.probe.os), os); |
| 248 | gtk_label_set_text(GTK_LABEL(ui.probe.arch), arch); |
| 249 | sprintf(buf, "%u.%u.%u", probe->fio_major, probe->fio_minor, probe->fio_patch); |
| 250 | gtk_label_set_text(GTK_LABEL(ui.probe.fio_ver), buf); |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 251 | } |
| 252 | |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 253 | static void gfio_update_thread_status(char *status_message, double perc) |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 254 | { |
| 255 | static char message[100]; |
| 256 | const char *m = message; |
| 257 | |
| 258 | strncpy(message, status_message, sizeof(message) - 1); |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 259 | gtk_progress_bar_set_text( |
| 260 | GTK_PROGRESS_BAR(ui.thread_status_pb), m); |
| 261 | gtk_progress_bar_set_fraction( |
| 262 | GTK_PROGRESS_BAR(ui.thread_status_pb), perc / 100.0); |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 263 | gdk_threads_enter(); |
| 264 | gtk_widget_queue_draw(ui.window); |
| 265 | gdk_threads_leave(); |
| 266 | } |
| 267 | |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 268 | struct client_ops gfio_client_ops = { |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 269 | .text_op = gfio_text_op, |
| 270 | .disk_util = gfio_disk_util_op, |
| 271 | .thread_status = gfio_thread_status_op, |
| 272 | .group_stats = gfio_group_stats_op, |
| 273 | .eta = gfio_eta_op, |
| 274 | .probe = gfio_probe_op, |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 275 | }; |
| 276 | |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 277 | static void quit_clicked(__attribute__((unused)) GtkWidget *widget, |
| 278 | __attribute__((unused)) gpointer data) |
| 279 | { |
| 280 | gtk_main_quit(); |
| 281 | } |
| 282 | |
Stephen M. Cameron | 2592725 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 283 | static void *job_thread(void *arg) |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 284 | { |
Stephen M. Cameron | 2592725 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 285 | struct gui *ui = arg; |
| 286 | |
| 287 | fio_handle_clients(&gfio_client_ops); |
| 288 | gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1); |
| 289 | return NULL; |
| 290 | } |
| 291 | |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 292 | static int send_job_files(struct gui *ui) |
Stephen M. Cameron | 60f6b33 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 293 | { |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 294 | int i, ret; |
Stephen M. Cameron | 60f6b33 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 295 | |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 296 | for (i = 0; i < ui->nr_job_files; i++) { |
| 297 | ret = fio_clients_send_ini(ui->job_files[i]); |
| 298 | free(ui->job_files[i]); |
| 299 | ui->job_files[i] = NULL; |
| 300 | if (ret) |
| 301 | return ret; |
| 302 | } |
| 303 | |
| 304 | return 0; |
Stephen M. Cameron | 60f6b33 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 305 | } |
| 306 | |
Stephen M. Cameron | 2592725 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 307 | static void start_job_thread(pthread_t *t, struct gui *ui) |
| 308 | { |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 309 | if (send_job_files(ui)) { |
Stephen M. Cameron | 60f6b33 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 310 | printf("Yeah, I didn't really like those options too much.\n"); |
Stephen M. Cameron | 60f6b33 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 311 | gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 1); |
| 312 | return; |
| 313 | } |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 314 | |
Stephen M. Cameron | 2592725 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 315 | pthread_create(t, NULL, job_thread, ui); |
| 316 | } |
| 317 | |
| 318 | static void start_job_clicked(__attribute__((unused)) GtkWidget *widget, |
| 319 | gpointer data) |
| 320 | { |
| 321 | struct gui *ui = data; |
| 322 | |
Stephen M. Cameron | 2592725 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 323 | gtk_widget_set_sensitive(ui->button[START_JOB_BUTTON], 0); |
| 324 | start_job_thread(&ui->t, ui); |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 325 | } |
| 326 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 327 | static void connect_clicked(__attribute__((unused)) GtkWidget *widget, |
| 328 | gpointer data) |
| 329 | { |
| 330 | fio_clients_connect(); |
| 331 | gtk_widget_set_sensitive(ui.button[START_JOB_BUTTON], 1); |
| 332 | } |
| 333 | |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 334 | static void add_button(struct gui *ui, int i, GtkWidget *buttonbox, |
| 335 | struct button_spec *buttonspec) |
| 336 | { |
| 337 | ui->button[i] = gtk_button_new_with_label(buttonspec->buttontext); |
| 338 | g_signal_connect(ui->button[i], "clicked", G_CALLBACK (buttonspec->f), ui); |
| 339 | gtk_box_pack_start(GTK_BOX (ui->buttonbox), ui->button[i], TRUE, TRUE, 0); |
| 340 | gtk_widget_set_tooltip_text(ui->button[i], buttonspeclist[i].tooltiptext); |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 341 | gtk_widget_set_sensitive(ui->button[i], !buttonspec->start_insensitive); |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | static void add_buttons(struct gui *ui, |
| 345 | struct button_spec *buttonlist, |
| 346 | int nbuttons) |
| 347 | { |
| 348 | int i; |
| 349 | |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 350 | for (i = 0; i < nbuttons; i++) |
| 351 | add_button(ui, i, ui->buttonbox, &buttonlist[i]); |
| 352 | } |
| 353 | |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 354 | static void on_info_bar_response(GtkWidget *widget, gint response, |
| 355 | gpointer data) |
| 356 | { |
| 357 | if (response == GTK_RESPONSE_OK) { |
| 358 | gtk_widget_destroy(widget); |
| 359 | ui.error_info_bar = NULL; |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | void report_error(GError* error) |
| 364 | { |
| 365 | if (ui.error_info_bar == NULL) { |
| 366 | ui.error_info_bar = gtk_info_bar_new_with_buttons(GTK_STOCK_OK, |
| 367 | GTK_RESPONSE_OK, |
| 368 | NULL); |
| 369 | g_signal_connect(ui.error_info_bar, "response", G_CALLBACK(on_info_bar_response), NULL); |
| 370 | gtk_info_bar_set_message_type(GTK_INFO_BAR(ui.error_info_bar), |
| 371 | GTK_MESSAGE_ERROR); |
| 372 | |
| 373 | ui.error_label = gtk_label_new(error->message); |
| 374 | GtkWidget *container = gtk_info_bar_get_content_area(GTK_INFO_BAR(ui.error_info_bar)); |
| 375 | gtk_container_add(GTK_CONTAINER(container), ui.error_label); |
| 376 | |
| 377 | gtk_box_pack_start(GTK_BOX(ui.vbox), ui.error_info_bar, FALSE, FALSE, 0); |
| 378 | gtk_widget_show_all(ui.vbox); |
| 379 | } else { |
| 380 | char buffer[256]; |
| 381 | snprintf(buffer, sizeof(buffer), "Failed to open file."); |
| 382 | gtk_label_set(GTK_LABEL(ui.error_label), buffer); |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | static void file_open(GtkWidget *w, gpointer data) |
| 387 | { |
| 388 | GtkWidget *dialog; |
| 389 | GSList *filenames, *fn_glist; |
| 390 | GtkFileFilter *filter; |
| 391 | |
| 392 | dialog = gtk_file_chooser_dialog_new("Open File", |
| 393 | GTK_WINDOW(ui.window), |
| 394 | GTK_FILE_CHOOSER_ACTION_OPEN, |
| 395 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 396 | GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, |
| 397 | NULL); |
| 398 | gtk_file_chooser_set_select_multiple(GTK_FILE_CHOOSER(dialog), TRUE); |
| 399 | |
| 400 | filter = gtk_file_filter_new(); |
| 401 | gtk_file_filter_add_pattern(filter, "*.fio"); |
| 402 | gtk_file_filter_add_pattern(filter, "*.job"); |
| 403 | gtk_file_filter_add_mime_type(filter, "text/fio"); |
| 404 | gtk_file_filter_set_name(filter, "Fio job file"); |
| 405 | gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter); |
| 406 | |
| 407 | if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) { |
| 408 | gtk_widget_destroy(dialog); |
| 409 | return; |
| 410 | } |
| 411 | |
| 412 | fn_glist = gtk_file_chooser_get_filenames(GTK_FILE_CHOOSER(dialog)); |
| 413 | filenames = fn_glist; |
| 414 | while (filenames != NULL) { |
| 415 | const char *hostname; |
| 416 | |
| 417 | ui.job_files = realloc(ui.job_files, (ui.nr_job_files + 1) * sizeof(char *)); |
| 418 | ui.job_files[ui.nr_job_files] = strdup(filenames->data); |
| 419 | ui.nr_job_files++; |
| 420 | |
| 421 | hostname = gtk_entry_get_text(GTK_ENTRY(ui.hostname_entry)); |
| 422 | fio_client_add(hostname, &ui.cookie); |
| 423 | #if 0 |
| 424 | if (error) { |
| 425 | report_error(error); |
| 426 | g_error_free(error); |
| 427 | error = NULL; |
| 428 | } |
| 429 | #endif |
| 430 | |
| 431 | g_free(filenames->data); |
| 432 | filenames = g_slist_next(filenames); |
| 433 | } |
| 434 | g_slist_free(fn_glist); |
| 435 | gtk_widget_destroy(dialog); |
| 436 | } |
| 437 | |
| 438 | static void file_save(GtkWidget *w, gpointer data) |
| 439 | { |
| 440 | GtkWidget *dialog; |
| 441 | |
| 442 | dialog = gtk_file_chooser_dialog_new("Save File", |
| 443 | GTK_WINDOW(ui.window), |
| 444 | GTK_FILE_CHOOSER_ACTION_SAVE, |
| 445 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
| 446 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
| 447 | NULL); |
| 448 | |
| 449 | gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); |
| 450 | gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), "Untitled document"); |
| 451 | |
| 452 | if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { |
| 453 | char *filename; |
| 454 | |
| 455 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); |
| 456 | // save_job_file(filename); |
| 457 | g_free(filename); |
| 458 | } |
| 459 | gtk_widget_destroy(dialog); |
| 460 | } |
| 461 | |
| 462 | static void about_dialog(GtkWidget *w, gpointer data) |
| 463 | { |
| 464 | gtk_show_about_dialog(NULL, |
| 465 | "program-name", "gfio", |
| 466 | "comments", "Gtk2 UI for fio", |
| 467 | "license", "GPLv2", |
| 468 | "version", fio_version_string, |
| 469 | "copyright", "Jens Axboe <axboe@kernel.dk> 2012", |
| 470 | "logo-icon-name", "fio", |
| 471 | /* Must be last: */ |
| 472 | NULL, NULL, |
| 473 | NULL); |
| 474 | } |
| 475 | |
| 476 | static GtkActionEntry menu_items[] = { |
| 477 | { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL}, |
| 478 | { "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL}, |
| 479 | { "OpenFile", GTK_STOCK_OPEN, NULL, "<Control>O", NULL, G_CALLBACK(file_open) }, |
| 480 | { "SaveFile", GTK_STOCK_SAVE, NULL, "<Control>S", NULL, G_CALLBACK(file_save) }, |
| 481 | { "Quit", GTK_STOCK_QUIT, NULL, "<Control>Q", NULL, G_CALLBACK(quit_clicked) }, |
| 482 | { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) }, |
| 483 | }; |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 484 | static gint nmenu_items = sizeof(menu_items) / sizeof(menu_items[0]); |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 485 | |
| 486 | static const gchar *ui_string = " \ |
| 487 | <ui> \ |
| 488 | <menubar name=\"MainMenu\"> \ |
| 489 | <menu name=\"FileMenu\" action=\"FileMenuAction\"> \ |
| 490 | <menuitem name=\"Open\" action=\"OpenFile\" /> \ |
| 491 | <menuitem name=\"Save\" action=\"SaveFile\" /> \ |
| 492 | <separator name=\"Separator\"/> \ |
| 493 | <menuitem name=\"Quit\" action=\"Quit\" /> \ |
| 494 | </menu> \ |
| 495 | <menu name=\"Help\" action=\"HelpMenuAction\"> \ |
| 496 | <menuitem name=\"About\" action=\"About\" /> \ |
| 497 | </menu> \ |
| 498 | </menubar> \ |
| 499 | </ui> \ |
| 500 | "; |
| 501 | |
| 502 | static GtkWidget *get_menubar_menu(GtkWidget *window, GtkUIManager *ui_manager) |
| 503 | { |
| 504 | GtkActionGroup *action_group = gtk_action_group_new("Menu"); |
| 505 | GError *error = 0; |
| 506 | |
| 507 | action_group = gtk_action_group_new("Menu"); |
| 508 | gtk_action_group_add_actions(action_group, menu_items, nmenu_items, 0); |
| 509 | |
| 510 | gtk_ui_manager_insert_action_group(ui_manager, action_group, 0); |
| 511 | gtk_ui_manager_add_ui_from_string(GTK_UI_MANAGER(ui_manager), ui_string, -1, &error); |
| 512 | |
| 513 | gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ui_manager)); |
| 514 | return gtk_ui_manager_get_widget(ui_manager, "/MainMenu"); |
| 515 | } |
| 516 | |
| 517 | void gfio_ui_setup(GtkSettings *settings, GtkWidget *menubar, |
| 518 | GtkWidget *vbox, GtkUIManager *ui_manager) |
| 519 | { |
| 520 | gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, FALSE, 0); |
| 521 | } |
| 522 | |
Jens Axboe | 843ad23 | 2012-02-29 11:44:53 +0100 | [diff] [blame] | 523 | static GtkWidget *new_info_label_in_frame(GtkWidget *box, const char *label) |
| 524 | { |
| 525 | GtkWidget *label_widget; |
| 526 | GtkWidget *frame; |
| 527 | |
| 528 | frame = gtk_frame_new(label); |
| 529 | label_widget = gtk_label_new(NULL); |
| 530 | gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 3); |
| 531 | gtk_container_add(GTK_CONTAINER(frame), label_widget); |
| 532 | |
| 533 | return label_widget; |
| 534 | } |
| 535 | |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 536 | static void init_ui(int *argc, char **argv[], struct gui *ui) |
| 537 | { |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 538 | GList *hostname_type_list = NULL; |
| 539 | char portnum[20]; |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 540 | GtkSettings *settings; |
| 541 | GtkUIManager *uimanager; |
Jens Axboe | 843ad23 | 2012-02-29 11:44:53 +0100 | [diff] [blame] | 542 | GtkWidget *menu, *probe, *probe_frame, *probe_box; |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 543 | |
| 544 | memset(ui, 0, sizeof(*ui)); |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 545 | |
Stephen M. Cameron | 2839f0c | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 546 | /* Magical g*thread incantation, you just need this thread stuff. |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 547 | * Without it, the update that happens in gfio_update_thread_status |
Stephen M. Cameron | 2839f0c | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 548 | * doesn't really happen in a timely fashion, you need expose events |
| 549 | */ |
| 550 | if (!g_thread_supported ()) |
| 551 | g_thread_init(NULL); |
| 552 | gdk_threads_init(); |
| 553 | |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 554 | gtk_init(argc, argv); |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 555 | settings = gtk_settings_get_default(); |
| 556 | gtk_settings_set_long_property(settings, "gtk_tooltip_timeout", 10, "gfio setting"); |
| 557 | g_type_init(); |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 558 | |
| 559 | ui->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
| 560 | gtk_window_set_title(GTK_WINDOW(ui->window), "fio"); |
| 561 | gtk_window_set_default_size(GTK_WINDOW(ui->window), 700, 500); |
| 562 | |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 563 | g_signal_connect(ui->window, "delete-event", G_CALLBACK(quit_clicked), NULL); |
| 564 | g_signal_connect(ui->window, "destroy", G_CALLBACK(quit_clicked), NULL); |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 565 | |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 566 | ui->vbox = gtk_vbox_new(FALSE, 0); |
| 567 | gtk_container_add(GTK_CONTAINER (ui->window), ui->vbox); |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 568 | |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 569 | uimanager = gtk_ui_manager_new(); |
| 570 | menu = get_menubar_menu(ui->window, uimanager); |
| 571 | gfio_ui_setup(settings, menu, ui->vbox, uimanager); |
| 572 | |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 573 | /* |
Stephen M. Cameron | c36f98d | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 574 | * Set up alignments for widgets at the top of ui, |
| 575 | * align top left, expand horizontally but not vertically |
| 576 | */ |
| 577 | ui->topalign = gtk_alignment_new(0, 0, 1, 0); |
| 578 | ui->topvbox = gtk_vbox_new(FALSE, 0); |
| 579 | gtk_container_add(GTK_CONTAINER(ui->topalign), ui->topvbox); |
Stephen M. Cameron | e164534 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 580 | gtk_box_pack_start(GTK_BOX(ui->vbox), ui->topalign, FALSE, FALSE, 0); |
Stephen M. Cameron | c36f98d | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 581 | |
| 582 | /* |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 583 | * Set up hostname label + entry, port label + entry, |
| 584 | */ |
| 585 | ui->hostname_hbox = gtk_hbox_new(FALSE, 0); |
| 586 | ui->hostname_label = gtk_label_new("Host:"); |
| 587 | ui->hostname_entry = gtk_entry_new(); |
| 588 | gtk_entry_set_text(GTK_ENTRY(ui->hostname_entry), "localhost"); |
| 589 | ui->port_label = gtk_label_new("Port:"); |
| 590 | ui->port_entry = gtk_entry_new(); |
| 591 | snprintf(portnum, sizeof(portnum) - 1, "%d", FIO_NET_PORT); |
| 592 | gtk_entry_set_text(GTK_ENTRY(ui->port_entry), (gchar *) portnum); |
| 593 | |
| 594 | /* |
| 595 | * Set up combo box for address type |
| 596 | */ |
| 597 | ui->hostname_combo_box = gtk_combo_new(); |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 598 | gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(ui->hostname_combo_box)->entry), "IPv4"); |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 599 | hostname_type_list = g_list_append(hostname_type_list, (gpointer) "IPv4"); |
| 600 | hostname_type_list = g_list_append(hostname_type_list, (gpointer) "local socket"); |
| 601 | hostname_type_list = g_list_append(hostname_type_list, (gpointer) "IPv6"); |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 602 | gtk_combo_set_popdown_strings(GTK_COMBO(ui->hostname_combo_box), hostname_type_list); |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 603 | g_list_free(hostname_type_list); |
| 604 | |
| 605 | gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->hostname_label); |
| 606 | gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->hostname_entry); |
| 607 | gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->port_label); |
| 608 | gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->port_entry); |
| 609 | gtk_container_add(GTK_CONTAINER (ui->hostname_hbox), ui->hostname_combo_box); |
Stephen M. Cameron | c36f98d | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 610 | gtk_container_add(GTK_CONTAINER (ui->topvbox), ui->hostname_hbox); |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 611 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 612 | probe = gtk_frame_new("Job"); |
Jens Axboe | 843ad23 | 2012-02-29 11:44:53 +0100 | [diff] [blame] | 613 | gtk_box_pack_start(GTK_BOX(ui->topvbox), probe, TRUE, FALSE, 3); |
| 614 | probe_frame = gtk_vbox_new(FALSE, 3); |
| 615 | gtk_container_add(GTK_CONTAINER(probe), probe_frame); |
| 616 | |
| 617 | probe_box = gtk_hbox_new(FALSE, 3); |
| 618 | gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3); |
Jens Axboe | 843ad23 | 2012-02-29 11:44:53 +0100 | [diff] [blame] | 619 | ui->probe.hostname = new_info_label_in_frame(probe_box, "Host"); |
| 620 | ui->probe.os = new_info_label_in_frame(probe_box, "OS"); |
| 621 | ui->probe.arch = new_info_label_in_frame(probe_box, "Architecture"); |
| 622 | ui->probe.fio_ver = new_info_label_in_frame(probe_box, "Fio version"); |
| 623 | |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 624 | probe_box = gtk_hbox_new(FALSE, 3); |
| 625 | gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3); |
| 626 | ui->eta.jobs = new_info_label_in_frame(probe_box, "Jobs"); |
| 627 | ui->eta.files = new_info_label_in_frame(probe_box, "Open files"); |
| 628 | |
| 629 | probe_box = gtk_hbox_new(FALSE, 3); |
| 630 | gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3); |
| 631 | ui->eta.read_bw = new_info_label_in_frame(probe_box, "Read BW"); |
| 632 | ui->eta.read_iops = new_info_label_in_frame(probe_box, "IOPS"); |
| 633 | ui->eta.cr_bw = new_info_label_in_frame(probe_box, "Commit BW"); |
| 634 | ui->eta.cr_iops = new_info_label_in_frame(probe_box, "Commit IOPS"); |
| 635 | |
| 636 | probe_box = gtk_hbox_new(FALSE, 3); |
| 637 | gtk_box_pack_start(GTK_BOX(probe_frame), probe_box, TRUE, FALSE, 3); |
| 638 | ui->eta.write_bw = new_info_label_in_frame(probe_box, "Write BW"); |
| 639 | ui->eta.write_iops = new_info_label_in_frame(probe_box, "IOPS"); |
| 640 | ui->eta.cw_bw = new_info_label_in_frame(probe_box, "Commit BW"); |
| 641 | ui->eta.cw_iops = new_info_label_in_frame(probe_box, "Commit IOPS"); |
| 642 | |
Stephen M. Cameron | 45032dd | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 643 | /* |
Stephen M. Cameron | 04cc6b7 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 644 | * Set up thread status progress bar |
| 645 | */ |
| 646 | ui->thread_status_pb = gtk_progress_bar_new(); |
Jens Axboe | 3e47bd2 | 2012-02-29 13:45:02 +0100 | [diff] [blame^] | 647 | gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui->thread_status_pb), 0.0); |
| 648 | gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ui->thread_status_pb), "No jobs running"); |
| 649 | gtk_container_add(GTK_CONTAINER(ui->topvbox), ui->thread_status_pb); |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 650 | |
Stephen M. Cameron | 736f2df | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 651 | /* |
| 652 | * Add a text box for text op messages |
| 653 | */ |
| 654 | ui->textview = gtk_text_view_new(); |
| 655 | ui->text = gtk_text_view_get_buffer(GTK_TEXT_VIEW(ui->textview)); |
| 656 | gtk_text_buffer_set_text(ui->text, "", -1); |
| 657 | gtk_text_view_set_editable(GTK_TEXT_VIEW(ui->textview), FALSE); |
| 658 | gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(ui->textview), FALSE); |
| 659 | ui->scrolled_window = gtk_scrolled_window_new(NULL, NULL); |
| 660 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(ui->scrolled_window), |
| 661 | GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
| 662 | gtk_container_add(GTK_CONTAINER(ui->scrolled_window), ui->textview); |
Stephen M. Cameron | e164534 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 663 | gtk_box_pack_start(GTK_BOX(ui->vbox), ui->scrolled_window, |
| 664 | TRUE, TRUE, 0); |
Stephen M. Cameron | 736f2df | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 665 | |
Stephen M. Cameron | c36f98d | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 666 | /* |
| 667 | * Set up alignments for widgets at the bottom of ui, |
| 668 | * align bottom left, expand horizontally but not vertically |
| 669 | */ |
| 670 | ui->bottomalign = gtk_alignment_new(0, 1, 1, 0); |
| 671 | ui->buttonbox = gtk_hbox_new(FALSE, 0); |
| 672 | gtk_container_add(GTK_CONTAINER(ui->bottomalign), ui->buttonbox); |
Stephen M. Cameron | e164534 | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 673 | gtk_box_pack_start(GTK_BOX(ui->vbox), ui->bottomalign, |
| 674 | FALSE, FALSE, 0); |
Stephen M. Cameron | c36f98d | 2012-02-24 08:17:32 +0100 | [diff] [blame] | 675 | |
Stephen M. Cameron | f307400 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 676 | add_buttons(ui, buttonspeclist, ARRAYSIZE(buttonspeclist)); |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 677 | gtk_widget_show_all(ui->window); |
| 678 | } |
| 679 | |
Stephen M. Cameron | 8232e28 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 680 | int main(int argc, char *argv[], char *envp[]) |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 681 | { |
Stephen M. Cameron | 8232e28 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 682 | if (initialize_fio(envp)) |
| 683 | return 1; |
Jens Axboe | 0420ba6 | 2012-02-29 11:16:52 +0100 | [diff] [blame] | 684 | if (fio_init_options()) |
| 685 | return 1; |
Stephen M. Cameron | a182020 | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 686 | |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 687 | init_ui(&argc, &argv, &ui); |
Stephen M. Cameron | 5b7573a | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 688 | |
Stephen M. Cameron | 2839f0c | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 689 | gdk_threads_enter(); |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 690 | gtk_main(); |
Stephen M. Cameron | 2839f0c | 2012-02-24 08:17:31 +0100 | [diff] [blame] | 691 | gdk_threads_leave(); |
Stephen M. Cameron | ff1f328 | 2012-02-24 08:17:30 +0100 | [diff] [blame] | 692 | return 0; |
| 693 | } |