[Gtk-sharp-list] [Patch] Make Gtk.ListStore implement IEnumerable

Mike Kestner mkestner@novell.com
Tue, 03 May 2005 13:52:24 -0500


Hey Eric,

On Tue, 2005-05-03 at 11:22 -0700, Eric Butler wrote:

> As inspired by the Improving Gtk# thread here is a patch that makes
> ListStore implement IEnumerable. This allows you to do something like:
> 
> foreach (object[] row in trustedNodesListStore) {
> Console.WriteLine(row[0].ToString());
> }

Nice.  A few comments...

You need to deal with invalidation.  If the tree model changes under the
enumerator, it needs to be invalidated.  

You need to deal with an uninitialized TreeIter access in Current. A
check of reset should be sufficient, although I'm not sure whether an
exception or a null return is appropriate.  Check the .Net docs.

The TreeEnumerator class should be internal.  No need to expose this as
public API.  You'll like that because...  You need to document public
API, like the new ListStore.GetEnumerator method.  ;-) 

The metadata change should be made at the top of any other ListStore
rules as opposed to next to the other add-node, just to make all the
ListStore rules easier to see at a glance.

<anal>
The new file should go alphabetically in the Makefile.am.
</anal>

Please attach any revised patches to the bug report Miguel opened for
IList-iness to make sure they don't fall through the cracks.
  
Thanks for the patch.
-- 
Mike Kestner <mkestner@novell.com>