* The Saltydog <[EMAIL PROTECTED]> [2005-07-01 10:35]: > On 7/1/05, Jan Hudec <[EMAIL PROTECTED]> wrote: > > Wow, that's complex! Simply running Gtk2->main_iteration > > while Gtk2->events_pending; between reading the lines is > > easier and does the job just as well. > > Yes, but I needed the user to be free to start using all > program features, even while the treeview is growing. So he can > open trees, doubleclick, use menu items and even stop the scan.
You are programming by coincidence[1]. If you actually understood how Gtk2 works, you’d know that the loop Jan mentioned enables exactly the behaviour you want, and you could avoid a lot of complexity. By way of an explanation: a GUI program works by having a mainloop which runs indefinitely and checks whether the user did anything. For anything the user does, it registers an “event,” then calls handlers to react to that event. Gtk2->main_iteration does that for exactly one event. If there was no event pending processing, it blocks (so you don’t want to call it if there are none). Gtk2->event_pending checks whether there’s anything in the queue. That means that the loop Jan mentioned will process any clicks, redraws, etc which were queued up when the program was busy, any time it has a moment to spare. [1] http://www.pragmaticprogrammer.com/ppbook/extracts/coincidence.html Hope this helps, -- #Aristotle *AUTOLOAD=*_=sub{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1}; &Just->another->Perl->hacker; _______________________________________________ gtk-perl-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtk-perl-list
