Multi-threaded GUI



I am a new programmer to GTK and I am trying to wrap my head around several things. The biggest being the fact that GTK main is single threaded and blocking. I am using the gtkmm package.

Basicaly what happens is that when a user presses a connect button on my interface, the callback fires up a seperate pthread to handle the connection. Unfortunately I want this new thread to update the interface regularly to let the user know it is trying to connect.

I have tried using the following code:

while(Gtk::Main::events_pending() )
{
       Gtk::Main::iteration();
}


Now GTK keeps complaining that it is being told to update from outside the Gtk::Main loop, and the program is EXTREMELY flaky, usualy dying on a signal 11 shortely.

How do I get the main loop to update the interface without killing everything? I have tried finding information on the Glib::Dispatcher system but there is really no information on how it works, or how to use it.

Any help would be greatly apreciated.

Sincerely
Melvin Newman


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