About all my projects
Gnome::Gtk4::Widget

Gnome::Gtk4::Widget

Description

The base class for all widgets.

Gnome::Gtk4::Widget is the base class all widgets in GTK derive from. It manages the widget lifecycle, layout, states and style.

Height-for-width Geometry Management

GTK uses a height-for-width (and width-for-height) geometry management system. Height-for-width means that a widget can change how much vertical space it needs, depending on the amount of horizontal space that it is given (and similar for width-for-height). The most common example is a label that reflows to fill up the available width, wraps to fewer lines, and therefore needs less height.

Height-for-width geometry management is implemented in GTK by way of two virtual methods:

  • [vfunc $Gtk.Widget.get_request_mode]

  • [vfunc $Gtk.Widget.measure]

There are some important things to keep in mind when implementing height-for-width and when using it in widget implementations.

If you implement a direct Gnome::Gtk4::Widget subclass that supports height-for-width or width-for-height geometry management for itself or its child widgets, the [vfunc $Gtk.Widget.get_request_mode] virtual function must be implemented as well and return the widget's preferred request mode. The default implementation of this virtual function returns GTK_SIZE_REQUEST_CONSTANT_SIZE, which means that the widget will only ever get -1 passed as the for_size value to its [vfunc $Gtk.Widget.measure] implementation.

The geometry management system will query a widget hierarchy in only one orientation at a time. When widgets are initially queried for their minimum sizes it is generally done in two initial passes in the enumeration SizeRequestMode from Gnome::Gtk4::T-enums chosen by the toplevel.

For example, when queried in the normal GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH mode:

First, the default minimum and natural width for each widget in the interface will be computed using .measure() with an orientation of GTK_ORIENTATION_HORIZONTAL and a for_size of -1. Because the preferred widths for each widget depend on the preferred widths of their children, this information propagates up the hierarchy, and finally a minimum and natural width is determined for the entire toplevel. Next, the toplevel will use the minimum width to query for the minimum height contextual to that width using .measure() with an orientation of GTK_ORIENTATION_VERTICAL and a for_size of the just computed width. This will also be a highly recursive operation. The minimum height for the minimum width is normally used to set the minimum size constraint on the toplevel.

After the toplevel window has initially requested its size in both dimensions it can go on to allocate itself a reasonable size (or a size previously specified with .set-default-size() in class Gnome::Gtk4::Window). During the recursive allocation process it’s important to note that request cycles will be recursively executed while widgets allocate their children. Each widget, once allocated a size, will go on to first share the space in one orientation among its children and then request each child's height for its target allocated width or its width for allocated height, depending. In this way a Gnome::Gtk4::Widget will typically be requested its size a number of times before actually being allocated a size. The size a widget is finally allocated can of course differ from the size it has requested. For this reason, Gnome::Gtk4::Widget caches a small number of results to avoid re-querying for the same sizes in one allocation cycle.

If a widget does move content around to intelligently use up the allocated size then it must support the request in both enumeration GtkSizeRequestMode defined in Gnome::Gtk4::T-enumss even if the widget in question only trades sizes in a single orientation.

For instance, a Gnome::Gtk4::Label that does height-for-width word wrapping will not expect to have [vfunc $Gtk.Widget.measure] with an orientation of GTK_ORIENTATION_VERTICAL called because that call is specific to a width-for-height request. In this case the label must return the height required for its own minimum possible width. By following this rule any widget that handles height-for-width or width-for-height requests will always be allocated at least enough space to fit its own content.

Here are some examples of how a GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH widget generally deals with width-for-height requests:

Often a widget needs to get its own request during size request or allocation. For example, when computing height it may need to also compute width. Or when deciding how to use an allocation, the widget may need to know its natural size. In these cases, the widget should be careful to call its virtual methods directly, like in the code example above.

It will not work to use the wrapper function .measure() inside your own [vfunc $Gtk.Widget.size_allocate] implementation. These return a request adjusted by Gnome::Gtk4::SizeGroup, the widget's align and expand flags, as well as its CSS style.

If a widget used the wrappers inside its virtual method implementations, then the adjustments (such as widget margins) would be applied twice. GTK therefore does not allow this and will warn if you try to do it.

Of course if you are getting the size request for another widget, such as a child widget, you must use .measure(); otherwise, you would not properly consider widget margins, Gnome::Gtk4::SizeGroup, and so forth.

GTK also supports baseline vertical alignment of widgets. This means that widgets are positioned such that the typographical baseline of widgets in the same row are aligned. This happens if a widget supports baselines, has a vertical alignment using baselines, and is inside a widget that supports baselines and has a natural “row” that it aligns to the baseline, or a baseline assigned to it by the grandparent.

Baseline alignment support for a widget is also done by the [vfunc $Gtk.Widget.measure] virtual function. It allows you to report both a minimum and natural size.

If a widget ends up baseline aligned it will be allocated all the space in the parent as if it was GTK_ALIGN_FILL, but the selected baseline can be found via .get-baseline(). If the baseline has a value other than -1 you need to align the widget such that the baseline appears at the position.

GtkWidget as GtkBuildable

The Gnome::Gtk4::Widget implementation of the Gnome::Gtk4::R-Buildable interface supports various custom elements to specify additional aspects of widgets that are not directly expressed as properties.

If the widget uses a Gnome::Gtk4::LayoutManager, Gnome::Gtk4::Widget supports a custom `<layout>` element, used to define layout properties:

Gnome::Gtk4::Widget allows style information such as style classes to be associated with widgets, using the custom `<style>` element:

Gnome::Gtk4::Widget allows defining accessibility information, such as properties, relations, and states, using the custom `<accessibility>` element:

Building composite widgets from template XML

Gnome::Gtk4::Widget exposes some facilities to automate the procedure of creating composite widgets using "templates".

To create composite widgets with Gnome::Gtk4::Builder XML, one must associate the interface description with the widget class at class initialization time using .set-template() in class Gnome::Gtk4::Widget.

The interface description semantics expected in composite template descriptions is slightly different from regular Gnome::Gtk4::Builder XML.

Unlike regular interface descriptions, .set-template() in class Gnome::Gtk4::Widget will expect a `<template>` tag as a direct child of the toplevel `<interface>` tag. The `<template>` tag must specify the “class” attribute which must be the type name of the widget. Optionally, the “parent” attribute may be specified to specify the direct parent type of the widget type; this is ignored by Gnome::Gtk4::Builder but can be used by UI design tools to introspect what kind of properties and internal children exist for a given type when the actual type does not exist.

The XML which is contained inside the `<template>` tag behaves as if it were added to the `<object>` tag defining the widget itself. You may set properties on a widget by inserting `<property>` tags into the `<template>` tag, and also add `<child>` tags to add children and extend a widget in the normal way you would with `<object>` tags.

Additionally, `<object>` tags can also be added before and after the initial `<template>` tag in the normal way, allowing one to define auxiliary objects which might be referenced by other widgets declared as children of the `<template>` tag.

Since, unlike the `<object>` tag, the `<template>` tag does not contain an “id” attribute, if you need to refer to the instance of the object itself that the template will create, simply refer to the template class name in an applicable element content.

Here is an example of a template definition, which includes an example of this in the `<signal>` tag:

Typically, you'll place the template fragment into a file that is bundled with your project, using Gnome::Gio::N-Resource. In order to load the template, you need to call .set-template-from-resource() in class Gnome::Gtk4::Widget from the class initialization of your Gnome::Gtk4::Widget type:

You will also need to call .init-template() from the instance initialization function:

as well as calling .dispose-template() from the dispose function:

You can access widgets defined in the template using the .get-template-child() function, but you will typically declare a pointer in the instance private data structure of your type using the same name as the widget in the template definition, and call .bind-template-child-full() in class Gnome::Gtk4::Widget (or one of its wrapper macros .widget-class-bind-template-child() and .widget-class-bind-template-child-private()) with that name, e.g.

You can also use .bind-template-callback-full() in class Gnome::Gtk4::Widget (or is wrapper macro .widget-class-bind-template-callback()) to connect a signal callback defined in the template with a function visible in the scope of the class, e.g.

Class initialization

new

:native-object

Create an object using a native object from elsewhere. See also Gnome::N::TopLevelSupportClass.

multi method new ( N-Object :$native-object! )

Methods

action-set-enabled

Enable or disable an action installed with .class-install-action().

method action-set-enabled ( Str $action-name, Bool() $enabled )
  • $action-name; action name, such as "clipboard.paste".

  • $enabled; whether the action is now enabled.

activate

For widgets that can be “activated” (buttons, menu items, etc.), this function activates them.

The activation will emit the signal set using .set-activate-signal() in class Gnome::Gtk4::Widget during class initialization.

