Discussion:
[gedit-list] scroll to line?
Matěj Cepl
2016-05-07 23:14:44 UTC
Permalink
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: ***@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)
Matěj Cepl
2016-05-08 06:21:28 UTC
Permalink
Post by Matěj Cepl
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
And oh, I should mention, this is gedit-3.14.3-9.0.3.el7.x86_64
(i.e., on RHEL-7).

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

Puritanism: The haunting fear that someone, somewhere, may be happy.
-- H. L. Mencken
Loading...