#include "fio.h"
#include "gfio.h"
#include "ghelpers.h"
+#include "goptions.h"
#include "graph.h"
static int gfio_server_running;
};
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 gfio_update_thread_status_all(struct gui *ui, char *status_message, double perc);
+static void report_error(GError *error);
static struct graph *setup_iops_graph(void)
{
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), "");
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;
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;
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];
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]);
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);
static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd)
{
struct cmd_text_pdu *p = (struct cmd_text_pdu *) cmd->payload;
- struct gui *ui = &main_ui;
+ struct gfio_client *gc = client->client_data;
+ struct gui_entry *ge = gc->ge;
+ struct gui *ui = ge->ui;
GtkTreeIter iter;
struct tm *tm;
time_t sec;
sprintf(dst, " - %s", eta_str);
}
- gfio_update_thread_status_all(output, perc);
+ gfio_update_thread_status_all(ui, output, perc);
gdk_threads_leave();
}
strncpy(message, status_message, sizeof(message) - 1);
gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ge->thread_status_pb), m);
gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ge->thread_status_pb), perc / 100.0);
- gtk_widget_queue_draw(main_ui.window);
+ gtk_widget_queue_draw(ge->ui->window);
}
-static void gfio_update_thread_status_all(char *status_message, double perc)
+static void gfio_update_thread_status_all(struct gui *ui, char *status_message,
+ double perc)
{
- struct gui *ui = &main_ui;
static char message[100];
const char *m = message;
static void ge_widget_destroy(GtkWidget *w, gpointer data)
{
+ struct gui_entry *ge = (struct gui_entry *) data;
+
+ ge_destroy(ge);
}
static void gfio_quit(struct gui *ui)
static void quit_clicked(__attribute__((unused)) GtkWidget *widget,
__attribute__((unused)) gpointer data)
{
- gfio_quit(data);
+ struct gui *ui = (struct gui *) data;
+
+ gfio_quit(ui);
}
static void *job_thread(void *arg)
return NULL;
}
-static void gfio_start_server(void)
+static void gfio_start_server(struct gui *ui)
{
- struct gui *ui = &main_ui;
-
if (!gfio_server_running) {
gfio_server_running = 1;
pthread_create(&ui->server_t, NULL, server_thread, NULL);
}
}
-void report_error(GError *error)
+static void report_error(GError *error)
{
struct gui *ui = &main_ui;
gc = malloc(sizeof(*gc));
memset(gc, 0, sizeof(*gc));
+ options_default_fill(&gc->o);
gc->ge = ge;
gc->client = fio_get_client(client);
* Return the 'ge' corresponding to the tab. If the active tab is the
* main tab, open a new tab.
*/
-static struct gui_entry *get_ge_from_page(gint cur_page, int *created)
+static struct gui_entry *get_ge_from_page(struct gui *ui, gint cur_page,
+ int *created)
{
struct flist_head *entry;
struct gui_entry *ge;
if (created)
*created = 0;
- flist_for_each(entry, &main_ui.list) {
+ flist_for_each(entry, &ui->list) {
ge = flist_entry(entry, struct gui_entry, list);
if (ge->page_num == cur_page)
return ge;
*/
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(ui->notebook));
if (cur_page)
- return get_ge_from_page(cur_page, NULL);
+ return get_ge_from_page(ui, cur_page, NULL);
return NULL;
}
* current tab already has a client.
*/
cur_page = gtk_notebook_get_current_page(GTK_NOTEBOOK(ui->notebook));
- ge = get_ge_from_page(cur_page, &ge_is_new);
+ ge = get_ge_from_page(ui, cur_page, &ge_is_new);
if (ge->client) {
ge = get_new_ge_with_tab("Untitled");
ge_is_new = 1;
if (!ret) {
if (server_start)
- gfio_start_server();
+ gfio_start_server(ui);
} else {
if (ge_is_new)
gtk_widget_destroy(ge->vbox);
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)
{
GtkWidget *dialog, *frame, *box, **buttons, *vbox, *font;
GtkWidget *hbox, *spin, *entry, *spin_int;
+ struct gui *ui = (struct gui *) data;
int i;
dialog = gtk_dialog_new_with_buttons("Preferences",
- GTK_WINDOW(main_ui.window),
+ GTK_WINDOW(ui->window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
{ "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) },
}
set_job_menu_visible(ui, 1);
- ge = get_ge_from_page(page, NULL);
+ ge = get_ge_from_page(ui, page, NULL);
if (ge)
update_button_states(ui, ge);
}
static void drag_and_drop_received(GtkWidget *widget, GdkDragContext *ctx,
- gint x, gint y, GtkSelectionData *data,
- guint info, guint time)
+ gint x, gint y, GtkSelectionData *seldata,
+ guint info, guint time, gpointer *data)
{
- struct gui *ui = &main_ui;
+ struct gui *ui = (struct gui *) data;
gchar **uris;
GtkWidget *source;
int i;
return;
}
- uris = gtk_selection_data_get_uris(data);
+ uris = gtk_selection_data_get_uris(seldata);
if (!uris) {
gtk_drag_finish(ctx, FALSE, FALSE, time);
return;
gtk_window_set_title(GTK_WINDOW(ui->window), "fio");
gtk_window_set_default_size(GTK_WINDOW(ui->window), 1024, 768);
- g_signal_connect(ui->window, "delete-event", G_CALLBACK(quit_clicked), NULL);
- g_signal_connect(ui->window, "destroy", G_CALLBACK(quit_clicked), NULL);
+ g_signal_connect(ui->window, "delete-event", G_CALLBACK(quit_clicked), ui);
+ g_signal_connect(ui->window, "destroy", G_CALLBACK(quit_clicked), ui);
ui->vbox = gtk_vbox_new(FALSE, 0);
gtk_container_add(GTK_CONTAINER(ui->window), ui->vbox);