Re: Different Pixbuf on each treeview row - Please help
- From: Diego Zuccato <diego otello alma unibo it>
- To: Victor Mierla <lists bumerang ro>
- Cc: gtk-list gnome org
- Subject: Re: Different Pixbuf on each treeview row - Please help
- Date: Mon, 03 Mar 2003 13:14:44 +0000
Victor Mierla wrote:
> \"For example, you can bind the \"pixbuf\" property on the cell renderer to a pixbuf
> value in the model, thus rendering a different image in each row of the
> GtkTreeView.\"
> How can i do this??
See the example about setting fg/bg colours.
Basically, you have to add a column to the model, then store the colour
name (maybe, for a pixbuf, a ptr to the pixbuf itself?) in it and tell
the cell renderer OF ANOTHER COLUMN to use the previous one as "source".
Here's some code from one of my current projects:
// Prepare model "grotte" (id, nome, catasto, colprot, #att., #foto)
grotte=GTK_TREE_MODEL(gtk_list_store_new(6, G_TYPE_INT, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT));
// Init columns for model
v=GTK_TREE_VIEW(LW(src_crit_cave));
gtk_tree_view_set_model(v, grotte);
c=gtk_tree_view_column_new_with_attributes("Nome", rct, "text", 1,
"foreground", 3, NULL);
gtk_tree_view_append_column(v, c);
c=gtk_tree_view_column_new_with_attributes("Catasto", rct, "text", 2,
NULL);
gtk_tree_view_append_column(v, c);
c=gtk_tree_view_column_new_with_attributes("#att.", rcn, "text", 4,
"foreground", 3,NULL);
gtk_tree_view_append_column(v, c);
c=gtk_tree_view_column_new_with_attributes("#foto", rcn, "text", 5,
NULL);
gtk_tree_view_append_column(v, c);
Column 3 contains colour name (e.g. "red" or "black") to be used as
foreground for columns 1 and 4. IIUC pixbuf should be similar.
PS: do you know a way to detect if a column haven't been initialized?
gtk_tree_model_get_value() segfaults...
BYtE,
Diego.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]