gfio: demo of how to inherit option values into edit window
authorJens Axboe <axboe@kernel.dk>
Fri, 16 Mar 2012 13:56:44 +0000 (14:56 +0100)
committerJens Axboe <axboe@kernel.dk>
Fri, 16 Mar 2012 13:56:44 +0000 (14:56 +0100)
We now fill FIO_OPT_STR_STORE options directly into the edited
values.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
gfio.c
goptions.c
goptions.h

diff --git a/gfio.c b/gfio.c
index 5413da29d7fd153f82f054e91725e9b16c9d067c..15fce1df96a1afd5a52ab0181885776b5a284afd 100644 (file)
--- a/gfio.c
+++ b/gfio.c
@@ -2416,8 +2416,11 @@ static void send_job_entry(GtkWidget *w, gpointer data)
 static void edit_job_entry(GtkWidget *w, gpointer data)
 {
        struct gui *ui = (struct gui *) data;
 static void edit_job_entry(GtkWidget *w, gpointer data)
 {
        struct gui *ui = (struct gui *) data;
+       struct gui_entry *ge;
 
 
-       gopt_get_options_window(ui->window);
+       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)
 }
 
 static void start_job_entry(GtkWidget *w, gpointer data)
index 36477f0897bf73fc1008b312c3bc8b7188471175..7f23cef753703aa1f8787ad250dbec3e0a8a9c9b 100644 (file)
@@ -42,7 +42,7 @@ struct gopt_range {
        GtkWidget *spins[4];
 };
 
        GtkWidget *spins[4];
 };
 
-static struct gopt *gopt_new_str_store(struct fio_option *o)
+static struct gopt *gopt_new_str_store(struct fio_option *o, const char *text)
 {
        struct gopt_str *s;
        GtkWidget *label;
 {
        struct gopt_str *s;
        GtkWidget *label;
@@ -54,6 +54,8 @@ static struct gopt *gopt_new_str_store(struct fio_option *o)
        gtk_box_pack_start(GTK_BOX(s->gopt.box), label, FALSE, FALSE, 0);
 
        s->entry = gtk_entry_new();
        gtk_box_pack_start(GTK_BOX(s->gopt.box), label, FALSE, FALSE, 0);
 
        s->entry = gtk_entry_new();
+       if (text)
+               gtk_entry_set_text(GTK_ENTRY(s->entry), text);
        gtk_entry_set_editable(GTK_ENTRY(s->entry), 1);
 
        if (o->def)
        gtk_entry_set_editable(GTK_ENTRY(s->entry), 1);
 
        if (o->def)
@@ -181,14 +183,17 @@ static struct gopt *gopt_new_int_range(struct fio_option *o)
 }
 
 static void gopt_add_option(GtkWidget *hbox, struct fio_option *o,
 }
 
 static void gopt_add_option(GtkWidget *hbox, struct fio_option *o,
-                           unsigned int opt_index)
+                           unsigned int opt_index, struct thread_options *to)
 {
        struct gopt *go = NULL;
 
        switch (o->type) {
 {
        struct gopt *go = NULL;
 
        switch (o->type) {
-       case FIO_OPT_STR_STORE:
-               go = gopt_new_str_store(o);
+       case FIO_OPT_STR_STORE: {
+               char **p = td_var(to, o->off1);
+
+               go = gopt_new_str_store(o, *p);
                break;
                break;
+               }
        case FIO_OPT_STR_VAL:
        case FIO_OPT_STR_VAL_TIME:
        case FIO_OPT_INT:
        case FIO_OPT_STR_VAL:
        case FIO_OPT_STR_VAL_TIME:
        case FIO_OPT_INT:
@@ -200,7 +205,7 @@ static void gopt_add_option(GtkWidget *hbox, struct fio_option *o,
                break;
        case FIO_OPT_STR:
                if (!o->posval[0].ival) {
                break;
        case FIO_OPT_STR:
                if (!o->posval[0].ival) {
-                       go = gopt_new_str_store(o);
+                       go = gopt_new_str_store(o, NULL);
                        break;
                }
        case FIO_OPT_STR_MULTI:
                        break;
                }
        case FIO_OPT_STR_MULTI:
@@ -229,7 +234,7 @@ static void gopt_add_option(GtkWidget *hbox, struct fio_option *o,
        }
 }
 
        }
 }
 
-static void gopt_add_options(GtkWidget **vboxes)
+static void gopt_add_options(GtkWidget **vboxes, struct thread_options *to)
 {
        GtkWidget *hbox = NULL;
        int i;
 {
        GtkWidget *hbox = NULL;
        int i;
@@ -244,7 +249,7 @@ static void gopt_add_options(GtkWidget **vboxes)
 
                        hbox = gtk_hbox_new(FALSE, 3);
                        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
 
                        hbox = gtk_hbox_new(FALSE, 3);
                        gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5);
-                       gopt_add_option(hbox, &fio_options[i], i);
+                       gopt_add_option(hbox, o, i, to);
                }
        }
 }
                }
        }
 }
@@ -282,7 +287,7 @@ static void gopt_add_group_tabs(GtkWidget *notebook, GtkWidget **vbox)
        } while (1);
 }
 
        } while (1);
 }
 
-void gopt_get_options_window(GtkWidget *window)
+void gopt_get_options_window(GtkWidget *window, struct thread_options *o)
 {
        GtkWidget *dialog, *notebook;
        GtkWidget *vboxes[__FIO_OPT_G_NR];
 {
        GtkWidget *dialog, *notebook;
        GtkWidget *vboxes[__FIO_OPT_G_NR];
@@ -301,7 +306,7 @@ void gopt_get_options_window(GtkWidget *window)
 
        gopt_add_group_tabs(notebook, vboxes);
 
 
        gopt_add_group_tabs(notebook, vboxes);
 
-       gopt_add_options(vboxes);
+       gopt_add_options(vboxes, o);
 
        gtk_widget_show_all(dialog);
 
 
        gtk_widget_show_all(dialog);
 
index 14e54f7835d9e793923c2f4c77b43fb445974f50..4b409428153d3d1f99c6198d8b18cfad09972edc 100644 (file)
@@ -1,6 +1,6 @@
 #ifndef GFIO_OPTIONS_H
 #define GFIO_OPTIONS_H
 
 #ifndef GFIO_OPTIONS_H
 #define GFIO_OPTIONS_H
 
-void gopt_get_options_window(GtkWidget *window);
+void gopt_get_options_window(GtkWidget *window, struct thread_options *o);
 
 #endif
 
 #endif