[pygobject] GtkTreePath: make it iterable



commit fbd21ee7176bc1b70547ea464b512c8ffd674187
Author: Johan Dahlin <johan gnome org>
Date:   Wed Mar 14 17:13:04 2012 -0300

    GtkTreePath: make it iterable
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672093

 gi/overrides/Gtk.py     |    3 +++
 tests/test_overrides.py |    2 ++
 2 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 43ca2ea..8f0d74a 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -1140,6 +1140,9 @@ class TreePath(Gtk.TreePath):
     def __ge__(self, other):
         return other is None or self.compare(other) >= 0
 
+    def __iter__(self):
+        return iter(map(int, str(self).split(':')))
+
 TreePath = override(TreePath)
 __all__.append('TreePath')
 
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 185e43b..75e0b5e 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -1212,6 +1212,8 @@ class TestGtk(unittest.TestCase):
         self.assertFalse(p1 < None)
         self.assertFalse(p1 <= None)
 
+        self.assertEquals(tuple(p1), (1, 2, 3))
+
     def test_tree_model(self):
         tree_store = Gtk.TreeStore(int, str)
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]