Re: GtkTreeView possibilities to set text propertys on individual columns



Mikael Hermansson <mikeh bahnhof se> writes:
> 1. I have setup three tree_view_columns that is using the same cell
> renderer:
> and one mapped cell property ("foreground") like this:
> 
>   cell = gtk_cell_renderer_text_new ();
>   column = gtk_tree_view_column_new_with_attributes ("Source/Binary", cell,
> "text", 0, NULL);
>   gtk_tree_view_append_column (GTK_TREE_VIEW (app->treeview), column);
> 
>   column = gtk_tree_view_column_new_with_attributes ("Linenum", cell,
> "text", 1, NULL);
>   gtk_tree_view_append_column (GTK_TREE_VIEW (app->treeview), column);
> 
>   column = gtk_tree_view_column_new_with_attributes ("Message/commands",
> cell, "text", 2,"foreground",3, NULL);
>   gtk_tree_view_append_column (GTK_TREE_VIEW (app->treeview), column);

First of all, you should be using different cells here.  While you can
share a cell between columns, you should only do that if you are setting
identical attributes.  In this case, you will have the red color 'bleed'
from the third column into the next lines first two columns.

> And setup a new listitem like:
> 
>   gtk_tree_store_set (app->model, &iter, 0,"column 1", 1,"column 2", 2,
> "column 3", 3, "#ff0000", -1); /* items should be red colored */
> 
> Now if I am not want to set the foreground (means use default color):
> 
>   gtk_tree_store_set (app->model, &iter, 0,"column 1", 1,"column 2", 2,
> "column 3", -1)   /* don't pass last argument */
> 
> With this code I get a warning passing NULL to gdk_color_parse should we
> really 
> take this as an error/warning?  How about just set it to default property
> if you 
> don't pass all arguments to tree_store_set?

hrm.  I guess it could do that, but it feels unclean somehow.  I don't
know what other properties in GTK+ do if you set them to NULL.  Tim?

Thanks,
-Jonathan




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