Re: Gtk::Container and iterators
- From: Murray Cumming <murrayc murrayc com>
- To: Maitre Bart <maitrebart excite com>
- Cc: gtkmm-list gnome org
- Subject: Re: Gtk::Container and iterators
- Date: Tue, 02 Oct 2007 16:03:55 +0200
On Tue, 2007-10-02 at 06:40 -0700, Maitre Bart wrote:
>
>
> Emil Nowak-2 wrote:
> >
> > On 01-09-2007, 13:43:30 maitrebart wrote:
> >
> >>
> >> Is there a way to use some kind of iterators with the gtk containers
> >> (such as
> >> Gtk::Menu) in order to go through all the Gtk::MenuItem's in it?
> > You can use
> > Glib::ListHandle<Widget*> Gtk::Container::get_children();
> >
> >
>
> True, but (...and I realize what was missing in my first message...) with
> this solution, I get a newly-allocated list of the container's non-internal
> children, or in other words, a copy of the original elements (i.e. the
> Gtk::MenuItem's).
>
> In my specific case, I dynamically allocate all the Gtk::MenuItem's and have
> to delete them either after they are removed from the Gtk::Menu or when I
> destroy it. But to delete them, I need a way to get them back! For that, I
> need to get either the original Gtk::MenuItem objects' pointer or reference.
I still don't understand what is the difference between the list that
get_children() gives you and the list that you keep yourself. Both have
pointers to the same objects.
> At the present moment, I keep a list of pointers to my dynamically allocated
> elements in a std::stack. So when I'm in my destructor, I get the stack's
> top element, remove it from the menu, delete it, and pop the stack. I
> repeat this until the stack is empty, and so the menu will. I wish I want to
> eliminate this duplication of data.
>
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]