diff options
-rw-r--r-- | gi/overrides/Gtk.py | 6 | ||||
-rw-r--r-- | tests/test_overrides.py | 4 |
2 files changed, 10 insertions, 0 deletions
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index 007ea30b..aba5a73a 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -783,6 +783,12 @@ class TreeModel(Gtk.TreeModel): if success: return next_iter + def iter_previous(self, aiter): + prev_iter = aiter.copy() + success = super(TreeModel, self).iter_previous(prev_iter) + if success: + return prev_iter + def iter_children(self, aiter): success, child_iter = super(TreeModel, self).iter_children(aiter) if success: diff --git a/tests/test_overrides.py b/tests/test_overrides.py index 6f2fbaff..92c615cf 100644 --- a/tests/test_overrides.py +++ b/tests/test_overrides.py @@ -1350,6 +1350,8 @@ class TestGtk(unittest.TestCase): self.assertTrue(tree_store) self.assertEqual(len(tree_store), 100) + self.assertEqual(tree_store.iter_previous(tree_store.get_iter(0)), None) + for i,row in enumerate(tree_store): self.assertEqual(row.model, tree_store) self.assertEqual(row.parent, None) @@ -1375,6 +1377,8 @@ class TestGtk(unittest.TestCase): next = tree_store.iter_next(aiter) if i < len(tree_store) - 1: self.assertEqual(tree_store.get_path(next), row.next.path) + self.assertEqual(tree_store.get_path(tree_store.iter_previous(next)), + tree_store.get_path(aiter)) else: self.assertEqual(next, None) |