diff --git a/NEWS b/NEWS index e1a528a45e482f42d07e9ec87e01986fc03d52a8..e1f8cc3191646467308808f9f19b7be41913a52b 100644 --- a/NEWS +++ b/NEWS @@ -4,6 +4,7 @@ documents those changes that are of interest to users and admins. * Changes in SLURM 2.1.0-pre10 ============================= -- Improve sview layout of blocks in use. + -- A user can not change the dimensions of the grid in sview. * Changes in SLURM 2.1.0-pre9 ============================= diff --git a/src/sview/grid.c b/src/sview/grid.c index 6c1c4c41fd334d99bed9db8bd4cc83d282236205..44c2bad10fee2a2e1e56f575c9dd0e41a4db08cd 100644 --- a/src/sview/grid.c +++ b/src/sview/grid.c @@ -776,7 +776,7 @@ extern void add_extra_cr_buttons(List *button_list, node_info_t *node_ptr) extern void put_buttons_in_table(GtkTable *table, List button_list) { - int table_x=0, table_y=0; + int table_y=0; #ifndef HAVE_3D int coord_x=0, coord_y=0; #endif @@ -788,21 +788,23 @@ extern void put_buttons_in_table(GtkTable *table, List button_list) #ifdef HAVE_3D node_count = DIM_SIZE[X]; - table_x = DIM_SIZE[X] + DIM_SIZE[Z]; + global_x_width = DIM_SIZE[X] + DIM_SIZE[Z]; table_y = (DIM_SIZE[Z] * DIM_SIZE[Y]) + DIM_SIZE[Y]; #else - if(node_count < 50) { - table_x = 1; - } else if(node_count < 500) { - table_x = 10; - } else { - table_x=20; + if(!global_x_width) { + if(node_count < 50) { + global_x_width = 1; + } else if(node_count < 500) { + global_x_width = 10; + } else { + global_x_width=20; + } } - table_y = node_count/table_x; + table_y = node_count/global_x_width; table_y++; #endif - //g_print("the table size is y=%d x=%d\n", table_y, table_x); - gtk_table_resize(table, table_y, table_x); + //g_print("the table size is y=%d x=%d\n", table_y, global_x_width); + gtk_table_resize(table, table_y, global_x_width); itr = list_iterator_create(button_list); while((grid_button = list_next(itr))) { #ifdef HAVE_3D @@ -828,24 +830,18 @@ extern void put_buttons_in_table(GtkTable *table, List button_list) coord_x++; - if(coord_x == table_x) { + if(coord_x == global_x_width) { coord_x = 0; coord_y++; - if(!(coord_y%10)) { - gtk_table_set_row_spacing( - table, coord_y-1, 5); - } - + if(!(coord_y % global_vertical)) + gtk_table_set_row_spacing(table, coord_y-1, 5); } if(coord_y == table_y) break; - if(coord_x && !(coord_x%10)) { - gtk_table_set_col_spacing(table, - coord_x-1, - 5); - } + if(coord_x && !(coord_x % global_horizontal)) + gtk_table_set_col_spacing(table, coord_x-1, 5); #endif } list_iterator_destroy(itr); @@ -853,6 +849,128 @@ extern void put_buttons_in_table(GtkTable *table, List button_list) gtk_widget_show_all(GTK_WIDGET(table)); } +extern int update_grid_table(GtkTable *table, List button_list, List node_list) +{ + int error_code = SLURM_SUCCESS; + int coord_x=0, coord_y=0, inx=0, table_y = 0; + grid_button_t *grid_button = NULL; + int node_count = 0; + ListIterator itr = NULL, itr2 = NULL; + sview_node_info_t *sview_node_info_ptr = NULL; +#ifdef HAVE_3D + int default_y_offset= (DIM_SIZE[Z] * DIM_SIZE[Y]) + + (DIM_SIZE[Y] - DIM_SIZE[Z]); + node_count = DIM_SIZE[X]; + global_x_width = DIM_SIZE[X] + DIM_SIZE[Z]; + table_y = (DIM_SIZE[Z] * DIM_SIZE[Y]) + DIM_SIZE[Y]; +#else + node_count = list_count(node_list); + if(!global_x_width) { + if(node_count < 50) { + global_x_width = 1; + } else if(node_count < 500) { + global_x_width = 10; + } else { + global_x_width = 20; + } + } + table_y = node_count/global_x_width; + table_y++; +#endif + + if(!node_list) { + g_print("setup_grid_table: no node_list given\n"); + return SLURM_ERROR; + } + + gtk_table_resize(table, table_y, global_x_width); + gtk_table_set_row_spacings(table, 0); + gtk_table_set_col_spacings(table, 0); + itr = list_iterator_create(node_list); + itr2 = list_iterator_create(button_list); + while((sview_node_info_ptr = list_next(itr))) { + int found = 0; + again: + while((grid_button = list_next(itr2))) { + if(grid_button->inx != inx) + continue; + found = 1; +#ifdef HAVE_3D + int i = strlen(sview_node_info_ptr->node_ptr->name); + int x=0, y=0, z=0, y_offset=0; + /* On 3D system we need to translate a 3D space to + a 2D space and make it appear 3D. So we get the + coords of each node in xyz format and apply an x + and y offset to get a coord_x and coord_y. This is + not needed for linear systems since they can be + laid out in any fashion + */ + if (i < 4) { + g_error("bad node name %s\n", + sview_node_info_ptr->node_ptr->name); + goto end_it; + } else { + x = _coord(sview_node_info_ptr-> + node_ptr->name[i-3]); + y = _coord(sview_node_info_ptr-> + node_ptr->name[i-2]); + z = _coord(sview_node_info_ptr-> + node_ptr->name[i-1]); + } + coord_x = (x + (DIM_SIZE[Z] - 1)) - z; + + y_offset = default_y_offset - (DIM_SIZE[Z] * y); + coord_y = (y_offset - y) + z; +#endif + grid_button->table_x = coord_x; + grid_button->table_y = coord_y; + gtk_container_child_set(GTK_CONTAINER(table), + grid_button->button, + "left-attach", coord_x, + "right-attach", (coord_x+1), + "top-attach", coord_y, + "bottom-attach", (coord_y+1), + NULL); +#ifndef HAVE_3D + /* On linear systems we just up the x_coord until we + hit the side of the table and then incrememnt the + coord_y. We add space inbetween each 10th row. + */ + coord_x++; + if(coord_x == global_x_width) { + coord_x = 0; + coord_y++; + if(!(coord_y % global_vertical)) + gtk_table_set_row_spacing(table, + coord_y-1, 5); + } + + if(coord_y == table_y) + break; + + if(coord_x && !(coord_x%global_horizontal)) + gtk_table_set_col_spacing(table, coord_x-1, 5); +#endif + break; + } + if(!found) { + list_iterator_reset(itr2); + goto again; + } + inx++; + } +#ifdef HAVE_3D + /* This is needed to get the correct width of the grid + window. If it is not given then we get a really narrow + window. */ + gtk_table_set_row_spacing(table, coord_y-1, 1); +end_it: +#endif + list_iterator_destroy(itr); + list_iterator_destroy(itr2); + return error_code; +} + extern int get_system_stats(GtkTable *table) { int error_code = SLURM_SUCCESS; @@ -879,11 +997,15 @@ extern int get_system_stats(GtkTable *table) } ba_init(node_info_ptr, 0); - if(grid_button_list) - return SLURM_SUCCESS; - grid_button_list = list_create(destroy_grid_button); + node_list = create_node_info_list(node_info_ptr, changed); - setup_grid_table(main_grid_table, grid_button_list, node_list); + + if(grid_button_list) + update_grid_table(main_grid_table, grid_button_list, node_list); + else { + grid_button_list = list_create(destroy_grid_button); + setup_grid_table(main_grid_table, grid_button_list, node_list); + } gtk_widget_show_all(GTK_WIDGET(main_grid_table)); @@ -893,29 +1015,29 @@ extern int get_system_stats(GtkTable *table) extern int setup_grid_table(GtkTable *table, List button_list, List node_list) { int error_code = SLURM_SUCCESS; - int table_x=0, table_y=0; - int coord_x=0, coord_y=0, inx=0; + int coord_x=0, coord_y=0, inx=0, table_y = 0; grid_button_t *grid_button = NULL; int node_count = 0; ListIterator itr = NULL; sview_node_info_t *sview_node_info_ptr = NULL; - #ifdef HAVE_3D int default_y_offset= (DIM_SIZE[Z] * DIM_SIZE[Y]) + (DIM_SIZE[Y] - DIM_SIZE[Z]); node_count = DIM_SIZE[X]; - table_x = DIM_SIZE[X] + DIM_SIZE[Z]; + global_x_width = DIM_SIZE[X] + DIM_SIZE[Z]; table_y = (DIM_SIZE[Z] * DIM_SIZE[Y]) + DIM_SIZE[Y]; #else node_count = list_count(node_list); - if(node_count < 50) { - table_x = 1; - } else if(node_count < 500) { - table_x = 10; - } else { - table_x=20; + if(!global_x_width) { + if(node_count < 50) { + global_x_width = 1; + } else if(node_count < 500) { + global_x_width = 10; + } else { + global_x_width = 20; + } } - table_y = node_count/table_x; + table_y = node_count/global_x_width; table_y++; #endif @@ -924,7 +1046,7 @@ extern int setup_grid_table(GtkTable *table, List button_list, List node_list) return SLURM_ERROR; } - gtk_table_resize(table, table_y, table_x); + gtk_table_resize(table, table_y, global_x_width); itr = list_iterator_create(node_list); while((sview_node_info_ptr = list_next(itr))) { #ifdef HAVE_3D @@ -982,17 +1104,17 @@ extern int setup_grid_table(GtkTable *table, List button_list, List node_list) coord_y. We add space inbetween each 10th row. */ coord_x++; - if(coord_x == table_x) { + if(coord_x == global_x_width) { coord_x = 0; coord_y++; - if(!(coord_y%10)) + if(!(coord_y % global_vertical)) gtk_table_set_row_spacing(table, coord_y-1, 5); } if(coord_y == table_y) break; - if(coord_x && !(coord_x%10)) + if(coord_x && !(coord_x % global_horizontal)) gtk_table_set_col_spacing(table, coord_x-1, 5); #endif } diff --git a/src/sview/node_info.c b/src/sview/node_info.c index 4c69293bad69b9fe03063b57da54c465c786ab4c..7263ed0496e4d916a2c41be169775a2b17242a0b 100644 --- a/src/sview/node_info.c +++ b/src/sview/node_info.c @@ -496,11 +496,10 @@ extern List create_node_info_list(node_info_msg_t *node_info_ptr, int changed) goto update_color; } - if(info_list) { - list_destroy(info_list); - } - - info_list = list_create(_node_info_list_del); + if(info_list) + list_flush(info_list); + else + info_list = list_create(_node_info_list_del); if (!info_list) { g_print("malloc error\n"); return NULL; diff --git a/src/sview/popups.c b/src/sview/popups.c index d76b40782446a527495e105a26e479905334cb9f..ee2b5a21e52655bf0ce2c1bba3ce325435b0878a 100644 --- a/src/sview/popups.c +++ b/src/sview/popups.c @@ -574,7 +574,7 @@ extern void change_refresh_popup(GtkAction *action, gpointer user_data) GtkObject *adjustment = gtk_adjustment_new(global_sleep_time, 1, 10000, 5, 60, - 1); + 0); GtkWidget *spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); GtkWidget *popup = gtk_dialog_new_with_buttons( @@ -605,8 +605,7 @@ extern void change_refresh_popup(GtkAction *action, gpointer user_data) gtk_widget_show_all(popup); response = gtk_dialog_run (GTK_DIALOG(popup)); - if (response == GTK_RESPONSE_OK) - { + if (response == GTK_RESPONSE_OK) { global_sleep_time = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(spin_button)); @@ -619,8 +618,96 @@ extern void change_refresh_popup(GtkAction *action, gpointer user_data) temp); g_free(temp); if (!g_thread_create(_refresh_thr, GINT_TO_POINTER(response), - FALSE, &error)) - { + FALSE, &error)) { + g_printerr ("Failed to create refresh thread: %s\n", + error->message); + } + } + + gtk_widget_destroy(popup); + + return; +} + +extern void change_grid_popup(GtkAction *action, gpointer user_data) +{ + GtkWidget *table = gtk_table_new(1, 2, FALSE); + GtkWidget *label; + GtkObject *adjustment; + GtkWidget *width_sb, *hori_sb, *vert_sb; + int width = global_x_width, hori = global_horizontal, + vert = global_vertical; + GtkWidget *popup = gtk_dialog_new_with_buttons( + "Grid Properties", + GTK_WINDOW (user_data), + GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, + NULL); + GError *error = NULL; + int response = 0; + char *temp = NULL; + + label = gtk_dialog_add_button(GTK_DIALOG(popup), + GTK_STOCK_OK, GTK_RESPONSE_OK); + gtk_window_set_default(GTK_WINDOW(popup), label); + gtk_dialog_add_button(GTK_DIALOG(popup), + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(popup)->vbox), + table, FALSE, FALSE, 0); + + label = gtk_label_new("Nodes in row "); + adjustment = gtk_adjustment_new(global_x_width, 1, 1000, 1, 60, 0); + width_sb = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); + gtk_container_set_border_width(GTK_CONTAINER(table), 10); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); + gtk_table_attach_defaults(GTK_TABLE(table), width_sb, 1, 2, 0, 1); + + label = gtk_label_new("Nodes before horizontal break "); + adjustment = gtk_adjustment_new(global_horizontal, 1, 1000, 1, 60, 0); + hori_sb = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); + gtk_container_set_border_width(GTK_CONTAINER(table), 10); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); + gtk_table_attach_defaults(GTK_TABLE(table), hori_sb, 1, 2, 1, 2); + + label = gtk_label_new("Nodes before vertical break "); + adjustment = gtk_adjustment_new(global_vertical, 1, 1000, 1, 60, 0); + vert_sb = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); + gtk_container_set_border_width(GTK_CONTAINER(table), 10); + gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 2, 3); + gtk_table_attach_defaults(GTK_TABLE(table), vert_sb, 1, 2, 2, 3); + + gtk_widget_show_all(popup); + response = gtk_dialog_run (GTK_DIALOG(popup)); + + if (response == GTK_RESPONSE_OK) { + global_x_width = + gtk_spin_button_get_value_as_int( + GTK_SPIN_BUTTON(width_sb)); + global_horizontal = + gtk_spin_button_get_value_as_int( + GTK_SPIN_BUTTON(hori_sb)); + global_vertical = + gtk_spin_button_get_value_as_int( + GTK_SPIN_BUTTON(vert_sb)); + if((width == global_x_width) + && (hori == global_horizontal) + && (vert == global_vertical)) { + temp = g_strdup_printf("Grid: Nothing changed."); + } else { + temp = g_strdup_printf("Grid set to %d nodes breaks " + "at %d H and %d V.", + global_x_width, + global_horizontal, + global_vertical); + get_system_stats(main_grid_table); + } + gtk_statusbar_pop(GTK_STATUSBAR(main_statusbar), + STATUS_REFRESH); + response = gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), + STATUS_REFRESH, + temp); + g_free(temp); + if (!g_thread_create(_refresh_thr, GINT_TO_POINTER(response), + FALSE, &error)) { g_printerr ("Failed to create refresh thread: %s\n", error->message); } diff --git a/src/sview/sview.c b/src/sview/sview.c index 5722de5b688ce14912a888c36dd5dc1f9f27e9df..6e4ecf38982b7f79b005a06f5e3b07d324e97fc8 100644 --- a/src/sview/sview.c +++ b/src/sview/sview.c @@ -57,6 +57,9 @@ List popup_list = NULL; List signal_params_list = NULL; int page_running[PAGE_CNT]; int global_sleep_time = 5; +int global_x_width = 0; +int global_horizontal = 10; +int global_vertical = 10; bool admin_mode = FALSE; GtkWidget *main_notebook = NULL; GtkWidget *main_statusbar = NULL; @@ -405,6 +408,7 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) " </menu>" " <menu action='options'>" " <menuitem action='grid'/>" + " <menuitem action='grid_specs'/>" " <menuitem action='interval'/>" " <separator/>" " <menuitem action='admin'/>" @@ -493,7 +497,10 @@ static GtkWidget *_get_menubar_menu(GtkWidget *window, GtkWidget *notebook) "<control>x", "Exits Program", G_CALLBACK(_delete)}, {"help", NULL, "_Help", "<alt>h"}, {"about", GTK_STOCK_ABOUT, "A_bout", "<control>b"}, - {"manual", GTK_STOCK_HELP, "_Manual", "<control>m"} + {"manual", GTK_STOCK_HELP, "_Manual", "<control>m"}, + {"grid_specs", GTK_STOCK_EDIT, "Set Grid _Properties", + "<control>p", "Change Grid Properties", + G_CALLBACK(change_grid_popup)} }; GtkActionEntry admin_entries[] = { diff --git a/src/sview/sview.h b/src/sview/sview.h index b2d8eee0b78d905b58e37f268a881f2dde468530..05f793d233487e51a46fec901cb8b9274c281da0 100644 --- a/src/sview/sview.h +++ b/src/sview/sview.h @@ -274,6 +274,9 @@ extern List popup_list; extern List grid_button_list; extern List signal_params_list; extern int global_sleep_time; +extern int global_x_width; +extern int global_horizontal; +extern int global_vertical; extern bool admin_mode; extern GtkWidget *main_statusbar; extern GtkWidget *main_window; @@ -303,6 +306,7 @@ extern void create_config_popup(GtkAction *action, gpointer user_data); extern void create_daemon_popup(GtkAction *action, gpointer user_data); extern void create_search_popup(GtkAction *action, gpointer user_data); extern void change_refresh_popup(GtkAction *action, gpointer user_data); +extern void change_grid_popup(GtkAction *action, gpointer user_data); //grid.c extern void destroy_grid_button(void *arg);