On Thu, 28 Nov 2013 09:11:45 +0000 Osmo Antero <osm...@gmail.com> wrote: > My audio-recorder that was based on GTK2 had some threads that also > modified the GUI-elements. I had to call > GDK_THREADS_ENTER<https://developer.gnome.org/gdk3/3.10/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS> > / > GDK_THREADS_LEAVE<https://developer.gnome.org/gdk3/3.10/gdk3-Threads.html#GDK-THREADS-ENTER:CAPS> > before modifying the GTK-elements, otherwise the GUI froze. > > Now in GTK3, I've replaced the threads with > g_timeout_add_full<https://developer.gnome.org/glib/2.30/glib-The-Main-Event-Loop.html#g-timeout-add-full> > () and > GAsyncQueue<https://developer.gnome.org/glib/2.26/glib-Asynchronous-Queues.html#GAsyncQueue> > . > g_timeout_full_id() runs within the MainLoop so GUI-locking is handled > automatically.
I am not saying that using a polling timeout which checks for action keys has no uses, but using g_idle_add() to have a worker thread communicate with the glib main loop is usually preferable because it avoids the need to poll, and it is just as thread safe. Chris _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list