GNOME Bugzilla – Bug 680597
Gtk.TextIter.forward_search has wrong arguments
Last modified: 2012-07-31 15:06:47 UTC
Hello, I'm porting[1] a Sugar Activity called Log[2] to GTK3 and I found a problem with the search that it does on a TextBuffer. This is the relevant part of the code (Epdb) text 'w' (Epdb) text_iter <GtkTextIter at 0x37bc000> (Epdb) text_iter.forward_search(text, Gtk.TextSearchFlags.CASE_INSENSITIVE, 0) *** TypeError: Expected Gtk.TextIter, but got StructMeta (Epdb) text_iter.forward_search(text_iter, Gtk.TextSearchFlags.CASE_INSENSITIVE, 0) *** TypeError: Must be string, not TextIter (Epdb) Is this a bug or I should call this method in another way? Thanks, [1] http://wiki.sugarlabs.org/go/Features/GTK3/Porting/Log [2] http://git.sugarlabs.org/log
This is the way this software was using on gtk2: [... some code here ...] next_found = text_iter.forward_search(text, 0) if next_found is None: start, end = next_found [... some code here ...]
This seems to work fine for me, I just added a test case: http://git.gnome.org/browse/pygobject/commit/?id=94e5d58e7794de91d3291e0e51c42070da4fc92b Can you please attach a complete code example which breaks? Which version of pygobject are you using?
Well, I don't know what I was doing. I test what you said and it worked without problems (I'm attaching my test example) I change my code to: next_found = text_iter.forward_search(text, 0, None) So, maybe the problem is with the final argument? [...] Yes! That's the problem! (example modified attached)
Created attachment 219880 [details] test case with 0 as argument
Created attachment 219881 [details] test case with None as argument
Right, so it does not make sense to supply "0" as a "limit" argument (which needs to be a Gtk.TextIter). At least trunk now gives a more sensible error message: TypeError: argument limit: Expected Gtk.TextIter, but got int Thanks!