Re: Run menu action in background




On Jan 10, 2007, at 8:36 PM, Philipp E. Letschert wrote:

I have a subroutine connected to a popup menu item. When that routine is finished a new popup window displays the result. Sometimes the routine takes
longer to finish and during that time the popup menu stays visible.

How can I run the subroutine in background and have the popup menu disappear
right after activating the menu item?

Have your menu item handler install an idle action that starts the dialog box. That is:

1  user activates menu item
2  menu handler is called
3  menu handler does Glib::Idle->add (\&do_the_thing);
4  menu handler finishes, menu disappears
5  control returns to main loop
6  main loop sees that there is a pending idle action
7  do_the_thing() fires
8  do_the_thing() launches your dialog box

In essence, it's just a layer of indirection to defer running the dialog box until "sometime later".



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