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



Well, since resizing the widget by itself does not do any scrolling, whichever value you get from the adjustment _is_ the current scroll value. In the same way you have the function *_get_upper(), you have *_get_lower() and *_get_value()... Just change the computation however you need it to be. Did you even looked up the functions I used in the API docs? You would have seen the rest....

Hope that helps.

On 11/13/2009 12:49 PM, Eduardo M KALINOWSKI wrote:
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?




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