Re: GtkTreeView: g_signal_handlers_unblock_by_func



Tadej BorovÅak wrote:
Hello.

Essentially adding a simple store model:

store = gtk_list_store_new (1, G_TYPE_STRING);
while (foo_bar != NULL)
 {
 gtk_list_store_append (store, &iter);
 gtk_list_store_set (store, &iter, 0, my_name, -1);
 }
gtk_tree_view_set_model (GTK_TREE_VIEW (treeview), GTK_TREE_MODEL (store));
g_object_unref (store);

I need to block before and unblock in the end because treeview is connected
to this signal:

g_signal_connect (treeview, "cursor-changed",
G_CALLBACK (update_model), window);

Everytime a user clicks on a row, "cursor-changed" is triggered,
update_model is called, and a new model replaces the previous one. It
happens that this model change triggers again the "cursor-changed" signal,
so to prevent "cursor-changed" from calling again update_model, I have to
block the signal before I change the store model. The issue here is the
signal must be unblocked again only at the very end. What happens now is,
the signal is unblocked at the end, but GTK still calls update_model AFTER
that... the timer solves the issue, because it forces GTK to clean all his
stuff before calling the timer... in fact this works even with the delay set
to zero...

My assumptions were correct. The thing that is causing you troubles
here is GtkTreeView's internally installed idle callbacks that update
the tree view after the function that caused the changes returns. I'm
afraid that there is no other way around it but to use g_idle_add.
Idle callbacks that are installed by GtkTreeView have quite high
priority, so your installed timeout/idle handlers will be called after
the ones GtkTreeView installed.

Thanks Tadej,

so I will use the timeout method, which according to your explanation (and my testing) should work fine in all systems,

Cheers,
Carlos
Tadej






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