Scroll to a line of a text buffer inside a GtkViewport



Hello,

first of all I tried to find a problem similar to mine but were not
successful.

My GUI has the following elements:

GtkScrolledWindow -> GtkViewport -> GtkHBox -> 3x GtkTextView

All textviews are aligned side by side so if I scroll down manually, all
three textviews scroll down.

Now I would like to jump to a special line so I tried the following:


GtkTextIter start;

gtk_text_buffer_get_iter_at_line(gui.editor_textbuffer, &start, line);
gtk_text_view_scroll_to_iter((GtkTextView *) gui.editor_textview, &start, 0.0, TRUE, 0.0, 0.0)


I also tried to work with marks, e.g.


GtkTextIter start;
GtkTextMark *mark;

gtk_text_buffer_get_iter_at_line(gui.editor_textbuffer, &start, line);
gtk_text_buffer_place_cursor(gui.editor_textbuffer, &start);
mark = gtk_text_buffer_create_mark(gui.editor_textbuffer, "selected_line", &start, FALSE);
gtk_text_view_scroll_to_mark((GtkTextView *) gui.editor_textview, mark, 0.0, FALSE, 0.0, 0.0);


I haven't listed all of my trial & errors but hopefully you'll notice
that I tried several functions and different ways suggested by
websites/forums.

My guess is that it's not working because of the GtkViewport (textview
sends the 'scroll to' signal to the viewport and that simply doesn't
know what to do?), so that I [maybe?] have to manipulate the viewport to
make the GtkScrolledWindow scroll down.

Unfortunately I haven't worked with Gtk that much yet.

Does anyone of you have an idea what to try next?

Thanks in advance.
Marc



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