コード例 #1
0
ファイル: grid.c プロジェクト: jtfrey/slurm
void _put_button_as_inactive(grid_button_t *grid_button)
{
	if (GTK_IS_BUTTON(grid_button->button)) {
		//gtk_widget_set_sensitive (grid_button->button, false);
		return;
	}
	gtk_widget_destroy(grid_button->button);
	grid_button->button = gtk_button_new();
	gtk_widget_set_size_request(grid_button->button,
				    working_sview_config.button_size,
				    working_sview_config.button_size);
	//gtk_widget_set_sensitive (grid_button->button, false);

	_add_button_signals(grid_button);

/* 	if (grid_button->frame) */
/* 		gtk_container_add(GTK_CONTAINER(grid_button->frame), */
/* 				  grid_button->button); */
	if (grid_button->table)
		gtk_table_attach(grid_button->table, grid_button->button,
				 grid_button->table_x,
				 (grid_button->table_x+1),
				 grid_button->table_y,
				 (grid_button->table_y+1),
				 GTK_SHRINK, GTK_SHRINK,
				 1, 1);
	gtk_widget_show_all(grid_button->button);
	return;
}
コード例 #2
0
ファイル: grid.c プロジェクト: jtfrey/slurm
void _put_button_as_down(grid_button_t *grid_button, int state)
{
	GtkWidget *image = NULL;
/* 	GdkColor color; */

	if (GTK_IS_EVENT_BOX(grid_button->button)) {
		//gtk_widget_set_sensitive (grid_button->button, true);
		return;
	}

	gtk_widget_destroy(grid_button->button);
	grid_button->color = NULL;
	grid_button->color_inx = MAKE_DOWN;
	grid_button->button = gtk_event_box_new();
	gtk_widget_set_size_request(grid_button->button,
				    working_sview_config.button_size,
				    working_sview_config.button_size);
	gtk_event_box_set_above_child(GTK_EVENT_BOX(grid_button->button),
				      false);
	_add_button_signals(grid_button);

/* 	if (grid_button->frame) */
/* 		gtk_container_add(GTK_CONTAINER(grid_button->frame), */
/* 				  grid_button->button); */
	if (grid_button->table)
		gtk_table_attach(grid_button->table, grid_button->button,
				 grid_button->table_x,
				 (grid_button->table_x+1),
				 grid_button->table_y,
				 (grid_button->table_y+1),
				 GTK_SHRINK, GTK_SHRINK,
				 1, 1);

	//gdk_color_parse("black", &color);
	//sview_widget_modify_bg(grid_button->button, GTK_STATE_NORMAL, color);
	//gdk_color_parse(white_color, &color);
	//sview_widget_modify_bg(grid_button->button, GTK_STATE_ACTIVE, color);
	if (state == NODE_STATE_DRAIN)
		image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_ERROR,
						 GTK_ICON_SIZE_SMALL_TOOLBAR);
	else
		image = gtk_image_new_from_stock(GTK_STOCK_CANCEL,
						 GTK_ICON_SIZE_SMALL_TOOLBAR);
	gtk_container_add(GTK_CONTAINER(grid_button->button), image);
	gtk_widget_show_all(grid_button->button);
	return;
}
コード例 #3
0
ファイル: grid.c プロジェクト: jtfrey/slurm
extern List copy_main_button_list(int initial_color)
{
	ListIterator itr = NULL;
	grid_button_t *grid_button = NULL;
	grid_button_t *send_grid_button = NULL;
	List button_list = list_create(destroy_grid_button);

	itr = list_iterator_create(grid_button_list);
	while ((grid_button = list_next(itr))) {
		send_grid_button = create_grid_button_from_another(
			grid_button, grid_button->node_name, initial_color);
		if (send_grid_button) {
			send_grid_button->button_list = button_list;
			_add_button_signals(send_grid_button);
			send_grid_button->used = false;
			list_append(button_list, send_grid_button);
		}
	}
	list_iterator_destroy(itr);
	return button_list;
}
コード例 #4
0
ファイル: grid.c プロジェクト: jtfrey/slurm
extern void get_button_list_from_main(List *button_list, int start, int end,
				      int color_inx)
{
	ListIterator itr = NULL;
	ListIterator button_itr = NULL;
	grid_button_t *grid_button = NULL;
	grid_button_t *send_grid_button = NULL;

	if (!*button_list)
		*button_list = list_create(destroy_grid_button);

	color_inx %= sview_colors_cnt;
	itr = list_iterator_create(grid_button_list);
	while ((grid_button = list_next(itr))) {
		if ((grid_button->inx < start)
		    ||  (grid_button->inx > end))
			continue;
		button_itr = list_iterator_create(*button_list);
		while ((send_grid_button = list_next(button_itr))) {
			if (send_grid_button->inx == grid_button->inx)
				break;
		}
		list_iterator_destroy(button_itr);
		if (send_grid_button)
			continue;

		send_grid_button = create_grid_button_from_another(
			grid_button, grid_button->node_name, color_inx);
		if (send_grid_button) {
			send_grid_button->button_list = *button_list;
			_add_button_signals(send_grid_button);
			list_append(*button_list, send_grid_button);
		}
	}
	list_iterator_destroy(itr);
	return;
}
コード例 #5
0
ファイル: grid.c プロジェクト: jtfrey/slurm
/* Add a button for a given node. If node_ptr == NULL then fill in any gaps
 * in the grid just for a clean look. Always call with node_ptr == NULL for
 * the last call in the sequence. */
