[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Repacking a table
- From: "muppet" <scott asofyet org>
- To: gtk-perl-list gnome org
- Subject: Re: Repacking a table
- Date: Thu, 18 Oct 2007 12:46:12 -0400 (EDT)
Johan Aberg wrote:
> I'm trying to update the items packed in the table but I'm not sure I
> understand how to do it. I was trying to destroy everything in the
> table and then loop over my new images and then call attach to rebuild
> the table with new the images. For various reasons in my design, I
> can not just simply keep the images and just replace their pixbuffers
> to update the content of the table.
That seems like an odd limitation. The Gtk2::Image widgets are just views for
your images and should be interchangeable. Can't you fix your design? After
all, if you wind up having to manipulate a table as you propose below, you're
doing something that is not very idiomatic for the toolkit and there's likely
to be an easier way.
For example, can you use a Gtk2::IconView instead of this manual table thing?
> My question is, is it possible to repack after the main event loop has
> been started? I seems to be able to destroy items, but not add table
> items once the program is running?
Yes. Your solution will involve Gtk2::Container::remove() and
Gtk2::Container::get_children().
Note that Gtk2::Table does not appear to have a way to get the widget at some
location, so you need to know which child is which when you iterate over the
list of children.
> When I destroy an item with children, does GTK2 remove the children
> and free up the memory they allocated?
For the most part, yes. Watch for reference cycles. This is yet another
reason you'd likely be better off keeping only the pixbufs...
--
muppet <scott at asofyet dot org>
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]