0

I would like to know if there is a way to know if the user scrolled GtkScrolledWindow (containing a GtkTextView) to the bottom or not.

Indeed, I automatically scrolled to the end with:

gtk_text_buffer_get_end_iter(tbuf, &iter);
GtkTextMark *insert_mark = gtk_text_buffer_get_insert(tbuf);
gtk_text_buffer_place_cursor(tbuf, &iter);
gtk_text_view_scroll_to_mark(text, insert_mark, 0.0, TRUE, 0.0, 1.0);

But I don't want to run this code if user has scrolled by himself.

lock
  • 411
  • 4
  • 15

2 Answers2

1

It looks like you could check for "the edge-reached" signal before excecuting those lines. "edge-reached" a signal in GtkScrooledWindow, which could be GTK_POS_TOP and GTK_POS_BOTTOM.

take a look at: https://developer.gnome.org/gtk3/stable/GtkScrolledWindow.html#GtkScrolledWindow-edge-reached

  • It's a good idea indeed. But I did not want use signals for that. So, your answer leads me to the code of this signal and I have a solution. Many thanks. – lock Jan 08 '19 at 15:41
1

I think I have the answer to my own question:

This code should detects if the edge is reached.

value = gtk_adjustment_get_value(adjustment);
lower = gtk_adjustment_get_lower(adjustment);
upper = gtk_adjustment_get_upper(adjustment);
page_size = gtk_adjustment_get_page_size(adjustment);

if (value == upper - page_size)
    edge_reached = TRUE;
lock
  • 411
  • 4
  • 15