From 5c7848960c014a077ce3be659df8992df20f0a46 Mon Sep 17 00:00:00 2001
From: Danny Auble <da@llnl.gov>
Date: Wed, 8 Sep 2010 21:35:48 +0000
Subject: [PATCH] new functionality

---
 src/sview/common.c    |  30 ++-
 src/sview/defaults.c  | 193 ++++++++++++++++--
 src/sview/grid.c      | 463 ++++++++++++++++++------------------------
 src/sview/job_info.c  |   2 +-
 src/sview/node_info.c |   3 +-
 src/sview/part_info.c |   9 +-
 src/sview/popups.c    |  14 ++
 src/sview/sview.c     |  18 +-
 src/sview/sview.h     |  12 +-
 9 files changed, 454 insertions(+), 290 deletions(-)

diff --git a/src/sview/common.c b/src/sview/common.c
index fa093bacdab..364aa982ad2 100644
--- a/src/sview/common.c
+++ b/src/sview/common.c
@@ -700,7 +700,6 @@ extern int get_topo_conf(void)
 	if (TOPO_DEBUG)
 		g_print("get_topo_conf\n");
 
-
 	if ((g_topo_info_msg_ptr == NULL) &&
 	    slurm_load_topo(&g_topo_info_msg_ptr)) {
 		slurm_perror ("slurm_load_topo error");
@@ -709,6 +708,12 @@ extern int get_topo_conf(void)
 		return SLURM_ERROR;
 	}
 
+	if (g_topo_info_msg_ptr->record_count == 0) {
+		slurm_free_topo_info_msg(g_topo_info_msg_ptr);
+		g_topo_info_msg_ptr = NULL;
+		return SLURM_ERROR;
+	}
+
 	if (g_switch_nodes_maps)
 		slurm_free_switch_nodes_maps(g_switch_nodes_maps);
 
@@ -1464,6 +1469,7 @@ extern popup_info_t *create_popup_info(int type, int dest_type, char *title)
 	GtkWidget *table = NULL;
 	GtkWidget *close_btn = NULL;
 	popup_info_t *popup_win = xmalloc(sizeof(popup_info_t));
+//	int i=0;
 
 	list_push(popup_list, popup_win);
 
@@ -1496,6 +1502,17 @@ extern popup_info_t *create_popup_info(int type, int dest_type, char *title)
 	popup_win->force_refresh = 0;
 	popup_win->type = dest_type;
 	popup_win->not_found = false;
+	/*
+	  for(i=0;; i++) {
+	  if(main_popup_positioner[i].width == -1)
+	  break;
+	  if(strstr(title,main_popup_positioner[i].name)) {
+	  width = main_popup_positioner[i].width;
+	  height = main_popup_positioner[i].height;
+	  break;
+	  }
+	  }
+	*/
 	gtk_window_set_default_size(GTK_WINDOW(popup_win->popup),
 				    working_sview_config.fi_popup_width,
 				    working_sview_config.fi_popup_height);
@@ -1960,16 +1977,19 @@ extern void display_edit_note(char *edit_note)
 {
 	GError *error = NULL;
 	int msg_id = 0;
+
+	if(!edit_note)
+		return;
+
 	gtk_statusbar_pop(GTK_STATUSBAR(main_statusbar), STATUS_ADMIN_EDIT);
 	msg_id = gtk_statusbar_push(GTK_STATUSBAR(main_statusbar),
 				    STATUS_ADMIN_EDIT,
 				    edit_note);
 	if (!g_thread_create(_editing_thr, GINT_TO_POINTER(msg_id),
 			     FALSE, &error))
-	{
-		g_printerr ("Failed to create edit thread: %s\n",
-			    error->message);
-	}
+		g_printerr("Failed to create edit thread: %s\n",
+			   error->message);
+
 	return;
 }
 
diff --git a/src/sview/defaults.c b/src/sview/defaults.c
index b0d8bf7792d..8907b678913 100644
--- a/src/sview/defaults.c
+++ b/src/sview/defaults.c
@@ -51,11 +51,13 @@ enum {
 	SORTID_GRID_HORI,
 	SORTID_GRID_VERT,
 	SORTID_GRID_X_WIDTH,
+	SORTID_GRID_TOPO_ORDER,
 	SORTID_PAGE_VISIBLE,
 	SORTID_REFRESH_DELAY,
 	SORTID_RULED_TV,
 	SORTID_SHOW_GRID,
 	SORTID_SHOW_HIDDEN,
+	SORTID_EXCLUDED_PARTITIONS,
 	SORTID_TAB_POS,
 	SORTID_CNT
 };
@@ -77,6 +79,10 @@ static display_data_t display_data_defaults[] = {
 	 TRUE, EDIT_TEXTBOX, NULL, create_model_defaults, NULL},
 	{G_TYPE_STRING, SORTID_GRID_X_WIDTH, "Grid: Nodes in Row",
 	 TRUE, EDIT_TEXTBOX, NULL, create_model_defaults, NULL},
