[pygobject/pygobject-2-28] [gi-overrides] fix setting rows in treeview to accept None as a value
- From: John Palmieri <johnp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-2-28] [gi-overrides] fix setting rows in treeview to accept None as a value
- Date: Wed, 23 Feb 2011 20:13:20 +0000 (UTC)
commit 3534c1d4babefd4ee63e46119b279126058b7a71
Author: John (J5) Palmieri <johnp redhat com>
Date: Wed Feb 23 15:11:59 2011 -0500
[gi-overrides] fix setting rows in treeview to accept None as a value
* as done in PyGTK None indicates the column should not be set
gi/overrides/Gtk.py | 3 +++
tests/test_overrides.py | 18 +++++++++++++-----
2 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 37f4e98..31d1362 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -720,6 +720,9 @@ class TreeModel(Gtk.TreeModel):
for i in range(n_columns):
value = row[i]
+ if value is None:
+ continue # None means skip this row
+
self.set_value(treeiter, i, value)
def _convert_value(self, treeiter, column, value):
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 36b9f59..2fc5512 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -783,16 +783,24 @@ class TestGtk(unittest.TestCase):
False))
# add sorted items out of order to test insert* apis
+ # also test sending in None to not set a column
i = 97
label = 'this is row #97'
- treeiter = list_store.append((i,
- label,
- TestGtk.TestClass(self, i, label),
+ treeiter = list_store.append((None,
+ None,
+ None,
test_pyobj,
- test_pydict,
+ None,
test_pylist,
1,
- True))
+ None))
+
+ list_store.set_value(treeiter, 0, i)
+ list_store.set_value(treeiter, 1, label)
+ list_store.set_value(treeiter, 2, TestGtk.TestClass(self, i, label))
+ list_store.set_value(treeiter, 4, test_pydict)
+ list_store.set_value(treeiter, 7, True)
+
# this should append
i = 99
label = 'this is row #99'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]