Mercurial > repos > IBBoard.GtkSharp
changeset 15:f6126047dd8c
Re #26: Add GTK wrapper methods
* Add first cut of a method to get the iterator for an item in a tree model
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 27 Aug 2010 10:56:51 +0000 |
parents | 0a466c011016 |
children | c9aeaeaa3ea2 |
files | TreeUtils.cs |
diffstat | 1 files changed, 32 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/TreeUtils.cs Sat Aug 14 19:38:37 2010 +0000 +++ b/TreeUtils.cs Fri Aug 27 10:56:51 2010 +0000 @@ -36,5 +36,37 @@ return selected; } + + /// <summary> + /// Gets the <see cref="TreeIter"/> for an item in a tree, or the Zero TreeIter if the item can't be found + /// </summary> + /// <returns> + /// The TreeIter for the item, or TreeIter.Zero if it can't be found + /// </returns> + /// <param name='tree'> + /// The <see cref="TreeView"/> to search the model of + /// </param> + /// <param name='item'> + /// The item to find in the model + /// </param> + public static TreeIter GetItemIter(TreeView tree, object item) + { + TreeModel model = tree.Model; + TreeIter iter; + model.GetIterFirst(out iter); + TreeIter itemIter = TreeIter.Zero; + + do + { + if (model.GetValue(iter, 0).Equals(item)) + { + itemIter = iter; + break; + } + } + while (model.IterNext(ref iter)); + + return itemIter; + } } }