Activation is what happens when you press <kbd>Enter</kbd> on a widget during key navigation.

If you wish to handle the activation keybinding yourself, it is recommended to use .add-shortcut() in class Gnome::Gtk4::Widget with an action created with .newwidget() in class Gnome::Gtk4::SignalAction.

If $widget isn't activatable, the function returns False.

method activate (--> Bool )

Return value; True if the widget was activatable.

activate-action This function is not yet available

Looks up the action in the action groups associated with $widget and its ancestors, and activates it.

This is a wrapper around .activate-action-variant() that constructs the $args variant according to $format-string.

method activate-action ( Str $name, Str $format-string, … --> Bool )
  • $name; the name of the action to activate.

  • $format-string; GVariant format string for arguments.

  • …; …. Note that each argument must be specified as a type followed by its value!

Return value; True if the action was activated, False if the action does not exist.

activate-action-variant

Looks up the action in the action groups associated with $widget and its ancestors, and activates it.

If the action is in an action group added with .insert-action-group(), the $name is expected to be prefixed with the prefix that was used when the group was inserted.

The arguments must match the actions expected parameter type, as returned by g_action_get_parameter_type()`.

method activate-action-variant ( Str $name, N-Object $args --> Bool )
  • $name; the name of the action to activate.

  • $args; parameters to use

Return value; True if the action was activated, False if the action does not exist..

activate-default

Activates the default.activate` action from $widget.

method activate-default ( )

add-controller

Adds $controller to $widget so that it will receive events.

You will usually want to call this function right after creating any kind of Gnome::Gtk4::EventController.

method add-controller ( N-Object() $controller )
  • $controller; (transfer ownership: full) a Gnome::Gtk4::EventController that hasn't been added to a widget yet.

add-css-class

Adds a style class to $widget.

After calling this function, the widget’s style will match for $css-class, according to CSS matching rules.

Use .remove-css-class() to remove the style again.

method add-css-class ( Str $css-class )
  • $css-class; The style class to add to $widget, without the leading '.' used for notation of style classes.

add-mnemonic-label

Adds a widget to the list of mnemonic labels for this widget.

See .list-mnemonic-labels(). Note the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update its internal state at this point as well.

method add-mnemonic-label ( N-Object() $label )
  • $label; a Gnome::Gtk4::Widget that acts as a mnemonic label for $widget.

add-tick-callback This function is not yet available

Queues an animation frame update and adds a callback to be called before each frame.

Until the tick callback is removed, it will be called frequently (usually at the frame rate of the output device or as quickly as the application can be repainted, whichever is slower). For this reason, is most suitable for handling graphics that change every frame or every few frames. The tick callback does not automatically imply a relayout or repaint. If you want a repaint or relayout, and aren’t changing widget properties that would trigger that (for example, changing the text of a Gnome::Gtk4::Label), then you will have to call .queue-resize() or .queue-draw() yourself.

.get-frame-time() in class Gnome::Gdk4::FrameClock should generally be used for timing continuous animations and .get-predicted-presentation-time() in class Gnome::Gdk4::N-FrameTimings if you are trying to display isolated frames at particular times.

This is a more convenient alternative to connecting directly to the [signal $Gdk.FrameClock::update] signal of Gnome::Gdk4::FrameClock, since you don't have to worry about when a Gnome::Gdk4::FrameClock is assigned to a widget.

method add-tick-callback ( &callback, gpointer $user-data, … --> UInt )
  • &callback; function to call for updating animations. Tthe function must be specified with following signature; :( N-Object $widget, N-Object $frame-clock, gpointer $user-data -- gboolean )>.

  • $user-data; data to pass to $callback.

  • notify; function to call to free $user-data when the callback is removed.. Note that each argument must be specified as a type followed by its value!

Return value; an id for the connection of this callback. Remove the callback by passing the id returned from this function to .remove-tick-callback().

allocate

This function is only used by Gnome::Gtk4::Widget subclasses, to assign a size, position and (optionally) baseline to their child widgets.

In this function, the allocation and baseline may be adjusted. The given allocation will be forced to be bigger than the widget's minimum size, as well as at least 0×0 in size.

For a version that does not take a transform, see .size-allocate().

method allocate ( Int() $width, Int() $height, Int() $baseline, N-Object $transform )
  • $width; New width of $widget.

  • $height; New height of $widget.

  • $baseline; New baseline of $widget, or -1.

  • $transform; (transfer ownership: full) Transformation to be applied to $widget

child-focus

Called by widgets as the user moves around the window using keyboard shortcuts.

The $direction argument indicates what kind of motion is taking place (up, down, left, right, tab forward, tab backward).

This function calls the [vfunc $Gtk.Widget.focus] virtual function; widgets can override the virtual function in order to implement appropriate focus behavior.

The default focus()` virtual function for a widget should return True if moving in $direction left the focus on a focusable location inside that widget, and False if moving in $direction moved the focus outside the widget. When returning True, widgets normally call .grab-focus() to place the focus accordingly; when returning False, they don’t modify the current focus location.

This function is used by custom widget implementations; if you're writing an app, you’d use .grab-focus() to move the focus to a particular widget.

method child-focus ( GtkDirectionType $direction --> Bool )
  • $direction; direction of focus movement.

Return value; True if focus ended up inside $widget.

compute-bounds

Computes the bounds for $widget in the coordinate space of $target.

The bounds of widget are (the bounding box of) the region that it is expected to draw in. See the [coordinate system](coordinates.html) overview to learn more.

If the operation is successful, True is returned. If $widget has no bounds or the bounds cannot be expressed in $target's coordinate space (for example if both widgets are in different windows), False is returned and $bounds is set to the zero rectangle.

It is valid for $widget and $target to be the same widget.

method compute-bounds ( N-Object() $target, N-Object $out-bounds --> Bool )
  • $target; the Gnome::Gtk4::Widget.

  • $out-bounds; the rectangle taking the bounds

Return value; True if the bounds could be computed.

compute-expand

Computes whether a container should give this widget extra space when possible.

Containers should check this, rather than looking at .get-hexpand() or .get-vexpand().

This function already checks whether the widget is visible, so visibility does not need to be checked separately. Non-visible widgets are not expanded.

The computed expand value uses either the expand setting explicitly set on the widget itself, or, if none has been explicitly set, the widget may expand if some of its children do.

method compute-expand ( GtkOrientation $orientation --> Bool )
  • $orientation; expand direction.

Return value; whether widget tree rooted here should be expanded.

compute-point

Translates the given $point in $widget's coordinates to coordinates relative to $target’s coordinate system.

In order to perform this operation, both widgets must share a common ancestor.

method compute-point ( N-Object() $target, N-Object $point, N-Object $out-point --> Bool )
  • $target; the Gnome::Gtk4::Widget to transform into.

  • $point; a point in $widget's coordinate system

  • $out-point; Set to the corresponding coordinates in $target's coordinate system

Return value; True if the point could be determined, False on failure. In this case, 0 is stored in $out-point..

compute-transform

Computes a matrix suitable to describe a transformation from $widget's coordinate system into $target's coordinate system.

The transform can not be computed in certain cases, for example when $widget and $target do not share a common ancestor. In that case $out-transform gets set to the identity matrix.

To learn more about widget coordinate systems, see the coordinate system [overview](coordinates.html).

method compute-transform ( N-Object() $target, N-Object $out-transform --> Bool )
  • $target; the target widget that the matrix will transform to.

  • $out-transform; location to store the final transformation

Return value; True if the transform could be computed, False otherwise.

contains

Tests if the point at ( $x, $y) is contained in $widget.

The coordinates for ( $x, $y) must be in widget coordinates, so (0, 0) is assumed to be the top left of $widget's content area.

method contains ( Num() $x, Num() $y --> Bool )
  • $x; X coordinate to test, relative to $widget's origin.

  • $y; Y coordinate to test, relative to $widget's origin.

Return value; True if $widget contains ( $x, $y)..

create-pango-context

Creates a new Gnome::Pango::Context with the appropriate font map, font options, font description, and base direction for drawing text for this widget.

See also .get-pango-context().

method create-pango-context (--> N-Object )

Return value; the new Gnome::Pango::Context.

create-pango-layout

Creates a new Gnome::Pango::Layout with the appropriate font map, font description, and base direction for drawing text for this widget.

If you keep a Gnome::Pango::Layout created in this way around, you need to re-create it when the widget Gnome::Pango::Context is replaced. This can be tracked by listening to changes of the root property on the widget.

method create-pango-layout ( Str $text --> N-Object )
  • $text; text to set on the layout.

Return value; the new Gnome::Pango::Layout.

dispose-template

Clears the template children for the given widget.

This function is the opposite of .init-template(), and it is used to clear all the template children from a widget instance. If you bound a template child to a field in the instance structure, or in the instance private data structure, the field will be set to undefined after this function returns.

You should call this function inside the GObjectClass.dispose()` implementation of any widget that called C<.init-template()>`. Typically, you will want to call this function last, right before chaining up to the parent type's dispose implementation, e.g.

method dispose-template ( GType $widget-type )
  • $widget-type; the type of the widget to finalize the template for.

drag-check-threshold

Checks to see if a drag movement has passed the GTK drag threshold.

method drag-check-threshold ( Int() $start-x, Int() $start-y, Int() $current-x, Int() $current-y --> Bool )
  • $start-x; X coordinate of start of drag.

  • $start-y; Y coordinate of start of drag.

  • $current-x; current X coordinate.

  • $current-y; current Y coordinate.

Return value; True if the drag threshold has been passed..

error-bell

Notifies the user about an input-related error on this widget.

If the gtk-error-bell defined in Gnome::Gtk4::Settings setting is True, it calls .beep() in class Gnome::Gdk4::Surface, otherwise it does nothing.

Note that the effect of .beep() in class Gnome::Gdk4::Surface can be configured in many ways, depending on the windowing backend and the desktop environment or window manager that is used.

method error-bell ( )

get-allocated-baseline

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.12

Returns the baseline that has currently been allocated to $widget.

This function is intended to be used when implementing handlers for the Gnome::Gtk4::WidgetClass.snapshot() function, and when allocating child widgets in Gnome::Gtk4::WidgetClass.size_allocate().

method get-allocated-baseline (--> Int )

Return value; the baseline of the $widget, or -1 if none.

get-allocated-height

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.12

Returns the height that has currently been allocated to $widget.

To learn more about widget sizes, see the coordinate system [overview](coordinates.html).

method get-allocated-height (--> Int )

Return value; the height of the $widget.

get-allocated-width

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.12

Returns the width that has currently been allocated to $widget.

To learn more about widget sizes, see the coordinate system [overview](coordinates.html).

method get-allocated-width (--> Int )

Return value; the width of the $widget.

get-allocation This function is not yet available

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.12

Retrieves the widget’s allocation.

Note, when implementing a layout container: a widget’s allocation will be its “adjusted” allocation, that is, the widget’s parent typically calls .size-allocate() with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget. .get-allocation() returns the adjusted allocation that was actually assigned to the widget. The adjusted allocation is guaranteed to be completely contained within the .size-allocate() allocation, however.

So a layout container is guaranteed that its children stay inside the assigned bounds, but not that they have exactly the bounds the container assigned.

method get-allocation ( … )
  • allocation; a pointer to a Gnome::Gtk4::Widget to copy to. Note that each argument must be specified as a type followed by its value!

get-ancestor

Gets the first ancestor of $widget with type $widget-type.

For example, gtk_widget_get_ancestor (widget, GTK_TYPE_BOX)` gets the first Gnome::Gtk4::Box that’s an ancestor of $widget. No reference will be added to the returned widget; it should not be unreferenced.

