Re: exit program on notification



Michal,

you are basically doing this:

show_some_stuff

wait_on_the spot_for_answer

act_according_to_answer

This is plain wrong. It will eventually work,
after you waste a lot of time handling all
the weird problems that you are creating for yourself.
(example: what happens if the user clicks the WM
decoration to close the top main window instead of 
clicking on the YES, NO, CANCEL buttons?)

This is the right way to do things:

callback_yes ()
{
do_yes_stuff;
}

callback_no ()
{
do_no_stuff;
}

callback_cancel ()
{
do_cancel_stuff;
}

show_some_stuff

connect callback_yes, callback_no, callback_cancel

and nothing more! This way, instead of waiting on the spot
for the answer your app waits in the gtk main loop, and this
makes a lot of a difference, because now there's a single
place where your app waits for answers, instead of having
blocking stops all over your code! (the example above now
works naturally, because the "delete_event" callback and
the buttons callbacks are all handled in the same way,
starting and ending in the same gtk main loop!

Carlos




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