gfio: put disk utilization tab in a scrolled window
[fio.git] / gfio.c
diff --git a/gfio.c b/gfio.c
index 93c8e171c131b6a4db460f65666741ba0f31a756..bbeb229996272aa079c11d26856fda7f78600588 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -189,7 +189,6 @@ struct gfio_client {
        struct gui_entry *ge;
        struct fio_client *client;
        GtkWidget *err_entry;
-       unsigned int job_added;
        struct thread_options o;
 
        struct end_results *results;
@@ -1290,25 +1289,51 @@ static void disk_util_destroy(GtkWidget *w, gpointer data)
        gtk_widget_destroy(w);
 }
 
+static GtkWidget *get_scrolled_window(gint border_width)
+{
+       GtkWidget *scroll;
+
+       scroll = gtk_scrolled_window_new(NULL, NULL);
+       gtk_container_set_border_width(GTK_CONTAINER(scroll), border_width);
+       gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+
+       return scroll;
+}
+
+static GtkWidget *gfio_disk_util_get_vbox(struct gui_entry *ge)
+{
+       GtkWidget *vbox, *box, *scroll, *res_notebook;
+
+       if (ge->disk_util_vbox)
+               return ge->disk_util_vbox;
+
+       scroll = get_scrolled_window(5);
+       vbox = gtk_vbox_new(FALSE, 3);
+       box = gtk_hbox_new(FALSE, 0);
+       gtk_box_pack_start(GTK_BOX(vbox), box, TRUE, FALSE, 5);
+
+       gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), vbox);
+       res_notebook = get_results_window(ge);
+
+       gtk_notebook_append_page(GTK_NOTEBOOK(res_notebook), scroll, gtk_label_new("Disk utilization"));
+       ge->disk_util_vbox = box;
+       g_signal_connect(vbox, "destroy", G_CALLBACK(disk_util_destroy), ge);
+
+       return ge->disk_util_vbox;
+}
+
 static int __gfio_disk_util_show(GtkWidget *res_notebook,
                                 struct gfio_client *gc, struct cmd_du_pdu *p)
 {
-       GtkWidget *box, *frame, *entry, *vbox;
+       GtkWidget *box, *frame, *entry, *vbox, *util_vbox;
        struct gui_entry *ge = gc->ge;
        double util;
        char tmp[16];
 
-       res_notebook = get_results_window(ge);
-
-       if (!ge->disk_util_vbox) {
-               vbox = gtk_vbox_new(FALSE, 3);
-               gtk_notebook_append_page(GTK_NOTEBOOK(res_notebook), vbox, gtk_label_new("Disk utilization"));
-               ge->disk_util_vbox = vbox;
-               g_signal_connect(vbox, "destroy", G_CALLBACK(disk_util_destroy), ge);
-       }
+       util_vbox = gfio_disk_util_get_vbox(ge);
 
        vbox = gtk_vbox_new(FALSE, 3);
-       gtk_container_add(GTK_CONTAINER(ge->disk_util_vbox), vbox);
+       gtk_container_add(GTK_CONTAINER(util_vbox), vbox);
 
        frame = gtk_frame_new((char *) p->dus.name);
        gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2);
@@ -1463,11 +1488,15 @@ static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
                            struct group_run_stats *rs)
 {
        struct gfio_client *gc = client->client_data;
+       struct gui_entry *ge = gc->ge;
 
        gfio_add_end_results(gc, ts, rs);
 
        gdk_threads_enter();
-       gfio_display_end_results(gc);
+       if (ge->results_window)
+               __gfio_display_end_results(ge->results_notebook, gc, ts, rs);
+       else
+               gfio_display_end_results(gc);
        gdk_threads_leave();
 }
 
@@ -1503,6 +1532,7 @@ static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd
 {
        struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload;
        struct gfio_client *gc = client->client_data;
+       struct gui_entry *ge = gc->ge;
        unsigned int nr = gc->nr_du;
 
        gc->du = realloc(gc->du, (nr + 1) * sizeof(struct cmd_du_pdu));
@@ -1510,7 +1540,10 @@ static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd
        gc->nr_du++;
 
        gdk_threads_enter();
-       gfio_disk_util_show(gc);
+       if (ge->results_window)
+               __gfio_disk_util_show(ge->results_notebook, gc, p);
+       else
+               gfio_disk_util_show(gc);
        gdk_threads_leave();
 }
 
@@ -1883,8 +1916,6 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
        multitext_set_entry(&ge->eta.ioengine, 0);
        multitext_set_entry(&ge->eta.iodepth, 0);
 
-       gc->job_added++;
-
        gfio_set_state(ge, GE_STATE_JOB_SENT);
 
        gdk_threads_leave();
@@ -2091,6 +2122,8 @@ static void connect_clicked(GtkWidget *widget, gpointer data)
                if (!ge->nr_job_files)
                        return;
 
+               gc = ge->client;
+
                gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ge->thread_status_pb), "No jobs running");
                gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ge->thread_status_pb), 0.0);
                ret = fio_client_connect(gc->client);