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



On Thu, 2002-09-12 at 18:54, Jonathan Blandford wrote:
Geert Vanderkelen <geert kemuri org> writes:

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.

That would be great indeed :)

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 i have the renderer bound to the column globally set as 'renderTime'.
Global is good in this case because of testing :)

Every 300ms I have a function with the iteration called via a timeout.
I'm getting the GtkListStore out of the GtkTreeView and clear it.

slotlist = (GtkWidget*)g_object_get_data(G_OBJECT(window),
                                           "slotlist");
store = GTK_LIST_STORE(
        gtk_tree_view_get_model(GTK_TREE_VIEW(slotlist)));
gtk_list_store_clear(store);

while(databaseresult) {

        if( age > 4) {
                g_object_set(G_OBJECT(renderTime),"background","red",NULL);
        } else {
                g_object_set(G_OBJECT(renderTime),"background","red",NULL);
        }
        gtk_list_store_append(store, &iter);
        gtk_list_store_set(....);
}

See? I think I got it all wrong with the renderer stuff anyway :)
Weird, append and then set.. I just saw.. Shouldn't that be first set
and then append?

It works all fine btw, that list.. except for everytime the function is
called, the memory piles up.. And I spend hours debugging.. but that is
another matter.


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.

Great, but I guess I'm going to write that renderer myself somehow.. But
I will need some directions in doing so :/

Thanks!

Regards,

Geert

-- 
Geert Vanderkelen
Kemuri.Org

http://kemuri.org





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