Note that unlike .is-ancestor(), this function considers $widget to be an ancestor of itself.

method get-ancestor ( GType $widget-type --> N-Object )
  • $widget-type; ancestor type.

Return value; the ancestor widget.

get-baseline

Returns the baseline that has currently been allocated to $widget.

This function is intended to be used when implementing handlers for the Gnome::Gtk4::WidgetClass.snapshot() function, and when allocating child widgets in Gnome::Gtk4::WidgetClass.size_allocate().

method get-baseline (--> Int )

Return value; the baseline of the $widget, or -1 if none.

get-can-focus

Determines whether the input focus can enter $widget or any of its children.

See .set-focusable().

method get-can-focus (--> Bool )

Return value; True if the input focus can enter $widget, False otherwise.

get-can-target

Queries whether $widget can be the target of pointer events.

method get-can-target (--> Bool )

Return value; True if $widget can receive pointer events.

get-child-visible

Gets the value set with .set-child-visible().

If you feel a need to use this function, your code probably needs reorganization.

This function is only useful for container implementations and should never be called by an application.

method get-child-visible (--> Bool )

Return value; True if the widget is mapped with the parent..

get-clipboard

Gets the clipboard object for $widget.

This is a utility function to get the clipboard object for the Gnome::Gdk4::Display that $widget is using.

Note that this function always works, even when $widget is not realized yet.

method get-clipboard (--> N-Object )

Return value; the appropriate clipboard object.

get-color

Gets the current foreground color for the widget’s CSS style.

This function should only be used in snapshot implementations that need to do custom drawing with the foreground color.

method get-color ( N-Object $color )
  • $color; return location for the color

get-css-classes

Returns the list of style classes applied to $widget.

method get-css-classes (--> Array[Str] )

Return value; a undefined-terminated list of css classes currently applied to $widget. The returned list must freed using g_strfreev()..

get-css-name

Returns the CSS name that is used for $self.

method get-css-name (--> Str )

Return value; the CSS name.

get-cursor

Queries the cursor set on $widget.

See .set-cursor() for details.

method get-cursor (--> N-Object )

Return value; the cursor currently in use or undefined if the cursor is inherited.

get-direction

Gets the reading direction for a particular widget.

See .set-direction().

method get-direction (--> GtkTextDirection )

Return value; the reading direction for the widget..

get-display

Get the Gnome::Gdk4::Display for the toplevel window associated with this widget.

This function can only be called after the widget has been added to a widget hierarchy with a Gnome::Gtk4::Window at the top.

In general, you should only create display specific resources when a widget has been realized, and you should free those resources when the widget is unrealized.

method get-display (--> N-Object )

Return value; the Gnome::Gdk4::Display for the toplevel for this widget..

get-first-child

Returns the widget’s first child.

This API is primarily meant for widget implementations.

method get-first-child (--> N-Object )

Return value; The widget's first child.

get-focus-child

Returns the current focus child of $widget.

method get-focus-child (--> N-Object )

Return value; The current focus child of $widget.

get-focus-on-click

Returns whether the widget should grab focus when it is clicked with the mouse.

See .set-focus-on-click().

method get-focus-on-click (--> Bool )

Return value; True if the widget should grab focus when it is clicked with the mouse.

get-focusable

Determines whether $widget can own the input focus.

See .set-focusable().

method get-focusable (--> Bool )

Return value; True if $widget can own the input focus, False otherwise.

get-font-map

Gets the font map of $widget.

See .set-font-map().

method get-font-map (--> N-Object )

Return value; A Gnome::Pango::FontMap.

get-font-options

Returns the Gnome::Cairo::N-Context of widget.

Seee .set-font-options().

method get-font-options (--> N-Object )

Return value; the Gnome::Cairo::N-Context of widget.

get-frame-clock

Obtains the frame clock for a widget.

The frame clock is a global “ticker” that can be used to drive animations and repaints. The most common reason to get the frame clock is to call .get-frame-time() in class Gnome::Gdk4::FrameClock, in order to get a time to use for animating. For example you might record the start of the animation with an initial value from .get-frame-time() in class Gnome::Gdk4::FrameClock, and then update the animation by calling .get-frame-time() in class Gnome::Gdk4::FrameClock again during each repaint.

.request-phase() in class Gnome::Gdk4::FrameClock will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to use .queue-draw() which invalidates the widget (thus scheduling it to receive a draw on the next frame). .queue-draw() will also end up requesting a frame on the appropriate frame clock.

A widget’s frame clock will not change while the widget is mapped. Reparenting a widget (which implies a temporary unmap) can change the widget’s frame clock.

Unrealized widgets do not have a frame clock.

method get-frame-clock (--> N-Object )

Return value; a Gnome::Gdk4::FrameClock.

get-halign

Gets the horizontal alignment of $widget.

For backwards compatibility reasons this method will never return one of the baseline alignments, but instead it will convert it to GTK_ALIGN_FILL or GTK_ALIGN_CENTER.

Baselines are not supported for horizontal alignment.

method get-halign (--> GtkAlign )

Return value; the horizontal alignment of $widget.

get-has-tooltip

Returns the current value of the has-tooltip` property.

method get-has-tooltip (--> Bool )

Return value; current value of has-tooltip` on $widget..

get-height

Returns the content height of the widget.

This function returns the height passed to its size-allocate implementation, which is the height you should be using in [vfunc $Gtk.Widget.snapshot].

For pointer events, see .contains().

To learn more about widget sizes, see the coordinate system [overview](coordinates.html).

method get-height (--> Int )

Return value; The height of $widget.

get-hexpand

Gets whether the widget would like any available extra horizontal space.