static int _add_button_to_list(node_info_t *node_ptr,
			       button_processor_t *button_processor)
{
	static bool *node_exists = NULL;
	static int node_exists_cnt = 1;
	grid_button_t *grid_button = button_processor->grid_button;
	int *dim_size = NULL, i, coord_x = 0, coord_y = 0;
	int len = 0, len_a = 0;

	if (cluster_dims > 1) {
		dim_size = _get_cluster_dims();
		if (dim_size == NULL) {
			g_error("Could not read dim_size\n");
			return SLURM_ERROR;
		}
		if ((dim_size[0] < 1) || (cluster_dims < 1)) {
			g_error("Invalid dim_size %d or cluster_dims %d\n",
				dim_size[0], cluster_dims);
			return SLURM_ERROR;
		}

		/* Translate a 3D or 4D space into a 2D space to the extent
		 * possible. */
		if (node_exists == NULL) {
			node_exists_cnt = 1;
			for (i = 0; i < cluster_dims; i++)
				node_exists_cnt *= dim_size[i];
			node_exists = xmalloc(sizeof(bool) * node_exists_cnt);
		}
		if (node_ptr) {
			len = strlen(node_ptr->name);
			if (len < cluster_dims) {
				g_error("bad node name %s\n", node_ptr->name);
				return SLURM_ERROR;
			}
			if (cluster_flags & CLUSTER_FLAG_CRAY_A) {
				len_a = strlen(node_ptr->node_addr);
				if (len_a < cluster_dims) {
					g_error("bad node addr %s\n",
						node_ptr->node_addr);
					return SLURM_ERROR;
				}
			}
		}
	}

	if (cluster_dims == 3) {
		int x, y, z;
		if (node_ptr) {
			if (cluster_flags & CLUSTER_FLAG_CRAY_A) {
				x = select_char2coord(
					node_ptr->node_addr[len_a-3]);
				y = select_char2coord(
					node_ptr->node_addr[len_a-2]);
				z = select_char2coord(
					node_ptr->node_addr[len_a-1]);
			} else {
				x = select_char2coord(node_ptr->name[len-3]);
				y = select_char2coord(node_ptr->name[len-2]);
				z = select_char2coord(node_ptr->name[len-1]);
			}
			i = (x * dim_size[1] + y) * dim_size[2] + z;
			node_exists[i] = true;
			_calc_coord_3d(x, y, z,
				       button_processor->default_y_offset,
				       &coord_x, &coord_y, dim_size);
		} else {
			for (x = 0; x < dim_size[0]; x++) {
				for (y = 0; y < dim_size[1]; y++) {
					for (z = 0; z < dim_size[2]; z++) {
						i = (x * dim_size[1] + y) *
							dim_size[2] + z;
						if (node_exists[i])
							continue;
						_calc_coord_3d(x, y, z,
				      			button_processor->
							default_y_offset,
							&coord_x, &coord_y,
							dim_size);
						_build_empty_node(
							coord_x, coord_y,
							button_processor);
					}
				}
			}
			xfree(node_exists);
			return SLURM_SUCCESS;
		}
	}
	if (node_ptr == NULL)
		return SLURM_SUCCESS;

	if (cluster_dims > 1) {
		(*button_processor->coord_x) = coord_x;
		(*button_processor->coord_y) = coord_y;
#if 0
		g_print("%s %d:%d\n", node_ptr->name, coord_x, coord_y);
#endif
	}

	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,
					    working_sview_config.button_size,
					    working_sview_config.button_size);
		_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), */
