gfio: put results from same job file into a notebook
[fio.git] / gfio.c
diff --git a/gfio.c b/gfio.c
index 15bf8f80602a79fda092809685ef53d660f1cacd..c7160ada468d139ea110fed0dba786e41af6601a 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -88,6 +88,8 @@ struct gui {
        GtkWidget *textview;
        GtkWidget *error_info_bar;
        GtkWidget *error_label;
+       GtkWidget *results_notebook;
+       GtkWidget *results_window;
        GtkTextBuffer *text;
        struct probe_widget probe;
        struct eta_widget eta;
@@ -700,30 +702,53 @@ static void gfio_show_io_depths(GtkWidget *vbox, struct thread_stat *ts)
        gtk_box_pack_start(GTK_BOX(box), tree_view, TRUE, FALSE, 3);
 }
 
+static gboolean results_window_delete(GtkWidget *w, gpointer data)
+{
+       struct gui *ui = (struct gui *) data;
+
+       gtk_widget_destroy(w);
+       ui->results_window = NULL;
+       ui->results_notebook = NULL;
+       return TRUE;
+}
+
+static GtkWidget *get_results_window(struct gui *ui)
+{
+       GtkWidget *win, *notebook;
+
+       if (ui->results_window)
+               return ui->results_notebook;
+
+       win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+       gtk_window_set_title(GTK_WINDOW(win), "Results");
+       g_signal_connect(win, "delete-event", G_CALLBACK(results_window_delete), ui);
+       g_signal_connect(win, "destroy", G_CALLBACK(results_window_delete), ui);
+
+       notebook = gtk_notebook_new();
+       gtk_container_add(GTK_CONTAINER(win), notebook);
+
+       ui->results_window = win;
+       ui->results_notebook = notebook;
+       return ui->results_notebook;
+}
+
 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
                            struct group_run_stats *rs)
 {
-       GtkWidget *dialog, *box, *vbox, *entry, *content;
+       GtkWidget *res_win, *box, *vbox, *entry;
        struct gui *ui = client->client_data;
 
        gdk_threads_enter();
 
-       dialog = gtk_dialog_new_with_buttons("Results", GTK_WINDOW(ui->window),
-                       GTK_DIALOG_DESTROY_WITH_PARENT,
-                       GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
-
-       g_signal_connect_swapped(dialog, "response",
-                             G_CALLBACK(gtk_widget_destroy),
-                             dialog);
-
-       content = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+       res_win = get_results_window(ui);
 
        vbox = gtk_vbox_new(FALSE, 3);
-       gtk_container_add(GTK_CONTAINER(content), vbox);
 
        box = gtk_hbox_new(TRUE, 3);
        gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 5);
 
+       gtk_notebook_append_page(GTK_NOTEBOOK(res_win), vbox, gtk_label_new(ts->name));
+
        entry = new_info_entry_in_frame(box, "Name");
        gtk_entry_set_text(GTK_ENTRY(entry), ts->name);
        if (strlen(ts->description)) {
@@ -748,7 +773,7 @@ static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
        gfio_show_cpu_usage(vbox, ts);
        gfio_show_io_depths(vbox, ts);
 
-       gtk_widget_show_all(dialog);
+       gtk_widget_show_all(ui->results_window);
        gdk_threads_leave();
 }
 
@@ -772,8 +797,10 @@ static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd)
 
 static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd)
 {
+       gdk_threads_enter();
        printf("gfio_disk_util_op called\n");
        fio_client_ops.disk_util(client, cmd);
+       gdk_threads_leave();
 }
 
 extern int sum_stat_clients;
@@ -807,8 +834,10 @@ static void gfio_thread_status_op(struct fio_client *client,
 static void gfio_group_stats_op(struct fio_client *client,
                                struct fio_net_cmd *cmd)
 {
+       gdk_threads_enter();
        printf("gfio_group_stats_op called\n");
        fio_client_ops.group_stats(client, cmd);
+       gdk_threads_leave();
 }
 
 static void gfio_update_eta(struct jobs_eta *je)
@@ -820,6 +849,8 @@ static void gfio_update_eta(struct jobs_eta *je)
        double perc = 0.0;
        int i2p = 0;
 
+       gdk_threads_enter();
+
        eta_str[0] = '\0';
        output[0] = '\0';
 
@@ -889,6 +920,7 @@ static void gfio_update_eta(struct jobs_eta *je)
        }
                
        gfio_update_thread_status(output, perc);
+       gdk_threads_leave();
 }
 
 static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
@@ -908,11 +940,15 @@ static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
        if (!client->name)
                client->name = strdup((char *) probe->hostname);
 
+       gdk_threads_enter();
+
        gtk_label_set_text(GTK_LABEL(ui.probe.hostname), (char *) probe->hostname);
        gtk_label_set_text(GTK_LABEL(ui.probe.os), os);
        gtk_label_set_text(GTK_LABEL(ui.probe.arch), arch);
        sprintf(buf, "%u.%u.%u", probe->fio_major, probe->fio_minor, probe->fio_patch);
        gtk_label_set_text(GTK_LABEL(ui.probe.fio_ver), buf);
+
+       gdk_threads_leave();
 }
 
 static void gfio_update_thread_status(char *status_message, double perc)
@@ -925,16 +961,16 @@ static void gfio_update_thread_status(char *status_message, double perc)
                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();
 }
 
 static void gfio_quit_op(struct fio_client *client)
 {
        struct gui *ui = client->client_data;
 
+       gdk_threads_enter();
        gfio_set_connected(ui, 0);
+       gdk_threads_leave();
 }
 
 static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
@@ -955,12 +991,16 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
        p->numjobs              = le32_to_cpu(p->numjobs);
        p->group_reporting      = le32_to_cpu(p->group_reporting);
 
+       gdk_threads_enter();
+
        gtk_entry_set_text(GTK_ENTRY(ui->eta.name), (gchar *) p->jobname);
        gtk_entry_set_text(GTK_ENTRY(ui->eta.iotype), ddir_str(p->rw));
        gtk_entry_set_text(GTK_ENTRY(ui->eta.ioengine), (gchar *) p->ioengine);
 
        sprintf(tmp, "%u", p->iodepth);
        gtk_entry_set_text(GTK_ENTRY(ui->eta.iodepth), tmp);
+
+       gdk_threads_leave();
 }
 
 static void gfio_client_timed_out(struct fio_client *client)