gtk.scrolled_window
Module for [ScrolledWindow] class
Types 3
GtkScrolledWindow is a container that accepts a single child widget and makes that child scrollable using either internally added scrollbars or externally associated adjustments.
Widgets with native scrolling support, i.e. those whose classes implement the #GtkScrollable interface, are added directly. For other types of widget, the class #GtkViewport acts as an adaptor, giving scrollability to other widgets. GtkScrolledWindow’s implementation of [gtk.container.Container.add] intelligently accounts for whether or not the added child is a #GtkScrollable. If it isn’t, #GtkScrolledWindow wraps the child in a #GtkViewport and adds that for you. Therefore, you can just add any child widget and not worry about the details.
If [gtk.container.Container.add] has added a #GtkViewport for you, you can remove both your added child widget from the #GtkViewport, and the #GtkViewport from the GtkScrolledWindow, like this:
GtkWidget *scrolled_window = gtk_scrolled_window_new (NULL, NULL);
GtkWidget *child_widget = gtk_button_new ();
// GtkButton is not a GtkScrollable, so GtkScrolledWindow will automatically
// add a GtkViewport.
gtk_container_add (GTK_CONTAINER (scrolled_window),
child_widget);
// Either of these will result in child_widget being unparented:
gtk_container_remove (GTK_CONTAINER (scrolled_window),
child_widget);
// or
gtk_container_remove (GTK_CONTAINER (scrolled_window),
gtk_bin_get_child (GTK_BIN (scrolled_window)));Unless #GtkScrolledWindow:policy is GTK_POLICY_NEVER or GTK_POLICY_EXTERNAL, GtkScrolledWindow adds internal #GtkScrollbar widgets around its child. The scroll position of the child, and if applicable the scrollbars, is controlled by the #GtkScrolledWindow:hadjustment and #GtkScrolledWindow:vadjustment that are associated with the GtkScrolledWindow. See the docs on #GtkScrollbar for the details, but note that the “step_increment” and “page_increment” fields are only effective if the policy causes scrollbars to be present.
If a GtkScrolledWindow doesn’t behave quite as you would like, or doesn’t have exactly the right layout, it’s very possible to set up your own scrolling with #GtkScrollbar and for example a #GtkGrid.
Touch support
GtkScrolledWindow has built-in support for touch devices. When a touchscreen is used, swiping will move the scrolled window, and will expose 'kinetic' behavior. This can be turned off with the #GtkScrolledWindow:kinetic-scrolling property if it is undesired.
GtkScrolledWindow also displays visual 'overshoot' indication when the content is pulled beyond the end, and this situation can be captured with the #GtkScrolledWindow::edge-overshot signal.
If no mouse device is present, the scrollbars will overlayed as narrow, auto-hiding indicators over the content. If traditional scrollbars are desired although no mouse is present, this behaviour can be turned off with the #GtkScrolledWindow:overlay-scrolling property.
CSS nodes
GtkScrolledWindow has a main CSS node with name scrolledwindow.
It uses subnodes with names overshoot and undershoot to draw the overflow and underflow indications. These nodes get the .left, .right, .top or .bottom style class added depending on where the indication is drawn.
GtkScrolledWindow also sets the positional style classes (.left, .right, .top, .bottom) and style classes related to overlay scrolling (.overlay-indicator, .dragging, .hovering) on its scrollbars.
If both scrollbars are visible, the area where they meet is drawn with a subnode named junction.
ScrolledWindow self()Returns `this`, for use in `with` statements.ScrolledWindowGidBuilder builder()Get builder for [gtk.scrolled_window.ScrolledWindow] Returns: New builder objectgtk.adjustment.Adjustment hadjustment() @propertyvoid hadjustment(gtk.adjustment.Adjustment propval) @propertygtk.types.PolicyType hscrollbarPolicy() @propertyvoid hscrollbarPolicy(gtk.types.PolicyType propval) @propertybool kineticScrolling() @propertyGet `kineticScrolling` property. Returns: Whether kinetic scrolling is enabled or not. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen].void kineticScrolling(bool propval) @propertySet `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen].int maxContentHeight() @propertyGet `maxContentHeight` property. Returns: The maximum content height of @scrolled_window, or -1 if not set.void maxContentHeight(int propval) @propertySet `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window, or -1 if not set.int maxContentWidth() @propertyGet `maxContentWidth` property. Returns: The maximum content width of @scrolled_window, or -1 if not set.void maxContentWidth(int propval) @propertySet `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window, or -1 if not set.int minContentHeight() @propertyGet `minContentHeight` property. Returns: The minimum content height of @scrolled_window, or -1 if not set.void minContentHeight(int propval) @propertySet `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window, or -1 if not set.int minContentWidth() @propertyGet `minContentWidth` property. Returns: The minimum content width of @scrolled_window, or -1 if not set.void minContentWidth(int propval) @propertySet `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window, or -1 if not set.bool overlayScrolling() @propertyGet `overlayScrolling` property. Returns: Whether overlay scrolling is enabled or not. If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, they are ov...void overlayScrolling(bool propval) @propertySet `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not. If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, th...bool propagateNaturalHeight() @propertyGet `propagateNaturalHeight` property. Returns: Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.void propagateNaturalHeight(bool propval) @propertySet `propagateNaturalHeight` property. Params: propval = Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.bool propagateNaturalWidth() @propertyGet `propagateNaturalWidth` property. Returns: Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.void propagateNaturalWidth(bool propval) @propertySet `propagateNaturalWidth` property. Params: propval = Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.gtk.types.ShadowType shadowType() @propertyvoid shadowType(gtk.types.ShadowType propval) @propertygtk.adjustment.Adjustment vadjustment() @propertyvoid vadjustment(gtk.adjustment.Adjustment propval) @propertygtk.types.PolicyType vscrollbarPolicy() @propertyvoid vscrollbarPolicy(gtk.types.PolicyType propval) @propertygtk.types.CornerType windowPlacement() @propertyvoid windowPlacement(gtk.types.CornerType propval) @propertybool windowPlacementSet() @propertyGet `windowPlacementSet` property. Returns: Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars.void windowPlacementSet(bool propval) @propertySet `windowPlacementSet` property. Params: propval = Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars.void addWithViewport(gtk.widget.Widget child)Used to add children without native scrolling capabilities. This is simply a convenience function; it is equivalent to adding the unscrollable child to a viewport, then adding the viewport to the s...bool getCaptureButtonPress()Return whether button presses are captured during kinetic scrolling. See [gtk.scrolled_window.ScrolledWindow.setCaptureButtonPress]. Returns: true if button presses are captured during kinetic scro...gtk.adjustment.Adjustment getHadjustment()Returns the horizontal scrollbar’s adjustment, used to connect the horizontal scrollbar to the child widget’s horizontal scroll functionality. Returns: the horizontal #GtkAdjustmentgtk.widget.Widget getHscrollbar()Returns the horizontal scrollbar of scrolled_window. Returns: the horizontal scrollbar of the scrolled window.bool getKineticScrolling()Returns the specified kinetic scrolling behavior. Returns: the scrolling behavior flags.int getMaxContentHeight()Returns the maximum content height set. Returns: the maximum content height, or -1int getMaxContentWidth()Returns the maximum content width set. Returns: the maximum content width, or -1int getMinContentHeight()Gets the minimal content height of scrolled_window, or -1 if not set. Returns: the minimal content heightint getMinContentWidth()Gets the minimum content width of scrolled_window, or -1 if not set. Returns: the minimum content widthbool getOverlayScrolling()Returns whether overlay scrolling is enabled for this scrolled window. Returns: true if overlay scrolling is enabledgtk.types.CornerType getPlacement()Gets the placement of the contents with respect to the scrollbars for the scrolled window. See [gtk.scrolled_window.ScrolledWindow.setPlacement]. Returns: the current placement value.void getPolicy(out gtk.types.PolicyType hscrollbarPolicy, out gtk.types.PolicyType vscrollbarPolicy)Retrieves the current policy values for the horizontal and vertical scrollbars. See [gtk.scrolled_window.ScrolledWindow.setPolicy].bool getPropagateNaturalHeight()Reports whether the natural height of the child will be calculated and propagated through the scrolled window’s requested natural height. Returns: whether natural height propagation is enabled.bool getPropagateNaturalWidth()Reports whether the natural width of the child will be calculated and propagated through the scrolled window’s requested natural width. Returns: whether natural width propagation is enabled.gtk.types.ShadowType getShadowType()Gets the shadow type of the scrolled window. See [gtk.scrolled_window.ScrolledWindow.setShadowType]. Returns: the current shadow typegtk.adjustment.Adjustment getVadjustment()Returns the vertical scrollbar’s adjustment, used to connect the vertical scrollbar to the child widget’s vertical scroll functionality. Returns: the vertical #GtkAdjustmentgtk.widget.Widget getVscrollbar()Returns the vertical scrollbar of scrolled_window. Returns: the vertical scrollbar of the scrolled window.void setCaptureButtonPress(bool captureButtonPress)Changes the behaviour of scrolledwindow with regard to the initial event that possibly starts kinetic scrolling. When capturebutton_press is set to true, the event is captured by the scrolled windo...void setHadjustment(gtk.adjustment.Adjustment hadjustment = null)Sets the #GtkAdjustment for the horizontal scrollbar.void setKineticScrolling(bool kineticScrolling)Turns kinetic scrolling on or off. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen].void setMaxContentHeight(int height)Sets the maximum height that scrolledwindow should keep visible. The scrolledwindow will grow up to this height before it starts scrolling the content.void setMaxContentWidth(int width)Sets the maximum width that scrolledwindow should keep visible. The scrolledwindow will grow up to this width before it starts scrolling the content.void setMinContentHeight(int height)Sets the minimum height that scrolled_window should keep visible. Note that this can and (usually will) be smaller than the minimum size of the content.void setMinContentWidth(int width)Sets the minimum width that scrolled_window should keep visible. Note that this can and (usually will) be smaller than the minimum size of the content.void setOverlayScrolling(bool overlayScrolling)Enables or disables overlay scrolling for this scrolled window.void setPlacement(gtk.types.CornerType windowPlacement)Sets the placement of the contents with respect to the scrollbars for the scrolled window.void setPolicy(gtk.types.PolicyType hscrollbarPolicy, gtk.types.PolicyType vscrollbarPolicy)Sets the scrollbar policy for the horizontal and vertical scrollbars.void setPropagateNaturalHeight(bool propagate)Sets whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.void setPropagateNaturalWidth(bool propagate)Sets whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.void setShadowType(gtk.types.ShadowType type)Changes the type of shadow drawn around the contents of scrolled_window.void setVadjustment(gtk.adjustment.Adjustment vadjustment = null)Sets the #GtkAdjustment for the vertical scrollbar.void unsetPlacement()Unsets the placement of the contents with respect to the scrollbars for the scrolled window. If no window placement is set for a scrolled window, it defaults to [gtk.types.CornerType.TopLeft].gulong connectEdgeOvershot(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.PositionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3)Connect to `EdgeOvershot` signal.gulong connectEdgeReached(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.PositionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3)Connect to `EdgeReached` signal.gulong connectMoveFocusOut(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == void)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.DirectionType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 3)Connect to `MoveFocusOut` signal.gulong connectScrollChild(T)(T callback, Flag!"After" after = No.After) if (isCallable!T
&& is(ReturnType!T == bool)
&& (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gtk.types.ScrollType)))
&& (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] == bool)))
&& (Parameters!T.length < 3 || (ParameterStorageClassTuple!T[2] == ParameterStorageClass.none && is(Parameters!T[2] : gtk.scrolled_window.ScrolledWindow)))
&& Parameters!T.length < 4)Connect to `ScrollChild` signal.this(gtk.adjustment.Adjustment hadjustment = null, gtk.adjustment.Adjustment vadjustment = null)Creates a new scrolled window.T hadjustment(gtk.adjustment.Adjustment propval)T hscrollbarPolicy(gtk.types.PolicyType propval)T kineticScrolling(bool propval)Set `kineticScrolling` property. Params: propval = Whether kinetic scrolling is enabled or not. Kinetic scrolling only applies to devices with source [gdk.types.InputSource.Touchscreen]. Returns: B...T maxContentHeight(int propval)Set `maxContentHeight` property. Params: propval = The maximum content height of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT maxContentWidth(int propval)Set `maxContentWidth` property. Params: propval = The maximum content width of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT minContentHeight(int propval)Set `minContentHeight` property. Params: propval = The minimum content height of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT minContentWidth(int propval)Set `minContentWidth` property. Params: propval = The minimum content width of @scrolled_window, or -1 if not set. Returns: Builder instance for fluent chainingT overlayScrolling(bool propval)Set `overlayScrolling` property. Params: propval = Whether overlay scrolling is enabled or not. If it is, the scrollbars are only added as traditional widgets when a mouse is present. Otherwise, th...T propagateNaturalHeight(bool propval)Set `propagateNaturalHeight` property. Params: propval = Whether the natural height of the child should be calculated and propagated through the scrolled window’s requested natural height.T propagateNaturalWidth(bool propval)Set `propagateNaturalWidth` property. Params: propval = Whether the natural width of the child should be calculated and propagated through the scrolled window’s requested natural width.T shadowType(gtk.types.ShadowType propval)T vadjustment(gtk.adjustment.Adjustment propval)T vscrollbarPolicy(gtk.types.PolicyType propval)T windowPlacement(gtk.types.CornerType propval)T windowPlacementSet(bool propval)Set `windowPlacementSet` property. Params: propval = Whether "window-placement" should be used to determine the location of the contents with respect to the scrollbars. Returns: Builder instance fo...Fluent builder for [gtk.scrolled_window.ScrolledWindow]