Mercurial > repos > IBBoard.GtkSharp
view TreeUtils.cs @ 8:14ce41d2f9bd
* Add TreeUtils to simplify TreeView handling in GTK# (GTK# = thin wrapper around GTK = looks like C calls = looks ugly and out of place and has far too many steps in an OO lang)
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Fri, 04 Sep 2009 20:08:07 +0000 |
parents | |
children | f6126047dd8c |
line wrap: on
line source
// This file (TreeUtils.cs) is a part of the IBBoard.GtkSharp project and is copyright 2009 IBBoard // // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. // using System; using Gtk; namespace IBBoard.GtkSharp { /// <summary> /// Utility methods for working with GTK TreeViews and TreeModels /// </summary> public class TreeUtils { public static object GetItemAtPath(TreeView tree, TreePath path) { TreeModel model = tree.Model; TreeIter iter; model.GetIter(out iter, path); return model.GetValue(iter, 0); } public static object GetSelectedItem(TreeView tree) { TreeSelection selection = tree.Selection; TreeModel model; TreeIter iter; object selected = null; if (selection.CountSelectedRows() > 0) { selection.GetSelected(out model, out iter); selected = model.GetValue(iter, 0); } return selected; } } }