Re: Gtk2: GtkCellRendererText: changing bgcolor based on..



Hey men,
you no need to write your own renderers for output text in columns of TreeView.
You can use next:

GtkListStore *list_store = gtk_list_store_new(2,G_TYPE_STRING,GDK_TYPE_COLOR);
view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store));
renderer = gtk_cell_renderer_text_new();
col=gtk_tree_view_column_new_with_attributes("Tittle",renderer,
                                    "text",0,
                                    "background-gdk",1,NULL)
gtk_tree_view_append_column(view,col);

Just store GdkColor in second column of the list store to set background of the row.

GdkColor color;
gtk_list_store_set(list_store, iter,0,"Text of the Row",1,&color,-1);

In the same way you can set foreground color of the row (just add one more column to the store).




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