Re: ListStore and Text Color




On Apr 8, 2005, at 7:14 AM, Stephan Martin wrote:

i'm entering the next step in my lesson "how to read documentation" :-)

I have a ListStore with text fileds inside. Depending on the value, i want
to add the text in one special field in red or in green.

Is there a way to achieve that?

There are three ways to set the color of a cell:

a) tie the foreground property to a column in your model where the color is stored. b) use pango markup for the cell text (the "markup" property instead of the "text" property) and specify the color there.
c) use a custom cell data function to calculate and set the color.

c) is the most flexible option, giving you complete control over the display separated from the data. however, cell data functions get called a *lot*, and have the potential to become performance bottlenecks. a) and b) trade memory for speed, and couple the display rules with the data; you essentially precalculate and cache the color at the time you insert the data value into the model.

all that said, the stock browser example in gtk-demo uses cell data functions to set stock pixbufs and text; so you can get fairly sophisticated before you start to see performance problems.


You might want to read the TreeView tutorial.

http://scentric.net/tutorial/

http://scentric.net/tutorial/sec-treeview-col-whole-row.html


--
elysse (pregnant): are your hands cold?
me: uh, i suppose so.
elysse: will you put them on me?




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