[Beginner] How to write at the end of a GtkTextBuffer ?



Dear all,

  I have troubles understanding (and controlling) where
to write on a GtkTextBuffer. Here are my variables :

  SGinfosbuffer=gtk_text_buffer_new(NULL);
  SGinfos=gtk_text_view_new_with_buffer(SGinfosbuffer);
  SGscrolledinfos=gtk_scrolled_window_new(NULL,NULL);
  gtk_container_add(GTK_CONTAINER(SGscrolledinfos),SGinfos);

and I write in it via:

void SG_print_infos(char *letexte)
{
    gtk_text_buffer_insert_at_cursor (SGinfosbuffer,letexte,-1);
    while (gtk_events_pending()) gtk_main_iteration(); /* flush */
    gtk_widget_show_all(SGinfos);
}

All goes well until the text in  SGinfosbuffer gets out of the
viewed area. Then some messages are repeated, and some times
when I scroll the buffer down I discover the text has been
inserted at uncanny places (almost reversed order sometimes).

What I want :
  -- the info written always at the end of the buffer
  -- this end should be in the viewable area (scroll if needed).
I can't quite get an inkling as to this last one either :-(

Many thanks in advance !
Best,
Amities,
          Olivier




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