When a user resizes a Gnome::Gtk4::Window, widgets with expand=TRUE generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.

Containers should use .compute-expand() rather than this function, to see whether a widget, or any of its children, has the expand flag set. If any child of a widget wants to expand, the parent may ask to expand also.

This function only looks at the widget’s own hexpand flag, rather than computing whether the entire widget tree rooted at this widget wants to expand.

method get-hexpand (--> Bool )

Return value; whether hexpand flag is set.

get-hexpand-set

Gets whether .set-hexpand() has been used to explicitly set the expand flag on this widget.

If hexpand property is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.

There are few reasons to use this function, but it’s here for completeness and consistency.

method get-hexpand-set (--> Bool )

Return value; whether hexpand has been explicitly set.

get-last-child

Returns the widget’s last child.

This API is primarily meant for widget implementations.

method get-last-child (--> N-Object )

Return value; The widget's last child.

get-layout-manager

Retrieves the layout manager used by $widget.

See .set-layout-manager().

method get-layout-manager (--> N-Object )

Return value; a Gnome::Gtk4::LayoutManager.

get-mapped

Whether the widget is mapped.

method get-mapped (--> Bool )

Return value; True if the widget is mapped, False otherwise..

get-margin-bottom

Gets the bottom margin of $widget.

method get-margin-bottom (--> Int )

Return value; The bottom margin of $widget.

get-margin-end

Gets the end margin of $widget.

method get-margin-end (--> Int )

Return value; The end margin of $widget.

get-margin-start

Gets the start margin of $widget.

method get-margin-start (--> Int )

Return value; The start margin of $widget.

get-margin-top

Gets the top margin of $widget.

method get-margin-top (--> Int )

Return value; The top margin of $widget.

get-name

Retrieves the name of a widget.

See .set-name() for the significance of widget names.

method get-name (--> Str )

Return value; name of the widget. This string is owned by GTK and should not be modified or freed.

get-native

Returns the nearest Gnome::Gtk4::R-Native ancestor of $widget.

This function will return undefined if the widget is not contained inside a widget tree with a native ancestor.

Gnome::Gtk4::R-Native widgets will return themselves here.

method get-native (--> N-Object )

Return value; the Gnome::Gtk4::R-Native ancestor of $widget.

get-next-sibling

Returns the widget’s next sibling.

This API is primarily meant for widget implementations.

method get-next-sibling (--> N-Object )

Return value; The widget's next sibling.

get-opacity

#Fetches the requested opacity for this widget.

See .set-opacity().

method get-opacity (--> Num )

Return value; the requested opacity for this widget..

get-overflow

Returns the widget’s overflow value.

method get-overflow (--> GtkOverflow )

Return value; The widget's overflow..

get-pango-context

Gets a Gnome::Pango::Context with the appropriate font map, font description, and base direction for this widget.

Unlike the context returned by .create-pango-context(), this context is owned by the widget (it can be used until the screen for the widget changes or the widget is removed from its toplevel), and will be updated to match any changes to the widget’s attributes. This can be tracked by listening to changes of the root property on the widget.

method get-pango-context (--> N-Object )

Return value; the Gnome::Pango::Context for the widget..

get-parent

Returns the parent widget of $widget.

method get-parent (--> N-Object )

Return value; the parent widget of $widget.

get-preferred-size

Retrieves the minimum and natural size of a widget, taking into account the widget’s preference for height-for-width management.

This is used to retrieve a suitable size by container widgets which do not impose any restrictions on the child placement. It can be used to deduce toplevel window and menu sizes as well as child widgets in free-form containers such as Gnome::Gtk4::Fixed.

Handle with care. Note that the natural height of a height-for-width widget will generally be a smaller size than the minimum height, since the required height for the natural width is generally smaller than the required height for the minimum width.

Use .measure() if you want to support baseline alignment.

method get-preferred-size ( N-Object $minimum-size, N-Object $natural-size )
  • $minimum-size; location for storing the minimum size

  • $natural-size; location for storing the natural size

get-prev-sibling

Returns the widget’s previous sibling.

This API is primarily meant for widget implementations.

method get-prev-sibling (--> N-Object )

Return value; The widget's previous sibling.

get-primary-clipboard

Gets the primary clipboard of $widget.

This is a utility function to get the primary clipboard object for the Gnome::Gdk4::Display that $widget is using.

Note that this function always works, even when $widget is not realized yet.

method get-primary-clipboard (--> N-Object )

Return value; the appropriate clipboard object.

get-realized

Determines whether $widget is realized.

method get-realized (--> Bool )

Return value; True if $widget is realized, False otherwise.

get-receives-default

Determines whether $widget is always treated as the default widget within its toplevel when it has the focus, even if another widget is the default.

See .set-receives-default().

method get-receives-default (--> Bool )

Return value; True if $widget acts as the default widget when focused, False otherwise.

get-request-mode

Gets whether the widget prefers a height-for-width layout or a width-for-height layout.

Single-child widgets generally propagate the preference of their child, more complex widgets need to request something either in context of their children or in context of their allocation capabilities.

method get-request-mode (--> GtkSizeRequestMode )

Return value; The enumeration GtkSizeRequestMode defined in Gnome::Gtk4::T-enums preferred by $widget..

get-root

Returns the Gnome::Gtk4::R-Root widget of $widget.

This function will return undefined if the widget is not contained inside a widget tree with a root widget.

Gnome::Gtk4::R-Root widgets will return themselves here.

method get-root (--> N-Object )

Return value; the root widget of $widget.

get-scale-factor

Retrieves the internal scale factor that maps from window coordinates to the actual device pixels.

On traditional systems this is 1, on high density outputs, it can be a higher value (typically 2).

See .get-scale-factor() in class Gnome::Gdk4::Surface.

method get-scale-factor (--> Int )

Return value; the scale factor for $widget.

get-sensitive

Returns the widget’s sensitivity.

This function returns the value that has been set using .set-sensitive()).

The effective sensitivity of a widget is however determined by both its own and its parent widget’s sensitivity. See .is-sensitive().

method get-sensitive (--> Bool )

Return value; True if the widget is sensitive.

get-settings

Gets the settings object holding the settings used for this widget.

