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



Geert Vanderkelen <geert kemuri org> writes:

Hi,

It's a GTK-2.0 question, so I'm not sure if I have to use this
mailinglist.. :)

Anyway. I have a GtkTreeView with a GtkListStore and such. It updates
every 300ms (query to database, get rows, show rows). It's a monitoring
system. It's running really great, and I'm not sure if I can make it
faster with other widgets.

To make it more appealing, the cells should have colors. Like a time
cell > 5 secs.. color red and so on.

Setting the bg color of a cell isn't doable in GTK+2.0 without a custom
renderer.  With 2.1, you can just set the "cell_background" property.

Now, I can set the cell color with g_object_set().. But I want to do
this when updating the Store.. So on the fly a color where a column can
have let's say 5 different colors.. you know.
I tried to set the property in the iteration making the list, but I'm
not successful. Probably it is not placed correctly.

Where are you setting the cell color?  That doesn't sound correct.

So, do I need to write a new GtkCellRenderer that can based on the value
the cell has, change it's backgroundcolor. Or can I do it with
GtkCellRendererText?
You know, a signal like 'changed' instead of 'edited' would be great :)

For 2.0 you will have to write your own renderer.  It should be pretty
simple, though.  You can also change the color of the text by changing
the "foreground" property.  That may be sufficient until 2.2 is
finished.

-Jonathan



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