Re: CellRenderText properties question.



* Diego Zuccato (diego otello alma unibo it) wrote:
> "Carl B. Constantine" wrote:
> 
> > ...Also, with GtkTreeViewColumn, you can bind a property to a value in a
> > GtkTreeModel. For example, you can bind the "text" property on the cell
> > renderer to a string value in the model, thus rendering a different string in
> > each row of the GtkTreeView.
> When you add a column to your view, you put ..., "text", COL, ... to
> show the text from model column COL in the currently being added column.
> The same is with "background" and "foreground" attributes, and the
> pointed columns must contain a colour name (as string: "red", "blue",
> etc).

Thanks for the reply. That confirms what I suspected, but IMHO very bad
design as it creates extra overhead for memory and storage in the
TreeModel (ListStore in this case) instead of being able to determine
the property programatically. What if I have a preference setting where
the user change pick a color so it's not just "red" or "blue" it's
"between blue and purple"?

> > However, I can't really find any code examples of how to do anything
> > suggested in these docs. For example, I have a GtkTextView that only has
> > a single column in it. When I click a button in my window, I want to
> > find out the current selection in that TreeView and set it's text to Red
> > or Bold or something. I can't seem to find anything that shows how to
> > get the exact cell and then change its attributes. I can do it globably
> > for a column (and have for testing) but not on a single cell.
> I posted an example a couple of days ago. Just a code snippet from one
> of my projects, but should give you the idea.
> You have to add a column for every attribute.

or add multiple attributes to the column with
gtk_tree_view_column_add_attribute(). But this means I have to add a
column to the model and then hide it after it's appended to the view
right?

> ... If only it could be possible to map values to attributes (1=>"red",
> 2=>"blue" and so on...)

or have a hex value that can then be used for the color. Then a user can
use the color selector to pick a color for certain cells. However, I
find that interface rather awkward to use in that instance, again
because it can't be determined programatically or you have to change the
column the cell looks at "on the fly" which is awkward.


-- 
 .''`.      Carl B. Constantine
: :' :     duckwing duckwing ca
`. `'    GnuPG: 135F FC30 7A02 B0EB 61DB  34E3 3AF1 DC6C 9F7A 3FF8
  `-  Debian GNU/Linux -- The power of freedom

Attachment: pgpMyOdnUa5TV.pgp
Description: PGP signature



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