+	{G_TYPE_STRING, SORTID_GRID_TOPO_ORDER, "Grid: Topology Order",
+	 TRUE, EDIT_MODEL, NULL, create_model_defaults, NULL},
+	{G_TYPE_STRING, SORTID_EXCLUDED_PARTITIONS, "Excluded Partitions: ",
+	 TRUE, EDIT_TEXTBOX, NULL, create_model_defaults, NULL},
 	{G_TYPE_STRING, SORTID_PAGE_VISIBLE, "Visible Pages",
 	 TRUE, EDIT_ARRAY, NULL, create_model_defaults, NULL},
 	{G_TYPE_STRING, SORTID_REFRESH_DELAY, "Refresh Delay in Secs",
@@ -95,6 +101,25 @@ static display_data_t display_data_defaults[] = {
 
 extern display_data_t main_display_data[];
 
+static char *_excluded_partitions;
+static char *_pending_excluded_partitions = "";
+
+char *_replace_str(char *str, char *orig, char *rep)
+{
+  static char buffer[50];
+  char *p;
+
+  if(!(p = strstr(str, orig)))
+    return NULL;
+
+  strncpy(buffer, str, p-str);
+  buffer[p-str] = '\0';
+  sprintf(buffer+(p-str), "%s%s", rep, p+strlen(orig));
+
+  return buffer;
+}
+
+
 static void _set_active_combo_defaults(GtkComboBox *combo,
 				       sview_config_t *sview_config,
 				       int type)
@@ -105,6 +130,9 @@ static void _set_active_combo_defaults(GtkComboBox *combo,
 	case SORTID_ADMIN:
 		action = sview_config->admin_mode;
 		break;
+	case SORTID_GRID_TOPO_ORDER:
+		action = sview_config->grid_topological;
+		break;
 	case SORTID_RULED_TV:
 		action = sview_config->ruled_treeview;
 		break;
@@ -209,6 +237,17 @@ static const char *_set_sview_config(sview_config_t *sview_config,
 		else
 			sview_config->show_grid = 0;
 		break;
+	case SORTID_GRID_TOPO_ORDER:
+		type = "Topology order";
+		if (!strcasecmp(new_text, "yes"))
+			sview_config->grid_topological = 1;
+		else
+			sview_config->grid_topological =  0;
+		break;
+	case SORTID_EXCLUDED_PARTITIONS:
+		type = "Excluded Partitions";
+		_excluded_partitions = xstrdup_printf(new_text);
+		break;
 	case SORTID_SHOW_HIDDEN:
 		type = "Show Hidden";
 		if (!strcasecmp(new_text, "yes"))
@@ -233,8 +272,10 @@ static const char *_set_sview_config(sview_config_t *sview_config,
 		type = "unknown";
 		break;
 	}
-	if(strcmp(type, "unknown"))
+	if(strcmp(type, "unknown")) {
 		global_send_update_msg = 1;
+
+	}
 	return type;
 
 return_error:
@@ -247,6 +288,7 @@ static void _admin_focus_toggle(GtkToggleButton *toggle_button,
 {
 	if(visible) {
 		(*visible) = gtk_toggle_button_get_active(toggle_button);
+		g_print("_admin_focus_toggle\n");
 		global_send_update_msg = 1;
 	}
 }
@@ -261,7 +303,6 @@ static void _admin_edit_combo_box_defaults(GtkComboBox *combo,
 
 	if(!sview_config)
 		return;
-
 	if(!gtk_combo_box_get_active_iter(combo, &iter)) {
 		g_print("nothing selected\n");
 		return;
@@ -271,12 +312,10 @@ static void _admin_edit_combo_box_defaults(GtkComboBox *combo,
 		g_print("nothing selected\n");
 		return;
 	}
-
 	gtk_tree_model_get(model, &iter, 0, &name, -1);
 	gtk_tree_model_get(model, &iter, 1, &column, -1);
 
 	_set_sview_config(sview_config, name, column);
-
 	g_free(name);
 }
 
@@ -359,6 +398,12 @@ static void _local_display_admin_edit(GtkTable *table,
 			temp_char = xstrdup_printf("%u",
 						   sview_config->refresh_delay);
 			break;
+
+
+		case SORTID_EXCLUDED_PARTITIONS:
+			temp_char = xstrdup_printf(_pending_excluded_partitions);
+			xstrcat(temp_char,_excluded_partitions);
+			break;
 		default:
 			break;
 		}
@@ -485,6 +530,7 @@ static void _init_sview_conf()
 extern int load_defaults()
 {
 	s_p_hashtbl_t *hashtbl = NULL;
+//	s_p_options_t sview_conf_resize_options[20];
 	s_p_options_t sview_conf_options[] = {
 		{"AdminMode", S_P_BOOLEAN},
 		{"DefaultPage", S_P_STRING},
@@ -511,6 +557,8 @@ extern int load_defaults()
 	uint32_t hash_val = NO_VAL;
 	int rc = SLURM_SUCCESS;
 	char *tmp_str;
+//	char *tmp_str2;
+//	int i=0;
 
 	_init_sview_conf();
 
@@ -577,8 +625,11 @@ extern int load_defaults()
 		       "FullInfoPopupWidth", hashtbl);
 	s_p_get_uint32(&default_sview_config.fi_popup_height,
 		       "FullInfoPopupHeight", hashtbl);
-	s_p_get_string(&excluded_partitions,
-		       "ExcludedPartitions", hashtbl);
+	if (s_p_get_string(&default_sview_config.excluded_partitions,
+			"ExcludedPartitions", hashtbl) == 0)
+		default_sview_config.excluded_partitions =xstrdup_printf("-");
+	_excluded_partitions =
+			xstrdup_printf(default_sview_config.excluded_partitions);
 	if (default_sview_config.main_width == 0) {
 		default_sview_config.main_width=1000;
 		default_sview_config.main_height=450;
@@ -613,11 +664,50 @@ extern int load_defaults()
 			default_sview_config.page_visible[NODE_PAGE] = 1;
 		xfree(tmp_str);
 	}
-	if (!s_p_get_string(&excluded_partitions, "ExcludedPartitions",
-			    hashtbl))
-		excluded_partitions = xstrdup("-");
-
 	s_p_hashtbl_destroy(hashtbl);
+	/*cant use this yet since s_p_parse_file kicks out
+	 * errors on static table above. The errors are ignored
+	 * but better to not even see them. Probably llnl would know
+	 * how to suppress those errors
+
+	//create dynamic hashtable
+	for(i=0;; i++) {
+		if(main_popup_positioner[i].width == -1)
+			break;
+		//replace ' ' in name with '|'
+		tmp_str = xstrdup(main_popup_positioner[i].name);
+		while (1) {
+			tmp_str2 = _replace_str(tmp_str,
+				" ", "|");
+			if(tmp_str2 != NULL) {
+					tmp_str = xstrdup(tmp_str2);
+			}
+			else
+					break;
+		}
+		if(tmp_str) {
+			tmp_str2 = xstrdup_printf("%s_w", tmp_str);
+			sview_conf_resize_options[i].key = xstrdup(tmp_str2);
+			g_print("key: %s built\n",
+					sview_conf_resize_options[i].key);
+			sview_conf_resize_options[i].type = S_P_UINT32;
+		}
+		xfree(tmp_str);
+		xfree(tmp_str2);
+	}
+	sview_conf_resize_options[i].key = NULL;
+	hashtbl = s_p_hashtbl_create(sview_conf_resize_options);
+	for(i=0;; i++) {
+		if(main_popup_positioner[i].width == -1)
+			break;
+		s_p_get_uint32(&main_popup_positioner[i].width,
+				sview_conf_resize_options[i].key, hashtbl);
+		g_print("key: %s : width: %d\n",
+				sview_conf_resize_options[i].key,
+				main_popup_positioner[i].width);
+	}
+	s_p_hashtbl_destroy(hashtbl);
+	 */
 
 end_it:
 	/* copy it all into the working struct */
@@ -731,8 +821,39 @@ extern int save_defaults()
 	xfree(tmp_str);
 	if(rc != SLURM_SUCCESS)
 		goto end_it;
+	/* TODO .. suppress sp parse errors on the read-in
+	for(i=0;; i++) {
+		if(main_popup_positioner[i].width == -1)
+			break;
+		//replace spaces in name
+		tmp_str = xstrdup(main_popup_positioner[i].name);
+		while (1) {
+			tmp_str2 = _replace_str(tmp_str,
+				" ", "|");
+			if(tmp_str2 != NULL) {
+					tmp_str = xstrdup(tmp_str2);
+			}
+			else
+					break;
+		}
+		if(tmp_str) {
+			tmp_str2 = xstrdup_printf("%s_w=%u\n",
+					tmp_str,
+					main_popup_positioner[i].width);
+			rc = _write_to_file(fd, tmp_str2);
+			tmp_str2 = xstrdup_printf("%s_h=%u\n",
+					tmp_str,
+					main_popup_positioner[i].height);
+			rc = _write_to_file(fd, tmp_str2);
+		}
+		xfree(tmp_str);
+		xfree(tmp_str2);
+		if(rc != SLURM_SUCCESS)
+			goto end_it;
+	}
+	*/
 	tmp_str = xstrdup_printf("ExcludedPartitions=%s\n",
-				 excluded_partitions);
+		_excluded_partitions);
 	rc = _write_to_file(fd, tmp_str);
 	xfree(tmp_str);
 	if(rc != SLURM_SUCCESS)
@@ -800,6 +921,7 @@ extern GtkListStore *create_model_defaults(int type)
 
 	switch(type) {
 	case SORTID_ADMIN:
+	case SORTID_GRID_TOPO_ORDER:
 	case SORTID_RULED_TV:
 	case SORTID_SHOW_GRID:
 	case SORTID_SHOW_HIDDEN:
@@ -892,13 +1014,27 @@ extern int configure_defaults()
 	sview_config_t tmp_config;
 	int response = 0;
 	int rc = SLURM_SUCCESS;
+	uint32_t width = 150;
+	uint32_t height = 700;
 
 	memcpy(&tmp_config, &default_sview_config, sizeof(sview_config_t));
 	gtk_window_set_default(GTK_WINDOW(popup), label);
 	gtk_dialog_add_button(GTK_DIALOG(popup),
 			      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL);
 
-	gtk_window_set_default_size(GTK_WINDOW(popup), 150, 600);
+	/*
+	for(i=0;; i++) {
+		if(main_popup_positioner[i].width == -1)
+			break;
+		if(strstr("Sview Defaults", main_popup_positioner[i].name)) {
+			pos_x = main_popup_positioner[i].width;
+			pos_y = main_popup_positioner[i].height;
+			break;
+		}
+	}
+	*/
+
+	gtk_window_set_default_size(GTK_WINDOW(popup), width, height);
 	snprintf(tmp_char, sizeof(tmp_char),
 		 "Default Settings for Sview");
 	label = gtk_label_new(tmp_char);
@@ -940,6 +1076,8 @@ extern int configure_defaults()
 	gtk_widget_show_all(popup);
 	response = gtk_dialog_run (GTK_DIALOG(popup));
 	if (response == GTK_RESPONSE_OK) {
+		tmp_char_ptr = g_strdup_printf(
+				"Defaults updated successfully");
 		if(global_edit_error)
 			tmp_char_ptr = global_edit_error_msg;
 		else if(!global_send_update_msg)
@@ -955,6 +1093,35 @@ extern int configure_defaults()
 				cluster_change_job();
 				cluster_change_node();
 			}
+			if(tmp_config.grid_topological
+					   != working_sview_config.grid_topological) {
+				if (tmp_config.grid_topological) {
+					if(grid_button_list) {
+						list_destroy(grid_button_list);
+						grid_button_list = NULL;
+					}
+					default_sview_config.grid_topological =
+							tmp_config.grid_topological;
+					if(!g_switch_nodes_maps)
+						rc = get_topo_conf();
+					if(rc != SLURM_SUCCESS) {
+						/*denied*/
+						tmp_char_ptr = g_strdup_printf(
+							"Valid topology not detected");
+						tmp_config.grid_topological = FALSE;
+					}
+				}
+			}
+			else if(strcmp(_excluded_partitions,
+					   working_sview_config.excluded_partitions)) {
+				_pending_excluded_partitions = "(pending)";
+				if ((strlen(_excluded_partitions) == 0)) {
+					_excluded_partitions = xstrdup_printf("-");
+				}
+				tmp_char_ptr = g_strdup_printf(
+						"Defaults updated: "
+						"Sview restart required to process this change!!");
+			}
 
 			memcpy(&default_sview_config, &tmp_config,
 			       sizeof(sview_config_t));
@@ -991,8 +1158,6 @@ extern int configure_defaults()
 			get_system_stats(main_grid_table);
 			/******************************************/
 
-			tmp_char_ptr = g_strdup_printf(
-				"Defaults updated successfully");
 			save_defaults();
 		}
 		display_edit_note(tmp_char_ptr);
diff --git a/src/sview/grid.c b/src/sview/grid.c
index 54b02711ec6..a22a1146782 100644
--- a/src/sview/grid.c
+++ b/src/sview/grid.c
@@ -59,6 +59,17 @@ typedef struct {
 	List button_list;
 } grid_foreach_t;
 
+typedef struct {
+	List button_list;
+	int *coord_x;
+	int *coord_y;
+	int default_y_offset;
+	grid_button_t *grid_button;
+	int *inx;
+	GtkTable *table;
+	int table_y;
+} button_processor_t;
+
 GStaticMutex blinking_mutex = G_STATIC_MUTEX_INIT;
 
 static int _coord(char coord)
@@ -421,14 +432,12 @@ static void _each_highlightd(GtkTreeModel *model,
 
 	}
 
-
 	list_iterator_destroy(itr);
 	if(changed && working_sview_config.grid_speedup) {
 		gtk_widget_set_sensitive(GTK_WIDGET(main_grid_table), 0);
 		gtk_widget_set_sensitive(GTK_WIDGET(main_grid_table), 1);
 	}
 	return;
-
 }
 
 
@@ -481,11 +490,9 @@ static int _block_in_node(int *bp_inx, int inx)
 }
 
 static int _add_button_to_list(node_info_t *node_ptr,
-			       GtkTable *table, List button_list,
-			       int *coord_x, int *coord_y, int *inx,
-			       int default_y_offset, int table_y)
+			       button_processor_t *button_processor)
 {
-	grid_button_t *grid_button = NULL;
+	grid_button_t *grid_button = button_processor->grid_button;
 
 	if(cluster_dims == 4) {
 		/* FIXME: */
@@ -510,30 +517,45 @@ static int _add_button_to_list(node_info_t *node_ptr,
 			y = _coord(node_ptr->name[i-2]);
 			z = _coord(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;
+		(*button_processor->coord_x) = (x + (DIM_SIZE[Z] - 1)) - z;
+		y_offset = button_processor->default_y_offset
+			- (DIM_SIZE[Z] * y);
+		(*button_processor->coord_y) = (y_offset - y) + z;
 	}
 
-	grid_button = xmalloc(sizeof(grid_button_t));
-	grid_button->color_inx = MAKE_INIT;
-	grid_button->inx = (*inx)++;
-	grid_button->table = table;
-	grid_button->table_x = (*coord_x);
-	grid_button->table_y = (*coord_y);
-	grid_button->button = gtk_button_new();
-	grid_button->node_name = xstrdup(node_ptr->name);
-
-	gtk_widget_set_size_request(grid_button->button, 10, 10);
-	_add_button_signals(grid_button);
-	list_append(button_list, grid_button);
-
-	gtk_table_attach(table, grid_button->button,
-			 (*coord_x), ((*coord_x)+1),
-			 (*coord_y), ((*coord_y)+1),
-			 GTK_SHRINK, GTK_SHRINK,
-			 1, 1);
-
+	if(!grid_button) {
+		grid_button = xmalloc(sizeof(grid_button_t));
+		grid_button->color_inx = MAKE_INIT;
+		grid_button->inx = (*button_processor->inx);
+		grid_button->table = button_processor->table;
+		grid_button->table_x = (*button_processor->coord_x);
+		grid_button->table_y = (*button_processor->coord_y);
+		grid_button->button = gtk_button_new();
+		grid_button->node_name = xstrdup(node_ptr->name);
+
+		gtk_widget_set_size_request(grid_button->button, 10, 10);
+		_add_button_signals(grid_button);
+		list_append(button_processor->button_list, grid_button);
+
+		gtk_table_attach(button_processor->table, grid_button->button,
+				 (*button_processor->coord_x),
+				 ((*button_processor->coord_x)+1),
+				 (*button_processor->coord_y),
+				 ((*button_processor->coord_y)+1),
+				 GTK_SHRINK, GTK_SHRINK,
+				 1, 1);
+	} else {
+		grid_button->table_x = (*button_processor->coord_x);
+		grid_button->table_y = (*button_processor->coord_y);
+		gtk_container_child_set(
+			GTK_CONTAINER(button_processor->table),
+			grid_button->button,
+			"left-attach", (*button_processor->coord_x),
+			"right-attach", ((*button_processor->coord_x)+1),
+			"top-attach", (*button_processor->coord_y),
+			"bottom-attach", ((*button_processor->coord_y)+1),
+			NULL);
+	}
 	/* gtk_container_add(GTK_CONTAINER(grid_button->frame),  */
 /* 				  grid_button->button); */
 /* 		gtk_frame_set_shadow_type(GTK_FRAME(grid_button->frame), */
@@ -545,62 +567,55 @@ static int _add_button_to_list(node_info_t *node_ptr,
 		   coord_y.  We add space inbetween
 		   each 10th row.
 		*/
-		(*coord_x)++;
-		if((*coord_x) == working_sview_config.grid_x_width) {
-			(*coord_x) = 0;
-			(*coord_y)++;
-			 if(!((*coord_y) % working_sview_config.grid_vert))
-				 gtk_table_set_row_spacing(
-					 table, (*coord_y)-1, 5);
+		(*button_processor->coord_x)++;
+		if((*button_processor->coord_x)
+		   == working_sview_config.grid_x_width) {
+			(*button_processor->coord_x) = 0;
+			(*button_processor->coord_y)++;
+			if(!((*button_processor->coord_y)
+			     % working_sview_config.grid_vert))
+				gtk_table_set_row_spacing(
+					button_processor->table,
+					(*button_processor->coord_y)-1, 5);
 		}
 
-		if((*coord_y) == table_y)
-			return SLURM_ERROR;
+		if((*button_processor->coord_y) == button_processor->table_y)
+			return SLURM_SUCCESS;
 
-		if((*coord_x) && !((*coord_x) % working_sview_config.grid_hori))
-			gtk_table_set_col_spacing(table, (*coord_x)-1, 5);
+		if((*button_processor->coord_x) &&
+		   !((*button_processor->coord_x)
+		     % working_sview_config.grid_hori))
+			gtk_table_set_col_spacing(
+				button_processor->table,
+				(*button_processor->coord_x)-1, 5);
 	}
 	return SLURM_SUCCESS;
 }
 
-static int _grid_table_by_switch(GtkTable *table, List button_list,
-				 int *coord_x, int *coord_y,
-				 int default_y_offset, int table_y)
+static int _grid_table_by_switch(button_processor_t *button_processor)
 {
 	int rc = SLURM_SUCCESS;
-//	GdkColor switch_color;
-//	int color_assignment = 2;
 	int i = 0;
 	switch_record_bitmaps_t *sw_nodes_bitmaps_ptr = g_switch_nodes_maps;
-	int inx=0;
 
-	for (i=0; i<g_topo_info_msg_ptr->record_count; i++,
-		     sw_nodes_bitmaps_ptr++) {
+	for (i=0; i<g_topo_info_msg_ptr->record_count;
+	     i++, sw_nodes_bitmaps_ptr++) {
 		int j = 0, first, last;
 		if (g_topo_info_msg_ptr->topo_array[i].level)
 			continue;
-//		if (color_assignment > switch_colors_cnt) {
-//			color_assignment=2;
-//		}
-//		gdk_color_parse(switch_colors[color_assignment],
-//			&switch_color);
 		first = bit_ffs(sw_nodes_bitmaps_ptr->node_bitmap);
 		if (first == -1)
 			continue;
 		last = bit_fls(sw_nodes_bitmaps_ptr->node_bitmap);
+		button_processor->inx = &j;
 		for (j = first; j <= last; j++) {
-//			if (!(g_node_info_ptr->node_array[j].node_state ==
-//					NODE_STATE_ALLOCATED))
-//					continue;
 			if (TOPO_DEBUG)
 				g_print("allocated node = %s button# %d\n",
 					g_node_info_ptr->node_array[j].name,
 					j);
-
 			if((rc = _add_button_to_list(
 				    &g_node_info_ptr->node_array[j],
-				    table, button_list, coord_x, coord_y, &inx,
-				    default_y_offset, table_y))
+				    button_processor))
 			   != SLURM_SUCCESS)
 				break;
 		}
@@ -608,51 +623,86 @@ static int _grid_table_by_switch(GtkTable *table, List button_list,
 	/* 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);
+	gtk_table_set_row_spacing(button_processor->table,
+				  (*button_processor->coord_y)-1, 1);
 
 	return rc;
 
 }
 
-static int _grid_table_by_list(GtkTable *table,
-			       List button_list, List node_list,
-			       int *coord_x, int *coord_y,
-			       int default_y_offset, int table_y)
+static int _grid_table_by_list(button_processor_t *button_processor,
+			       List node_list)
 {
 	sview_node_info_t *sview_node_info_ptr = NULL;
 	static partition_info_msg_t *part_info_ptr = NULL;
 	int inx = 0, rc = SLURM_SUCCESS;
-
+	int exclude_partitions =
+		strcmp(working_sview_config.excluded_partitions, "-");
 	ListIterator itr = list_iterator_create(node_list);
-	while((sview_node_info_ptr = list_next(itr))) {
-		if (strcmp(excluded_partitions, "-")) {
-			int rc = get_new_info_part(
-				&part_info_ptr, force_refresh);
-			if((rc == SLURM_NO_CHANGE_IN_DATA)
-			   || (rc == SLURM_SUCCESS))
-				if(!check_part_includes_node(
-					   part_info_ptr, inx)) {
-					inx++;
-					continue;
-				}
+	button_processor->inx = &inx;
+
+	while ((sview_node_info_ptr = list_next(itr))) {
+		if (exclude_partitions) {
+			get_new_info_part(&part_info_ptr, force_refresh);
+			if(part_info_ptr
+			   && !check_part_includes_node(part_info_ptr, inx)) {
+				inx++;
+				continue;
+			}
 		}
-		if((rc = _add_button_to_list(
-			    sview_node_info_ptr->node_ptr,
-			    table, button_list, coord_x, coord_y, &inx,
-			    default_y_offset, table_y)) != SLURM_SUCCESS)
+		if ((rc = _add_button_to_list(
+			     sview_node_info_ptr->node_ptr,
+			     button_processor)) != SLURM_SUCCESS)
 			break;
+		inx++;
 	}
 	list_iterator_destroy(itr);
 
 	/* 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);
+	gtk_table_set_row_spacing(button_processor->table,
+				  (*button_processor->coord_y)-1, 1);
 
 
 	return rc;
 }
 
+static int _init_button_processor(button_processor_t *button_processor,
+				  int node_count)
+{
+	if(node_count == 0) {
+		g_print("_init_button_processor: no nodes selected\n");
+		return SLURM_ERROR;
+	}
+
+	memset(button_processor, 0, sizeof(button_processor_t));
+
+	if(cluster_dims == 4) {
+		/* FIXME: */
+		return SLURM_ERROR;
+	} else if(cluster_dims == 3) {
+		button_processor->default_y_offset = (DIM_SIZE[Z] * DIM_SIZE[Y])
+			+ (DIM_SIZE[Y] - DIM_SIZE[Z]);
+		working_sview_config.grid_x_width = DIM_SIZE[X] + DIM_SIZE[Z];
+		button_processor->table_y =
+			(DIM_SIZE[Z] * DIM_SIZE[Y]) + DIM_SIZE[Y];
+	} else {
+		if(!working_sview_config.grid_x_width) {
+			if(node_count < 50) {
+				working_sview_config.grid_x_width = 1;
+			} else if(node_count < 500) {
+				working_sview_config.grid_x_width = 10;
+			} else {
+				working_sview_config.grid_x_width = 20;
+			}
+		}
+		button_processor->table_y =
+			(node_count / working_sview_config.grid_x_width) + 1;
+	}
+
+	return SLURM_SUCCESS;
+}
 /* static void _destroy_grid_foreach(void *arg) */
 /* { */
 /* 	grid_foreach_t *grid_foreach = (grid_foreach_t *)arg; */
@@ -977,7 +1027,7 @@ extern void add_extra_bluegene_buttons(List *button_list, int inx,
 {
 	block_info_msg_t *block_ptr = NULL;
 	block_info_t *bg_info_ptr = NULL;
-	int error_code = SLURM_SUCCESS;
+	int rc = SLURM_SUCCESS;
 	ListIterator itr = NULL;
 	grid_button_t *grid_button = NULL;
 	grid_button_t *send_grid_button = NULL;
@@ -988,10 +1038,9 @@ extern void add_extra_bluegene_buttons(List *button_list, int inx,
 	int coord_y=0;
 	uint16_t orig_state;
 
-	error_code = get_new_info_block(&block_ptr, 0);
+	rc = get_new_info_block(&block_ptr, 0);
 
-	if (error_code != SLURM_SUCCESS
-	    && error_code != SLURM_NO_CHANGE_IN_DATA) {
+	if ((rc != SLURM_SUCCESS) && (rc != SLURM_NO_CHANGE_IN_DATA)) {
 		return;
 	}
 
@@ -1088,39 +1137,29 @@ 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_y=0;
 	int coord_x=0, coord_y=0;
+	button_processor_t button_processor;
 	grid_button_t *grid_button = NULL;
 	ListIterator itr = NULL;
-	int node_count = list_count(button_list);
 	list_sort(button_list, (ListCmpF) _sort_button_inx);
 
-	if(node_count == 0) {
-		g_print("put_buttons_in_table: no nodes selected\n");
+	if(!button_list) {
+		g_print("put_buttons_in_table: no node_list given\n");
 		return;
 	}
 
-	if(cluster_dims == 4) {
-		/* FIXME: */
+	if(_init_button_processor(&button_processor, list_count(button_list))
+	   != SLURM_SUCCESS)
 		return;
-	} else if(cluster_dims == 3) {
-		node_count = DIM_SIZE[X];
-		working_sview_config.grid_x_width = DIM_SIZE[X] + DIM_SIZE[Z];
-		table_y = (DIM_SIZE[Z] * DIM_SIZE[Y]) + DIM_SIZE[Y];
-	} else {
-		if(!working_sview_config.grid_x_width) {
-			if(node_count < 50) {
-				working_sview_config.grid_x_width = 1;
-			} else if(node_count < 500) {
-				working_sview_config.grid_x_width = 10;
-			} else {
-				working_sview_config.grid_x_width=20;
-			}
-		}
-		table_y = node_count/working_sview_config.grid_x_width;
-		table_y++;
-	}
-	gtk_table_resize(table, table_y, working_sview_config.grid_x_width);
+
+	button_processor.table = table;
+	button_processor.button_list = button_list;
+	button_processor.coord_x = &coord_x;
+	button_processor.coord_y = &coord_y;
+
+	gtk_table_resize(table, button_processor.table_y,
+			 working_sview_config.grid_x_width);
+
 	itr = list_iterator_create(button_list);
 	while((grid_button = list_next(itr))) {
 		if(cluster_dims == 4) {
@@ -1157,7 +1196,7 @@ extern void put_buttons_in_table(GtkTable *table, List button_list)
 						table, coord_y-1, 5);
 			}
 
-			if(coord_y == table_y)
+			if(coord_y == button_processor.table_y)
 				break;
 
 			if(coord_x
@@ -1178,129 +1217,56 @@ extern void put_buttons_in_table(GtkTable *table, List button_list)
 
 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;
+	int rc = SLURM_SUCCESS;
+	int coord_x=0, coord_y=0, inx=0;
 	ListIterator itr = NULL, itr2 = NULL;
+	static partition_info_msg_t *part_info_ptr = NULL;
 	sview_node_info_t *sview_node_info_ptr = NULL;
-	int default_y_offset = 0;
+	button_processor_t button_processor;
+	int exclude_partitions =
+		strcmp(working_sview_config.excluded_partitions, "-");
 
-	if(cluster_dims == 4) {
-		/* FIXME: */
+	if (!node_list) {
+		g_print("update_grid_table: no node_list given\n");
 		return SLURM_ERROR;
-	} else if(cluster_dims == 3) {
-		default_y_offset = (DIM_SIZE[Z] * DIM_SIZE[Y])
-			+ (DIM_SIZE[Y] - DIM_SIZE[Z]);
-		node_count = DIM_SIZE[X];
-		working_sview_config.grid_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 == 0) {
-			g_print("put_buttons_in_table: no nodes selected\n");
-			return SLURM_ERROR;
-		}
-		if(!working_sview_config.grid_x_width) {
-			if(node_count < 50) {
-				working_sview_config.grid_x_width = 1;
-			} else if(node_count < 500) {
-				working_sview_config.grid_x_width = 10;
-			} else {
-				working_sview_config.grid_x_width = 20;
-			}
-		}
-		table_y = node_count/working_sview_config.grid_x_width;
-		table_y++;
 	}
 
-	if(!node_list) {
-		g_print("update_grid_table: no node_list given\n");
+	if (_init_button_processor(&button_processor, list_count(node_list))
+	    != SLURM_SUCCESS)
 		return SLURM_ERROR;
-	}
 
-	gtk_table_resize(table, table_y, working_sview_config.grid_x_width);
+	button_processor.table = table;
+	button_processor.button_list = button_list;
+	button_processor.coord_x = &coord_x;
+	button_processor.coord_y = &coord_y;
+	button_processor.inx = &inx;
+
+	gtk_table_resize(table, button_processor.table_y,
+			 working_sview_config.grid_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))) {
+	while ((sview_node_info_ptr = list_next(itr))) {
 		int found = 0;
+		if (exclude_partitions) {
+			get_new_info_part(&part_info_ptr, force_refresh);
+			if(part_info_ptr
+			   && !check_part_includes_node(part_info_ptr, inx)) {
+				inx++;
+				continue;
+			}
+		}
 	again:
-		while((grid_button = list_next(itr2))) {
-			if(grid_button->inx != inx)
+		while ((button_processor.grid_button = list_next(itr2))) {
+			if (button_processor.grid_button->inx != inx)
 				continue;
 			found = 1;
-			if(cluster_dims == 4) {
-				/* FIXME: */
-				return SLURM_ERROR;
-			} else if(cluster_dims == 3) {
-				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;
-			}
 
-			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);
-
-			if(cluster_dims < 3) {
-				/* 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
-				   == working_sview_config.grid_x_width) {
-					coord_x = 0;
-					coord_y++;
-					if(!(coord_y
-					     % working_sview_config.grid_vert))
-						gtk_table_set_row_spacing(
-							table, coord_y-1, 5);
-				}
-
-				if(coord_y == table_y)
-					break;
-
-				if(coord_x
-				   && !(coord_x%working_sview_config.grid_hori))
-					gtk_table_set_col_spacing(
-						table, coord_x-1, 5);
-			}
+			if ((rc = _add_button_to_list(
+				     sview_node_info_ptr->node_ptr,
+				     &button_processor)) != SLURM_SUCCESS)
+				goto end_it;
 			break;
 		}
 		if(!found) {
@@ -1318,26 +1284,25 @@ extern int update_grid_table(GtkTable *table, List button_list, List node_list)
 end_it:
 	list_iterator_destroy(itr);
 	list_iterator_destroy(itr2);
-	return error_code;
+	return rc;
 }
 
 extern int get_system_stats(GtkTable *table)
 {
-	int error_code = SLURM_SUCCESS;
+	int rc = SLURM_SUCCESS;
 	node_info_msg_t *node_info_ptr = NULL;
 	List node_list = NULL;
 	int changed = 1;
 
-	if((error_code = get_new_info_node(&node_info_ptr, force_refresh))
+	if((rc = get_new_info_node(&node_info_ptr, force_refresh))
 	   == SLURM_NO_CHANGE_IN_DATA) {
 		changed = 0;
-	} else if (error_code != SLURM_SUCCESS)
+	} else if (rc != SLURM_SUCCESS)
 		return SLURM_ERROR;
 
 	ba_init(node_info_ptr, 0);
 
 	node_list = create_node_info_list(node_info_ptr, changed, FALSE);
-
 	if(grid_button_list)
 		update_grid_table(main_grid_table, grid_button_list, node_list);
 	else {
@@ -1353,54 +1318,30 @@ extern int get_system_stats(GtkTable *table)
 extern int setup_grid_table(GtkTable *table, List button_list, List node_list)
 {
 	int rc = SLURM_SUCCESS;
-	int coord_x=0, coord_y=0, table_y = 0;
-	int node_count = 0;
-	int default_y_offset = 0;
-
-	if(cluster_dims == 4) {
-		/* FIXME: */
-		return SLURM_ERROR;
-	} else if(cluster_dims == 3) {
-		default_y_offset = (DIM_SIZE[Z] * DIM_SIZE[Y])
-			+ (DIM_SIZE[Y] - DIM_SIZE[Z]);
-		node_count = DIM_SIZE[X];
-		working_sview_config.grid_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(!working_sview_config.grid_x_width) {
-			if(node_count < 50) {
-				working_sview_config.grid_x_width = 1;
-			} else if(node_count < 500) {
-				working_sview_config.grid_x_width = 10;
-			} else {
-				working_sview_config.grid_x_width = 20;
-			}
-		}
-		table_y = (node_count/working_sview_config.grid_x_width) + 1;
-	}
+	button_processor_t button_processor;
+	int coord_x=0, coord_y=0;
 
 	if(!node_list) {
 		g_print("setup_grid_table: no node_list given\n");
 		return SLURM_ERROR;
 	}
 
-	if(node_count == 0) {
-		g_print("setup_grid_table: no nodes selected\n");
+	if(_init_button_processor(&button_processor, list_count(node_list))
+	   != SLURM_SUCCESS)
 		return SLURM_ERROR;
-	}
 
-	gtk_table_resize(table, table_y, working_sview_config.grid_x_width);
+	button_processor.table = table;
+	button_processor.button_list = button_list;
+	button_processor.coord_x = &coord_x;
+	button_processor.coord_y = &coord_y;
+
+	gtk_table_resize(table, button_processor.table_y,
+			 working_sview_config.grid_x_width);
 
-	if (default_sview_config.grid_topological &&
-	    (g_topo_info_msg_ptr != NULL))
-		rc = _grid_table_by_switch(table, button_list,
-					   &coord_x, &coord_y,
-					   default_y_offset, table_y);
+	if (default_sview_config.grid_topological && g_topo_info_msg_ptr)
+		rc = _grid_table_by_switch(&button_processor);
 	else
-		rc = _grid_table_by_list(table, button_list, node_list,
-					 &coord_x, &coord_y,
-					 default_y_offset, table_y);
+		rc = _grid_table_by_list(&button_processor, node_list);
 
 	list_sort(button_list, (ListCmpF) _sort_button_inx);
 
@@ -1410,18 +1351,18 @@ extern int setup_grid_table(GtkTable *table, List button_list, List node_list)
 extern void sview_init_grid(bool reset_highlight)
 {
 	static node_info_msg_t *node_info_ptr = NULL;
-	int error_code = SLURM_SUCCESS;
+	int rc = SLURM_SUCCESS;
 	node_info_t *node_ptr = NULL;
 	int i = 0;
 	ListIterator itr = NULL;
 	grid_button_t *grid_button = NULL;
 
-	if((error_code = get_new_info_node(&node_info_ptr, force_refresh))
+	if((rc = get_new_info_node(&node_info_ptr, force_refresh))
 	   == SLURM_NO_CHANGE_IN_DATA) {
 		/* need to clear out old data */
 		set_grid_used(grid_button_list, -1, -1, false, reset_highlight);
 		return;
-	} else if (error_code != SLURM_SUCCESS) {
+	} else if (rc != SLURM_SUCCESS) {
 		return;
 	}
 
diff --git a/src/sview/job_info.c b/src/sview/job_info.c
index cea2063fd59..02c5e5ff9c8 100644
--- a/src/sview/job_info.c
+++ b/src/sview/job_info.c
@@ -2442,7 +2442,7 @@ static List _create_job_info_list(job_info_msg_t *job_info_ptr,
 
 	for(i=0; i<job_info_ptr->record_count; i++) {
 		job_ptr = &(job_info_ptr->job_array[i]);
-		if (strstr(excluded_partitions, job_ptr->partition))
+		if (strstr(working_sview_config.excluded_partitions, job_ptr->partition))
 			continue;
 		sview_job_info_ptr = xmalloc(sizeof(sview_job_info_t));
 		sview_job_info_ptr->job_ptr = job_ptr;
diff --git a/src/sview/node_info.c b/src/sview/node_info.c
index 57d016b170f..2750c1a12b1 100644
--- a/src/sview/node_info.c
+++ b/src/sview/node_info.c
@@ -596,7 +596,7 @@ extern List create_node_info_list(node_info_msg_t *node_info_ptr,
 			continue;
 		if (by_partition) {
 			/*constrain list to included partitions' nodes*/
-			if (strcmp(excluded_partitions, "-")) {
+			if (strcmp(working_sview_config.excluded_partitions, "-")) {
 				int rc = get_new_info_part(
 					&part_info_ptr, force_refresh);
 				if(rc == SLURM_NO_CHANGE_IN_DATA ||
@@ -768,6 +768,7 @@ extern int get_new_info_node(node_info_msg_t **info_ptr, int force)
 	}
 
 	*info_ptr = g_node_info_ptr;
+
 	if (!g_topo_info_msg_ptr &&
 	    default_sview_config.grid_topological) {
 		get_topo_conf(); /*pull in topology NOW*/
diff --git a/src/sview/part_info.c b/src/sview/part_info.c
index 96fd63d2057..1e7f0731122 100644
--- a/src/sview/part_info.c
+++ b/src/sview/part_info.c
@@ -1568,7 +1568,7 @@ static List _create_part_info_list(partition_info_msg_t *part_info_ptr,
 	for (i=0; i<part_info_ptr->record_count; i++) {
 		part_ptr = &(part_info_ptr->partition_array[i]);
 		/*dont include configured excludes*/
-		if (strstr(excluded_partitions,
+		if (strstr(working_sview_config.excluded_partitions,
 			   part_info_ptr->partition_array[i].name))
 			continue;
 		sview_part_info = _create_sview_part_info(part_ptr);
@@ -1703,14 +1703,17 @@ extern bool check_part_includes_node(partition_info_msg_t *part_info_ptr,
 	bool rc = FALSE;
 	int i, j2;
 
+	if (!part_info_ptr)
+		return rc;
+
 	for (i=0; i<part_info_ptr->record_count; i++) {
 		/*dont include configured excludes*/
-		if (strstr(excluded_partitions,
+		if (strstr(working_sview_config.excluded_partitions,
 			   part_info_ptr->partition_array[i].name))
 			continue;
 		part_ptr = &(part_info_ptr->partition_array[i]);
 		j2 = 0;
-		while(part_ptr->node_inx[j2] >= 0) {
+		while (part_ptr->node_inx[j2] >= 0) {
 			if (_DEBUG) {
 				g_print("node_dx = %d ", node_dx);
 				g_print("part_node_inx[j2] = %d ",
diff --git a/src/sview/popups.c b/src/sview/popups.c
index 4a18904cd65..b27c79ca9ce 100644
--- a/src/sview/popups.c
+++ b/src/sview/popups.c
@@ -803,6 +803,20 @@ extern void change_grid_popup(GtkAction *action, gpointer user_data)
 	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 (&gtbtton,working_sview_config.grid_topological);
+	*/
+
 	gtk_widget_show_all(popup);
 	response = gtk_dialog_run (GTK_DIALOG(popup));
 
diff --git a/src/sview/sview.c b/src/sview/sview.c
index 43ddd1034c8..e2f98dbaa51 100644
--- a/src/sview/sview.c
+++ b/src/sview/sview.c
@@ -81,7 +81,6 @@ uint32_t cluster_flags;
 int cluster_dims;
 List cluster_list = NULL;
 switch_record_bitmaps_t *g_switch_nodes_maps = NULL;
-char *excluded_partitions = NULL;
 
 block_info_msg_t *g_block_info_ptr = NULL;
 job_info_msg_t *g_job_info_ptr = NULL;
@@ -99,6 +98,15 @@ static char *orig_cluster_name = NULL;
 static int g_menu_id = 0;
 static GtkUIManager *g_ui_manager = NULL;
 
+/*
+popup_positioner_t main_popup_positioner[] = {
+	{0,"Sview Defaults", 150, 700 },
+	{0,"Full info for job", 450, 650 },
+	{0,"Title_2", 100, 100 },
+	{-1,"FENCE", -1, -1 }
+};
+*/
+
 display_data_t main_display_data[] = {
 	{G_TYPE_NONE, JOB_PAGE, "Jobs", TRUE, -1,
 	 refresh_main, create_model_job, admin_edit_job,
@@ -1031,17 +1039,22 @@ extern void _change_cluster_main(GtkComboBox *combo, gpointer extra)
 						page_check_widget[NODE_PAGE]),
 				     main_display_data[NODE_PAGE].name);
 	}
+
 	/* reinit */
 	rc = get_system_stats(main_grid_table);
 
 	if(rc == SLURM_SUCCESS) {
-		/* It turns out if we didn't have the grid before the
+		/* It turns out if we didn't have the grid (cluster
+		   not responding) before the
 		   new grid doesn't get set up correctly.  Redoing the
 		   system_stats fixes it.  There is probably a better
 		   way of doing this, but it doesn't happen very often
 		   and isn't that bad to handle every once in a while.
 		*/
 		if(!got_grid) {
+			/* I know we just did this before, but it
+			   needs to be done again here.
+			*/
 			if(grid_button_list) {
 				list_destroy(grid_button_list);
 				grid_button_list = NULL;
@@ -1196,7 +1209,6 @@ int main(int argc, char *argv[])
 	GtkWidget *menubar = NULL;
 	GtkWidget *table = NULL;
 	GtkWidget *combo = NULL;
-/* 	GtkWidget *button = NULL; */
 	GtkBin *bin = NULL;
 	GtkViewport *view = NULL;
 	int i=0;
diff --git a/src/sview/sview.h b/src/sview/sview.h
index 3cfecc5508a..928fbb312e1 100644
--- a/src/sview/sview.h
+++ b/src/sview/sview.h
@@ -184,11 +184,13 @@ typedef struct {
 	GtkToggleAction *action_ruled;
 	GtkRadioAction *action_tab;
 	uint16_t tab_pos;
+	char *excluded_partitions;
 } sview_config_t;
 
 typedef struct display_data display_data_t;
 typedef struct specific_info specific_info_t;
 typedef struct popup_info popup_info_t;
+typedef struct popup_positioner popup_positioner_t;
 
 struct display_data {
 	GType type;
@@ -210,6 +212,13 @@ struct display_data {
 	gpointer button_list;
 };
 
+struct popup_positioner {
+	int id;
+	char *name;
+	uint32_t width;
+	uint32_t height;
+};
+
 typedef struct {
 	sview_search_type_t search_type;
 	gchar *gchar_data;
@@ -325,7 +334,7 @@ extern slurm_ctl_conf_info_msg_t *g_ctl_info_ptr;
 extern job_step_info_response_msg_t *g_step_info_ptr;
 extern topo_info_response_msg_t *g_topo_info_msg_ptr;
 extern switch_record_bitmaps_t *g_switch_nodes_maps;
-
+extern popup_positioner_t main_popup_positioner[];
 
 extern void init_grid(node_info_msg_t *node_info_ptr);
 extern int set_grid(int start, int end, int count);
@@ -399,7 +408,6 @@ extern void select_admin_partitions(GtkTreeModel *model, GtkTreeIter *iter,
 				    GtkTreeView *treeview);
 extern void admin_part(GtkTreeModel *model, GtkTreeIter *iter, char *type);
 extern void cluster_change_part();
-extern char *excluded_partitions;
 
 // block_info.c
 extern void refresh_block(GtkAction *action, gpointer user_data);
-- 
GitLab