Пример #1
0
static void _each_highlightd(GtkTreeModel *model,
			     GtkTreePath *path,
			     GtkTreeIter *iter,
			     gpointer userdata)
{
	ListIterator itr = NULL;
	grid_button_t *grid_button = NULL;
	int *node_inx = NULL;
	int color_inx;

	int j=0;
	GdkColor color;

	grid_foreach_t *grid_foreach = userdata;

	gtk_tree_model_get(model, iter, grid_foreach->node_inx_id,
			   &node_inx, -1);
	gtk_tree_model_get(model, iter, grid_foreach->color_inx_id,
			   &color_inx, -1);

	if (!node_inx)
		return;

	if (color_inx > sview_colors_cnt) {
		g_print("hey the color_inx from %d was set to %d > %d\n",
			grid_foreach->color_inx_id, color_inx,
			sview_colors_cnt);
		color_inx %= sview_colors_cnt;
	}
	gdk_color_parse(sview_colors[color_inx], &color);

	itr = list_iterator_create(grid_foreach->button_list);
	while ((grid_button = list_next(itr))) {
		/*For multiple selections, need to retain all selected.
		 *(previously this assumed only one selected).
		 */

		if ((node_inx[j] < 0)
		    || (grid_button->inx < node_inx[j])
		    || (grid_button->inx > node_inx[j+1]))
			continue;

		(void)_change_button_color(grid_button, color_inx,
				     sview_colors[color_inx],
				     color, 0, 0);

		if (GTK_WIDGET_STATE(grid_button->button) != GTK_STATE_NORMAL)
			gtk_widget_set_state(grid_button->button,
					     GTK_STATE_NORMAL);

		if (grid_button->inx == node_inx[j+1])
			j+=2;

	}

	list_iterator_destroy(itr);
	return;
}
Пример #2
0
/* This variation of change_grid_color() is faster when changing many
 * button colors at the same time since we can issue a single call to
 * _change_button_color() and eliminate a nested loop. */
extern void change_grid_color_array(List button_list, int array_len,
				    int *color_inx, bool *color_set_flag,
				    bool only_change_unused,
				    enum node_states state_override)
{
	ListIterator itr = NULL;
	grid_button_t *grid_button = NULL;
	GdkColor color;
	char *new_col = NULL;

	if (!button_list)
		return;

	itr = list_iterator_create(button_list);
	while ((grid_button = list_next(itr))) {
		if ((grid_button->inx < 0) || (grid_button->inx >= array_len))
			continue;
		if (!color_set_flag[grid_button->inx])
			continue;

		if (color_inx[grid_button->inx] >= 0) {
			color_inx[grid_button->inx] %= sview_colors_cnt;
			new_col = sview_colors[color_inx[grid_button->inx]];
		} else if (color_inx[grid_button->inx] == MAKE_BLACK) {
			new_col = blank_color;
		} else if (color_inx[grid_button->inx] == MAKE_TOPO_1) {
			new_col = topo1_color;
		} else if (color_inx[grid_button->inx] == MAKE_TOPO_2) {
			new_col = topo2_color;
		} else
			new_col = white_color;
		gdk_color_parse(new_col, &color);

		_change_button_color(grid_button, color_inx[grid_button->inx],
				     new_col, color, only_change_unused,
				     state_override);
	}
	list_iterator_destroy(itr);
	return;
}
Пример #3
0
/* start == -1 for all */
extern char *change_grid_color(List button_list, int start, int end,
			       int color_inx, bool only_change_unused,
			       enum node_states state_override)
{
	ListIterator itr = NULL;
	grid_button_t *grid_button = NULL;
	GdkColor color;
	char *new_col = NULL;

	if (!button_list)
		return NULL;

	if (color_inx >= 0) {
		color_inx %= sview_colors_cnt;
		new_col = sview_colors[color_inx];
	} else if (color_inx == MAKE_BLACK) {
		new_col = blank_color;
	} else if (color_inx == MAKE_TOPO_1) {
		new_col = topo1_color;
	} else if (color_inx == MAKE_TOPO_2) {
		new_col = topo2_color;
	} else
		new_col = white_color;

	gdk_color_parse(new_col, &color);

	itr = list_iterator_create(button_list);
	while ((grid_button = list_next(itr))) {
		if ((start != -1) &&
		    ((grid_button->inx < start) || (grid_button->inx > end)))
			continue;
		_change_button_color(grid_button, color_inx, new_col,
				     color, only_change_unused, state_override);
	}
	list_iterator_destroy(itr);

	return sview_colors[color_inx];
}