fio: Use a progress bar instead of a label

Signed-off-by: Stephen M. Cameron <stephenmcameron@gmail.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/client.c b/client.c
index 1b7dee6..e109b93 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 dea35bb..150d133 100644
--- a/client.h
+++ b/client.h
@@ -17,7 +17,7 @@
 
 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 0833d34..64c02fe 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 @@
 	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 2d97cac..0d48974 100644
--- a/gfio.c
+++ b/gfio.c
@@ -51,7 +51,7 @@
 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 @@
 	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 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 @@
 
 	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);