Note that this function can only be called when the Gnome::Gtk4::Widget is attached to a toplevel, since the settings object is specific to a particular Gnome::Gdk4::Display. If you want to monitor the widget for changes in its settings, connect to the notify::display` signal.

method get-settings (--> N-Object )

Return value; the relevant Gnome::Gtk4::Settings object.

get-size

Returns the content width or height of the widget.

Which dimension is returned depends on $orientation.

This is equivalent to calling .get-width() for GTK_ORIENTATION_HORIZONTAL or .get-height() for GTK_ORIENTATION_VERTICAL, but can be used when writing orientation-independent code, such as when implementing Gnome::Gtk4::R-Orientable widgets.

To learn more about widget sizes, see the coordinate system [overview](coordinates.html).

method get-size ( GtkOrientation $orientation --> Int )
  • $orientation; the orientation to query.

Return value; The size of $widget in $orientation..

get-size-request

Gets the size request that was explicitly set for the widget using .set-size-request().

A value of -1 stored in $width or $height indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead. See .set-size-request(). To get the size a widget will actually request, call .measure() instead of this function.

method get-size-request ( Array[Int] $width, Array[Int] $height )
  • $width; (transfer ownership: full) return location for width.

  • $height; (transfer ownership: full) return location for height.

get-state-flags

Returns the widget state as a flag set.

It is worth mentioning that the effective GTK_STATE_FLAG_INSENSITIVE state will be returned, that is, also based on parent insensitivity, even if $widget itself is sensitive.

Also note that if you are looking for a way to obtain the [flags $Gtk.StateFlags] to pass to a Gnome::Gtk4::StyleContext method, you should look at .get-state() in class Gnome::Gtk4::StyleContext.

method get-state-flags (--> UInt )

Return value; The state flags for widget.

get-style-context

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Returns the style context associated to $widget.

The returned object is guaranteed to be the same for the lifetime of $widget.

method get-style-context (--> N-Object )

Return value; the widget’s Gnome::Gtk4::StyleContext.

get-template-child

Fetch an object build from the template XML for $widget-type in this $widget instance.

This will only report children which were previously declared with .bind-template-child-full() in class Gnome::Gtk4::Widget or one of its variants.

This function is only meant to be called for code which is private to the $widget-type which declared the child and is meant for language bindings which cannot easily make use of the GObject structure offsets.

method get-template-child ( GType $widget-type, Str $name --> N-Object )
  • $widget-type; The Gnome::GObject::Widget to get a template child for.

  • $name; The “id” of the child defined in the template XML.

Return value; The object built in the template XML with the id $name.

get-tooltip-markup

Gets the contents of the tooltip for $widget.

If the tooltip has not been set using .set-tooltip-markup(), this function returns undefined.

method get-tooltip-markup (--> Str )

Return value; the tooltip text.

get-tooltip-text

Gets the contents of the tooltip for $widget.

If the $widget's tooltip was set using .set-tooltip-markup(), this function will return the escaped text.

method get-tooltip-text (--> Str )

Return value; the tooltip text.

get-valign

Gets the vertical alignment of $widget.

method get-valign (--> GtkAlign )

Return value; the vertical alignment of $widget.

get-vexpand

Gets whether the widget would like any available extra vertical space.

See .get-hexpand() for more detail.

method get-vexpand (--> Bool )

Return value; whether vexpand flag is set.

get-vexpand-set

Gets whether .set-vexpand() has been used to explicitly set the expand flag on this widget.

See .get-hexpand-set() for more detail.

method get-vexpand-set (--> Bool )

Return value; whether vexpand has been explicitly set.

get-visible

Determines whether the widget is visible.

If you want to take into account whether the widget’s parent is also marked as visible, use .is-visible() instead.

This function does not check if the widget is obscured in any way.

See .set-visible().

method get-visible (--> Bool )

Return value; True if the widget is visible.

get-width

Returns the content width of the widget.

This function returns the width passed to its size-allocate implementation, which is the width you should be using in [vfunc $Gtk.Widget.snapshot].

For pointer events, see .contains().

To learn more about widget sizes, see the coordinate system [overview](coordinates.html).

method get-width (--> Int )

Return value; The width of $widget.

grab-focus

Causes $widget to have the keyboard focus for the Gnome::Gtk4::Window it's inside.

If $widget is not focusable, or its [vfunc $Gtk.Widget.grab_focus] implementation cannot transfer the focus to a descendant of $widget that is focusable, it will not take focus and False will be returned.

Calling .grab-focus() on an already focused widget is allowed, should not have an effect, and return True.

method grab-focus (--> Bool )

Return value; True if focus is now inside $widget..

has-css-class

Returns whether $css-class is currently applied to $widget.

method has-css-class ( Str $css-class --> Bool )
  • $css-class; A style class, without the leading '.' used for notation of style classes.

Return value; True if $css-class is currently applied to $widget, False otherwise..

has-default

Determines whether $widget is the current default widget within its toplevel.

method has-default (--> Bool )

Return value; True if $widget is the current default widget within its toplevel, False otherwise.

has-focus

Determines if the widget has the global input focus.

See .is-focus() for the difference between having the global input focus, and only having the focus within a toplevel.

method has-focus (--> Bool )

Return value; True if the widget has the global input focus..

has-visible-focus

Determines if the widget should show a visible indication that it has the global input focus.

This is a convenience function that takes into account whether focus indication should currently be shown in the toplevel window of $widget. See .get-focus-visible() in class Gnome::Gtk4::Window for more information about focus indication.

To find out if the widget has the global input focus, use .has-focus().

method has-visible-focus (--> Bool )

Return value; True if the widget should display a “focus rectangle”.

hide

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Reverses the effects of .show().

This is causing the widget to be hidden (invisible to the user).

method hide ( )

in-destruction

Returns whether the widget is currently being destroyed.

This information can sometimes be used to avoid doing unnecessary work.

method in-destruction (--> Bool )

Return value; True if $widget is being destroyed.

init-template

Creates and initializes child widgets defined in templates.

This function must be called in the instance initializer for any class which assigned itself a template using .set-template() in class Gnome::Gtk4::Widget.

It is important to call this function in the instance initializer of a Gnome::Gtk4::Widget subclass and not in Gnome::GObject::Object.constructed()` or Gnome::GObject::Object.constructor()` for two reasons:

  • derived widgets will assume that the composite widgets defined by its parent classes have been created in their relative instance initializers

  • when calling g_object_new()` on a widget with composite templates, it’s important to build the composite widgets before the construct properties are set. Properties passed to g_object_new()` should take precedence over properties set in the private template XML

A good rule of thumb is to call this function as the first thing in an instance initialization function.

method init-template ( )

insert-action-group

Inserts $group into $widget.

Children of $widget that implement Gnome::Gtk4::R-Actionable can then be associated with actions in $group by setting their “action-name” to $prefix.action-name`.

Note that inheritance is defined for individual actions. I.e. even if you insert a group with prefix $prefix, actions with the same prefix will still be inherited from the parent, unless the group contains an action with the same name.

If $group is undefined, a previously inserted group for $name is removed from $widget.

method insert-action-group ( Str $name, N-Object() $group )
  • $name; the prefix for actions in $group.

  • $group; a Gnome::Gio::R-ActionGroup, or undefined to remove the previously inserted group for $name.

insert-after

Inserts $widget into the child widget list of $parent.

It will be placed after $previous-sibling, or at the beginning if $previous-sibling is undefined.

After calling this function, gtk_widget_get_prev_sibling(widget)` will return $previous-sibling.

If $parent is already set as the parent widget of $widget, this function can also be used to reorder $widget in the child widget list of $parent.

This API is primarily meant for widget implementations; if you are just using a widget, you *must* use its own API for adding children.

method insert-after ( N-Object() $parent, N-Object() $previous-sibling )
  • $parent; the parent Gnome::Gtk4::Widget to insert $widget into.

  • $previous-sibling; the new previous sibling of $widget.

insert-before

Inserts $widget into the child widget list of $parent.

It will be placed before $next-sibling, or at the end if $next-sibling is undefined.

After calling this function, gtk_widget_get_next_sibling(widget)` will return $next-sibling.

If $parent is already set as the parent widget of $widget, this function can also be used to reorder $widget in the child widget list of $parent.

This API is primarily meant for widget implementations; if you are just using a widget, you *must* use its own API for adding children.

method insert-before ( N-Object() $parent, N-Object() $next-sibling )
  • $parent; the parent Gnome::Gtk4::Widget to insert $widget into.

  • $next-sibling; the new next sibling of $widget.

is-ancestor

Determines whether $widget is somewhere inside $ancestor, possibly with intermediate containers.

method is-ancestor ( N-Object() $ancestor --> Bool )
  • $ancestor; another Gnome::Gtk4::Widget.

Return value; True if $ancestor contains $widget as a child, grandchild, great grandchild, etc..

is-drawable

Determines whether $widget can be drawn to.

A widget can be drawn if it is mapped and visible.

method is-drawable (--> Bool )

Return value; True if $widget is drawable, False otherwise.

is-focus

Determines if the widget is the focus widget within its toplevel.

This does not mean that the has-focus property is necessarily set; has-focus will only be set if the toplevel widget additionally has the global input focus.

method is-focus (--> Bool )

Return value; True if the widget is the focus widget..

is-sensitive

Returns the widget’s effective sensitivity.

This means it is sensitive itself and also its parent widget is sensitive.

method is-sensitive (--> Bool )

Return value; True if the widget is effectively sensitive.

is-visible

Determines whether the widget and all its parents are marked as visible.

This function does not check if the widget is obscured in any way.

See also .get-visible() and .set-visible().

method is-visible (--> Bool )

Return value; True if the widget and all its parents are visible.

keynav-failed

Emits the `::keynav-failed` signal on the widget.

This function should be called whenever keyboard navigation within a single widget hits a boundary.

The return value of this function should be interpreted in a way similar to the return value of .child-focus(). When True is returned, stay in the widget, the failed keyboard navigation is OK and/or there is nowhere we can/should move the focus to. When False is returned, the caller should continue with keyboard navigation outside the widget, e.g. by calling .child-focus() on the widget’s toplevel.

The default keynav-failed handler returns False for GTK_DIR_TAB_FORWARD and GTK_DIR_TAB_BACKWARD. For the other values of enumeration GtkDirectionType defined in Gnome::Gtk4::T-enums it returns True.

Whenever the default handler returns True, it also calls .error-bell() to notify the user of the failed keyboard navigation.

A use case for providing an own implementation of keynav-failed (either by connecting to it or by overriding it) would be a row of Gnome::Gtk4::Entry widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.

method keynav-failed ( GtkDirectionType $direction --> Bool )
  • $direction; direction of focus movement.

Return value; True if stopping keyboard navigation is fine, False if the emitting widget should try to handle the keyboard navigation attempt in its parent container(s)..

list-mnemonic-labels

Returns the widgets for which this widget is the target of a mnemonic.

Typically, these widgets will be labels. See, for example, .set-mnemonic-widget() in class Gnome::Gtk4::Label.

