Mercurial > repos > IBBoard.GtkSharp
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:d92d11bd4808 | 8:14ce41d2f9bd |
---|---|
1 // This file (TreeUtils.cs) is a part of the IBBoard.GtkSharp project and is copyright 2009 IBBoard | |
2 // | |
3 // 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. | |
4 // | |
5 | |
6 using System; | |
7 using Gtk; | |
8 | |
9 namespace IBBoard.GtkSharp | |
10 { | |
11 /// <summary> | |
12 /// Utility methods for working with GTK TreeViews and TreeModels | |
13 /// </summary> | |
14 public class TreeUtils | |
15 { | |
16 public static object GetItemAtPath(TreeView tree, TreePath path) | |
17 { | |
18 TreeModel model = tree.Model; | |
19 TreeIter iter; | |
20 model.GetIter(out iter, path); | |
21 return model.GetValue(iter, 0); | |
22 } | |
23 | |
24 public static object GetSelectedItem(TreeView tree) | |
25 { | |
26 TreeSelection selection = tree.Selection; | |
27 TreeModel model; | |
28 TreeIter iter; | |
29 object selected = null; | |
30 | |
31 if (selection.CountSelectedRows() > 0) | |
32 { | |
33 selection.GetSelected(out model, out iter); | |
34 selected = model.GetValue(iter, 0); | |
35 } | |
36 | |
37 return selected; | |
38 } | |
39 } | |
40 } |