Re: Gtk::Container and iterators





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.

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.

-- 
View this message in context: http://www.nabble.com/Gtk%3A%3AContainer-and-iterators-tf4550935.html#a12999025
Sent from the Gtkmm mailing list archive at Nabble.com.




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