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