[gedit-list] scroll to line?



Hi, I get what seems like a very stupid problem. I would like to 
scroll to particular line in the current view. So, I tried these 
two methods:

    def goto_line(self, lineno):
            view = self.window.get_active_view()
            it = view.get_buffer().get_iter_at_line(lineno)
            log.debug('iterator = %s, %d', it, it.get_line())
            it.set_line(lineno)
            log.debug('iterator = %s, %d', it, it.get_line())
            log.debug('scrolling to iter!')
            view.scroll_to_iter(it, 0, True, 0.5, 0.5)

and

    def goto_line(self, lineno):
            view = self.window.get_active_view()
            view.get_buffer().goto_line(lineno)
            view.scroll_to_cursor()

Neither of these methods actually scrolls anywhere (the cursor 
is still in the first line of the buffer). Running of the first 
method gives this on stderr:

    DEBUG:goto_line:iterator = <GtkTextIter at 0x3f06230>, 0
    DEBUG:goto_line:iterator = <GtkTextIter at 0x3f06230>, 0
    DEBUG:goto_line:scrolling to iter!
    object of type `GtkSourceStyle' does not have property `weight-set'

Why is it.get_line() always 0?

Any thoughts on how to make this work?

Thank you,

Matěj

-- 
https://matej.ceplovi.cz/blog/, Jabber: mcepl ceplovi cz
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8

Extremism in the defense of liberty is no vice; moderation in
the pursuit of justice is no virtue.
    -- Barry Goldwater (actually written by Karl Hess)



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