[pygobject] Add a default argument to Gtk.TreeView.set_cursor



commit 02950cabb38b1b3c9378c42c069eefdbccbce17d
Author: Johan Dahlin <johan gnome org>
Date:   Wed Mar 14 13:31:41 2012 -0300

    Add a default argument to Gtk.TreeView.set_cursor
    
    And also make sure that the path is a Gtk.TreePath.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=672081

 gi/overrides/Gtk.py     |    4 ++++
 tests/test_overrides.py |   10 ++++++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 6ce3b04..81d2e69 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -1261,6 +1261,10 @@ class TreeView(Gtk.TreeView, Container):
             path = TreePath(path)
         super(TreeView, self).scroll_to_cell(path, column, use_align, row_align, col_align)
 
+    def set_cursor(self, path, column=None, start_editing=False):
+        if not isinstance(path, Gtk.TreePath):
+            path = TreePath(path)
+        super(TreeView, self).set_cursor(path, column, start_editing)
 
 TreeView = override(TreeView)
 __all__.append('TreeView')
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index c030603..185e43b 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -1429,6 +1429,16 @@ class TestGtk(unittest.TestCase):
 
         self.assertRaises(ValueError, set_row3)
 
+    def test_tree_view(self):
+        store = Gtk.ListStore(int, str)
+        store.append((0, "foo"))
+        store.append((1, "bar"))
+        view = Gtk.TreeView()
+        # We can't easily call get_cursor() to make sure this works as
+        # expected as we need to realize and focus the column
+        view.set_cursor(store[1].path)
+        view.set_cursor(str(store[1].path))
+
     def test_tree_view_column(self):
         cell = Gtk.CellRendererText()
         column = Gtk.TreeViewColumn(title='This is just a test',



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