/* 					  GTK_SHADOW_ETCHED_OUT); */
	if (cluster_dims < 3) {
		/* On linear systems we just up the x_coord until we hit the
		 * side of the table and then increment the coord_y.  We add
		 * space between each tenth row. */
		(*button_processor->coord_x)++;

		if (button_processor->force_row_break) {
			(*button_processor->coord_x) = 0;
			(*button_processor->coord_y)++;
			gtk_table_set_row_spacing(
				button_processor->table,
				(*button_processor->coord_y)-1,
				working_sview_config.gap_size);
			return SLURM_SUCCESS;
		}

		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,
					working_sview_config.gap_size);
		}

		if ((*button_processor->coord_y) == button_processor->table_y)
			return SLURM_SUCCESS;

		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,
				working_sview_config.gap_size);
	}
	return SLURM_SUCCESS;
}
コード例 #6
0
ファイル: grid.c プロジェクト: tpatki/slurm_test
extern void add_extra_bluegene_buttons(List *button_list, int inx,
				       int *color_inx)
{
	block_info_msg_t *block_ptr = NULL;
	block_info_t *bg_info_ptr = NULL;
	int rc = SLURM_SUCCESS;
	ListIterator itr = NULL;
	grid_button_t *grid_button = NULL;
	grid_button_t *send_grid_button = NULL;
	int i=0;
	char *mp_str = NULL;
	char tmp_nodes[256];
	int found = 0;
	int coord_y=0;
	uint16_t orig_state;

	rc = get_new_info_block(&block_ptr, 0);

	if ((rc != SLURM_SUCCESS) && (rc != SLURM_NO_CHANGE_IN_DATA)) {
		return;
	}

	if (!*button_list)
		*button_list = list_create(NULL);

	*color_inx %= sview_colors_cnt;

	itr = list_iterator_create(grid_button_list);
	while ((grid_button = list_next(itr))) {
		if (grid_button->inx == inx)
			break;
	}
	list_iterator_destroy(itr);

	if (!grid_button)
		return;
	orig_state = grid_button->state;
	/* remove all (if any) buttons pointing to this node since we
	   will be creating all of them */

	itr = list_iterator_create(*button_list);
	while ((send_grid_button = list_next(itr))) {
		if (send_grid_button->inx == grid_button->inx)
			list_remove(itr);
	}
	list_iterator_destroy(itr);

	for (i=0; i < block_ptr->record_count; i++) {
		bg_info_ptr = &block_ptr->block_array[i];
		if (!_block_in_node(bg_info_ptr->mp_inx, inx))
			continue;
		found = 1;
		mp_str = bg_info_ptr->mp_str;
		if (bg_info_ptr->ionode_str) {
			sprintf(tmp_nodes, "%s[%s]", mp_str,
				bg_info_ptr->ionode_str);
			mp_str = tmp_nodes;
		}
		if (bg_info_ptr->state & BG_BLOCK_ERROR_FLAG)
			grid_button->state = NODE_STATE_ERROR;
		else if (bg_info_ptr->job_running > NO_JOB_RUNNING)
			grid_button->state = NODE_STATE_ALLOCATED;
		else
			grid_button->state = NODE_STATE_IDLE;
		send_grid_button = create_grid_button_from_another(
			grid_button, mp_str, *color_inx);
		grid_button->state = orig_state;
		if (send_grid_button) {
			send_grid_button->button_list = *button_list;
			send_grid_button->table_x = 0;
			send_grid_button->table_y = coord_y++;
			//_add_button_signals(send_grid_button);
			/* this is a different signal than usual */
			g_signal_connect(
				G_OBJECT(send_grid_button->button),
				"button-press-event",
				G_CALLBACK(_open_block),
				send_grid_button);
			g_signal_connect(G_OBJECT(grid_button->button),
					 "enter-notify-event",
					 G_CALLBACK(_mouseover_node),
					 grid_button);
			g_signal_connect(G_OBJECT(grid_button->button),
					 "leave-notify-event",
					 G_CALLBACK(_mouseoff_node),
					 grid_button);
			list_append(*button_list, send_grid_button);
			(*color_inx)++;
		}
	}
	if (!found) {
		send_grid_button = create_grid_button_from_another(
			grid_button, grid_button->node_name, *color_inx);
		if (send_grid_button) {
			send_grid_button->button_list = *button_list;
			send_grid_button->table_x = 0;
			send_grid_button->table_y = coord_y++;
			_add_button_signals(send_grid_button);
			list_append(*button_list, send_grid_button);
			(*color_inx)++;
		}
	}

}