gfio: fill default options on new job
[fio.git] / gfio.c
diff --git a/gfio.c b/gfio.c
index 9998077ec619c4319dd804cb6a1f1db4b00b2fd9..d62b8a5b5086648dc3a9e8177764eefdfea3c29e 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -32,6 +32,7 @@
 #include "fio.h"
 #include "gfio.h"
 #include "ghelpers.h"
+#include "goptions.h"
 #include "graph.h"
 
 static int gfio_server_running;
@@ -75,7 +76,7 @@ static struct button_spec {
 
 static void gfio_update_thread_status(struct gui_entry *ge, char *status_message, double perc);
 static void gfio_update_thread_status_all(char *status_message, double perc);
-void report_error(GError *error);
+static void report_error(GError *error);
 
 static struct graph *setup_iops_graph(void)
 {
@@ -116,54 +117,6 @@ static void setup_graphs(struct gfio_graphs *g)
        g->bandwidth_graph = setup_bandwidth_graph();
 }
 
-static void multitext_add_entry(struct multitext_widget *mt, const char *text)
-{
-       mt->text = realloc(mt->text, (mt->max_text + 1) * sizeof(char *));
-       mt->text[mt->max_text] = strdup(text);
-       mt->max_text++;
-}
-
-static void multitext_set_entry(struct multitext_widget *mt, unsigned int index)
-{
-       if (index >= mt->max_text)
-               return;
-       if (!mt->text || !mt->text[index])
-               return;
-
-       mt->cur_text = index;
-       gtk_entry_set_text(GTK_ENTRY(mt->entry), mt->text[index]);
-}
-
-static void multitext_update_entry(struct multitext_widget *mt,
-                                  unsigned int index, const char *text)
-{
-       if (!mt->text)
-               return;
-
-       if (mt->text[index])
-               free(mt->text[index]);
-
-       mt->text[index] = strdup(text);
-       if (mt->cur_text == index)
-               gtk_entry_set_text(GTK_ENTRY(mt->entry), mt->text[index]);
-}
-
-static void multitext_free(struct multitext_widget *mt)
-{
-       int i;
-
-       gtk_entry_set_text(GTK_ENTRY(mt->entry), "");
-
-       for (i = 0; i < mt->max_text; i++) {
-               if (mt->text[i])
-                       free(mt->text[i]);
-       }
-
-       free(mt->text);
-       mt->cur_text = -1;
-       mt->max_text = 0;
-}
-
 static void clear_ge_ui_info(struct gui_entry *ge)
 {
        gtk_label_set_text(GTK_LABEL(ge->probe.hostname), "");
@@ -291,21 +244,21 @@ static void update_button_states(struct gui *ui, struct gui_entry *ge)
 
        case GE_STATE_NEW:
                connect_state = 1;
-               edit_state = 0;
+               edit_state = 1;
                connect_str = "Connect";
                send_state = 0;
                start_state = 0;
                break;
        case GE_STATE_CONNECTED:
                connect_state = 1;
-               edit_state = 0;
+               edit_state = 1;
                connect_str = "Disconnect";
                send_state = 1;
                start_state = 0;
                break;
        case GE_STATE_JOB_SENT:
                connect_state = 1;
-               edit_state = 0;
+               edit_state = 1;
                connect_str = "Disconnect";
                send_state = 0;
                start_state = 1;
@@ -358,51 +311,6 @@ static void gfio_set_state(struct gui_entry *ge, unsigned int state)
        update_button_states(ge->ui, ge);
 }
 
-#define ALIGN_LEFT 1
-#define ALIGN_RIGHT 2
-#define INVISIBLE 4
-#define UNSORTABLE 8
-
-GtkTreeViewColumn *tree_view_column(GtkWidget *tree_view, int index, const char *title, unsigned int flags)
-{
-       GtkCellRenderer *renderer;
-       GtkTreeViewColumn *col;
-       double xalign = 0.0; /* left as default */
-       PangoAlignment align;
-       gboolean visible;
-
-       align = (flags & ALIGN_LEFT) ? PANGO_ALIGN_LEFT :
-               (flags & ALIGN_RIGHT) ? PANGO_ALIGN_RIGHT :
-               PANGO_ALIGN_CENTER;
-       visible = !(flags & INVISIBLE);
-
-       renderer = gtk_cell_renderer_text_new();
-       col = gtk_tree_view_column_new();
-
-       gtk_tree_view_column_set_title(col, title);
-       if (!(flags & UNSORTABLE))
-               gtk_tree_view_column_set_sort_column_id(col, index);
-       gtk_tree_view_column_set_resizable(col, TRUE);
-       gtk_tree_view_column_pack_start(col, renderer, TRUE);
-       gtk_tree_view_column_add_attribute(col, renderer, "text", index);
-       gtk_object_set(GTK_OBJECT(renderer), "alignment", align, NULL);
-       switch (align) {
-       case PANGO_ALIGN_LEFT:
-               xalign = 0.0;
-               break;
-       case PANGO_ALIGN_CENTER:
-               xalign = 0.5;
-               break;
-       case PANGO_ALIGN_RIGHT:
-               xalign = 1.0;
-               break;
-       }
-       gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(renderer), xalign, 0.5);
-       gtk_tree_view_column_set_visible(col, visible);
-       gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), col);
-       return col;
-}
-
 static void gfio_ui_setup_log(struct gui *ui)
 {
        GtkTreeSelection *selection;
@@ -439,6 +347,7 @@ static struct graph *setup_clat_graph(char *title, unsigned int *ovals,
        g = graph_new(xdim, ydim, gfio_graph_font);
        graph_title(g, title);
        graph_x_title(g, "Percentile");
+       graph_y_title(g, "Time");
 
        for (i = 0; i < len; i++) {
                char fbuf[8];
@@ -749,6 +658,7 @@ static struct graph *setup_lat_bucket_graph(const char *title, double *lat,
        g = graph_new(xdim, ydim, gfio_graph_font);
        graph_title(g, title);
        graph_x_title(g, "Buckets");
+       graph_y_title(g, "Percent");
 
        for (i = 0; i < len; i++) {
                graph_add_label(g, labels[i]);
@@ -1116,7 +1026,7 @@ static GtkWidget *gfio_disk_util_get_vbox(struct gui_entry *ge)
        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_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 5);
 
        gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), vbox);
        res_notebook = get_results_window(ge);
@@ -1992,7 +1902,7 @@ static void on_info_bar_response(GtkWidget *widget, gint response,
        }
 }
 
-void report_error(GError *error)
+static void report_error(GError *error)
 {
        struct gui *ui = &main_ui;
 
@@ -2160,6 +2070,7 @@ static void gfio_client_added(struct gui_entry *ge, struct fio_client *client)
 
        gc = malloc(sizeof(*gc));
        memset(gc, 0, sizeof(*gc));
+       options_default_fill(&gc->o);
        gc->ge = ge;
        gc->client = fio_get_client(client);
 
@@ -2507,6 +2418,12 @@ static void send_job_entry(GtkWidget *w, gpointer data)
 
 static void edit_job_entry(GtkWidget *w, gpointer data)
 {
+       struct gui *ui = (struct gui *) data;
+       struct gui_entry *ge;
+
+       ge = get_ge_from_cur_tab(ui);
+       if (ge && ge->client)
+               gopt_get_options_window(ui->window, &ge->client->o);
 }
 
 static void start_job_entry(GtkWidget *w, gpointer data)
@@ -2699,7 +2616,7 @@ static GtkActionEntry menu_items[] = {
        { "Preferences", GTK_STOCK_PREFERENCES, NULL, "<Control>p", NULL, G_CALLBACK(preferences) },
        { "ViewLog", NULL, "Log", "<Control>l", NULL, G_CALLBACK(view_log) },
        { "ViewResults", NULL, "Results", "<Control>R", NULL, G_CALLBACK(view_results) },
-       { "ConnectJob", NULL, "Connect", "<Control>E", NULL, G_CALLBACK(connect_job_entry) },
+       { "ConnectJob", NULL, "Connect", "<Control>D", NULL, G_CALLBACK(connect_job_entry) },
        { "EditJob", NULL, "Edit job", "<Control>E", NULL, G_CALLBACK(edit_job_entry) },
        { "SendJob", NULL, "Send job", "<Control>X", NULL, G_CALLBACK(send_job_entry) },
        { "StartJob", NULL, "Start job", "<Control>L", NULL, G_CALLBACK(start_job_entry) },