Use of threads with gtkmm.



Hello

I've got a C++ program I'd like to add a Gtk+ GUI onto, the program
needs to be able to update the GUI with changes.

I did try doing as a small test:
       g_thread_init(NULL);
       gdk_threads_init();
       gdk_threads_enter();
       /* Gtk stuff */
       gdk_threads_leave();
       std::cout << "Blah" << std::end;
but it never reached the cout statement.

This excerpt from the FAQ sounds like what I'm after:
"or alternatively, ensure that only a single thread makes such calls.
One common way to do this is to have non-GUI threads send requests to
the GUI thread via a pipe. The pipe is hooked into the main glib event
loop used by GTK."

But I've been unable to find any simple example code for this. Could anyone
provide a brief example?

Many thanks



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