GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Wed Aug 24, 2016 5:56 pm

All times are UTC

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: "autoscroll down" for a textview scrolls up immedi
PostPosted: Mon Mar 10, 2008 3:50 pm 

Joined: Mon Mar 10, 2008 3:27 pm
Posts: 1

the GtkTextView is initialized with:

pOutputView = gtk_text_view_new();
gtk_text_view_set_border_window_size(GTK_TEXT_VIEW(pOutputView), GTK_TEXT_WINDOW_TEXT, 1);
gtk_text_view_set_editable(GTK_TEXT_VIEW(pOutputView), false);

pOutputWindow = gtk_scrolled_window_new( NULL, NULL);

gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(pOutputWindow), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);

gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(pOutputWindow), pOutputView);

pOutputBuffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(pOutputView));

After a line is written to the buffer the view should scroll down with:

GtkTextIter   iterEnd;
gtk_text_buffer_get_end_iter(pOutputBuffer, &iterEnd);
gtk_text_buffer_insert(pOutputBuffer, &iterEnd, szOutput, -1);
// scroll down
gtk_text_buffer_get_end_iter(pOutputBuffer, &iterEnd);
GtkTextMark   *pMarkEnd = gtk_text_buffer_get_mark(pOutputBuffer, MARK_END_NAME);
gtk_text_buffer_move_mark(pOutputBuffer, pMarkEnd, &iterEnd);
gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(pOutputView), pMarkEnd, 0, false, 0, 0);

... but it doesn't work. I can see that the view is scrolling down for milliseconds and then poping back to the top of the buffer again.

Any suggestion?


ps: the gtk version is 2.6.10

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC

Who is online

Users browsing this forum: Google [Bot] and 3 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group