1.213 <GtkViewport>

Class: <GtkViewport>

It derives from <GtkWidget>.

Implements scrollability for widgets that don’t support scrolling on their own.

Use <GtkViewport> to scroll child widgets such as <GtkGrid>, <GtkBox>, and so on.

The <GtkViewport> will start scrolling content only if allocated less than the child widget’s minimum size in a given orientation.

CSS nodes

<GtkViewport> has a single CSS node with name viewport.

Accessibility

Until GTK 4.10, <GtkViewport> used the Gtk.AccessibleRole.group role.

Starting from GTK 4.12, <GtkViewport> uses the Gtk.AccessibleRole.generic role.

Properties

Property: viewport:child self

The child widget.

Its value is a <GtkWidget>, or #f.

Set it with (set! (viewport:child self) value).

Property: viewport:scroll-to-focus self

Whether to scroll when the focus changes.

Before 4.6.2, this property was mistakenly defaulting to FALSE, so if your code needs to work with older versions, consider setting it explicitly to TRUE.

Its value is a boolean.

Set it with (set! (viewport:scroll-to-focus self) value).

Procedures

Method: viewport:get-child self ⇒ %return
Method: get-child self ⇒ %return

Gets the child widget of self.

self

Passed: a <GtkViewport>.

a <GtkViewport>

%return

Returned: a <GtkWidget>, or #f.

the child widget of self

Method: viewport:get-scroll-to-focus? self ⇒ %return
Method: get-scroll-to-focus? self ⇒ %return

Gets whether the viewport is scrolling to keep the focused child in view.

self

Passed: a <GtkViewport>.

a <GtkViewport>

%return

Returned: a boolean.

#t if the viewport keeps the focus child scrolled to view

Procedure: viewport:new [hadjustment] [vadjustment] ⇒ %return

Creates a new <GtkViewport>.

The new viewport uses the given adjustments, or default adjustments if none are given.

hadjustment

Passed, or left out: a <GtkAdjustment>, or #f.

horizontal adjustment

vadjustment

Passed, or left out: a <GtkAdjustment>, or #f.

vertical adjustment

%return

Returned: a <GtkWidget>.

a new <GtkViewport>

Method: viewport:scroll-to self descendant [scroll]
Method: scroll-to self descendant [scroll]

Scrolls a descendant of the viewport into view.

The viewport and the descendant must be visible and mapped for this function to work, otherwise no scrolling will be performed.

self

Passed: a <GtkViewport>.

a <GtkViewport>

descendant

Passed: a <GtkWidget>.

a descendant widget of the viewport

scroll

Passed, or left out: a <GtkScrollInfo>, or #f.

details of how to perform the scroll operation or NULL to scroll into view

Method: viewport:set-child self [child]
Method: set-child self [child]

Sets the child widget of self.

self

Passed: a <GtkViewport>.

a <GtkViewport>

child

Passed, or left out: a <GtkWidget>, or #f.

the child widget

Method: viewport:set-scroll-to-focus self scroll-to-focus
Method: set-scroll-to-focus self scroll-to-focus

Sets whether the viewport should automatically scroll to keep the focused child in view.

self

Passed: a <GtkViewport>.

a <GtkViewport>

scroll-to-focus

Passed: a boolean.

whether to keep the focus widget scrolled to view