Re: [gtk-list] Re: [patch] mainloop




James A <jamesa@demon.net> writes:

> johannes@nada.kth.se (Johannes Keukelaar) writes:
 
> > Does that mean that it was already possible to call the main loop
> > recursively from a signal callback? If that is so, is that the way
> > to go about building functions like, for example,
> > my_ask_yes_or_no( "Really want to quit?" ), which would pop up a
> > modal dialog box and return after the user clicks on the yes or no
> > button?
 
>  The way to implement modality is to use gtk_grab_add and
> gtk_grab_remove see the below example.
 
[ example deleted ]

The existing main loop should work OK called from a signal callback.
(The usefully named "Test" example in testgtk does this, although
you can't quit it right now because of the "delete_event" change)

It's probably better not to call it recursively, when possible, simply
to avoid extra complexity. But it may be useful - if you need to
do something like:

  * set up a complex state
  * get user input to confirm something
  * remove the complex state

A reentrant callback is probably easier than saving the state
globally. But you should probably also add a grab to make sure that
the user doesn't go off and do something else. There are major
pitfalls if you have two such reentrant callbacks at once:

  gtk_main_quit() doesn't have any way of specifying _which_ mainloop
    to quit.
  The user will see strange effects if they try to quit the two
    dialogs in the opposite order from the way they were created.

Regards,
                                        Owen



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