[pygobject] Add missing override for TreeModel.iter_previous()
- From: Martin Pitt <martinpitt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Add missing override for TreeModel.iter_previous()
- Date: Mon, 23 Apr 2012 15:41:49 +0000 (UTC)
commit d37680bb9390426f7f58ea3d352c3e5e2106e978
Author: Martin Pitt <martinpitt gnome org>
Date: Mon Apr 23 15:24:04 2012 +0200
Add missing override for TreeModel.iter_previous()
This should behave like the override for TreeModel.iter_next().
https://bugzilla.gnome.org/show_bug.cgi?id=660018
gi/overrides/Gtk.py | 6 ++++++
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 1323e4d..88e748f 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -802,6 +802,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 1d27abd..ab7525f 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -1352,6 +1352,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)
@@ -1377,6 +1379,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)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]