The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call g_list_foreach (result, (GFunc)g_object_ref, NULL)` first, and then unref all the widgets afterwards.

method list-mnemonic-labels (--> N-List )

Return value; the list of mnemonic labels; free this list with g_list_free() when you are done with it..

map

Causes a widget to be mapped if it isn’t already.

This function is only for use in widget implementations.

method map ( )

measure

Measures $widget in the orientation $orientation and for the given $for-size.

As an example, if $orientation is GTK_ORIENTATION_HORIZONTAL and $for-size is 300, this functions will compute the minimum and natural width of $widget if it is allocated at a height of 300 pixels.

See [GtkWidget’s geometry management section](class.Widget.html#height-for-width-geometry-management) for a more details on implementing GtkWidgetClass.measure()`.

method measure ( GtkOrientation $orientation, Int() $for-size, Array[Int] $minimum, Array[Int] $natural, Array[Int] $minimum-baseline, Array[Int] $natural-baseline )
  • $orientation; the orientation to measure.

  • $for-size; Size for the opposite of $orientation, i.e. if $orientation is GTK_ORIENTATION_HORIZONTAL, this is the height the widget should be measured with. The GTK_ORIENTATION_VERTICAL case is analogous. This way, both height-for-width and width-for-height requests can be implemented. If no size is known, -1 can be passed..

  • $minimum; (transfer ownership: full) location to store the minimum size.

  • $natural; (transfer ownership: full) location to store the natural size.

  • $minimum-baseline; (transfer ownership: full) location to store the baseline position for the minimum size, or -1 to report no baseline.

  • $natural-baseline; (transfer ownership: full) location to store the baseline position for the natural size, or -1 to report no baseline.

mnemonic-activate

Emits the mnemonic-activate signal.

See mnemonic-activate.

method mnemonic-activate ( Bool() $group-cycling --> Bool )
  • $group-cycling; True if there are other widgets with the same mnemonic.

Return value; True if the signal has been handled.

observe-children

Returns a Gnome::Gio::R-ListModel to track the children of $widget.

Calling this function will enable extra internal bookkeeping to track children and emit signals on the returned listmodel. It may slow down operations a lot.

Applications should try hard to avoid calling this function because of the slowdowns.

method observe-children (--> N-List )

Return value; a Gnome::Gio::R-ListModel tracking $widget's children.

observe-controllers

Returns a Gnome::Gio::R-ListModel to track the Gnome::Gtk4::EventControllers of $widget.

Calling this function will enable extra internal bookkeeping to track controllers and emit signals on the returned listmodel. It may slow down operations a lot.

Applications should try hard to avoid calling this function because of the slowdowns.

method observe-controllers (--> N-List )

Return value; a Gnome::Gio::R-ListModel tracking $widget's controllers.

pick

Finds the descendant of $widget closest to the point ( $x, $y).

The point must be given in widget coordinates, so (0, 0) is assumed to be the top left of $widget's content area.

Usually widgets will return undefined if the given coordinate is not contained in $widget checked via .contains(). Otherwise they will recursively try to find a child that does not return undefined. Widgets are however free to customize their picking algorithm.

This function is used on the toplevel to determine the widget below the mouse cursor for purposes of hover highlighting and delivering events.

method pick ( Num() $x, Num() $y, UInt $flags --> N-Object )
  • $x; X coordinate to test, relative to $widget's origin.

  • $y; Y coordinate to test, relative to $widget's origin.

  • $flags; Flags to influence what is picked.

Return value; The widget descendant at the given point.

queue-allocate

Flags the widget for a rerun of the [vfunc $Gtk.Widget.size_allocate] function.

Use this function instead of .queue-resize() when the $widget's size request didn't change but it wants to reposition its contents.

An example user of this function is .set-halign().

This function is only for use in widget implementations.

method queue-allocate ( )

queue-draw

Schedules this widget to be redrawn in the paint phase of the current or the next frame.

This means $widget's [vfunc $Gtk.Widget.snapshot] implementation will be called.

method queue-draw ( )

queue-resize

Flags a widget to have its size renegotiated.

This should be called when a widget for some reason has a new size request. For example, when you change the text in a Gnome::Gtk4::Label, the label queues a resize to ensure there’s enough space for the new text.

Note that you cannot call .queue-resize() on a widget from inside its implementation of the [vfunc $Gtk.Widget.size_allocate] virtual method. Calls to .queue-resize() from inside [vfunc $Gtk.Widget.size_allocate] will be silently ignored.

This function is only for use in widget implementations.

method queue-resize ( )

realize

Creates the GDK resources associated with a widget.

Normally realization happens implicitly; if you show a widget and all its parent containers, then the widget will be realized and mapped automatically.

Realizing a widget requires all the widget’s parent widgets to be realized; calling this function realizes the widget’s parents in addition to $widget itself. If a widget is not yet inside a toplevel window when you realize it, bad things will happen.

This function is primarily used in widget implementations, and isn’t very useful otherwise. Many times when you think you might need it, a better approach is to connect to a signal that will be called after the widget is realized automatically, such as realize.

method realize ( )

remove-controller

Removes $controller from $widget, so that it doesn't process events anymore.

It should not be used again.

Widgets will remove all event controllers automatically when they are destroyed, there is normally no need to call this function.

method remove-controller ( N-Object() $controller )
  • $controller; a Gnome::Gtk4::EventController.

remove-css-class

Removes a style from $widget.

After this, the style of $widget will stop matching for $css-class.

method remove-css-class ( Str $css-class )
  • $css-class; The style class to remove from $widget, without the leading '.' used for notation of style classes.

remove-mnemonic-label

Removes a widget from the list of mnemonic labels for this widget.

See .list-mnemonic-labels(). The widget must have previously been added to the list with .add-mnemonic-label().

method remove-mnemonic-label ( N-Object() $label )
  • $label; a Gnome::Gtk4::Widget that was previously set as a mnemonic label for $widget with .add-mnemonic-label().

remove-tick-callback

Removes a tick callback previously registered with .add-tick-callback().

method remove-tick-callback ( UInt() $id )
  • $id; an id returned by .add-tick-callback().

set-can-focus

Specifies whether the input focus can enter the widget or any of its children.

Applications should set $can-focus to False to mark a widget as for pointer/touch use only.

Note that having $can-focus be True is only one of the necessary conditions for being focusable. A widget must also be sensitive and focusable and not have an ancestor that is marked as not can-focus in order to receive input focus.

See .grab-focus() for actually setting the input focus on a widget.

method set-can-focus ( Bool() $can-focus )
  • $can-focus; whether or not the input focus can enter the widget or any of its children.

set-can-target

Sets whether $widget can be the target of pointer events.

method set-can-target ( Bool() $can-target )
  • $can-target; whether this widget should be able to receive pointer events.

set-child-visible

Sets whether $widget should be mapped along with its parent.

The child visibility can be set for widget before it is added to a container with .set-parent(), to avoid mapping children unnecessary before immediately unmapping them. However it will be reset to its default state of True when the widget is removed from a container.

Note that changing the child visibility of a widget does not queue a resize on the widget. Most of the time, the size of a widget is computed from all visible children, whether or not they are mapped. If this is not the case, the container can queue a resize itself.

This function is only useful for container implementations and should never be called by an application.

method set-child-visible ( Bool() $child-visible )
  • $child-visible; if True, $widget should be mapped along with its parent..

set-css-classes

Clear all style classes applied to $widget and replace them with $classes.

method set-css-classes ( Array[Str] $classes )
  • $classes; undefined-terminated list of style classes to apply to $widget..

set-cursor

Sets the cursor to be shown when pointer devices point towards $widget.

If the $cursor is NULL, $widget will use the cursor inherited from the parent widget.

method set-cursor ( N-Object() $cursor )
  • $cursor; the new cursor.

set-cursor-from-name

Sets a named cursor to be shown when pointer devices point towards $widget.

This is a utility function that creates a cursor via .new-from-name() in class Gnome::Gdk4::Cursor and then sets it on $widget with .set-cursor(). See those functions for details.

On top of that, this function allows $name to be undefined, which will do the same as calling .set-cursor() with a undefined cursor.

method set-cursor-from-name ( Str $name )
  • $name; The name of the cursor.

set-direction

Sets the reading direction on a particular widget.

This direction controls the primary direction for widgets containing text, and also the direction in which the children of a container are packed. The ability to set the direction is present in order so that correct localization into languages with right-to-left reading directions can be done. Generally, applications will let the default reading direction present, except for containers where the containers are arranged in an order that is explicitly visual rather than logical (such as buttons for text justification).

If the direction is set to GTK_TEXT_DIR_NONE, then the value set by .Widget.set-default-direction() will be used.

method set-direction ( GtkTextDirection $dir )
  • $dir; the new direction.

