From 04cc6b77973636a914de3dff8ca6ae0857cf453b Mon Sep 17 00:00:00 2001 From: "Stephen M. Cameron" Date: Fri, 24 Feb 2012 08:17:31 +0100 Subject: [PATCH] fio: Use a progress bar instead of a label Signed-off-by: Stephen M. Cameron Signed-off-by: Jens Axboe --- client.c | 2 +- client.h | 2 +- eta.c | 4 ++-- gfio.c | 23 +++++++++++++++++------ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/client.c b/client.c index 1b7dee66..e109b93f 100644 --- a/client.c +++ b/client.c @@ -21,7 +21,7 @@ #include "flist.h" #include "hash.h" -extern void (*update_thread_status)(char *status_message); +extern void (*update_thread_status)(char *status_message, double perc); struct client_eta { struct jobs_eta eta; diff --git a/client.h b/client.h index dea35bb7..150d1334 100644 --- a/client.h +++ b/client.h @@ -17,7 +17,7 @@ typedef void (*client_eta_op)(struct fio_client *client, struct fio_net_cmd *cmd typedef void (*client_probe_op)(struct fio_client *client, struct fio_net_cmd *cmd); -typedef void (*client_thread_status_display_op)(char *status_message); +typedef void (*client_thread_status_display_op)(char *status_message, double perc); struct client_ops { client_text_op_func text_op; diff --git a/eta.c b/eta.c index 0833d341..64c02fe2 100644 --- a/eta.c +++ b/eta.c @@ -7,7 +7,7 @@ #include "fio.h" -void (*update_thread_status)(char *status_message) = NULL; +void (*update_thread_status)(char *status_message, double perc) = NULL; static char run_str[REAL_MAX_JOBS + 1]; @@ -414,7 +414,7 @@ void display_thread_status(struct jobs_eta *je) p += sprintf(p, "\r"); if (update_thread_status) { - update_thread_status(output); + update_thread_status(output, perc); } else { printf("%s", output); fflush(stdout); diff --git a/gfio.c b/gfio.c index 2d97caca..0d48974e 100644 --- a/gfio.c +++ b/gfio.c @@ -51,7 +51,7 @@ static struct button_spec { struct gui { GtkWidget *window; GtkWidget *vbox; - GtkWidget *thread_status_label; + GtkWidget *thread_status_pb; GtkWidget *buttonbox; GtkWidget *button[ARRAYSIZE(buttonspeclist)]; pthread_t t; @@ -93,13 +93,16 @@ static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd) fio_client_ops.probe(client, cmd); } -static void gfio_update_thread_status(char *status_message) +static void gfio_update_thread_status(char *status_message, double perc) { static char message[100]; const char *m = message; strncpy(message, status_message, sizeof(message) - 1); - gtk_label_set_text(GTK_LABEL(ui.thread_status_label), m); + gtk_progress_bar_set_text( + GTK_PROGRESS_BAR(ui.thread_status_pb), m); + gtk_progress_bar_set_fraction( + GTK_PROGRESS_BAR(ui.thread_status_pb), perc / 100.0); gdk_threads_enter(); gtk_widget_queue_draw(ui.window); gdk_threads_leave(); @@ -169,7 +172,7 @@ static void add_buttons(struct gui *ui, static void init_ui(int *argc, char **argv[], struct gui *ui) { /* Magical g*thread incantation, you just need this thread stuff. - * Without it, the label update that happens in gfio_update_thread_status + * Without it, the update that happens in gfio_update_thread_status * doesn't really happen in a timely fashion, you need expose events */ if (!g_thread_supported ()) @@ -187,8 +190,16 @@ static void init_ui(int *argc, char **argv[], struct gui *ui) ui->vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER (ui->window), ui->vbox); - ui->thread_status_label = gtk_label_new("No jobs currently running."); - gtk_container_add(GTK_CONTAINER (ui->vbox), ui->thread_status_label); + + /* + * Set up thread status progress bar + */ + ui->thread_status_pb = gtk_progress_bar_new(); + gtk_progress_bar_set_fraction( + GTK_PROGRESS_BAR(ui->thread_status_pb), 0.0); + gtk_progress_bar_set_text( + GTK_PROGRESS_BAR(ui->thread_status_pb), "No jobs running"); + gtk_container_add(GTK_CONTAINER (ui->vbox), ui->thread_status_pb); add_buttons(ui, buttonspeclist, ARRAYSIZE(buttonspeclist)); gtk_widget_show_all(ui->window); -- 2.25.1