Usando ajustes o caminho fácil

Os widgets ajustáveis ​​podem ser grosseiramente divididos naqueles que usam e requerem unidades específicas para estes valores, e aqueles que tratá-los como números arbitrários.

The group which treats the values as arbitrary numbers includes the Range widgets (Scrollbar and Scale), the ScaleButton widget, and the SpinButton widget. These widgets are typically "adjusted" directly by the user with the mouse or keyboard. They will treat the lower and upper values of an adjustment as a range within which the user can manipulate the adjustment's value. By default, they will only modify the value of an adjustment.

The other group includes the Viewport widget and the ScrolledWindow widget. All of these widgets use pixel values for their adjustments. These are also typically adjusted indirectly using scrollbars. While all widgets which use adjustments can either create their own adjustments or use ones you supply, you'll generally want to let this particular category of widgets create its own adjustments.

If you share an adjustment object between a Scrollbar and a TextView widget, manipulating the scrollbar will automagically adjust the TextView widget. You can set it up like this:

// cria seus próprios ajustes
Gtk::TextView textview;
// usa o ajuste recém-criado para a barra de rolagem assim
Gtk::Scrollbar vscrollbar (textview.get_vadjustment(), Gtk::ORIENTATION_VERTICAL);