fio: Use a progress bar instead of a label
authorStephen M. Cameron <stephenmcameron@gmail.com>
Fri, 24 Feb 2012 07:17:31 +0000 (08:17 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 24 Feb 2012 07:17:31 +0000 (08:17 +0100)
Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
client.c
client.h
eta.c
gfio.c

index 1b7dee66cb2f424afb29f07e225dbdc77c26af93..e109b93fcc86e4db88cdc2edf9d06a745e22f17e 100644 (file)
--- 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;
index dea35bb71f34f98b611a81a52edfe1a61caed76d..150d1334539b77d65b305f75663caa53ccb557e8 100644 (file)
--- 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 0833d3412450a6ddd788369cf2c064f41918ef34..64c02fe2d3690e9ff3421d94d233fc01d2bcf903 100644 (file)
--- 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 2d97cacab41cd9d59caf8364bef39a39cf60a553..0d48974ee7148a4338c7e1a85a84c71cb516d5a0 100644 (file)
--- 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);