static void _open_block(GtkWidget *widget, GdkEventButton *event, grid_button_t *grid_button) { GError *error = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; snprintf(title, 100, "Info about block containing %s", grid_button->node_name); itr = list_iterator_create(popup_list); while ((popup_win = list_next(itr))) { if (popup_win->spec_info) if (!xstrcmp(popup_win->spec_info->title, title)) { break; } } list_iterator_destroy(itr); if (!popup_win) { popup_win = create_popup_info(INFO_PAGE, BLOCK_PAGE, title); popup_win->spec_info->search_info->search_type = SEARCH_BLOCK_NODENAME; popup_win->spec_info->search_info->gchar_data = g_strdup(grid_button->node_name); if (!sview_thread_new((gpointer)popup_thr, popup_win, false, &error)) { g_printerr ("Failed to create block " "grid popup thread: %s\n", error->message); return; } } else gtk_window_present(GTK_WINDOW(popup_win->popup)); return; }
extern void popup_all_resv(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1); switch(id) { case PART_PAGE: snprintf(title, 100, "Partition(s) with reservation %s", name); break; case JOB_PAGE: snprintf(title, 100, "Job(s) in reservation %s", name); break; case NODE_PAGE: if (cluster_flags & CLUSTER_FLAG_BG) snprintf(title, 100, "Midplane(s) in reservation %s", name); else snprintf(title, 100, "Node(s) in reservation %s ", name); break; case BLOCK_PAGE: snprintf(title, 100, "Block(s) in reservation %s", name); break; case SUBMIT_PAGE: snprintf(title, 100, "Submit job in reservation %s", name); break; case INFO_PAGE: snprintf(title, 100, "Full info for reservation %s", name); break; default: g_print("resv got %d\n", id); } 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) { if (id == INFO_PAGE) popup_win = create_popup_info(id, RESV_PAGE, title); else popup_win = create_popup_info(RESV_PAGE, id, title); } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } /* Pass the model and the structs from the iter so we can always get the current node_inx. */ popup_win->model = model; popup_win->iter = *iter; popup_win->node_inx_id = SORTID_NODE_INX; switch(id) { case JOB_PAGE: case INFO_PAGE: popup_win->spec_info->search_info->gchar_data = name; //specific_info_job(popup_win); break; case BLOCK_PAGE: case NODE_PAGE: case PART_PAGE: g_free(name); gtk_tree_model_get(model, iter, SORTID_NODELIST, &name, -1); popup_win->spec_info->search_info->gchar_data = name; popup_win->spec_info->search_info->search_type = SEARCH_NODE_NAME; //specific_info_node(popup_win); break; case SUBMIT_PAGE: break; default: g_print("resv got unknown type %d\n", id); } if (!sview_thread_new((gpointer)popup_thr, popup_win, FALSE, &error)) { g_printerr ("Failed to create resv popup thread: %s\n", error->message); return; } }
extern void popup_all_front_end(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char title[100] = {0}; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1); switch (id) { case INFO_PAGE: snprintf(title, 100, "Full info for front end node %s", name); break; default: g_print("front end got %d\n", id); } itr = list_iterator_create(popup_list); while ((popup_win = list_next(itr))) { if (popup_win->spec_info) if (!xstrcmp(popup_win->spec_info->title, title)) { break; } } list_iterator_destroy(itr); if (!popup_win) { if (id == INFO_PAGE) popup_win = create_popup_info(id, FRONT_END_PAGE, title); else { popup_win = create_popup_info(FRONT_END_PAGE, id, title); } } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } /* Pass the model and the structs from the iter so we can always get * the current node_inx. */ popup_win->model = model; popup_win->iter = *iter; popup_win->node_inx_id = SORTID_NODE_INX; switch (id) { case INFO_PAGE: popup_win->spec_info->search_info->gchar_data = name; break; default: g_print("resv got unknown type %d\n", id); } if (!sview_thread_new((gpointer)popup_thr, popup_win, false, &error)) { g_printerr ("Failed to create resv popup thread: %s\n", error->message); return; } }
static void _page_switched(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer user_data) { GtkScrolledWindow *window = GTK_SCROLLED_WINDOW( gtk_notebook_get_nth_page(notebook, page_num)); if (!window) return; GtkBin *bin = GTK_BIN(&window->container); GtkViewport *view = GTK_VIEWPORT(bin->child); GtkBin *bin2 = GTK_BIN(&view->bin); GtkTable *table = GTK_TABLE(bin2->child); int i = 0; page_thr_t *page_thr = NULL; GError *error = NULL; static int started_grid_init = 0; /*set spinning cursor while loading*/ if (main_window->window && (page_num != TAB_PAGE)) gdk_window_set_cursor(main_window->window, in_process_cursor); /* make sure we aren't adding the page, and really asking for info */ if (adding) return; else if (!grid_init && !started_grid_init) { /* start the thread to make the grid only once */ if (!sview_thread_new( _grid_init_thr, notebook, false, &error)) { g_printerr ("Failed to create grid init thread: %s\n", error->message); return; } started_grid_init = 1; } if (page_running != -1) page_running = page_num; for(i=0; i<PAGE_CNT; i++) { if ((main_display_data[i].id == -1) || (main_display_data[i].extra == page_num)) break; } if (main_display_data[i].extra != page_num) return; if (main_display_data[i].get_info) { page_running = i; /* If we return here we would not clear the grid which may need to be done. */ /* if (toggled || force_refresh) { */ /* (main_display_data[i].get_info)( */ /* table, &main_display_data[i]); */ /* return; */ /* } */ page_thr = xmalloc(sizeof(page_thr_t)); page_thr->page_num = i; page_thr->table = table; if (!sview_thread_new(_page_thr, page_thr, false, &error)) { g_printerr ("Failed to create page thread: %s\n", error->message); return; } } }
/* Function to setup popup windows for Burst Buffer */ extern void popup_all_bb(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; gtk_tree_model_get(model, iter, SORTID_NAME, &name, -1); switch(id) { case INFO_PAGE: snprintf(title, 100, "Full info for Burst Buffer %s", name); break; default: g_print("Burst Buffer got %d\n", id); } itr = list_iterator_create(popup_list); while ((popup_win = list_next(itr))) { if (popup_win->spec_info) if (!xstrcmp(popup_win->spec_info->title, title)) { break; } } list_iterator_destroy(itr); if (!popup_win) { if (id == INFO_PAGE) { popup_win = create_popup_info(id, BB_PAGE, title); } else { popup_win = create_popup_info(BB_PAGE, id, title); } } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } /* Pass the model and the structs from the iter so we can always get the current node_inx. */ popup_win->model = model; popup_win->iter = *iter; /* Sets up right click information */ switch(id) { case JOB_PAGE: case INFO_PAGE: popup_win->spec_info->search_info->gchar_data = name; specific_info_bb(popup_win); break; case BLOCK_PAGE: case NODE_PAGE: case PART_PAGE: case SUBMIT_PAGE: break; default: g_print("Burst Buffer got unknown type %d\n", id); } if (!sview_thread_new((gpointer)popup_thr, popup_win, FALSE, &error)) { g_printerr ("Failed to create burst buffer popup thread: %s\n", error->message); return; } }
extern void popup_all_block(GtkTreeModel *model, GtkTreeIter *iter, int id) { char *name = NULL; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; int i=0; gtk_tree_model_get(model, iter, SORTID_BLOCK, &name, -1); switch(id) { case JOB_PAGE: snprintf(title, 100, "Jobs(s) in block %s", name); break; case PART_PAGE: snprintf(title, 100, "Partition(s) containing block %s", name); break; case RESV_PAGE: snprintf(title, 100, "Reservations(s) containing block %s", name); break; case NODE_PAGE: snprintf(title, 100, "Midplane(s) in block %s", name); break; case SUBMIT_PAGE: snprintf(title, 100, "Submit job on %s", name); break; case INFO_PAGE: snprintf(title, 100, "Full info for block %s", name); break; default: g_print("Block got %d\n", id); } itr = list_iterator_create(popup_list); while ((popup_win = list_next(itr))) { if (popup_win->spec_info) if (!xstrcmp(popup_win->spec_info->title, title)) { break; } } list_iterator_destroy(itr); if (!popup_win) { if (id == INFO_PAGE) popup_win = create_popup_info(id, BLOCK_PAGE, title); else popup_win = create_popup_info(BLOCK_PAGE, id, title); } else { g_free(name); gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } /* Pass the model and the structs from the iter so we can always get the current node_inx. */ popup_win->model = model; popup_win->iter = *iter; popup_win->node_inx_id = SORTID_NODE_INX; switch(id) { case JOB_PAGE: popup_win->spec_info->search_info->gchar_data = name; break; case PART_PAGE: g_free(name); gtk_tree_model_get(model, iter, SORTID_PARTITION, &name, -1); popup_win->spec_info->search_info->gchar_data = name; break; case RESV_PAGE: case NODE_PAGE: g_free(name); gtk_tree_model_get(model, iter, SORTID_NODELIST, &name, -1); gtk_tree_model_get(model, iter, SORTID_SMALL_BLOCK, &i, -1); if (i) { i=0; /* strip off the ionodes part */ while (name[i]) { if (name[i] == '[') { name[i] = '\0'; break; } i++; } } popup_win->spec_info->search_info->gchar_data = name; break; case INFO_PAGE: popup_win->spec_info->search_info->gchar_data = name; break; default: g_print("block got %d\n", id); } if (!sview_thread_new((gpointer)popup_thr, popup_win, FALSE, &error)) { g_printerr ("Failed to create part popup thread: %s\n", error->message); 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 = working_sview_config.grid_x_width, hori = working_sview_config.grid_hori, vert = working_sview_config.grid_vert; 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(working_sview_config.grid_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(working_sview_config.grid_hori, 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(working_sview_config.grid_vert, 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); /*TODO * do we care about this? label = gtk_label_new("Topology ordered "); adjustment = gtk_adjustment_new(working_sview_config.grid_topological, 1, 1000, 1, 60, 0); GtkWidget *gtbtton = gtk_check_button_new (); gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 3, 4); gtk_table_attach_defaults(GTK_TABLE(table), gtbtton, 1, 2, 3, 4); gtk_toggle_button_set_active (>btton, working_sview_config.grid_topological); */ gtk_widget_show_all(popup); response = gtk_dialog_run (GTK_DIALOG(popup)); if (response == GTK_RESPONSE_OK) { working_sview_config.grid_x_width = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(width_sb)); working_sview_config.grid_hori = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(hori_sb)); working_sview_config.grid_vert = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(vert_sb)); memcpy(&default_sview_config, &working_sview_config, sizeof(sview_config_t)); if ((width == working_sview_config.grid_x_width) && (hori == working_sview_config.grid_hori) && (vert == working_sview_config.grid_vert)) { temp = g_strdup_printf("Grid: Nothing changed."); } else if (working_sview_config.grid_topological) { temp = g_strdup_printf("Grid: Invalid mode .." " switch to non-topology " "order first."); } else { bool refresh = 0; temp = g_strdup_printf( "Grid set to %d nodes breaks " "at %d H and %d V.", working_sview_config.grid_x_width, working_sview_config.grid_hori, working_sview_config.grid_vert); /* If the old width was wider than the * current we need to remake the list so the * table gets set up correctly, so destroy it * here and it will be remade in get_system_stats(). */ if ((width > working_sview_config.grid_x_width) && grid_button_list) { list_destroy(grid_button_list); grid_button_list = NULL; refresh = 1; } get_system_stats(main_grid_table); if (refresh) refresh_main(NULL, NULL); } gtk_statusbar_pop(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH); response = gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH, temp); g_free(temp); if (!sview_thread_new(_refresh_thr, GINT_TO_POINTER(response), FALSE, &error)) { g_printerr ("Failed to create refresh thread: %s\n", error->message); } } gtk_widget_destroy(popup); return; }
extern void change_refresh_popup(GtkAction *action, gpointer user_data) { GtkWidget *table = gtk_table_new(1, 2, FALSE); GtkWidget *label = NULL; GtkObject *adjustment = gtk_adjustment_new( working_sview_config.refresh_delay, 1, 10000, 5, 60, 0); GtkWidget *spin_button = gtk_spin_button_new(GTK_ADJUSTMENT(adjustment), 1, 0); GtkWidget *popup = gtk_dialog_new_with_buttons( "Refresh Interval", 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); label = gtk_label_new("Interval in Seconds "); gtk_container_set_border_width(GTK_CONTAINER(table), 10); gtk_box_pack_start(GTK_BOX(GTK_DIALOG(popup)->vbox), table, FALSE, FALSE, 0); gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); gtk_table_attach_defaults(GTK_TABLE(table), spin_button, 1, 2, 0, 1); gtk_widget_show_all(popup); response = gtk_dialog_run (GTK_DIALOG(popup)); if (response == GTK_RESPONSE_OK) { working_sview_config.refresh_delay = gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON(spin_button)); temp = g_strdup_printf("Refresh Interval set to %d seconds.", working_sview_config.refresh_delay); gtk_statusbar_pop(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH); response = gtk_statusbar_push(GTK_STATUSBAR(main_statusbar), STATUS_REFRESH, temp); g_free(temp); if (!sview_thread_new(_refresh_thr, GINT_TO_POINTER(response), FALSE, &error)) { g_printerr ("Failed to create refresh thread: %s\n", error->message); } } gtk_widget_destroy(popup); return; }
/* Creates a tree model containing the completions */ void _search_entry(sview_search_info_t *sview_search_info) { int id = 0; char title[100]; ListIterator itr = NULL; popup_info_t *popup_win = NULL; GError *error = NULL; char *upper = NULL, *lower = NULL; char *type; if (cluster_flags & CLUSTER_FLAG_BG) type = "Midplane"; else type = "Node"; if (sview_search_info->int_data == NO_VAL && (!sview_search_info->gchar_data || !strlen(sview_search_info->gchar_data))) { g_print("nothing given to search for.\n"); return; } switch(sview_search_info->search_type) { case SEARCH_JOB_STATE: id = JOB_PAGE; upper = job_state_string(sview_search_info->int_data); lower = str_tolower(upper); snprintf(title, 100, "Job(s) in the %s state", lower); xfree(lower); break; case SEARCH_JOB_ID: id = JOB_PAGE; snprintf(title, 100, "Job %s info", sview_search_info->gchar_data); break; case SEARCH_JOB_USER: id = JOB_PAGE; snprintf(title, 100, "Job(s) info for user %s", sview_search_info->gchar_data); break; case SEARCH_BLOCK_STATE: id = BLOCK_PAGE; upper = bg_block_state_string(sview_search_info->int_data); lower = str_tolower(upper); snprintf(title, 100, "BG Block(s) in the %s state", lower); xfree(lower); break; case SEARCH_BLOCK_NAME: id = BLOCK_PAGE; snprintf(title, 100, "Block %s info", sview_search_info->gchar_data); break; case SEARCH_BLOCK_SIZE: id = BLOCK_PAGE; sview_search_info->int_data = revert_num_unit(sview_search_info->gchar_data); if (sview_search_info->int_data == -1) return; snprintf(title, 100, "Block(s) of size %d cnodes", sview_search_info->int_data); break; case SEARCH_PARTITION_NAME: id = PART_PAGE; snprintf(title, 100, "Partition %s info", sview_search_info->gchar_data); break; case SEARCH_PARTITION_STATE: id = PART_PAGE; if (sview_search_info->int_data) snprintf(title, 100, "Partition(s) that are up"); else snprintf(title, 100, "Partition(s) that are down"); break; case SEARCH_NODE_NAME: id = NODE_PAGE; snprintf(title, 100, "%s(s) %s info", type, sview_search_info->gchar_data); break; case SEARCH_NODE_STATE: id = NODE_PAGE; upper = node_state_string(sview_search_info->int_data); lower = str_tolower(upper); snprintf(title, 100, "%s(s) in the %s state", type, lower); xfree(lower); break; case SEARCH_RESERVATION_NAME: id = RESV_PAGE; snprintf(title, 100, "Reservation %s info", sview_search_info->gchar_data); break; default: g_print("unknown search type %d.\n", sview_search_info->search_type); return; } 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(id, id, title); } else { gtk_window_present(GTK_WINDOW(popup_win->popup)); return; } memcpy(popup_win->spec_info->search_info, sview_search_info, sizeof(sview_search_info_t)); if (!sview_thread_new((gpointer)popup_thr, popup_win, FALSE, &error)) { g_printerr ("Failed to create main popup thread: %s\n", error->message); return; } return; }