Re: How to create a scrolled text window with GTK 2.x?



On Mon, 21 Jun 2004, Jan-Marek Glogowski wrote:

> Untested, but an other idea:
>
> // Maybe not needed
> gtk_text_buffer_get_end_iter( buffer, &iter );
> gtk_text_buffer_place_cursor( buffer, &iter );
> // Ok - get insert mark
> mark = gtk_text_buffer_get_insert( buffer );
> // Move insert into the bottom right
> gtk_text_view_scroll_to_mark( view, mark, 0.0, TRUE, 1.0, 1.0 );
> // gtk_text_buffer_delete_mark( mark ); // Not sure if needed

  No, it doesn't work either. (And by the way, isn't it unnecessary to
move the cursor to the end of the buffer because doesn't inserting text
at the end of the buffer move the cursor automatically there?)

  I noticed however, that the text window scrolls to the end (where the
cursor is located) when the text window gets focus (eg. by pressing tab
until it gets focus). I mean without any of the scrolling calls suggested
already: Just inserting text to the text buffer, and then giving the
text window focus (by pressing tab enough times).

  This probably means that if there's a way to give focus to the text
window with a function call (there probably is), that would cause it
to scroll to the end.
  However, this is perhaps not a good solution: The focus may be somewhere
else, and the user might want the focus to stay there even though some
text might appear in the text window.
  But anyways, if I (nor anybody else) can't come up with any other solution,
I suppose I will have to use this ugly trick.

  Why isn't there a way of doing it like in GTK 1.x? It was very handy
and easy there.
  I would use the 1.x way, but I don't really want to use deprecated code...

							- Juha Nieminen




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