From 16ce5adf97de087c4c5220f6800bf310a3a70045 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Mon, 12 Mar 2012 11:56:09 +0100 Subject: [PATCH 1/1] gfio: add close-tab functionality And start Job menu. Signed-off-by: Jens Axboe --- gfio.c | 78 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 59 insertions(+), 19 deletions(-) diff --git a/gfio.c b/gfio.c index 7f478282..4bc3a3e6 100644 --- a/gfio.c +++ b/gfio.c @@ -407,6 +407,24 @@ static void entry_set_int_value(GtkWidget *entry, unsigned int val) gtk_entry_set_text(GTK_ENTRY(entry), tmp); } +static void show_info_dialog(struct gui *ui, const char *title, + const char *message) +{ + GtkWidget *dialog, *content, *label; + + dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(ui->window), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + + content = gtk_dialog_get_content_area(GTK_DIALOG(dialog)); + label = gtk_label_new(message); + gtk_container_add(GTK_CONTAINER(content), label); + gtk_widget_show_all(dialog); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); +} + #define ALIGN_LEFT 1 #define ALIGN_RIGHT 2 #define INVISIBLE 4 @@ -1494,7 +1512,6 @@ static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd) static void gfio_client_timed_out(struct fio_client *client) { struct gfio_client *gc = client->client_data; - GtkWidget *dialog, *label, *content; char buf[256]; gdk_threads_enter(); @@ -1503,22 +1520,7 @@ static void gfio_client_timed_out(struct fio_client *client) clear_ge_ui_info(gc->ge); sprintf(buf, "Client %s: timeout talking to server.\n", client->hostname); - - dialog = gtk_dialog_new_with_buttons("Timed out!", - GTK_WINDOW(main_ui.window), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - - /* gtk_dialog_get_content_area() is 2.14 and newer */ - content = GTK_DIALOG(dialog)->vbox; - - label = gtk_label_new((const gchar *) buf); - gtk_container_add(GTK_CONTAINER(content), label); - gtk_widget_show_all(dialog); - gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_ACCEPT); - - gtk_dialog_run(GTK_DIALOG(dialog)); - gtk_widget_destroy(dialog); + show_info_dialog(gc->ge->ui, "Network timeout", buf); gdk_threads_leave(); } @@ -1914,8 +1916,12 @@ static void ge_destroy(GtkWidget *w, gpointer data) struct gui_entry *ge = data; struct gfio_client *gc = ge->client; - if (gc->client) + if (gc && gc->client) { + if (ge->connected) + fio_client_terminate(gc->client); + fio_put_client(gc->client); + } flist_del(&ge->list); free(ge); @@ -1939,7 +1945,11 @@ static struct gui_entry *get_new_ge_with_tab(const char *name) static void file_new(GtkWidget *w, gpointer data) { - get_new_ge_with_tab("Untitled"); + struct gui *ui = (struct gui *) data; + struct gui_entry *ge; + + ge = get_new_ge_with_tab("Untitled"); + gtk_notebook_set_current_page(GTK_NOTEBOOK(ui->notebook), ge->page_num); } /* @@ -1963,6 +1973,25 @@ static struct gui_entry *get_ge_from_page(unsigned int cur_page) return NULL; } +static void file_close(GtkWidget *w, gpointer data) +{ + struct gui *ui = (struct gui *) data; + gint cur_page; + + /* + * Can't close the main tab + */ + cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(ui->notebook)); + if (cur_page) { + struct gui_entry *ge = get_ge_from_page(cur_page); + + gtk_widget_destroy(ge->vbox); + return; + } + + show_info_dialog(ui, "Error", "The main page view cannot be closed\n"); +} + static void file_open(GtkWidget *w, gpointer data) { struct gui *ui = data; @@ -2108,6 +2137,10 @@ static void view_log(GtkWidget *w, gpointer data) gtk_widget_show_all(win); } +static void edit_options(GtkWidget *w, gpointer data) +{ +} + static void __update_graph_limits(struct gfio_graphs *g) { line_graph_set_data_count_limit(g->iops_graph, gfio_graph_limit); @@ -2261,12 +2294,15 @@ static void about_dialog(GtkWidget *w, gpointer data) static GtkActionEntry menu_items[] = { { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL}, { "ViewMenuAction", GTK_STOCK_FILE, "View", NULL, NULL, NULL}, + { "JobMenuAction", GTK_STOCK_FILE, "Job", NULL, NULL, NULL}, { "HelpMenuAction", GTK_STOCK_HELP, "Help", NULL, NULL, NULL}, { "NewFile", GTK_STOCK_NEW, "New", "N", NULL, G_CALLBACK(file_new) }, + { "CloseFile", GTK_STOCK_CLOSE, "Close", "W", NULL, G_CALLBACK(file_close) }, { "OpenFile", GTK_STOCK_OPEN, NULL, "O", NULL, G_CALLBACK(file_open) }, { "SaveFile", GTK_STOCK_SAVE, NULL, "S", NULL, G_CALLBACK(file_save) }, { "Preferences", GTK_STOCK_PREFERENCES, NULL, "p", NULL, G_CALLBACK(preferences) }, { "ViewLog", NULL, "Log", "l", NULL, G_CALLBACK(view_log) }, + { "EditOptions", NULL, "Edit Options", "E", NULL, G_CALLBACK(edit_options) }, { "Quit", GTK_STOCK_QUIT, NULL, "Q", NULL, G_CALLBACK(quit_clicked) }, { "About", GTK_STOCK_ABOUT, NULL, NULL, NULL, G_CALLBACK(about_dialog) }, }; @@ -2277,6 +2313,7 @@ static const gchar *ui_string = " \ \ \ \ + \ \ \ \ @@ -2285,6 +2322,9 @@ static const gchar *ui_string = " \ \ \ \ + \ + \ + \ \ \ \ -- 2.25.1