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



On 4/23/05, Olivier Ramare <Olivier Ramare math univ-lille1 fr> wrote:
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 :-(


I wrote a SQL console widget which has the same usage as the one you
mention here. You can have a look at the code in the
http://cvs.gnome.org/viewcvs/libgnomedb/libgnomedb/gnome-db-sql-console.c?rev=1.2&view=markup
file.

Cheers,

Vivien



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