Re: Colour rows of TreeView



I have done this, but it doesn't work, all cells in the first column are

in red!

void insert_row_colored(const char *color, bool colored, int ncolonne, ...){
GList *listcellrend= NULL, *listcol= NULL; GtkTreeViewColumn *col= NULL; GtkCellRenderer *renderer= NULL;

	va_list args;
	va_start(args, ncolonne);
	GtkTreeIter newrow;
	gtk_list_store_append(GTK_LIST_STORE(liststore), &newrow);
	gtk_list_store_set_valist(GTK_LIST_STORE(liststore), &newrow, args);
	va_end(args);

	listcol = gtk_tree_view_get_columns(GTK_TREE_VIEW(treeview));
	col= (GtkTreeViewColumn*) listcol->data;
	listcellrend= gtk_tree_view_column_get_cell_renderers(col);
	renderer= (GtkCellRenderer*) listcellrend->data;
	if (colored){
		std::cout<<"COLORED"<<std::endl;
		g_object_set(renderer, "foreground", color, "foreground-set", TRUE, NULL);
	}
	else{
		std::cout<<"NOT COLORED"<<std::endl;
		g_object_set(renderer, "foreground-set", FALSE, NULL);
	}
}


------------------
OUTPUT AT RUNTIME:
------------------
COLORED
NOT COLORED
COLORED
NOT COLORED
COLORED


But All cells in the first column are in RED!



Thanks you!








[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]