On Mon, Nov 17, 2008 at 21:10, Sergei Steshenko <[EMAIL PROTECTED]> wrote: snip > When the button is clicked and Gtk2->main_quit is called, will > Gtk2->main_quit be executed immediately or the anonymous sub containing > the call to Gtk2->main_quit will be executed to the end and only then main > loop depth will be decreased by one ? snip
Gtk2->main_quit sets a flag that causes Gtk2->main to exit the next time it has control. snip > I am not going to call Gtk2->main_quit just for fun, I want to execute a > really lengthy subroutine taking up to, say, 10 seconds. I've noticed that > shorter (a couple of seconds) subroutines work fine, but the long ones > sometimes interfere with GUI behavior - it looks like some events are > either lost or are recognized out of order. snip The best way to deal with this is to continue to handle events during you long subroutines. You can handle all pending events by saying Gtk2->main_iteration while Gtk2->pending_events; If your subroutine has loops, then it is a good idea to put the code above at the top of the loops; otherwise, spread a few instances of the code through your subroutine. snip > So, overall my idea is to temporarily freeze GUI functionality by calling > Gtk2->main_quit, then to execute the lengthly subroutine, then to revive > the GUI by again calling Gtk2->main. snip Not a good idea. Handle the events as they happen, don't try to turn off the GUI. An unresponsive GUI is incredibly annoying. If events aren't handled then even the draw/resize events won't occur. So if I move a window over your app's window and then go back, the portion that was covered will be gray (or whatever the base color of the theme is). If you have widgets that should not be interacted with during your callback you should call ->sensitive(0) on each of them with at the start of your callback and ->sensitive(1) on each of them at the end. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. _______________________________________________ gtk-perl-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtk-perl-list
