GTK has various widgets that can be visually adjusted by the user using the mouse or the keyboard, such as the range widgets, described in the Range Widgets section. There are also a few widgets that display some adjustable portion of a larger area of data, such as the text widget and the viewport widget.
Obviously, an application needs to be able to react to changes the user makes in range widgets. One way to do this would be to have each widget emit its own type of signal when its adjustment changes, and either pass the new value to the signal handler, or require it to look inside the widget's data structure in order to ascertain the value. But you may also want to connect the adjustments of several widgets together, so that adjusting one adjusts the others. The most obvious example of this is connecting a scrollbar to a panning viewport or a scrolling text area. If each widget has its own way of setting or getting the adjustment value, then the programmer may have to write their own signal handlers to translate between the output of one widget's signal and the "input" of another's adjustment setting function.
GTK solves this problem using the Adjustment object, which is not a widget but a way for widgets to store and pass adjustment information in an abstract and flexible form. The most obvious use of Adjustment is to store the configuration parameters and values of range widgets, such as scrollbars and scale controls. However, since Adjustments are derived from Gtk::Object, they have some special powers beyond those of normal data structures. Most importantly, they can emit signals, just like widgets, and these signals can be used not only to allow your program to react to user input on adjustable widgets, but also to propagate adjustment values transparently between adjustable widgets.
You will see how adjustments fit in when you see the other widgets that incorporate them: Progress Bars, Viewports, Scrolled Windows, and others.
Many of the widgets which use adjustment objects do so automatically, but some cases will be shown in later examples where you may need to create one yourself. You create an adjustment using:
adj = Gtk::Adjustment.new lower, upper, step_increment, page_increment, page_size
value (double) is the initial value you want to give to the adjustment, usually corresponding to the topmost or leftmost position of an adjustable widget.
lower (double) specifies the lowest value which the adjustment can hold.
step_increment (double) specifies the "smaller" of the two increments by which the user can change the value.
page_increment (double) specifies the "larger" of the two increments by which the user can change the value.
page_size usually corresponds somehow to the visible area of a panning widget.
upper (double) specifies the highest value which the bottom most or right most coordinate in a panning widget's child. Therefore, it is not always the largest number that value can take. Specifically, the largest number that value can take is equal to upper + page_size. Now, for for some widgets, the effective page_size is always 0. These are discussed next.