Re: [gtk-list] Re: How do I scroll from the program



Thanks Rene:
   Work's great now.

-Eric

Rene' Seindal wrote:
> 
> I use this code in one of my programs to append messages to a log window
> and have the window scroll to the end.
> 
> static GtkText *logwin;
> static GtkAdjustment *logadj;
> 
> static void
> append_to_log(const gchar *prefix, const gchar *msg)
> {
>     guint pos = gtk_text_get_length(logwin);
> 
>     gtk_text_freeze(logwin);
>     if (prefix)
>         gtk_editable_insert_text(GTK_EDITABLE(logwin),
>                                  prefix, strlen(prefix), &pos);
>     gtk_editable_insert_text(GTK_EDITABLE(logwin), msg, strlen(msg),
> &pos);
>     gtk_editable_insert_text(GTK_EDITABLE(logwin), "\n", 1, &pos);
>     gtk_text_thaw(logwin);
> 
>     gtk_adjustment_set_value(logadj, logadj->upper - logadj->page_size);
> }
> 
> The following initialises the two static variables.  It depends on glade
> produced code, but the idea shoud be clear.
> 
>     logwin = GTK_TEXT(lookup_widget(top->window, "top_level_message"));
>     scr = GTK_SCROLLED_WINDOW(lookup_widget(top->window,
> "scrolledwindow8"));
>     logadj = gtk_scrolled_window_get_vadjustment(scr);
> 
> --
> René Seindal (rene@seindal.dk)                  http://www.seindal.dk/rene/
> 
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com < /dev/null

-- 
Eric Hegstrom                          .~.
Senior Software Engineer               /V\  
Sonoran Scanners, Inc.                // \\          L I N U X
ehegstrom@sonoranscanners.com        /(   )\  >don't fear the penguin<
520-617-0072 x402                     ^^-^^
          ---------------------------------------
 HELP FEED THE HUNGRY AT NO COST TO YOU: http://www.thehungersite.com



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