Re: g_object_set and threads



abel schie wrote:
abel schie wrote:
I've made a gtktreeviewcolumn with a custom GtkTreeCellDataFunc,
called cell_func(). This custom function uses the underlying
GtkListStore to render the cells: it uses gtk_tree_model_get() to
fetch some values, and then g_object_set(renderer,...) to update the
cell renderer.

Now, there are some time out functions running, which update the
GtkListStore. These functions are all surrounded by
gdk_threads_enter() and gdk_threads_leave(). However, the treeview
isn't refreshed automatically. Only when I hover it with the mouse it
gets really updated. Everytime these timeouts are running, cell_func()
is actually called.

My question is: how can I force g_object_set() to instantly redraw the
cell renderer? My first thought was: use gdk_threads_enter() and
gdk_threads_leave() also within cell_func(). But when I do that, I get
a lock while constructing the treeview, therefore the app
hangs. Putting the routine creating the treeview in a separate thread
as well didn't result in anything good.

Any ideas?

My guess would be gtk_tree_model_row_changed().

But how could I do that? Within a GtkTreeCellDataFunc it's not
possible to find out to which row that cell belongs I think.

No, you don't call gtk_tree_model_row_changed() from you cell data function,
but from you time out function, which updates the list store.  And you call
it on the list store.

Anyway, you _can_ find which row the cell belongs to from the cell data
function, that's what the `iter' argument is for.

Is there a way to force the redraw of the cell renderer?

I think you misunderstand things.  You cannot redraw a cell renderer, because
cell renderer is merely an algorithm that draws cells.  It is not bound to
any specific cell or tree row or whatever.

Paul




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