diff --git a/src/sview/common.c b/src/sview/common.c index 81bd623585c60b2dd87d1eeefbe19ab4974b9da8..3ceb0d26d91253ff60468c1a0c8e0249fcb9f48a 100644 --- a/src/sview/common.c +++ b/src/sview/common.c @@ -33,6 +33,22 @@ typedef struct { GtkTreeIter iter; } treedata_t; +static void _handle_response(GtkDialog *dialog, gint response_id, + popup_info_t *popup_win) +{ + switch(response_id) { + case GTK_RESPONSE_OK: //refresh + (popup_win->display_data->refresh)(NULL, popup_win); + break; + case GTK_RESPONSE_CLOSE: // close + delete_popup(NULL, NULL, popup_win->spec_info->title); + break; + default: + g_print("handle unknown response %d\n", response_id); + break; + } + return; +} static int _sort_iter_compare_func_char(GtkTreeModel *model, GtkTreeIter *a, @@ -345,7 +361,11 @@ extern void make_popup_fields_menu(popup_info_t *popup_win, GtkMenu *menu) { GtkWidget *menuitem = NULL; display_data_t *display_data = popup_win->display_data; - + + /* we don't want to display anything on the full info page */ + if(popup_win->spec_info->type == INFO_PAGE) + return; + while(display_data++) { if(display_data->id == -1) break; @@ -574,43 +594,48 @@ extern popup_info_t *create_popup_info(int type, int dest_type, char *title) GtkBin *bin = NULL; GtkViewport *view = NULL; GtkBin *bin2 = NULL; - GtkWidget *table = NULL; GtkWidget *popup = NULL; + GtkWidget *label = NULL; popup_info_t *popup_win = xmalloc(sizeof(popup_info_t)); list_push(popup_list, popup_win); popup_win->spec_info = xmalloc(sizeof(specific_info_t)); - popup_win->popup = gtk_dialog_new(); + popup_win->spec_info->type = type; + popup_win->spec_info->title = xstrdup(title); + popup_win->popup = gtk_dialog_new_with_buttons( + title, + GTK_WINDOW(main_window), + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_REFRESH, + GTK_RESPONSE_OK, + GTK_STOCK_CLOSE, + GTK_RESPONSE_CLOSE, + NULL); popup_win->toggled = 0; popup_win->force_refresh = 0; popup_win->type = dest_type; popup_win->not_found = false; gtk_window_set_default_size(GTK_WINDOW(popup_win->popup), 600, 400); - gtk_window_set_title(GTK_WINDOW(popup_win->popup), title); popup = popup_win->popup; - table = gtk_table_new(1, 2, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(table), 10); - popup_win->event_box = gtk_event_box_new(); + label = gtk_label_new(popup_win->spec_info->title); + gtk_container_add(GTK_CONTAINER(popup_win->event_box), label); + + g_signal_connect(G_OBJECT(popup_win->event_box), + "button-press-event", + G_CALLBACK(redo_popup), + popup_win); + gtk_event_box_set_above_child( GTK_EVENT_BOX(popup_win->event_box), FALSE); - popup_win->button = gtk_button_new_with_label("Refresh"); - gtk_table_attach_defaults(GTK_TABLE(table), - popup_win->event_box, - 0, 1, 0, 1); - gtk_table_attach(GTK_TABLE(table), - popup_win->button, - 1, 2, 0, 1, - GTK_SHRINK, GTK_EXPAND | GTK_FILL, - 0, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(popup)->vbox), - table, FALSE, FALSE, 0); + popup_win->event_box, FALSE, FALSE, 0); window = create_scrolled_window(); bin = GTK_BIN(&window->container); @@ -621,11 +646,13 @@ extern popup_info_t *create_popup_info(int type, int dest_type, char *title) gtk_box_pack_start(GTK_BOX(GTK_DIALOG(popup)->vbox), GTK_WIDGET(window), TRUE, TRUE, 0); - popup_win->spec_info->type = type; - popup_win->spec_info->title = xstrdup(title); g_signal_connect(G_OBJECT(popup_win->popup), "delete_event", G_CALLBACK(delete_popup), popup_win->spec_info->title); + g_signal_connect(G_OBJECT(popup_win->popup), "response", + G_CALLBACK(_handle_response), + popup_win); + gtk_widget_show_all(popup_win->popup); return popup_win; } @@ -634,9 +661,7 @@ extern void setup_popup_info(popup_info_t *popup_win, display_data_t *display_data, int cnt) { - GtkWidget *label = NULL; int i = 0; - specific_info_t *spec_info = popup_win->spec_info; popup_win->display_data = xmalloc(sizeof(display_data_t)*(cnt+2)); for(i=0; i<cnt+1; i++) { @@ -644,20 +669,6 @@ extern void setup_popup_info(popup_info_t *popup_win, &display_data[i], sizeof(display_data_t)); } - - g_signal_connect(G_OBJECT(popup_win->event_box), - "button-press-event", - G_CALLBACK(redo_popup), - popup_win); - - g_signal_connect(G_OBJECT(popup_win->button), - "pressed", - G_CALLBACK(popup_win->display_data->refresh), - popup_win); - - label = gtk_label_new(spec_info->title); - gtk_container_add(GTK_CONTAINER(popup_win->event_box), label); - gtk_widget_show(label); } extern void redo_popup(GtkWidget *widget, GdkEventButton *event, @@ -705,10 +716,6 @@ extern void destroy_popup_info(void *arg) gtk_widget_destroy(GTK_WIDGET(popup_win->table)); popup_win->table = NULL; } - if(popup_win->button) { - gtk_widget_destroy(popup_win->button); - popup_win->button = NULL; - } if(popup_win->event_box) { gtk_widget_destroy(popup_win->event_box); popup_win->event_box = NULL; diff --git a/src/sview/grid.c b/src/sview/grid.c index bc11b1fddcadce9d11b5f460ff2e933aedbdd8aa..f8126a8d1651f7ad3413c6ab95d31d1af6bccc7d 100644 --- a/src/sview/grid.c +++ b/src/sview/grid.c @@ -35,3 +35,363 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. \*****************************************************************************/ #include "sview.h" + +typedef struct { + GtkWidget *button; + int coord[BA_SYSTEM_DIMENSIONS]; + int indecies; + int state; +} grid_button_t; + +List grid_button_list = NULL; + +char *sview_colors[] = {"green", + "blue", + "red", + "orange", + "yellow", + "violet", + "brown", + "DarkCyan", + "DarkRed", + "wheat4", + "gold4", + "LightBlue3", + "DeepSkyBlue2", + "MistyRose2", + "HotPink", + "tan", + "ForestGreen", + "moccasin", + "sienna", + "peru"}; +int sview_colors_cnt = 20; + +void *_blink_thr(void *arg) +{ + ListIterator itr = NULL; + grid_button_t *grid_button = NULL; + uint16_t node_base_state; + GdkColor color; + static bool flash = true; + while(1) { + if(flash) { + flash = false; + gdk_color_parse("red", &color); + + } else { + flash = true; + gdk_color_parse("black", &color); + + } + sleep(1); + gdk_threads_enter(); + itr = list_iterator_create(grid_button_list); + while((grid_button = list_next(itr))) { + node_base_state = grid_button->state & NODE_STATE_BASE; + if ((node_base_state == NODE_STATE_DOWN) + || (grid_button->state & NODE_STATE_DRAIN)) { + gtk_widget_modify_bg(grid_button->button, + GTK_STATE_NORMAL, &color); + } + } + list_iterator_destroy(itr); + gdk_flush(); + gdk_threads_leave(); + } + + return NULL; +} + +static void _open_node(GtkWidget *widget, GdkEventButton *event, + grid_button_t *grid_button) +{ + int error_code = SLURM_SUCCESS; + node_info_msg_t *node_info_ptr = NULL; + node_info_t *node_ptr = NULL; + GError *error = NULL; + char title[100]; + ListIterator itr = NULL; + popup_info_t *popup_win = NULL; + + if((error_code = get_new_info_node(&node_info_ptr, force_refresh)) + == SLURM_NO_CHANGE_IN_DATA) { + goto update_it; + } + if (error_code != SLURM_SUCCESS) { + printf("slurm_load_node: %s\n", slurm_strerror(error_code)); + return; + } +update_it: + node_ptr = &node_info_ptr->node_array[grid_button->indecies]; +#ifdef HAVE_BG + snprintf(title, 100, + "Info about base partition %s", node_ptr->name); +#else + snprintf(title, 100, "Info about node %s", node_ptr->name); +#endif + itr = list_iterator_create(popup_list); + while((popup_win = list_next(itr))) { + if(popup_win->spec_info) + if(!strcmp(popup_win->spec_info->title, title)) { + break; + } + } + list_iterator_destroy(itr); + + if(!popup_win) { + popup_win = create_popup_info(PART_PAGE, NODE_PAGE, title); + } + popup_win->spec_info->data = g_strdup(node_ptr->name); + if (!g_thread_create((gpointer)popup_thr, popup_win, FALSE, &error)) + { + g_printerr ("Failed to create part popup thread: %s\n", + error->message); + return; + } + return; +} + +static void _destroy_grid_button(void *arg) +{ + grid_button_t *grid_button = (grid_button_t *)arg; + if(grid_button) { + if(grid_button->button) { + gtk_widget_destroy(grid_button->button); + grid_button->button = NULL; + } + xfree(grid_button); + } +} + +extern void add_button_to_grid_table(GtkTable *table, char *name, int color) +{ + +} + +extern void change_grid_color(GtkTable *table, int start, int end, + int color_inx) +{ +/* char temp[255]; */ + ListIterator itr = list_iterator_create(grid_button_list); + grid_button_t *grid_button = NULL; + uint16_t node_base_state; + GdkColor color; + while((grid_button = list_next(itr))) { + if ((grid_button->indecies < start) + || (grid_button->indecies > end)) + continue; + node_base_state = grid_button->state & NODE_STATE_BASE; + if ((node_base_state == NODE_STATE_DOWN) + || (grid_button->state & NODE_STATE_DRAIN)) + continue; + + color_inx %= sview_colors_cnt; + gdk_color_parse(sview_colors[color_inx], &color); + gtk_widget_modify_bg(grid_button->button, + GTK_STATE_NORMAL, &color); + } + list_iterator_destroy(itr); + return; +} + +extern void set_grid_size(GtkTable *table, int node_cnt) +{ + int y=0, x=0; + // FIX ME!!!! these are bad values +#ifndef HAVE_BG + x=20; + y = node_cnt/20; + if(y < 1) + y=1; +#else +#endif + gtk_table_resize(table, y, x); + +} + +extern int get_system_stats() +{ + int error_code = SLURM_SUCCESS; + node_info_msg_t *node_info_ptr = NULL; + int x=0, table_x=0, table_y=0; + int coord_x=0, coord_y=0, i=0; + grid_button_t *grid_button = NULL; +/* GtkWidget *event_box = NULL; */ + GdkColor color; + GError *error = NULL; + +#ifdef HAVE_BG + int y=0, z=0; +#endif + if((error_code = get_new_info_node(&node_info_ptr, force_refresh)) + == SLURM_NO_CHANGE_IN_DATA) { + goto update_it; + } + if (error_code != SLURM_SUCCESS) { + printf("slurm_load_node: %s\n", slurm_strerror(error_code)); + return SLURM_ERROR; + } +update_it: + ba_init(node_info_ptr); + if(grid_button_list) + return SLURM_SUCCESS; + grid_button_list = list_create(_destroy_grid_button); +#ifndef HAVE_BG + if(DIM_SIZE[X] < 50) { + table_x = 1; + table_y = DIM_SIZE[X]; + } else if(DIM_SIZE[X] < 500) { + table_x = DIM_SIZE[X]; + table_y = 1; + } else { + table_x=20; + table_y = DIM_SIZE[X]/20; + if(table_y < 1) + table_y=1; + else + table_y++; + } +#else + if(DIM_SIZE[X] < 12) { + table_x = DIM_SIZE[X]; + table_y = 1; + } else { + table_x=12; + table_y = DIM_SIZE[X]/12; + if(table_y < 1) + table_y=1; + else + table_y++; + } +#endif + gtk_table_resize(main_grid_table, table_y, table_x); + gdk_color_parse("red", &color); + + for (x=0; x<DIM_SIZE[X]; x++) { +#ifdef HAVE_BG + for (y=0; y<DIM_SIZE[Y]; y++) { + for (z=0; z<DIM_SIZE[Z]; z++){ + grid_button = xmalloc(sizeof(grid_button_t)); + grid_button->coord[X] = x; + grid_button->coord[Y] = y; + grid_button->coord[Z] = z; + grid_button->indecies = i++; + grid_button->button = gtk_button_new(); + list_push(grid_button_list, grid_button); + /* FIXME! we need to make sure this + gets laid out correctly on Bluegene + systems. */ + } + } +#else + grid_button = xmalloc(sizeof(grid_button_t)); + grid_button->coord[X] = x; + grid_button->indecies = i++; + grid_button->button = gtk_button_new(); + gtk_widget_set_size_request(grid_button->button, 10, 10); + gtk_widget_modify_fg(grid_button->button, + GTK_STATE_NORMAL, &color); + g_signal_connect(G_OBJECT(grid_button->button), + "button-press-event", + G_CALLBACK(_open_node), + grid_button); + list_push(grid_button_list, grid_button); + gtk_table_attach(main_grid_table, grid_button->button, + coord_x, (coord_x+1), coord_y, (coord_y+1), + GTK_SHRINK, GTK_SHRINK, + 1, 1); + + coord_x++; + if(coord_x == table_x) { + coord_x = 0; + coord_y++; + } + if(coord_y == table_y) + break; +#endif + } + if (!g_thread_create(_blink_thr, NULL, FALSE, &error)) + { + g_printerr ("Failed to create page thread: %s\n", + error->message); + return SLURM_ERROR; + } + return SLURM_SUCCESS; +} + +extern void sview_init_grid() +{ + node_info_msg_t *node_info_ptr = NULL; + int error_code = SLURM_SUCCESS; + node_info_t *node_ptr = NULL; + int i = 0; + uint16_t node_base_state; + ListIterator itr = NULL; + grid_button_t *grid_button = NULL; + GdkColor color; + GdkColor color2; + + if((error_code = get_new_info_node(&node_info_ptr, force_refresh)) + == SLURM_NO_CHANGE_IN_DATA) { + return; + } + if (error_code != SLURM_SUCCESS) { + g_print("slurm_load_node: %s\n", slurm_strerror(error_code)); + return; + } + if(!grid_button_list) { + g_print("you need to run get_system_stats() first\n"); + exit(0); + } + + gdk_color_parse("black", &color); + gdk_color_parse("white", &color2); + + itr = list_iterator_create(grid_button_list); + for(i=0; i<node_info_ptr->record_count; i++) { + node_ptr = &node_info_ptr->node_array[i]; + list_iterator_reset(itr); + while((grid_button = list_next(itr))) { + if (grid_button->indecies != i) + continue; + node_base_state = node_ptr->node_state + & NODE_STATE_BASE; + if ((node_base_state == NODE_STATE_DOWN) || + (node_ptr->node_state & NODE_STATE_DRAIN)) { + gtk_widget_modify_bg(grid_button->button, + GTK_STATE_NORMAL, &color); + } else + gtk_widget_modify_bg(grid_button->button, + GTK_STATE_NORMAL, &color2); + grid_button->state = node_ptr->node_state; + break; + } + } + list_iterator_destroy(itr); +} + +extern void sview_reset_grid() +{ + grid_button_t *grid_button = NULL; + uint16_t node_base_state; + ListIterator itr = NULL; + GdkColor color; + + if(!grid_button_list) { + g_print("you need to run get_system_stats() first\n"); + exit(0); + } + gdk_color_parse("white", &color); + + itr = list_iterator_create(grid_button_list); + while((grid_button = list_next(itr))) { + node_base_state = grid_button->state & NODE_STATE_BASE; + if ((node_base_state == NODE_STATE_DOWN) + || (grid_button->state & NODE_STATE_DRAIN)) + continue; + gtk_widget_modify_bg(grid_button->button, + GTK_STATE_NORMAL, &color); + } + list_iterator_destroy(itr); +} diff --git a/src/sview/job_info.c b/src/sview/job_info.c index f1a408bb662165ac61303a43a1d613c4a251916a..1d504933a13d038cad53ec033ffca2d0a5ac1361 100644 --- a/src/sview/job_info.c +++ b/src/sview/job_info.c @@ -84,7 +84,7 @@ enum { static display_data_t display_data_job[] = { {G_TYPE_INT, SORTID_POS, NULL, FALSE, -1, refresh_job, create_model_job, admin_edit_job}, - {G_TYPE_STRING, SORTID_ACTION, "Action", TRUE, 0, refresh_job, + {G_TYPE_STRING, SORTID_ACTION, "Action", FALSE, 0, refresh_job, create_model_job, admin_edit_job}, {G_TYPE_INT, SORTID_JOBID, "JobID", TRUE, -1, refresh_job, create_model_job, admin_edit_job}, @@ -663,7 +663,6 @@ static void _update_info_step(job_step_info_response_msg_t *step_info_ptr, while(1) { gtk_tree_model_get(model, step_iter, SORTID_UPDATED, &i, -1); - g_print("updated is %d\n", i); if(!i) { if(!gtk_tree_store_remove( GTK_TREE_STORE(model), @@ -1379,7 +1378,10 @@ extern void get_info_job(GtkTable *table, display_data_t *display_data) GtkWidget *label = NULL; GtkTreeView *tree_view = NULL; static GtkWidget *display_widget = NULL; - + int changed = 1; + int j=0, i=0; + job_info_t *job_ptr = NULL; + if(display_data) local_display_data = display_data; if(!table) { @@ -1418,7 +1420,7 @@ get_steps: if((!display_widget || view == ERROR_VIEW) || (job_error_code != SLURM_NO_CHANGE_IN_DATA)) goto display_it; - + changed = 0; goto update_it; } @@ -1437,6 +1439,7 @@ get_steps: goto end_it; } display_it: + if(view == ERROR_VIEW && display_widget) { gtk_widget_destroy(display_widget); display_widget = NULL; @@ -1456,6 +1459,19 @@ display_it: } update_it: + /* set up the grid */ + for (i = 0; i < job_info_ptr->record_count; i++) { + job_ptr = &job_info_ptr->job_array[i]; + j=0; + while(job_ptr->node_inx[j] >= 0) { + change_grid_color(main_grid_table, + job_ptr->node_inx[j], + job_ptr->node_inx[j+1], + i); + j += 2; + } + } + view = INFO_VIEW; _update_info_job(job_info_ptr, step_info_ptr, GTK_TREE_VIEW(display_widget), NULL); diff --git a/src/sview/part_info.c b/src/sview/part_info.c index 5240446b90422cc28ff81c632bcf4ee02e5b2d10..da0383e31960ee821c3bcb2c490912b9625dacc8 100644 --- a/src/sview/part_info.c +++ b/src/sview/part_info.c @@ -1376,7 +1376,11 @@ extern void get_info_part(GtkTable *table, display_data_t *display_data) static GtkWidget *display_widget = NULL; List info_list = NULL; int changed = 1; - + int j=0, i=0; + sview_part_info_t *sview_part_info = NULL; + partition_info_t *part_ptr = NULL; + ListIterator itr = NULL; + if(display_data) local_display_data = display_data; if(!table) { @@ -1439,7 +1443,27 @@ display_it: info_list = _create_info_list(part_info_ptr, node_info_ptr, changed); if(!info_list) return; - + else if(changed) { + int j=0, i=0; + sview_part_info_t *sview_part_info = NULL; + partition_info_t *part_ptr = NULL; + + ListIterator itr = list_iterator_create(info_list); + while ((sview_part_info = list_next(itr))) { + part_ptr = sview_part_info->part_ptr; + j=0; + while(part_ptr->node_inx[j] >= 0) { + change_grid_color(main_grid_table, + part_ptr->node_inx[j], + part_ptr->node_inx[j+1], + i); + j += 2; + } + i++; + } + list_iterator_destroy(itr); + } + if(view == ERROR_VIEW && display_widget) { gtk_widget_destroy(display_widget); display_widget = NULL; @@ -1457,6 +1481,21 @@ display_it: create_treestore(tree_view, display_data_part, SORTID_CNT); } view = INFO_VIEW; + /* set up the grid */ + itr = list_iterator_create(info_list); + while ((sview_part_info = list_next(itr))) { + part_ptr = sview_part_info->part_ptr; + j=0; + while(part_ptr->node_inx[j] >= 0) { + change_grid_color(main_grid_table, + part_ptr->node_inx[j], + part_ptr->node_inx[j+1], + i); + j += 2; + } + i++; + } + list_iterator_destroy(itr); _update_info_part(info_list, GTK_TREE_VIEW(display_widget), NULL); end_it: toggled = FALSE; @@ -1584,6 +1623,7 @@ extern void set_menus_part(void *arg, GtkTreePath *path, { GtkTreeView *tree_view = (GtkTreeView *)arg; popup_info_t *popup_win = (popup_info_t *)arg; + switch(type) { case TAB_CLICKED: make_fields_menu(menu, display_data_part); diff --git a/src/sview/popups.c b/src/sview/popups.c index ca0e26d7175fcda80a89ca5349a5e5bd1fd383d8..76e16803b897bc25d15f5028ee2b2ed6616851be 100644 --- a/src/sview/popups.c +++ b/src/sview/popups.c @@ -48,6 +48,31 @@ void *_refresh_thr(gpointer arg) gdk_threads_leave(); return NULL; } +static gboolean _delete_popup(GtkWidget *widget, + GtkWidget *event, + gpointer data) +{ + gtk_widget_destroy(widget); + return FALSE; +} + +void *_local_popup_thr(GtkWidget *popup) +{ + int response = 0; + + gdk_threads_enter(); + response = gtk_dialog_run(GTK_DIALOG(popup)); + gdk_flush(); + gdk_threads_leave(); + + if (response == GTK_RESPONSE_OK) + { + + } + + gtk_widget_destroy(popup); + return NULL; +} /* Creates a tree model containing the completions */ void _search_entry(GtkEntry *entry, GtkComboBox *combo) @@ -417,19 +442,23 @@ extern void create_config_popup(GtkToggleAction *action, gpointer user_data) { GtkWidget *popup = gtk_dialog_new_with_buttons( "SLURM Config Info", - GTK_WINDOW (user_data), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_WINDOW(user_data), + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - int error_code; - int response = 0; GtkTreeStore *treestore = _local_create_treestore_2cols(popup, 600, 400); static slurm_ctl_conf_info_msg_t *old_slurm_ctl_conf_ptr = NULL; slurm_ctl_conf_info_msg_t *slurm_ctl_conf_ptr = NULL; + g_signal_connect(G_OBJECT(popup), "delete_event", + G_CALLBACK(_delete_popup), NULL); + g_signal_connect(G_OBJECT(popup), "response", + G_CALLBACK(_delete_popup), NULL); + + if (old_slurm_ctl_conf_ptr) { error_code = slurm_load_ctl_conf( old_slurm_ctl_conf_ptr->last_update, @@ -449,15 +478,7 @@ extern void create_config_popup(GtkToggleAction *action, gpointer user_data) gtk_widget_show_all(popup); - response = gtk_dialog_run(GTK_DIALOG(popup)); - if (response == GTK_RESPONSE_OK) - { - - } - - gtk_widget_destroy(popup); - return; } @@ -466,12 +487,11 @@ extern void create_daemon_popup(GtkToggleAction *action, gpointer user_data) GtkWidget *popup = gtk_dialog_new_with_buttons( "SLURM Daemons running", GTK_WINDOW(user_data), - GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); - int response = 0; int update = 0; slurm_ctl_conf_info_msg_t *conf; char me[MAX_SLURM_NAME], *b, *c, *n; @@ -479,6 +499,10 @@ extern void create_daemon_popup(GtkToggleAction *action, gpointer user_data) GtkTreeStore *treestore = _local_create_treestore_2cols(popup, 300, 100); GtkTreeIter iter; + g_signal_connect(G_OBJECT(popup), "delete_event", + G_CALLBACK(_delete_popup), NULL); + g_signal_connect(G_OBJECT(popup), "response", + G_CALLBACK(_delete_popup), NULL); slurm_conf_init(NULL); conf = slurm_conf_lock(); @@ -513,15 +537,7 @@ extern void create_daemon_popup(GtkToggleAction *action, gpointer user_data) gtk_widget_show_all(popup); - response = gtk_dialog_run(GTK_DIALOG(popup)); - - if (response == GTK_RESPONSE_OK) - { - } - - gtk_widget_destroy(popup); - return; } diff --git a/src/sview/sview.c b/src/sview/sview.c index a3006cdbf536dde11b5f930dc3b0a5fca407f7eb..a59d678a8e357562f8cb80090f2ff7cda5279627 100644 --- a/src/sview/sview.c +++ b/src/sview/sview.c @@ -57,6 +57,8 @@ bool admin_mode = FALSE; GtkWidget *main_notebook = NULL; GtkWidget *main_statusbar = NULL; GtkWidget *main_window = NULL; +GtkWidget *grid_window = NULL; +GtkTable *main_grid_table = NULL; GStaticMutex sview_mutex = G_STATIC_MUTEX_INIT; display_data_t main_display_data[] = { @@ -108,9 +110,12 @@ void *_page_thr(void *arg) display_data_t *display_data = &main_display_data[num]; xfree(page); + sview_reset_grid(); + while(page_running[num]) { g_static_mutex_lock(&sview_mutex); gdk_threads_enter(); + sview_init_grid(); (display_data->get_info)(table, display_data); gdk_flush(); gdk_threads_leave(); @@ -197,6 +202,21 @@ static void _set_admin_mode(GtkToggleAction *action) } } +static void _set_grid(GtkToggleAction *action) +{ + static bool open = TRUE; + + if(open) { + gtk_widget_hide(grid_window); + open = FALSE; + } else { + gtk_widget_show(grid_window); + open = TRUE; + } + + return; +} + static void _tab_pos(GtkRadioAction *action, GtkRadioAction *extra, @@ -239,6 +259,7 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) "<ui>" " <menubar name='main'>" " <menu action='options'>" + " <menuitem action='grid'/>" " <menuitem action='interval'/>" " <menuitem action='refresh'/>" " <separator/>" @@ -305,6 +326,9 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) }; GtkToggleActionEntry toggle_entries[] = { + {"grid", NULL, "Show _Grid", + "<control>g", "Visual display of cluster", + G_CALLBACK(_set_grid)}, {"admin", NULL, "_Admin Mode", "<control>a", "Allows user to change or update information", @@ -346,27 +370,77 @@ void *_popup_thr_main(void *arg) return NULL; } +extern void refresh_main(GtkAction *action, gpointer user_data) +{ + int page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_notebook)); + if(page == -1) + g_error("no pages in notebook for refresh\n"); + force_refresh = 1; + _page_switched(GTK_NOTEBOOK(main_notebook), NULL, page, NULL); +} + +extern void tab_pressed(GtkWidget *widget, GdkEventButton *event, + const display_data_t *display_data) +{ + /* single click with the right mouse button? */ + gtk_notebook_set_current_page(GTK_NOTEBOOK(main_notebook), + display_data->extra); + if(event->button == 3) { + right_button_pressed(NULL, NULL, event, + display_data, TAB_CLICKED); + } +} + int main(int argc, char *argv[]) { GtkWidget *menubar = NULL; GtkWidget *table = NULL; - GtkWidget *button = NULL; +/* GtkWidget *button = NULL; */ + GtkBin *bin = NULL; + GtkViewport *view = NULL; int i=0; + _init_pages(); g_thread_init(NULL); gdk_threads_init(); gdk_threads_enter(); /* Initialize GTK */ gtk_init (&argc, &argv); + /* make sure the system is up */ + grid_window = GTK_WIDGET(create_scrolled_window()); + bin = GTK_BIN(>K_SCROLLED_WINDOW(grid_window)->container); + view = GTK_VIEWPORT(bin->child); + bin = GTK_BIN(&view->bin); + main_grid_table = GTK_TABLE(bin->child); + gtk_table_set_homogeneous(main_grid_table, TRUE); + while(get_system_stats() != SLURM_SUCCESS) + sleep(10); +#ifdef HAVE_BG + gtk_widget_set_size_request(grid_window, 164, -1); +#else + if(DIM_SIZE[X] < 50) { + gtk_widget_set_size_request(grid_window, 54, -1); + gtk_table_set_row_spacing(main_grid_table, 9, 5); + } else if(DIM_SIZE[X] < 500) { + gtk_widget_set_size_request(grid_window, 162, -1); + gtk_table_set_row_spacing(main_grid_table, 9, 5); + } else { + gtk_widget_set_size_request(grid_window, 287, -1); + gtk_table_set_col_spacing(main_grid_table, 9, 5); + gtk_table_set_row_spacing(main_grid_table, 9, 5); + } + +#endif /* fill in all static info for pages */ /* Make a window */ main_window = gtk_dialog_new(); g_signal_connect(G_OBJECT(main_window), "delete_event", G_CALLBACK(_delete), NULL); + gtk_window_set_title(GTK_WINDOW(main_window), "Sview"); - gtk_window_set_default_size(GTK_WINDOW(main_window), 600, 400); + gtk_window_set_default_size(GTK_WINDOW(main_window), 700, 450); gtk_container_set_border_width( GTK_CONTAINER(GTK_DIALOG(main_window)->vbox), 1); /* Create the main notebook, place the position of the tabs */ @@ -381,16 +455,16 @@ int main(int argc, char *argv[]) menubar = _get_menubar_menu(main_window, main_notebook); gtk_table_attach_defaults(GTK_TABLE(table), menubar, 0, 1, 0, 1); - /*create search button */ - button = gtk_button_new_with_label("Search"); - g_signal_connect(G_OBJECT(button), - "pressed", - G_CALLBACK(create_search_popup), - main_window); + /* create search button */ +/* button = gtk_button_new_with_label("Search"); */ +/* g_signal_connect(G_OBJECT(button), */ +/* "pressed", */ +/* G_CALLBACK(create_search_popup), */ +/* main_window); */ - gtk_table_attach(GTK_TABLE(table), button, 1, 2, 0, 1, - GTK_SHRINK, GTK_EXPAND | GTK_FILL, - 0, 0); +/* gtk_table_attach(GTK_TABLE(table), button, 1, 2, 0, 1, */ +/* GTK_SHRINK, GTK_EXPAND | GTK_FILL, */ +/* 0, 0); */ gtk_notebook_popup_enable(GTK_NOTEBOOK(main_notebook)); gtk_notebook_set_scrollable(GTK_NOTEBOOK(main_notebook), TRUE); @@ -402,8 +476,16 @@ int main(int argc, char *argv[]) /* Pack it all together */ gtk_box_pack_start(GTK_BOX(GTK_DIALOG(main_window)->vbox), table, FALSE, FALSE, 0); + table = gtk_table_new(1, 2, FALSE); + + gtk_table_attach(GTK_TABLE(table), grid_window, 0, 1, 0, 1, + GTK_SHRINK, GTK_EXPAND | GTK_FILL, + 0, 0); + gtk_table_attach_defaults(GTK_TABLE(table), main_notebook, 1, 2, 0, 1); + + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(main_window)->vbox), - main_notebook, TRUE, TRUE, 0); + table, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(main_window)->vbox), main_statusbar, FALSE, FALSE, 0); @@ -418,7 +500,7 @@ int main(int argc, char *argv[]) /* tell signal we are done adding */ adding = 0; popup_list = list_create(destroy_popup_info); - gtk_widget_show_all (main_window); + gtk_widget_show_all(main_window); /* Finished! */ gtk_main (); @@ -427,24 +509,3 @@ int main(int argc, char *argv[]) return 0; } -extern void refresh_main(GtkAction *action, gpointer user_data) -{ - int page = gtk_notebook_get_current_page(GTK_NOTEBOOK(main_notebook)); - if(page == -1) - g_error("no pages in notebook for refresh\n"); - force_refresh = 1; - _page_switched(GTK_NOTEBOOK(main_notebook), NULL, page, NULL); -} - -extern void tab_pressed(GtkWidget *widget, GdkEventButton *event, - const display_data_t *display_data) -{ - /* single click with the right mouse button? */ - gtk_notebook_set_current_page(GTK_NOTEBOOK(main_notebook), - display_data->extra); - if(event->button == 3) { - right_button_pressed(NULL, NULL, event, - display_data, TAB_CLICKED); - } -} - diff --git a/src/sview/sview.h b/src/sview/sview.h index fe20f1a7d2ba7415e9f0c9c073cdf82c68ea5860..7950bd7cd4bb3d3fe4f6a060b99ba4282a6bd13e 100644 --- a/src/sview/sview.h +++ b/src/sview/sview.h @@ -162,7 +162,6 @@ struct popup_info { bool not_found; GtkWidget *popup; GtkWidget *event_box; - GtkWidget *button; GtkTable *table; specific_info_t *spec_info; display_data_t *display_data; @@ -187,6 +186,7 @@ extern int global_sleep_time; extern bool admin_mode; extern GtkWidget *main_statusbar; extern GtkWidget *main_window; +extern GtkTable *main_grid_table; extern GStaticMutex sview_mutex; extern void init_grid(node_info_msg_t *node_info_ptr); @@ -209,6 +209,14 @@ extern void create_daemon_popup(GtkToggleAction *action, gpointer user_data); extern void create_search_popup(GtkToggleAction *action, gpointer user_data); extern void change_refresh_popup(GtkToggleAction *action, gpointer user_data); +//grid.c +extern void add_button_to_grid_table(GtkTable *table, char *name, int color); +extern void change_grid_color(GtkTable *table, int start_inx, int end_inx, + int color_inx); +extern void set_grid_size(GtkTable *table, int node_cnt); +extern int get_system_stats(); +extern void sview_init_grid(); +extern void sview_reset_grid(); // part_info.c extern void refresh_part(GtkAction *action, gpointer user_data);