Hi Simon,
On 03/02/2013 01:37 PM, Simon Feltman wrote:
http://thread.gmane.org/gmane.__comp.gnome.gtk+.general/24817/__focus=24834...
<http://thread.gmane.org/gmane.comp.gnome.gtk+.general/24817/focus=24834>
Eh.
I've been reading the whole thread, as well as other threads on the
group, and I'm not sure the situation is clarified in my head... :-)
Some says Gdk.thread_* functions are deprecated and everything
touching Gtk should run in the main thread, some says GLib.idle_add
is running in the main thread and it's OK but maybe not...
I think I was able to gain a some understanding from that discussion.
What I got from it is the deprecation is only for
gdk_threads_enter/leave, not threading functions in general. Instead of
using enter/leave, use gdk_threads_add_* functions to queue up a
callbacks that interact with GTK/GDK. Internally these just wrap your
callback in enter/leave anyhow. And enter/leave won't go away until GTK
4, they will always remain functional for the lifetime of GTK 3.
All of this seems somewhat irrelevant at least in the current state of
the code base if you are writing a single threaded app. So unless you
want to intact with GTK from a thread other than the main one, you never
need to call gdk_threads_init. And if you don't call gdk_threads_init,
gdk_threads_enter/leave are a no-op anyway and a lock is not even used.
OK, so my plan will be to remove all the threads from the application, except one I think (which does background download of URLs - although I'm looking towards GIO to do this - it's not supposed to touch any Gtk related things, I'll double check anyway). There are interesting parts where the threads are not really required if Gtk is properly used.
>
> GLib.idle_add(gtk_entry.set_text, "foo bar")
If GDK threading is enabled, I think it should be:
Gdk.threads_add_idle(GLib.PRIORITY_DEFAULT, gtk_entry.set_text, "foo bar")
Then, I should be able to remove the Gdk.threads_* related functions and hopefully to remove all the GLib.idle_add function calls described above (which should simplify the code).
Hopefully, I grasp the Gtk's threading model better now...
Thanks for your help!
Jonathan
_______________________________________________
python-hackers-list mailing list
python-hackers-list gnome org
https://mail.gnome.org/mailman/listinfo/python-hackers-list