set-focus-child

Set $child as the current focus child of $widget.

This function is only suitable for widget implementations. If you want a certain widget to get the input focus, call .grab-focus() on it.

method set-focus-child ( N-Object() $child )
  • $child; a direct child widget of $widget or undefined to unset the focus child of $widget.

set-focus-on-click

Sets whether the widget should grab focus when it is clicked with the mouse.

Making mouse clicks not grab focus is useful in places like toolbars where you don’t want the keyboard focus removed from the main area of the application.

method set-focus-on-click ( Bool() $focus-on-click )
  • $focus-on-click; whether the widget should grab focus when clicked with the mouse.

set-focusable

Specifies whether $widget can own the input focus.

Widget implementations should set $focusable to True in their init() function if they want to receive keyboard input.

Note that having $focusable be True is only one of the necessary conditions for being focusable. A widget must also be sensitive and can-focus and not have an ancestor that is marked as not can-focus in order to receive input focus.

See .grab-focus() for actually setting the input focus on a widget.

method set-focusable ( Bool() $focusable )
  • $focusable; whether or not $widget can own the input focus.

set-font-map

Sets the font map to use for Pango rendering.

The font map is the object that is used to look up fonts. Setting a custom font map can be useful in special situations, e.g. when you need to add application-specific fonts to the set of available fonts.

When not set, the widget will inherit the font map from its parent.

method set-font-map ( N-Object() $font-map )
  • $font-map; a Gnome::Pango::FontMap, or undefined to unset any previously set font map.

set-font-options

Sets the Gnome::Cairo::N-Context used for Pango rendering in this widget.

When not set, the default font options for the Gnome::Gdk4::Display will be used.

method set-font-options ( N-Object $options )
  • $options; a Gnome::Cairo::N-Context to unset any previously set default font options

set-halign

Sets the horizontal alignment of $widget.

method set-halign ( GtkAlign $align )
  • $align; the horizontal alignment.

set-has-tooltip

