Re: gtk_main_quit() and destruction



Owen Taylor <otaylor@redhat.com> writes:

> Well, the easiest way is just to insert your cleanup calls
> immediately after your call to gtk_main(). When you call
> gtk_main_quit(), the gtk_main() will exit and return to your code.

I know I can clean things up after gtk_main() returns, but then I have 
to explicitly keep track of what to remove.  For example, I currently
use (if you'll excuse my Python):

    window.connect ("destroy", self.goodbye_cruel_world)

To simulate gtk_main_quit()-friendly equivalent functionality, I'd
have to add something like:

    # Global variable
    windows_to_be_cleaned_up = []

    ...

    windows_to_be_cleaned_up.append (window)

And then make sure I destroy all the windows after gtk_main_loop()
quits, as well as making sure entries get deleted from
`windows_to_be_cleaned_up' within their respective "destroy"
callbacks.  This might be quite a bit of work in C.

Don't get me wrong: this is not /hard/ to do, but it's very
inelegant.  I hoped someone would point me to a signal that gets
invoked upon gtk_main_quit().  It looked obvious to me that there has
to be one because I use gtk_main_quit() to exit the whole thing.  Now
it is no longer as obvious.

Still, it would be nice if I were able to say:

    window.connect ("destroy",        self.goodbye_cruel_world)
    window.connect ("main_loop_quit", self.goodbye_cruel_world)

...or, if I were able to explain to gtk_main_quit() that I really want 
everything to be destroyed.



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