[Gtk-sharp-list] Removing all the widgets from a table Mac OSX GTK#

Michael Hutchinson m.j.hutchinson at gmail.com
Sat Jun 28 15:23:32 EDT 2008


On Sat, Jun 28, 2008 at 1:52 PM, Billy Schoenberg <wasbridge at gmail.com> wrote:
> Hey,
>
> Thanks for the response. I do not think the code I use to reattch them is an
> issue, but I have attached it below.  The reason I do not think its an
> issues is because if i comment out those lines I showed you last e-mail the
> program does not crash, it just piles widgets on top of each other.  Also
> this code works just fine on Windows (all versions) and Linux (SUSE and
> Ubuntu) I use the "Native Version" of GTK on OSX 10.5 with Mono 1.9.1 that I

Ah. Yeah, that's the followup I was going to ask. If it works fine on
linux and windows, the OS X "native" GTK port is probably to blame.
It's nowhere near as mature as the other GTK ports.

You could use the X11 version of GTK on OS X for now, though it's less
convenient to install, as it requires X11.

> installed 3 or so months ago.  Do you have any ideas about a work around,
> another way to remove widgets from a table?

Firstly, it's bad in a "foreach" to modify the collection over which
you're iterating, since the enumerator object usually becomes invalid
(in fact, most of the .NET collections will throw exceptions if you
try this). Try this:

while (controller.GTKObjectPropertiesTable.Children.Count > 0)
    controller.GTKObjectPropertiesTable.Remove(controller.GTKObjectPropertiesTable.Children[0]);

A workaround could be to do

controller.GTKObjectPropertiesTable.Visible = false;

or since you're clearing the entire table, just Destroy() it and
create a new one.

Also, doesn't keeping a widget on your controller violate MVC? :)

-- 
Michael Hutchinson
http://mjhutchinson.com


More information about the Gtk-sharp-list mailing list