Re: Control what happens when GtkTextView is resized: keep the bottom part visible



Todor Todorov wrote:
Bind a callback to the "size-allocate" signal of the scrolled window:

#include <gtk/gtk.h>

void cb_autoscroll_to_end( GtkWidget* widget, GtkAllocation* allocation, 
gpointer user_data)
{
<snip>
}

After you create the scroll window in main(), connect like:

g_signal_connect( scr1, "size-allocate", G_CALLBACK( 
cb_autoscroll_to_end ), NULL );

It will work with every scroll bar policy (always, none, auto)....
  

Thanks for that, it works for keeping always the bottom part displayed.

However, I'd like something slightly more complex: if the scroll bar is
not at its end, that is, some other part of the text view is being
shown, I'd like that part to remain at the end, shrinking the bottom
widget at the top but keeping the bottom part displaying the same thing,
instead of resizing the bottom and moving it.

One way to do that might be to check the value of the GtkAdjustment
before it starts to be resized and then, in a callback like you posted,
set the new value to display the desired part. But how can one obtain
the value before the resizing starts?

-- 
<Culus> Saens demonstrates no less than 3 tcp/ip bugs in 2.2.3

Eduardo M KALINOWSKI
eduardo kalinowski com br




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