[pygobject] Fix TextBuffer.get_selection_bounds() override



commit 94c0e2f71636d055bdebe3ec378f3d339eea66c9
Author: Paolo Borelli <pborelli gnome org>
Date:   Sat Nov 27 16:10:33 2010 +0100

    Fix TextBuffer.get_selection_bounds() override
    
    Fix the override and add unit test

 gi/overrides/Gtk.py     |    8 +++++---
 tests/test_overrides.py |    7 +++++++
 2 files changed, 12 insertions(+), 3 deletions(-)
---
diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py
index 59f7fd9..28211a5 100644
--- a/gi/overrides/Gtk.py
+++ b/gi/overrides/Gtk.py
@@ -537,9 +537,11 @@ class TextBuffer(Gtk.TextBuffer):
         Gtk.TextBuffer.insert_at_cursor(self, text, length)
 
     def get_selection_bounds(self):
-        success, start, end = super(TextBuffer, self).get_selection_bounds(string,
-            flags, limit)
-        return (start, end)
+        success, start, end = super(TextBuffer, self).get_selection_bounds()
+        if success:
+            return (start, end)
+        else:
+            return ()
 
 TextBuffer = override(TextBuffer)
 __all__.append('TextBuffer')
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 7e0546a..4e41d63 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -610,6 +610,13 @@ class TestGtk(unittest.TestCase):
 
         self.assertEquals(text, 'Hello Jane Hello Bob')
 
+        sel = buffer.get_selection_bounds()
+        self.assertEquals(sel, ())
+        buffer.select_range(start, end)
+        sel = buffer.get_selection_bounds()
+        self.assertTrue(sel[0].equal(start))
+        self.assertTrue(sel[1].equal(end))
+
     def test_buttons(self):
         self.assertEquals(Gtk.Button, overrides.Gtk.Button)
 



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