Sets the has-tooltip` property on $widget to $has-tooltip.

method set-has-tooltip ( Bool() $has-tooltip )
  • $has-tooltip; whether or not $widget has a tooltip..

set-hexpand

Sets whether the widget would like any available extra horizontal space.

When a user resizes a Gnome::Gtk4::Window, widgets with expand=TRUE generally receive the extra space. For example, a list or scrollable area or document in your window would often be set to expand.

Call this function to set the expand flag if you would like your widget to become larger horizontally when the window has extra room.

By default, widgets automatically expand if any of their children want to expand. (To see if a widget will automatically expand given its current children and state, call .compute-expand(). A container can decide how the expandability of children affects the expansion of the container by overriding the compute_expand virtual method on Gnome::Gtk4::Widget.).

Setting hexpand explicitly with this function will override the automatic expand behavior.

This function forces the widget to expand or not to expand, regardless of children. The override occurs because .set-hexpand() sets the hexpand-set property (see .set-hexpand-set()) which causes the widget’s hexpand value to be used, rather than looking at children and widget state.

method set-hexpand ( Bool() $expand )
  • $expand; whether to expand.

set-hexpand-set

Sets whether the hexpand flag will be used.

The hexpand-set property will be set automatically when you call .set-hexpand() to set hexpand, so the most likely reason to use this function would be to unset an explicit expand flag.

If hexpand is set, then it overrides any computed expand value based on child widgets. If hexpand is not set, then the expand value depends on whether any children of the widget would like to expand.

There are few reasons to use this function, but it’s here for completeness and consistency.

method set-hexpand-set ( Bool() $set )
  • $set; value for hexpand-set property.

set-layout-manager

Sets the layout manager delegate instance that provides an implementation for measuring and allocating the children of $widget.

method set-layout-manager ( N-Object() $layout-manager )
  • $layout-manager; (transfer ownership: full) a Gnome::Gtk4::LayoutManager.

set-margin-bottom

Sets the bottom margin of $widget.

method set-margin-bottom ( Int() $margin )
  • $margin; the bottom margin.

set-margin-end

Sets the end margin of $widget.

method set-margin-end ( Int() $margin )
  • $margin; the end margin.

set-margin-start

Sets the start margin of $widget.

method set-margin-start ( Int() $margin )
  • $margin; the start margin.

set-margin-top

Sets the top margin of $widget.

method set-margin-top ( Int() $margin )
  • $margin; the top margin.

set-name

Sets a widgets name.

Setting a name allows you to refer to the widget from a CSS file. You can apply a style to widgets with a particular name in the CSS file. See the documentation for the CSS syntax (on the same page as the docs for Gnome::Gtk4::StyleContext.

Note that the CSS syntax has certain special characters to delimit and represent elements in a selector (period, #, >, *...), so using these will make your widget impossible to match by name. Any combination of alphanumeric symbols, dashes and underscores will suffice.

method set-name ( Str $name )
  • $name; name for the widget.

set-opacity

Request the $widget to be rendered partially transparent.

An opacity of 0 is fully transparent and an opacity of 1 is fully opaque.

Opacity works on both toplevel widgets and child widgets, although there are some limitations: For toplevel widgets, applying opacity depends on the capabilities of the windowing system. On X11, this has any effect only on X displays with a compositing manager, see gdk_display_is_composited(). On Windows and Wayland it should always work, although setting a window’s opacity after the window has been shown may cause some flicker.

Note that the opacity is inherited through inclusion — if you set a toplevel to be partially translucent, all of its content will appear translucent, since it is ultimatively rendered on that toplevel. The opacity value itself is not inherited by child widgets (since that would make widgets deeper in the hierarchy progressively more translucent). As a consequence, Gnome::Gtk4::Popovers and other Gnome::Gtk4::R-Native widgets with their own surface will use their own opacity value, and thus by default appear non-translucent, even if they are attached to a toplevel that is translucent.

method set-opacity ( Num() $opacity )
  • $opacity; desired opacity, between 0 and 1.

set-overflow

Sets how $widget treats content that is drawn outside the widget's content area.

See the definition of enumeration Overflow from Gnome::Gtk4::T-enums for details.

This setting is provided for widget implementations and should not be used by application code.

The default value is GTK_OVERFLOW_VISIBLE.

method set-overflow ( GtkOverflow $overflow )
  • $overflow; desired overflow.

set-parent

Sets $parent as the parent widget of $widget.

This takes care of details such as updating the state and style of the child to reflect its new location and resizing the parent. The opposite function is .unparent().

This function is useful only when implementing subclasses of Gnome::Gtk4::Widget.

method set-parent ( N-Object() $parent )
  • $parent; parent widget.

set-receives-default

Specifies whether $widget will be treated as the default widget within its toplevel when it has the focus, even if another widget is the default.

method set-receives-default ( Bool() $receives-default )
  • $receives-default; whether or not $widget can be a default widget..

set-sensitive

Sets the sensitivity of a widget.

A widget is sensitive if the user can interact with it. Insensitive widgets are “grayed out” and the user can’t interact with them. Insensitive widgets are known as “inactive”, “disabled”, or “ghosted” in some other toolkits.

method set-sensitive ( Bool() $sensitive )
  • $sensitive; True to make the widget sensitive.

set-size-request

Sets the minimum size of a widget.

That is, the widget’s size request will be at least $width by $height. You can use this function to force a widget to be larger than it normally would be.

In most cases, .set-default-size() in class Gnome::Gtk4::Window is a better choice for toplevel windows than this function; setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request.

Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it's basically impossible to hardcode a size that will always be correct.

The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.

If the size request in a given direction is -1 (unset), then the “natural” size request of the widget will be used instead.

The size request set here does not include any margin from the properties margin-start, margin-end, margin-top, and margin-bottom, but it does include pretty much all other padding or border properties set by any subclass of Gnome::Gtk4::Widget.

method set-size-request ( Int() $width, Int() $height )
  • $width; width $widget should request, or -1 to unset.

  • $height; height $widget should request, or -1 to unset.

set-state-flags

Turns on flag values in the current widget state.

Typical widget states are insensitive, prelighted, etc.

This function accepts the values GTK_STATE_FLAG_DIR_LTR and GTK_STATE_FLAG_DIR_RTL but ignores them. If you want to set the widget's direction, use .set-direction().

This function is for use in widget implementations.

method set-state-flags ( UInt $flags, Bool() $clear )
  • $flags; State flags to turn on.

  • $clear; Whether to clear state before turning on $flags.

set-tooltip-markup

Sets $markup as the contents of the tooltip, which is marked up with Pango markup.

This function will take care of setting the has-tooltip as a side effect, and of the default handler for the query-tooltip signal.

See also .set-markup() in class Gnome::Gtk4::Tooltip.

method set-tooltip-markup ( Str $markup )
  • $markup; the contents of the tooltip for $widget.

set-tooltip-text

Sets $text as the contents of the tooltip.

If $text contains any markup, it will be escaped.

This function will take care of setting has-tooltip as a side effect, and of the default handler for the query-tooltip signal.

See also .set-text() in class Gnome::Gtk4::Tooltip.

method set-tooltip-text ( Str $text )
  • $text; the contents of the tooltip for $widget.

set-valign

Sets the vertical alignment of $widget.

method set-valign ( GtkAlign $align )
  • $align; the vertical alignment.

set-vexpand

Sets whether the widget would like any available extra vertical space.

See .set-hexpand() for more detail.

method set-vexpand ( Bool() $expand )
  • $expand; whether to expand.

set-vexpand-set

Sets whether the vexpand flag will be used.

See .set-hexpand-set() for more detail.

method set-vexpand-set ( Bool() $set )
  • $set; value for vexpand-set property.

set-visible

Sets the visibility state of $widget.

Note that setting this to True doesn’t mean the widget is actually viewable, see .get-visible().

method set-visible ( Bool() $visible )
  • $visible; whether the widget should be shown or not.

should-layout

Returns whether $widget should contribute to the measuring and allocation of its parent.

This is False for invisible children, but also for children that have their own surface.

method should-layout (--> Bool )

Return value; True if child should be included in measuring and allocating.

show

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.10

Flags a widget to be displayed.

Any widget that isn’t shown will not appear on the screen.

Remember that you have to show the containers containing a widget, in addition to the widget itself, before it will appear onscreen.

When a toplevel container is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel container is realized and mapped.

method show ( )

size-allocate This function is not yet available

Allocates widget with a transformation that translates the origin to the position in $allocation.

This is a simple form of .allocate().

method size-allocate ( …, Int() $baseline )
  • allocation; position and size to be allocated to $widget. Note that each argument must be specified as a type followed by its value!

  • $baseline; The baseline of the child, or -1.

snapshot-child

Snapshot the a child of $widget.

When a widget receives a call to the snapshot function, it must send synthetic [vfunc $Gtk.Widget.snapshot] calls to all children. This function provides a convenient way of doing this. A widget, when it receives a call to its [vfunc $Gtk.Widget.snapshot] function, calls .snapshot-child() once for each child, passing in the $snapshot the widget received.

.snapshot-child() takes care of translating the origin of $snapshot, and deciding whether the child needs to be snapshot.

This function does nothing for children that implement Gnome::Gtk4::R-Native.

method snapshot-child ( N-Object() $child, N-Object() $snapshot )
  • $child; a child of $widget.

  • $snapshot; Gnome::Gtk4::Snapshot as passed to the widget. In particular, no calls to gtk_snapshot_translate() or other transform calls should have been made..

translate-coordinates

Note: The native version of this routine is deprecated in gtk4-lib() since version 4.12

Translate coordinates relative to $src-widget’s allocation to coordinates relative to $dest-widget’s allocations.

In order to perform this operation, both widget must share a common ancestor.

method translate-coordinates ( N-Object() $dest-widget, Num() $src-x, Num() $src-y, Num() $dest-x, Num() $dest-y --> Bool )
  • $dest-widget; a Gnome::Gtk4::Widget.

  • $src-x; X position relative to $src-widget.

  • $src-y; Y position relative to $src-widget.

  • $dest-x; (transfer ownership: full) location to store X position relative to $dest-widget.

  • $dest-y; (transfer ownership: full) location to store Y position relative to $dest-widget.

Return value; False if $src-widget and $dest-widget have no common ancestor. In this case, 0 is stored in * $dest-x and * $dest-y. Otherwise True..

trigger-tooltip-query

Triggers a tooltip query on the display where the toplevel of $widget is located.

method trigger-tooltip-query ( )

unmap

Causes a widget to be unmapped if it’s currently mapped.

This function is only for use in widget implementations.

method unmap ( )

unparent

Dissociate $widget from its parent.

This function is only for use in widget implementations, typically in dispose.

method unparent ( )

unrealize

Causes a widget to be unrealized (frees all GDK resources associated with the widget).

This function is only useful in widget implementations.

method unrealize ( )

unset-state-flags

Turns off flag values for the current widget state.

See .set-state-flags().

This function is for use in widget implementations.

method unset-state-flags ( UInt $flags )
  • $flags; State flags to turn off.

Functions

get-default-direction

Obtains the current default reading direction.

See .Widget.set-default-direction().

method get-default-direction (--> GtkTextDirection )

Return value; the current default direction..

set-default-direction

Sets the default reading direction for widgets.

See .set-direction().

method set-default-direction ( GtkTextDirection $dir )
  • $dir; the new default direction. This cannot be GTK_TEXT_DIR_NONE..

Signals

destroy

Signals that all holders of a reference to the widget should release the reference that they hold.

May result in finalization of the widget if all references are released.

This signal is not suitable for saving widget state.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

direction-changed

Emitted when the text direction of a widget changes.

method handler (
   $previous-direction,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $previous-direction; the previous text direction of $widget.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

hide

Emitted when $widget is hidden.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

keynav-failed

Emitted if keyboard navigation fails.

See .keynav-failed() for details.

method handler (
   $direction,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
  --> gboolean
)
  • $direction; the direction of movement.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True if stopping keyboard navigation is fine, False if the emitting widget should try to handle the keyboard navigation attempt in its parent widget(s).

map

Emitted when $widget is going to be mapped.

A widget is mapped when the widget is visible (which is controlled with visible) and all its parents up to the toplevel widget are also visible.

The map signal can be used to determine whether a widget will be drawn, for instance it can resume an animation that was stopped during the emission of unmap.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

mnemonic-activate

Emitted when a widget is activated via a mnemonic.

The default handler for this signal activates $widget if $group-cycling is False, or just makes $widget grab focus if $group-cycling is True.

method handler (
  gboolean $group-cycling,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
  --> gboolean
)
  • $group-cycling; True if there are other widgets with the same mnemonic.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True to stop other handlers from being invoked for the event. False to propagate the event further.

move-focus

Emitted when the focus is moved.

The move-focus signal is a [keybinding signal](class.SignalAction.html).

The default bindings for this signal are <kbd>Tab</kbd> to move forward, and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move backward.

method handler (
   $direction,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $direction; the direction of the focus move.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

query-tooltip

Emitted when the widget’s tooltip is about to be shown.

This happens when the has-tooltip property is True and the hover timeout has expired with the cursor hovering "above" $widget; or emitted when $widget got focus in keyboard mode.

Using the given coordinates, the signal handler should determine whether a tooltip should be shown for $widget. If this is the case True should be returned, False otherwise. Note that if $keyboard-mode is True, the values of $x and $y are undefined and should not be used.

The signal handler is free to manipulate $tooltip with the therefore destined function calls.

method handler (
  gint $x,
  gint $y,
  gboolean $keyboard-mode,
  N-Object $tooltip,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
  --> gboolean
)
  • $x; the x coordinate of the cursor position where the request has been emitted, relative to $widget's left side.

  • $y; the y coordinate of the cursor position where the request has been emitted, relative to $widget's top.

  • $keyboard-mode; True if the tooltip was triggered using the keyboard.

  • $tooltip; a Gnome::Gtk4::Tooltip.

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

Return value; True if $tooltip should be shown right now, False otherwise.

realize

Emitted when $widget is associated with a Gnome::Gdk4::Surface.

This means that .realize() has been called or the widget has been mapped (that is, it is going to be drawn).

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

show

Emitted when $widget is shown.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

state-flags-changed

Emitted when the widget state changes.

See .get-state-flags().

method handler (
   $flags,
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $flags; The previous state flags..

  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

unmap

Emitted when $widget is going to be unmapped.

A widget is unmapped when either it or any of its parents up to the toplevel widget have been set as hidden.

As unmap indicates that a widget will not be shown any longer, it can be used to, for example, stop an animation on the widget.

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.

unrealize

Emitted when the Gnome::Gdk4::Surface associated with $widget is destroyed.

This means that .unrealize() has been called or the widget has been unmapped (that is, it is going to be hidden).

method handler (
  Int :$_handle_id,
  N-GObject :$_native-object,
  Gnome::Gtk4::Widget :$_widget,
  *C<user>-options
)
  • $_handle_id; The registered event handler id.

  • $_native-object; The native object provided by the Raku object which registered this event. This a native Gnome::Gtk4::Widget object.

  • $_widget; The object which registered the signal. User code may have left the object going out of scope.

  • user-options; A list of named arguments provided at the .register-signal() method from Gnome::GObject::Object.