Re: [gtk-list] Destroying windows & widgets -- anybody?
- From: Michael Babcock <mbabcock la creatureshop henson com>
- To: rknop mh1 lbl gov
- CC: gtk-list redhat com
- Subject: Re: [gtk-list] Destroying windows & widgets -- anybody?
- Date: Wed, 26 Aug 1998 15:24:19 -0700
Robert Knop wrote:
>
> Somebody out there must have done this, and must know how to do this....
>
> Basically, I have a window, which has lots of widgets within it. I want
> to destroy the window and all the associated widgets. I want to to go
> away, and to free all of the memory. The application that created it will
> still be going, but the window needs to be gone.
>
> How to do this with just Gtk+ would be useful. In actuality, I'm trying
> to do this with Gtk--. I'd like to know what calls are necessary to get
> the thing to be pulled out of what Gtk_Main is watching for events, and
> have all of the destructors called.
>
> Thank you for any help you can provide,
>
> -Rob
I'm fairly new to Gtk--, and I don't have an authoritive answer on this,
but I ran into the same problem and here's what I did. I made a global
(singleton actually) Window_list object that keeps track of all created
windows. When you create a new window, register it with the Window_list.
When you want to close the window, hide it and tell the Window list to
delete it. The issue is you can't just have a close button and make it
do "delete this". Nor can you directly call a Window_list method which
deletes the object that is still running. So the Window_list removes the
window from its internal list, but instead of deleting it immediately,
adds it to another internal list and then registers a gtk idle function
that will be called a bit later to actually delete the removed windows.
I made my own Window class, with a constructor that registers itself
with the Window_list and a Close method that hides itself and removes it
from the Window_list. I can derive all my own window classes from this
class so I don't have to worry about it, and can just call Close when I
need to. I suppose this won't work if you don't create windows on the
heap with "new" but I don't think that's a big problem.
Actually, as it happens I just came up with this solution today, and I
haven't fully tested it yet, but it seems to work.
Does this sound like a reasonable solution? Comments welcome.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]