1.214 <GtkWidget>

Class: <GtkWidget>

It derives from <GInitiallyUnowned>.

The base class for all widgets.

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:

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 <GtkWidget> subclass that supports height-for-width or width-for-height geometry management for itself or its child widgets, the widget:do-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 constant-size, which means that the widget will only ever get -1 passed as the for_size value to its widget:do-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 <GtkSizeRequestMode> chosen by the toplevel.

For example, when queried in the normal height-for-width mode:

First, the default minimum and natural width for each widget in the interface will be computed using widget:measure with an orientation of 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 widget:measure with an orientation of 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 window:set-default-size). 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 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, <GtkWidget> 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 <GtkSizeRequestMode>s even if the widget in question only trades sizes in a single orientation.

For instance, a <GtkLabel> that does height-for-width word wrapping will not expect to have widget:do-measure with an orientation of 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 height-for-width widget generally deals with width-for-height requests:

static void
foo_widget_measure (GtkWidget      *widget,
                    GtkOrientation  orientation,
                    int             for_size,
                    int            *minimum_size,
                    int            *natural_size,
                    int            *minimum_baseline,
                    int            *natural_baseline)
{
  if (orientation == GTK_ORIENTATION_HORIZONTAL)
    {
      // Calculate minimum and natural width
    }
  else // VERTICAL
    {
      if (i_am_in_height_for_width_mode)
        {
          int min_width, dummy;

          // First, get the minimum width of our widget
          GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_HORIZONTAL, -1,
                                                  &min_width, &dummy, &dummy, &dummy);

          // Now use the minimum width to retrieve the minimum and natural height to display
          // that width.
          GTK_WIDGET_GET_CLASS (widget)->measure (widget, GTK_ORIENTATION_VERTICAL, min_width,
                                                  minimum_size, natural_size, &dummy, &dummy);
        }
      else
        {
          // ... some widgets do both.
        }
    }
}

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 widget:measure inside your own widget:do-size-allocate implementation. These return a request adjusted by <GtkSizeGroup>, 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 widget:measure; otherwise, you would not properly consider widget margins, <GtkSizeGroup>, 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 widget:do-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 fill, but the selected baseline can be found via widget: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 <GtkWidget> implementation of the <GtkBuildable> interface supports various custom elements to specify additional aspects of widgets that are not directly expressed as properties.

If the widget uses a <GtkLayoutManager>, <GtkWidget> supports a custom <layout> element, used to define layout properties:

<object class="GtkGrid" id="my_grid">
  <child>
    <object class="GtkLabel" id="label1">
      <property name="label">Description</property>
      <layout>
        <property name="column">0</property>
        <property name="row">0</property>
        <property name="row-span">1</property>
        <property name="column-span">1</property>
      </layout>
    </object>
  </child>
  <child>
    <object class="GtkEntry" id="description_entry">
      <layout>
        <property name="column">1</property>
        <property name="row">0</property>
        <property name="row-span">1</property>
        <property name="column-span">1</property>
      </layout>
    </object>
  </child>
</object>

<GtkWidget> allows style information such as style classes to be associated with widgets, using the custom <style> element:

<object class="GtkButton" id="button1">
  <style>
    <class name="my-special-button-class"/>
    <class name="dark-button"/>
  </style>
</object>

<GtkWidget> allows defining accessibility information, such as properties, relations, and states, using the custom <accessibility> element:

<object class="GtkButton" id="button1">
  <accessibility>
    <property name="label">Download</property>
    <relation name="labelled-by">label1</relation>
  </accessibility>
</object>

Building composite widgets from template XML

GtkWidget exposes some facilities to automate the procedure of creating composite widgets using "templates".

To create composite widgets with <GtkBuilder> XML, one must associate the interface description with the widget class at class initialization time using widget-class:set-template.

The interface description semantics expected in composite template descriptions is slightly different from regular <GtkBuilder> XML.

Unlike regular interface descriptions, widget-class:set-template 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 <GtkBuilder> 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:

<interface>
  <template class="FooWidget" parent="GtkBox">
    <property name="orientation">horizontal</property>
    <property name="spacing">4</property>
    <child>
      <object class="GtkButton" id="hello_button">
        <property name="label">Hello World</property>
        <signal name="clicked" handler="hello_button_clicked" object="FooWidget" swapped="yes"/>
      </object>
    </child>
    <child>
      <object class="GtkButton" id="goodbye_button">
        <property name="label">Goodbye World</property>
      </object>
    </child>
  </template>
</interface>

Typically, you’ll place the template fragment into a file that is bundled with your project, using <GResource>. In order to load the template, you need to call widget-class:set-template-from-resource from the class initialization of your <GtkWidget> type:

static void
foo_widget_class_init (FooWidgetClass *klass)
{
  // ...

  gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
                                               "/com/example/ui/foowidget.ui");
}

You will also need to call widget:init-template from the instance initialization function:

static void
foo_widget_init (FooWidget *self)
{
  gtk_widget_init_template (GTK_WIDGET (self));

  // Initialize the rest of the widget...
}

as well as calling widget:dispose-template from the dispose function:

static void
foo_widget_dispose (GObject *gobject)
{
  FooWidget *self = FOO_WIDGET (gobject);

  // Dispose objects for which you have a reference...

  // Clear the template children for this widget type
  gtk_widget_dispose_template (GTK_WIDGET (self), FOO_TYPE_WIDGET);

  G_OBJECT_CLASS (foo_widget_parent_class)->dispose (gobject);
}

You can access widgets defined in the template using the widget: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 widget-class:bind-template-child-full (or one of its wrapper macros Gtk.widget_class_bind_template_child and Gtk.widget_class_bind_template_child_private) with that name, e.g.

typedef struct {
  GtkWidget *hello_button;
  GtkWidget *goodbye_button;
} FooWidgetPrivate;

G_DEFINE_TYPE_WITH_PRIVATE (FooWidget, foo_widget, GTK_TYPE_BOX)

static void
foo_widget_dispose (GObject *gobject)
{
  gtk_widget_dispose_template (GTK_WIDGET (gobject), FOO_TYPE_WIDGET);

  G_OBJECT_CLASS (foo_widget_parent_class)->dispose (gobject);
}

static void
foo_widget_class_init (FooWidgetClass *klass)
{
  // ...
  G_OBJECT_CLASS (klass)->dispose = foo_widget_dispose;

  gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
                                               "/com/example/ui/foowidget.ui");
  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
                                                FooWidget, hello_button);
  gtk_widget_class_bind_template_child_private (GTK_WIDGET_CLASS (klass),
                                                FooWidget, goodbye_button);
}

static void
foo_widget_init (FooWidget *widget)
{
  gtk_widget_init_template (GTK_WIDGET (widget));
}

You can also use widget-class:bind-template-callback-full (or is wrapper macro Gtk.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.

// the signal handler has the instance and user data swapped
// because of the swapped="yes" attribute in the template XML
static void
hello_button_clicked (FooWidget *self,
                      GtkButton *button)
{
  g_print ("Hello, world!\n");
}

static void
foo_widget_class_init (FooWidgetClass *klass)
{
  // ...
  gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass),
                                               "/com/example/ui/foowidget.ui");
  gtk_widget_class_bind_template_callback (GTK_WIDGET_CLASS (klass), hello_button_clicked);
}

Fields

parent-instance

Properties

Property: widget:can-focus self

Whether the widget or any of its descendents can accept the input focus.

This property is meant to be set by widget implementations, typically in their instance init function.

Its value is a boolean.

Set it with (set! (widget:can-focus self) value).

Property: widget:can-target self

Whether the widget can receive pointer events.

Its value is a boolean.

Set it with (set! (widget:can-target self) value).

Property: widget:css-classes self

A list of css classes applied to this widget.

Its value is a vector, each a string (or, to set it, a list), or #f.

Set it with (set! (widget:css-classes self) value).

Property: widget:css-name self

The name of this widget in the CSS tree.

This property is meant to be set by widget implementations, typically in their instance init function.

Its value is a string, or #f.

It can only be set when the object is made, with #:css-name.

Property: widget:cursor self

The cursor used by widget.

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

Set it with (set! (widget:cursor self) value).

Property: widget:focus-on-click self

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

This property is only relevant for widgets that can take focus.

Its value is a boolean.

Set it with (set! (widget:focus-on-click self) value).

Property: widget:focusable self

Whether this widget itself will accept the input focus.

Its value is a boolean.

Set it with (set! (widget:focusable self) value).

Property: widget:halign self

How to distribute horizontal space if widget gets extra space.

Its value is a <GtkAlign> (or, to set it, one of its symbols).

Set it with (set! (widget:halign self) value).

Property: widget:has-default self

Whether the widget is the default widget.

Its value is a boolean.

It is read only.

Property: widget:has-focus self

Whether the widget has the input focus.

Its value is a boolean.

It is read only.

Property: widget:has-tooltip self

Enables or disables the emission of the widget:query-tooltip signal on widget.

A true value indicates that widget can have a tooltip, in this case the widget will be queried using widget:query-tooltip to determine whether it will provide a tooltip or not.

Its value is a boolean.

Set it with (set! (widget:has-tooltip self) value).

Property: widget:height-request self

Overrides for height request of the widget.

If this is -1, the natural request will be used.

Its value is a 32-bit integer.

Set it with (set! (widget:height-request self) value).

Property: widget:hexpand self

Whether to expand horizontally.

Its value is a boolean.

Set it with (set! (widget:hexpand self) value).

Property: widget:hexpand-set self

Whether to use the hexpand property.

Its value is a boolean.

Set it with (set! (widget:hexpand-set self) value).

Property: widget:layout-manager self

The <GtkLayoutManager> instance to use to compute the preferred size of the widget, and allocate its children.

This property is meant to be set by widget implementations, typically in their instance init function.

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

Set it with (set! (widget:layout-manager self) value).

Property: widget:limit-events self

Makes this widget act like a modal dialog, with respect to event delivery.

Global event controllers will not handle events with targets inside the widget, unless they are set up to ignore propagation limits. See event-controller:set-propagation-limit.

Its value is a boolean.

Set it with (set! (widget:limit-events self) value).

Property: widget:margin-bottom self

Margin on bottom side of widget.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from widget:set-size-request for example.

Its value is a 32-bit integer.

Set it with (set! (widget:margin-bottom self) value).

Property: widget:margin-end self

Margin on end of widget, horizontally.

This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from widget:set-size-request for example.

Its value is a 32-bit integer.

Set it with (set! (widget:margin-end self) value).

Property: widget:margin-start self

Margin on start of widget, horizontally.

This property supports left-to-right and right-to-left text directions.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from widget:set-size-request for example.

Its value is a 32-bit integer.

Set it with (set! (widget:margin-start self) value).

Property: widget:margin-top self

Margin on top side of widget.

This property adds margin outside of the widget’s normal size request, the margin will be added in addition to the size from widget:set-size-request for example.

Its value is a 32-bit integer.

Set it with (set! (widget:margin-top self) value).

Property: widget:name self

The name of the widget.

Its value is a string, or #f.

Set it with (set! (widget:name self) value).

Property: widget:opacity self

The requested opacity of the widget.

Its value is a real number.

Set it with (set! (widget:opacity self) value).

Property: widget:overflow self

How content outside the widget’s content area is treated.

This property is meant to be set by widget implementations, typically in their instance init function.

Its value is a <GtkOverflow> (or, to set it, one of its symbols).

Set it with (set! (widget:overflow self) value).

Property: widget:parent self

The parent widget of this widget.

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

It is read only.

Property: widget:receives-default self

Whether the widget will receive the default action when it is focused.

Its value is a boolean.

Set it with (set! (widget:receives-default self) value).

Property: widget:root self

The <GtkRoot> widget of the widget tree containing this widget.

This will be NULL if the widget is not contained in a root widget.

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

It is read only.

Property: widget:scale-factor self

The scale factor of the widget.

Its value is a 32-bit integer.

It is read only.

Property: widget:sensitive self

Whether the widget responds to input.

Its value is a boolean.

Set it with (set! (widget:sensitive self) value).

Property: widget:tooltip-markup self

Sets the text of tooltip to be the given string, which is marked up with Pango markup.

Also see tooltip:set-markup.

This is a convenience property which will take care of getting the tooltip shown if the given string is not NULL: widget:has-tooltip will automatically be set to true and there will be taken care of widget:query-tooltip in the default signal handler.

Note that if both widget:tooltip-text and widget:tooltip-markup are set, the last one wins.

Its value is a string, or #f.

Set it with (set! (widget:tooltip-markup self) value).

Property: widget:tooltip-text self

Sets the text of tooltip to be the given string.

Also see tooltip:set-text.

This is a convenience property which will take care of getting the tooltip shown if the given string is not NULL: widget:has-tooltip will automatically be set to true and there will be taken care of widget:query-tooltip in the default signal handler.

Note that if both widget:tooltip-text and widget:tooltip-markup are set, the last one wins.

Its value is a string, or #f.

Set it with (set! (widget:tooltip-text self) value).

Property: widget:valign self

How to distribute vertical space if widget gets extra space.

Its value is a <GtkAlign> (or, to set it, one of its symbols).

Set it with (set! (widget:valign self) value).

Property: widget:vexpand self

Whether to expand vertically.

Its value is a boolean.

Set it with (set! (widget:vexpand self) value).

Property: widget:vexpand-set self

Whether to use the vexpand property.

Its value is a boolean.

Set it with (set! (widget:vexpand-set self) value).

Property: widget:visible self

Whether the widget is visible.

Its value is a boolean.

Set it with (set! (widget:visible self) value).

Property: widget:width-request self

Overrides for width request of the widget.

If this is -1, the natural request will be used.

Its value is a 32-bit integer.

Set it with (set! (widget:width-request self) value).

Procedures

Method: widget:action-set-enabled self action-name enabled
Method: action-set-enabled self action-name enabled

Enables or disables an action installed with widget-class:install-action.

self

Passed: a <GtkWidget>.

a widget

action-name

Passed: a string.

action name, such as "clipboard.paste"

enabled

Passed: a boolean.

whether the action is now enabled

Method: widget:activate-action? self name [args] ⇒ %return
Method: activate-action? self name [args] ⇒ %return

Activates an action for the widget.

The action is looked up in the action groups associated with self and its ancestors.

This is a wrapper around Gtk.Widget.activate_action_variant that constructs the args variant according to format-string.

self

Passed: a <GtkWidget>.

a widget

name

Passed: a string.

the name of the action to activate

args

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

%return

Returned: a boolean.

true if the action was activated

format-string

<GVariant> format string for arguments

...

arguments, as given by format string

Method: widget:activate-default self
Method: activate-default self

Activates the default.activate action for the widget.

The action is looked up in the same was as for widget:activate-action?.

self

Passed: a <GtkWidget>.

a widget

Method: widget:activate? self ⇒ %return
Method: activate? self ⇒ %return

Activates the widget.

The activation will emit the signal set using widget-class:set-activate-signal during class initialization.

Activation is what happens when you press Enter on a widget.

If you wish to handle the activation keybinding yourself, it is recommended to use widget-class:add-shortcut with an action created with signal-action:new.

If self is not activatable, the function returns false.

self

Passed: a <GtkWidget>.

a widget that is activatable

%return

Returned: a boolean.

true if the widget was activated

Method: widget:add-controller self controller
Method: add-controller self controller

Adds an event controller to the widget.

The event controllers of a widget handle the events that are propagated to the widget.

You will usually want to call this function right after creating any kind of <GtkEventController>.

self

Passed: a <GtkWidget>.

a widget

controller

Passed: a <GtkEventController>.

an event controller that hasn’t been added to a widget yet

Method: widget:add-css-class self css-class
Method: add-css-class self css-class

Adds a style class to the widget.

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

Use widget:remove-css-class to remove the style again.

self

Passed: a <GtkWidget>.

a widget

css-class

Passed: a string.

style class to add to self, without the leading period

Method: widget:add-mnemonic-label self label
Method: add-mnemonic-label self label

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

See widget:list-mnemonic-labels.

Note that 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.

self

Passed: a <GtkWidget>.

a widget

label

Passed: a <GtkWidget>.

a widget that acts as a mnemonic label for self

Method: widget:add-tick-callback self callback ⇒ %return
Method: add-tick-callback self callback ⇒ %return

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 label), then you will have to call widget:queue-resize or widget:queue-draw yourself.

frame-clock:get-frame-time should generally be used for timing continuous animations and frame-timings:get-predicted-presentation-time should be used if you are trying to display isolated frames at particular times.

This is a more convenient alternative to connecting directly to the frame-clock:update signal of the frame clock, since you don’t have to worry about when a frame clock is assigned to a widget.

To remove a tick callback, pass the ID that is returned by this function to widget:remove-tick-callback.

self

Passed: a <GtkWidget>.

a widget

callback

Passed: a procedure.

function to call for updating animations

See GtkTickCallback for how it is called.

%return

Returned: an unsigned 32-bit integer.

an ID for this callback

user-data

Not passed: guile-gi supplies it.

data to pass to callback

notify

Not passed: guile-gi supplies it.

function to call to free user-data

See GDestroyNotify for how it is called.

Method: widget:allocate self width height baseline [transform]
Method: allocate self width height baseline [transform]

Assigns size, position, (optionally) a baseline and transform to a child widget.

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.

This function is only used by widget implementations.

For a version that does not take a transform, see widget:size-allocate.

self

Passed: a <GtkWidget>.

a widget

width

Passed: a 32-bit integer.

new width

height

Passed: a 32-bit integer.

new height

baseline

Passed: a 32-bit integer.

new baseline, or -1

transform

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

transformation to be applied

Method: widget:child-focus? self direction ⇒ %return
Method: child-focus? self direction ⇒ %return

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 widget:do-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 widget: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 widget:grab-focus? to move the focus to a particular widget.

self

Passed: a <GtkWidget>.

a widget

direction

Passed: a <GtkDirectionType>, or one of its symbols.

direction of focus movement

%return

Returned: a boolean.

true if focus ended up inside self

Method: widget:compute-bounds! self target out-bounds ⇒ %return out-bounds
Method: compute-bounds! self target out-bounds ⇒ %return out-bounds

Computes the bounds for self 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 overview to learn more.

If the operation is successful, true is returned. If self 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 self and target to be the same widget.

self

Passed: a <GtkWidget>.

the widget to query

target

Passed: a <GtkWidget>.

the target widget

out-bounds

Passed, filled in, and returned: a <GrapheneRect>.

the rectangle taking the bounds

%return

Returned: a boolean.

true if the bounds could be computed

Method: widget:compute-expand? self orientation ⇒ %return
Method: compute-expand? self orientation ⇒ %return

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

Widgets with children should check this, rather than looking at widget:get-hexpand? or widget: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.

self

Passed: a <GtkWidget>.

a widget

orientation

Passed: a <GtkOrientation>, or one of its symbols.

expand direction

%return

Returned: a boolean.

whether widget tree rooted here should be expanded

Method: widget:compute-point! self target point out-point ⇒ %return out-point
Method: compute-point! self target point out-point ⇒ %return out-point

Translates the given point in self’s coordinates to coordinates in target’s coordinate system.

In order to perform this operation, both widgets must share a a common ancestor. If that is not the case, out-point is set to (0, 0) and false is returned.

self

Passed: a <GtkWidget>.

the widget to query

target

Passed: a <GtkWidget>.

the widget to transform into

point

Passed: a <GraphenePoint>.

a point in self’s coordinate system

out-point

Passed, filled in, and returned: a <GraphenePoint>.

set to the corresponding coordinates in target’s coordinate system

%return

Returned: a boolean.

true if src-widget and dest-widget have a common ancestor, false otherwise

Method: widget:compute-transform! self target out-transform ⇒ %return out-transform
Method: compute-transform! self target out-transform ⇒ %return out-transform

Computes a matrix suitable to describe a transformation from self’s coordinate system into target’s coordinate system.

The transform can not be computed in certain cases, for example when self 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.

self

Passed: a <GtkWidget>.

a widget

target

Passed: a <GtkWidget>.

the target widget that the matrix will transform to

out-transform

Passed, filled in, and returned: a <GrapheneMatrix>.

location to store the final transformation

%return

Returned: a boolean.

true if the transform could be computed

Method: widget:contains? self x y ⇒ %return
Method: contains? self x y ⇒ %return

Tests if a given point is contained in the widget.

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

self

Passed: a <GtkWidget>.

the widget to query

x

Passed: a real number.

X coordinate to test, relative to self’s origin

y

Passed: a real number.

Y coordinate to test, relative to self’s origin

%return

Returned: a boolean.

true if self contains the point (x, y)

Method: widget:create-pango-context self ⇒ %return
Method: create-pango-context self ⇒ %return

Creates a new <PangoContext> that is configured for the widget.

The <PangoContext> will have the appropriate font map, font options, font description, and base direction set.

See also widget:get-pango-context.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <PangoContext>.

the new <PangoContext>

Method: widget:create-pango-layout self [text] ⇒ %return
Method: create-pango-layout self [text] ⇒ %return

Creates a new <PangoLayout> that is configured for the widget.

The <PangoLayout> will have the appropriate font map, font description, and base direction set.

If you keep a <PangoLayout> created in this way around, you need to re-create it when the widgets <PangoContext> is replaced. This can be tracked by listening to changes of the widget:root property on the widget.

self

Passed: a <GtkWidget>.

a widget

text

Passed, or left out: a string, or #f.

text to set on the layout

%return

Returned: a <PangoLayout>.

the new <PangoLayout>

Method: widget:dispose-template self widget-type
Method: dispose-template self widget-type

Clears the template children for the widget.

This function is the opposite of widget: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 NULL after this function returns.

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

static void
some_widget_dispose (GObject *gobject)
{
  SomeWidget *self = SOME_WIDGET (gobject);

  // Clear the template data for SomeWidget
  gtk_widget_dispose_template (GTK_WIDGET (self), SOME_TYPE_WIDGET);

  G_OBJECT_CLASS (some_widget_parent_class)->dispose (gobject);
}
self

Passed: a <GtkWidget>.

the widget with a template

widget-type

Passed: a class, or a GType number.

the type of the widget to finalize the template for

Method: widget:drag-check-threshold? self start-x start-y current-x current-y ⇒ %return
Method: drag-check-threshold? self start-x start-y current-x current-y ⇒ %return

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

self

Passed: a <GtkWidget>.

a widget

start-x

Passed: a 32-bit integer.

X coordinate of start of drag

start-y

Passed: a 32-bit integer.

Y coordinate of start of drag

current-x

Passed: a 32-bit integer.

current X coordinate

current-y

Passed: a 32-bit integer.

current Y coordinate

%return

Returned: a boolean.

true if the drag threshold has been passed

Method: widget:error-bell self
Method: error-bell self

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

If the settings:gtk-error-bell setting is true, it calls surface:beep, otherwise it does nothing.

Note that the effect of surface:beep can be configured in many ways, depending on the windowing backend and the desktop environment or window manager that is used.

self

Passed: a <GtkWidget>.

a widget

Method: widget:get-allocated-baseline self ⇒ %return
Method: get-allocated-baseline self ⇒ %return

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

This function is intended to be used when implementing handlers for the <GtkWidget>Class.snapshot() function, and when allocating child widgets in <GtkWidget>Class.size_allocate().

self

Passed: a <GtkWidget>.

the widget to query

%return

Returned: a 32-bit integer.

the baseline of the self, or -1 if none

Method: widget:get-allocated-height self ⇒ %return
Method: get-allocated-height self ⇒ %return

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

To learn more about widget sizes, see the coordinate system overview.

self

Passed: a <GtkWidget>.

the widget to query

%return

Returned: a 32-bit integer.

the height of the self

Method: widget:get-allocated-width self ⇒ %return
Method: get-allocated-width self ⇒ %return

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

To learn more about widget sizes, see the coordinate system overview.

self

Passed: a <GtkWidget>.

the widget to query

%return

Returned: a 32-bit integer.

the width of the self

Method: widget:get-allocation! self allocation ⇒ allocation
Method: get-allocation! self allocation ⇒ allocation

Retrieves the widget’s allocation.

Note, when implementing a layout widget: a widget’s allocation will be its “adjusted” allocation, that is, the widget’s parent typically calls widget:size-allocate with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget. 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 widget:size-allocate allocation, however.

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

self

Passed: a <GtkWidget>.

a widget

allocation

Passed, filled in, and returned: a <GdkRectangle>.

a pointer to a GtkAllocation to copy to

Method: widget:get-ancestor self widget-type ⇒ %return
Method: get-ancestor self widget-type ⇒ %return

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

For example, gtk_widget_get_ancestor (widget, GTK_TYPE_BOX) gets the first <GtkBox> that’s an ancestor of self. No reference will be added to the returned widget; it should not be unreferenced.

Note that unlike widget:is-ancestor?, this function considers self to be an ancestor of itself.

self

Passed: a <GtkWidget>.

a widget

widget-type

Passed: a class, or a GType number.

ancestor type

%return

Returned: a <GtkWidget>, or #f.

the ancestor widget

Method: widget:get-baseline self ⇒ %return
Method: get-baseline self ⇒ %return

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

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

self

Passed: a <GtkWidget>.

the widget to query

%return

Returned: a 32-bit integer.

the baseline of the self, or -1 if none

Method: widget:get-can-focus? self ⇒ %return
Method: get-can-focus? self ⇒ %return

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

See widget:set-can-focus.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the input focus can enter self

Method: widget:get-can-target? self ⇒ %return
Method: get-can-target? self ⇒ %return

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if self can receive pointer events

Method: widget:get-child-visible? self ⇒ %return
Method: get-child-visible? self ⇒ %return

Gets the value set with widget:set-child-visible.

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

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget is mapped with the parent

Method: widget:get-clipboard self ⇒ %return
Method: get-clipboard self ⇒ %return

Gets the clipboard object for the widget.

This is a utility function to get the clipboard object for the display that self is using.

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GdkClipboard>.

the appropriate clipboard object

Method: widget:get-color! self color ⇒ color
Method: get-color! self color ⇒ color

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

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

self

Passed: a <GtkWidget>.

a widget

color

Passed, filled in, and returned: a <GdkRGBA>.

return location for the color

Method: widget:get-css-classes self ⇒ %return
Method: get-css-classes self ⇒ %return

Returns the list of style classes applied to the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a vector, each a string.

a NULL-terminated list of css classes currently applied to self

Method: widget:get-css-name self ⇒ %return
Method: get-css-name self ⇒ %return

Returns the CSS name of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a string.

the CSS name

Method: widget:get-cursor self ⇒ %return
Method: get-cursor self ⇒ %return

Gets the cursor set on the widget.

See widget:set-cursor for details.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GdkCursor>, or #f.

the cursor that is set on self

Procedure: widget:get-default-direction ⇒ %return

Obtains the default reading direction.

See widget:set-default-direction.

%return

Returned: a <GtkTextDirection>.

the current default direction

Method: widget:get-direction self ⇒ %return
Method: get-direction self ⇒ %return

Gets the reading direction for the widget.

See widget:set-direction.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkTextDirection>.

the reading direction for the widget

Method: widget:get-display self ⇒ %return
Method: get-display self ⇒ %return

Get the display for the window that the widget belongs to.

This function can only be called after the widget has been added to a widget hierarchy with a <GtkRoot> 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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GdkDisplay>.

the display for this widget

Method: widget:get-first-child self ⇒ %return
Method: get-first-child self ⇒ %return

Returns the widget’s first child.

This function is primarily meant for widget implementations.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkWidget>, or #f.

the widget’s first child

Method: widget:get-focus-child self ⇒ %return
Method: get-focus-child self ⇒ %return

Returns the focus child of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkWidget>, or #f.

the current focus child of self

Method: widget:get-focus-on-click? self ⇒ %return
Method: get-focus-on-click? self ⇒ %return

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

See widget:set-focus-on-click.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget should grab focus when it is clicked with the mouse

Method: widget:get-focusable? self ⇒ %return
Method: get-focusable? self ⇒ %return

Determines whether the widget can own the input focus.

See widget:set-focusable.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if self can own the input focus

Method: widget:get-font-map self ⇒ %return
Method: get-font-map self ⇒ %return

Gets the font map of the widget.

See widget:set-font-map.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <PangoFontMap>, or #f.

the font map of self

Method: widget:get-font-options self ⇒ %return
Method: get-font-options self ⇒ %return

Returns the <CairoFontOptions> of the widget.

Seee widget:set-font-options.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <CairoFontOptions>, or #f.

the <CairoFontOptions> of widget

Method: widget:get-frame-clock self ⇒ %return
Method: get-frame-clock self ⇒ %return

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 frame-clock:get-frame-time, 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 frame-clock:get-frame-time, and then update the animation by calling frame-clock:get-frame-time again during each repaint.

frame-clock:request-phase will result in a new frame on the clock, but won’t necessarily repaint any widgets. To repaint a widget, you have to use widget:queue-draw which invalidates the widget (thus scheduling it to receive a draw on the next frame). widget: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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GdkFrameClock>, or #f.

the frame clock

Method: widget:get-halign self ⇒ %return
Method: get-halign self ⇒ %return

Gets the horizontal alignment of the 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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkAlign>.

the horizontal alignment of self

Method: widget:get-has-tooltip? self ⇒ %return
Method: get-has-tooltip? self ⇒ %return

Returns the current value of the has-tooltip property.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

current value of has-tooltip on self

Method: widget:get-height self ⇒ %return
Method: get-height self ⇒ %return

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 widget:do-snapshot.

For pointer events, see widget:contains?.

To learn more about widget sizes, see the coordinate system overview.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a 32-bit integer.

The height of self

Method: widget:get-hexpand-set? self ⇒ %return
Method: get-hexpand-set? self ⇒ %return

Gets whether the hexpand flag has been explicitly set.

If widget: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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

whether hexpand has been explicitly set

Method: widget:get-hexpand? self ⇒ %return
Method: get-hexpand? self ⇒ %return

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

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

Widgets with children should use widget:compute-expand? rather than this function, to see whether 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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

whether hexpand flag is set

Method: widget:get-last-child self ⇒ %return
Method: get-last-child self ⇒ %return

Returns the widget’s last child.

This function is primarily meant for widget implementations.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkWidget>, or #f.

the widget’s last child

Method: widget:get-layout-manager self ⇒ %return
Method: get-layout-manager self ⇒ %return

Retrieves the layout manager of the widget.

See widget:set-layout-manager.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkLayoutManager>, or #f.

the layout manager of self

Method: widget:get-limit-events? self ⇒ %return
Method: get-limit-events? self ⇒ %return

Gets the value of the widget:limit-events property.

self

Passed: a <GtkWidget>.

a <GtkWidget>

%return

Returned: a boolean.

Method: widget:get-mapped? self ⇒ %return
Method: get-mapped? self ⇒ %return

Returns whether the widget is mapped.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget is mapped

Method: widget:get-margin-bottom self ⇒ %return
Method: get-margin-bottom self ⇒ %return

Gets the bottom margin of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a 32-bit integer.

The bottom margin of self

Method: widget:get-margin-end self ⇒ %return
Method: get-margin-end self ⇒ %return

Gets the end margin of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a 32-bit integer.

The end margin of self

Method: widget:get-margin-start self ⇒ %return
Method: get-margin-start self ⇒ %return

Gets the start margin of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a 32-bit integer.

The start margin of self

Method: widget:get-margin-top self ⇒ %return
Method: get-margin-top self ⇒ %return

Gets the top margin of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a 32-bit integer.

The top margin of self

Method: widget:get-name self ⇒ %return
Method: get-name self ⇒ %return

Retrieves the name of a widget.

See widget:set-name for the significance of widget names.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a string.

name of the widget

Method: widget:get-native self ⇒ %return
Method: get-native self ⇒ %return

Returns the nearest <GtkNative> ancestor of the widget.

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

<GtkNative> widgets will return themselves here.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkNative>, or #f.

the <GtkNative> ancestor of self

Method: widget:get-next-sibling self ⇒ %return
Method: get-next-sibling self ⇒ %return

Returns the widget’s next sibling.

This function is primarily meant for widget implementations.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkWidget>, or #f.

the widget’s next sibling

Method: widget:get-opacity self ⇒ %return
Method: get-opacity self ⇒ %return

Fetches the requested opacity for the widget.

See widget:set-opacity.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a real number.

the requested opacity for this widget

Method: widget:get-overflow self ⇒ %return
Method: get-overflow self ⇒ %return

Returns the widget’s overflow value.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkOverflow>.

The widget’s overflow value

Method: widget:get-pango-context self ⇒ %return
Method: get-pango-context self ⇒ %return

Gets a <PangoContext> that is configured for the widget.

The <PangoContext> will have the appropriate font map, font description, and base direction set.

Unlike the context returned by widget: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 widget:root property on the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <PangoContext>.

the <PangoContext> for the widget

Method: widget:get-parent self ⇒ %return
Method: get-parent self ⇒ %return

Returns the parent widget of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkWidget>, or #f.

the parent widget of self

Method: widget:get-preferred-size! self minimum-size natural-size ⇒ minimum-size natural-size
Method: get-preferred-size! self minimum-size natural-size ⇒ minimum-size natural-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 <GtkFixed>.

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 widget:measure if you want to support baseline alignment.

self

Passed: a <GtkWidget>.

a <GtkWidget> instance

minimum-size

Passed, filled in, and returned: a <GtkRequisition>.

location for storing the minimum size

natural-size

Passed, filled in, and returned: a <GtkRequisition>.

location for storing the natural size

Method: widget:get-prev-sibling self ⇒ %return
Method: get-prev-sibling self ⇒ %return

Returns the widget’s previous sibling.

This function is primarily meant for widget implementations.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkWidget>, or #f.

the widget’s previous sibling

Method: widget:get-primary-clipboard self ⇒ %return
Method: get-primary-clipboard self ⇒ %return

Gets the primary clipboard of the widget.

This is a utility function to get the primary clipboard object for the display that self is using.

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GdkClipboard>.

the appropriate clipboard object

Method: widget:get-realized? self ⇒ %return
Method: get-realized? self ⇒ %return

Determines whether the widget is realized.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if self is realized

Method: widget:get-receives-default? self ⇒ %return
Method: get-receives-default? self ⇒ %return

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

See widget:set-receives-default.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if self acts as the default widget when focused

Method: widget:get-request-mode self ⇒ %return
Method: get-request-mode self ⇒ %return

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.

self

Passed: a <GtkWidget>.

a <GtkWidget> instance

%return

Returned: a <GtkSizeRequestMode>.

The <GtkSizeRequestMode> preferred by self.

Method: widget:get-root self ⇒ %return
Method: get-root self ⇒ %return

Returns the <GtkRoot> widget of the widget.

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

<GtkRoot> widgets will return themselves here.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkRoot>, or #f.

the root widget of self

Method: widget:get-scale-factor self ⇒ %return
Method: get-scale-factor self ⇒ %return

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 surface:get-scale-factor.

Note that modern systems may support fractional scaling, where the scale factor is not an integer. On such systems, this function will return the next higher integer value, but you probably want to use surface:get-scale to get the fractional scale value.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a 32-bit integer.

the scale factor for self

Method: widget:get-sensitive? self ⇒ %return
Method: get-sensitive? self ⇒ %return

Returns the widget’s sensitivity.

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

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget is sensitive

Method: widget:get-settings self ⇒ %return
Method: get-settings self ⇒ %return

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

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkSettings>.

the relevant settings object

Method: widget:get-size self orientation ⇒ %return
Method: get-size self orientation ⇒ %return

Returns the content width or height of the widget.

Which dimension is returned depends on orientation.

This is equivalent to calling widget:get-width for Gtk.Orientation.horizontal or widget:get-height for Gtk.Orientation.vertical, but can be used when writing orientation-independent code, such as when implementing <GtkOrientable> widgets.

To learn more about widget sizes, see the coordinate system overview.

self

Passed: a <GtkWidget>.

a widget

orientation

Passed: a <GtkOrientation>, or one of its symbols.

the orientation to query

%return

Returned: a 32-bit integer.

the size of self in orientation

Method: widget:get-size-request self ⇒ width height
Method: get-size-request self ⇒ width height

Gets the size request that was explicitly set for the widget.

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 widget:set-size-request.

To get the size a widget will actually request, call widget:measure instead of this function.

self

Passed: a <GtkWidget>.

a widget

width

Returned: a 32-bit integer.

return location for width

height

Returned: a 32-bit integer.

return location for height

Method: widget:get-state-flags self ⇒ %return
Method: get-state-flags self ⇒ %return

Returns the widget state as a flag set.

It is worth mentioning that the effective Gtk.StateFlags.insensitive state will be returned, that is, also based on parent insensitivity, even if self itself is sensitive.

Also note that if you are looking for a way to obtain the <GtkStateFlags> to pass to a <GtkStyleContext> method, you should look at Gtk.StyleContext.get_state.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkStateFlags>.

the state flags of widget

Method: widget:get-style-context self ⇒ %return
Method: get-style-context self ⇒ %return

Returns the style context associated to the widget.

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkStyleContext>.

the widgets style context

Method: widget:get-template-child self widget-type name ⇒ %return
Method: get-template-child self widget-type name ⇒ %return

Fetches an object build from the template XML for widget-type in the widget.

This will only report children which were previously declared with widget-class:bind-template-child-full 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.

self

Passed: a <GtkWidget>.

a widget

widget-type

Passed: a class, or a GType number.

The type of the widget class that defines the child in the template

name

Passed: a string.

ID of the child defined in the template XML

%return

Returned: a <GObject>.

the object built in the template XML with the id name

Method: widget:get-tooltip-markup self ⇒ %return
Method: get-tooltip-markup self ⇒ %return

Gets the contents of the tooltip for the widget.

If the tooltip has not been set using widget:set-tooltip-markup, this function returns NULL.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a string, or #f.

the tooltip text

Method: widget:get-tooltip-text self ⇒ %return
Method: get-tooltip-text self ⇒ %return

Gets the contents of the tooltip for the widget.

If the self’s tooltip was set using widget:set-tooltip-markup, this function will return the escaped text.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a string, or #f.

the tooltip text

Method: widget:get-valign self ⇒ %return
Method: get-valign self ⇒ %return

Gets the vertical alignment of the widget.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GtkAlign>.

the vertical alignment of self

Method: widget:get-vexpand-set? self ⇒ %return
Method: get-vexpand-set? self ⇒ %return

Gets whether the vexpand flag has been explicitly set.

See widget:get-hexpand-set? for more detail.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

whether vexpand has been explicitly set

Method: widget:get-vexpand? self ⇒ %return
Method: get-vexpand? self ⇒ %return

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

See widget:get-hexpand? for more detail.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

whether vexpand flag is set

Method: widget:get-visible? self ⇒ %return
Method: get-visible? self ⇒ %return

Determines whether the widget is visible.

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

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

See widget:set-visible.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget is visible

Method: widget:get-width self ⇒ %return
Method: get-width self ⇒ %return

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 widget:do-snapshot.

For pointer events, see widget:contains?.

To learn more about widget sizes, see the coordinate system overview.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a 32-bit integer.

The width of self

Method: widget:grab-focus? self ⇒ %return
Method: grab-focus? self ⇒ %return

Causes self to have the keyboard focus for the window that it belongs to.

If self is not focusable, or its widget:do-grab-focus implementation cannot transfer the focus to a descendant of self that is focusable, it will not take focus and false will be returned.

Calling widget:grab-focus? on an already focused widget is allowed, should not have an effect, and return true.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if focus is now inside self

Method: widget:has-css-class? self css-class ⇒ %return
Method: has-css-class? self css-class ⇒ %return

Returns whether a style class is currently applied to the widget.

self

Passed: a <GtkWidget>.

a widget

css-class

Passed: a string.

style class, without the leading period

%return

Returned: a boolean.

true if css-class is currently applied to self

Method: widget:has-default? self ⇒ %return
Method: has-default? self ⇒ %return

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if self is the current default widget within its toplevel

Method: widget:has-focus? self ⇒ %return
Method: has-focus? self ⇒ %return

Determines if the widget has the global input focus.

See widget:is-focus? for the difference between having the global input focus, and only having the focus within a toplevel.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget has the global input focus

Method: widget:has-visible-focus? self ⇒ %return
Method: has-visible-focus? self ⇒ %return

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 self. See window:get-focus-visible? for more information about focus indication.

To find out if the widget has the global input focus, use widget:has-focus?.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget should display a “focus rectangle”

Method: widget:hide self
Method: hide self

Reverses the effects of [method.Gtk.Widget.show].

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

self

Passed: a <GtkWidget>.

a widget

Method: widget:in-destruction? self ⇒ %return
Method: in-destruction? self ⇒ %return

Returns whether the widget is currently being destroyed.

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if self is being destroyed

Method: widget:init-template self
Method: init-template self

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 widget-class:set-template.

It is important to call this function in the instance initializer of a widget subclass and not in GObject.constructed() or GObject.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.

self

Passed: a <GtkWidget>.

a widget

Method: widget:insert-action-group self name [group]
Method: insert-action-group self name [group]

Inserts an action group into the widget’s actions.

Children of self that implement <GtkActionable> 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 NULL, a previously inserted group for name is removed from self.

self

Passed: a <GtkWidget>.

a widget

name

Passed: a string.

the prefix for actions in group

group

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

an action group

Method: widget:insert-after self parent [previous-sibling]
Method: insert-after self parent [previous-sibling]

Sets the parent widget of the widget.

In contrast to widget:set-parent, this function inserts self at a specific position into the list of children of the parent widget.

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

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

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

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

self

Passed: a <GtkWidget>.

a widget

parent

Passed: a <GtkWidget>.

the parent widget to insert self into

previous-sibling

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

the new previous sibling of self

Method: widget:insert-before self parent [next-sibling]
Method: insert-before self parent [next-sibling]

Sets the parent widget of the widget.

In contrast to widget:set-parent, this function inserts self at a specific position into the list of children of the parent widget.

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

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

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

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

self

Passed: a <GtkWidget>.

a widget

parent

Passed: a <GtkWidget>.

the parent widget to insert self into

next-sibling

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

the new next sibling of self

Method: widget:is-ancestor? self ancestor ⇒ %return
Method: is-ancestor? self ancestor ⇒ %return

Determines whether the widget is a descendent of ancestor.

self

Passed: a <GtkWidget>.

a widget

ancestor

Passed: a <GtkWidget>.

another <GtkWidget>

%return

Returned: a boolean.

true if ancestor contains self as a child, grandchild, great grandchild, etc

Method: widget:is-drawable? self ⇒ %return
Method: is-drawable? self ⇒ %return

Determines whether the widget can be drawn to.

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if self is drawable

Method: widget:is-focus? self ⇒ %return
Method: is-focus? self ⇒ %return

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

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget is the focus widget

Method: widget:is-sensitive? self ⇒ %return
Method: is-sensitive? self ⇒ %return

Returns the widget’s effective sensitivity.

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

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget is effectively sensitive

Method: widget:is-visible? self ⇒ %return
Method: is-visible? self ⇒ %return

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 widget:get-visible? and widget:set-visible.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if the widget and all its parents are visible

Method: widget:keynav-failed? self direction ⇒ %return
Method: keynav-failed? self direction ⇒ %return

Emits the widget: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 widget: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 widget:child-focus? on the widget’s toplevel.

The default widget:keynav-failed handler returns false for Gtk.DirectionType.tab-forward and Gtk.DirectionType.tab-backward. For the other values of <GtkDirectionType> it returns true.

Whenever the default handler returns true, it also calls widget: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 <GtkEntry> 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.

self

Passed: a <GtkWidget>.

a widget

direction

Passed: a <GtkDirectionType>, or one of its symbols.

direction of focus movement

%return

Returned: a boolean.

true if stopping keyboard navigation is fine, false if the emitting widget should try to handle the keyboard navigation attempt in its parent widget

Method: widget:list-mnemonic-labels self ⇒ %return
Method: list-mnemonic-labels self ⇒ %return

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

Typically, these widgets will be labels. See, for example, label:set-mnemonic-widget.

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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a list, each a <GtkWidget>.

the list of mnemonic labels

Method: widget:map self
Method: map self

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

This function is only for use in widget implementations.

self

Passed: a <GtkWidget>.

a widget

Method: widget:measure self orientation for-size ⇒ minimum natural minimum-baseline natural-baseline
Method: measure self orientation for-size ⇒ minimum natural minimum-baseline natural-baseline

Measures self in the orientation orientation and for the given for-size.

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

See GtkWidget’s geometry management section for a more details on implementing GtkWidgetClass.measure().

self

Passed: a <GtkWidget>.

A <GtkWidget> instance

orientation

Passed: a <GtkOrientation>, or one of its symbols.

the orientation to measure

for-size

Passed: a 32-bit integer.

Size for the opposite of orientation, i.e. if orientation is horizontal, this is the height the widget should be measured with. The 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

Returned: a 32-bit integer.

location to store the minimum size

natural

Returned: a 32-bit integer.

location to store the natural size

minimum-baseline

Returned: a 32-bit integer.

location to store the baseline position for the minimum size, or -1 to report no baseline

natural-baseline

Returned: a 32-bit integer.

location to store the baseline position for the natural size, or -1 to report no baseline

Method: widget:mnemonic-activate? self group-cycling ⇒ %return
Method: mnemonic-activate? self group-cycling ⇒ %return

Emits the widget:mnemonic-activate signal.

self

Passed: a <GtkWidget>.

a widget

group-cycling

Passed: a boolean.

true if there are other widgets with the same mnemonic

%return

Returned: a boolean.

true if the signal has been handled

Method: widget:observe-children self ⇒ %return
Method: observe-children self ⇒ %return

Returns a list model to track the children of the 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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GListModel>.

a list model tracking self’s children

Method: widget:observe-controllers self ⇒ %return
Method: observe-controllers self ⇒ %return

Returns a list model to track the event controllers of the 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.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a <GListModel>.

a list model tracking self’s controllers

Method: widget:pick self x y flags ⇒ %return
Method: pick self x y flags ⇒ %return

Finds the descendant of the widget closest to a point.

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

Usually widgets will return NULL if the given coordinate is not contained in self checked via widget:contains?. Otherwise they will recursively try to find a child that does not return NULL. 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.

self

Passed: a <GtkWidget>.

the widget to query

x

Passed: a real number.

x coordinate to test, relative to self’s origin

y

Passed: a real number.

y coordinate to test, relative to self’s origin

flags

Passed: a <GtkPickFlags>, or a list of its symbols, or one of them.

flags to influence what is picked

%return

Returned: a <GtkWidget>, or #f.

the widget’s descendant at (x, y)

Method: widget:queue-allocate self
Method: queue-allocate self

Flags the widget for a rerun of the widget:do-size-allocate function.

Use this function instead of widget:queue-resize when the self’s size request didn’t change but it wants to reposition its contents.

An example user of this function is widget:set-halign.

This function is only for use in widget implementations.

self

Passed: a <GtkWidget>.

a widget

Method: widget:queue-draw self
Method: queue-draw self

Schedules this widget to be redrawn.

The redraw will happen in the paint phase of the current or the next frame.

This means self’s widget:do-snapshot implementation will be called.

self

Passed: a <GtkWidget>.

a widget

Method: widget:queue-resize self
Method: queue-resize self

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 <GtkLabel>, the label queues a resize to ensure there’s enough space for the new text.

Note that you cannot call widget:queue-resize on a widget from inside its implementation of the widget:do-size-allocate virtual method. Calls to widget:queue-resize from inside widget:do-size-allocate will be silently ignored.

This function is only for use in widget implementations.

self

Passed: a <GtkWidget>.

a widget

Method: widget:realize self
Method: realize self

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 self 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 widget:realize.

self

Passed: a <GtkWidget>.

a widget

Method: widget:remove-controller self controller
Method: remove-controller self controller

Removes an event controller from the widget.

The removed event controller will not receive any more events, and 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.

self

Passed: a <GtkWidget>.

a widget

controller

Passed: a <GtkEventController>.

an event controller

Method: widget:remove-css-class self css-class
Method: remove-css-class self css-class

Removes a style from the widget.

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

self

Passed: a <GtkWidget>.

a widget

css-class

Passed: a string.

style class to remove from self, without the leading period

Method: widget:remove-mnemonic-label self label
Method: remove-mnemonic-label self label

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

See widget:list-mnemonic-labels.

The widget must have previously been added to the list with widget:add-mnemonic-label.

self

Passed: a <GtkWidget>.

a widget

label

Passed: a <GtkWidget>.

a widget that is a mnemonic label for self

Method: widget:remove-tick-callback self id
Method: remove-tick-callback self id

Removes a tick callback previously registered with widget:add-tick-callback.

self

Passed: a <GtkWidget>.

a widget

id

Passed: an unsigned 32-bit integer.

an ID returned by widget:add-tick-callback

Method: widget:set-can-focus self can-focus
Method: set-can-focus self can-focus

Sets 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 widget:grab-focus? for actually setting the input focus on a widget.

self

Passed: a <GtkWidget>.

a widget

can-focus

Passed: a boolean.

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

Method: widget:set-can-target self can-target
Method: set-can-target self can-target

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

self

Passed: a <GtkWidget>.

a widget

can-target

Passed: a boolean.

whether this widget should be able to receive pointer events

Method: widget:set-child-visible self child-visible
Method: set-child-visible self child-visible

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

The child visibility can be set for widget before it is added to a container with widget: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 widget implementations and should never be called by an application.

self

Passed: a <GtkWidget>.

a widget

child-visible

Passed: a boolean.

whether self should be mapped along with its parent

Method: widget:set-css-classes self classes
Method: set-css-classes self classes

Replaces the current style classes of the widget with classes.

self

Passed: a <GtkWidget>.

a widget

classes

Passed: a list or vector, each a string.

NULL-terminated list of style classes

Method: widget:set-cursor self [cursor]
Method: set-cursor self [cursor]

Sets the cursor to be shown when the pointer hovers over the widget.

If the cursor is NULL, self will use the cursor inherited from its parent.

self

Passed: a <GtkWidget>.

a widget

cursor

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

the new cursor

Method: widget:set-cursor-from-name self [name]
Method: set-cursor-from-name self [name]

Sets the cursor to be shown when the pointer hovers over the widget.

This is a utility function that creates a cursor via cursor:new-from-name and then sets it on self with widget:set-cursor. See those functions for details.

On top of that, this function allows name to be NULL, which will do the same as calling widget:set-cursor with a NULL cursor.

self

Passed: a <GtkWidget>.

a widget

name

Passed, or left out: a string, or #f.

the name of the cursor

Procedure: widget:set-default-direction dir

Sets the default reading direction for widgets.

See widget:set-direction.

dir

Passed: a <GtkTextDirection>, or one of its symbols.

the new default direction, either Gtk.TextDirection.ltr or Gtk.TextDirection.rtl

Method: widget:set-direction self dir
Method: set-direction self dir

Sets the reading direction on the 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 prevail, except for widgets where the children 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.TextDirection.none, then the value set by widget:set-default-direction will be used.

self

Passed: a <GtkWidget>.

a widget

dir

Passed: a <GtkTextDirection>, or one of its symbols.

the new direction

Method: widget:set-focus-child self [child]
Method: set-focus-child self [child]

Set the focus child of the widget.

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

self

Passed: a <GtkWidget>.

a widget

child

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

a direct child widget of self or NULL to unset the focus child

Method: widget:set-focus-on-click self focus-on-click
Method: set-focus-on-click self 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.

self

Passed: a <GtkWidget>.

a widget

focus-on-click

Passed: a boolean.

whether the widget should grab focus when clicked with the mouse

Method: widget:set-focusable self focusable
Method: set-focusable self focusable

Sets whether the 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 widget:grab-focus? for actually setting the input focus on a widget.

self

Passed: a <GtkWidget>.

a widget

focusable

Passed: a boolean.

whether or not self can own the input focus

Method: widget:set-font-map self [font-map]
Method: set-font-map self [font-map]

Sets the font map to use for text rendering in the widget.

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.

self

Passed: a <GtkWidget>.

a widget

font-map

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

a <PangoFontMap>

Method: widget:set-font-options self [options]
Method: set-font-options self [options]

Sets the <CairoFontOptions> used for text rendering in the widget.

When not set, the default font options for the <GdkDisplay> will be used.

self

Passed: a <GtkWidget>.

a widget

options

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

a <CairoFontOptions> struct to unset any previously set default font options

Method: widget:set-halign self align
Method: set-halign self align

Sets the horizontal alignment of the widget.

self

Passed: a <GtkWidget>.

a widget

align

Passed: a <GtkAlign>, or one of its symbols.

the horizontal alignment

Method: widget:set-has-tooltip self has-tooltip
Method: set-has-tooltip self has-tooltip

Sets the has-tooltip property on the widget.

self

Passed: a <GtkWidget>.

a widget

has-tooltip

Passed: a boolean.

whether or not self has a tooltip

Method: widget:set-hexpand self expand
Method: set-hexpand self expand

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

When a user resizes a window, widgets with expand set to 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 widget:compute-expand?. A widget can decide how the expandability of children affects its own expansion by overriding the compute_expand virtual method on <GtkWidget>.).

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 widget:set-hexpand sets the hexpand-set property (see widget:set-hexpand-set) which causes the widget’s hexpand value to be used, rather than looking at children and widget state.

self

Passed: a <GtkWidget>.

a widget

expand

Passed: a boolean.

whether to expand

Method: widget:set-hexpand-set self set
Method: set-hexpand-set self set

Sets whether the hexpand flag will be used.

The widget:hexpand-set property will be set automatically when you call widget: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.

self

Passed: a <GtkWidget>.

a widget

set

Passed: a boolean.

value for hexpand-set property

Method: widget:set-layout-manager self [layout-manager]
Method: set-layout-manager self [layout-manager]

Sets the layout manager to use for measuring and allocating children of the widget.

self

Passed: a <GtkWidget>.

a widget

layout-manager

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

a layout manager

Method: widget:set-limit-events self limit-events
Method: set-limit-events self limit-events

Sets whether the widget acts like a modal dialog, with respect to event delivery.

self

Passed: a <GtkWidget>.

a <GtkWidget>

limit-events

Passed: a boolean.

whether to limit events

Method: widget:set-margin-bottom self margin
Method: set-margin-bottom self margin

Sets the bottom margin of the widget.

self

Passed: a <GtkWidget>.

a widget

margin

Passed: a 32-bit integer.

the bottom margin

Method: widget:set-margin-end self margin
Method: set-margin-end self margin

Sets the end margin of the widget.

self

Passed: a <GtkWidget>.

a widget

margin

Passed: a 32-bit integer.

the end margin

Method: widget:set-margin-start self margin
Method: set-margin-start self margin

Sets the start margin of the widget.

self

Passed: a <GtkWidget>.

a widget

margin

Passed: a 32-bit integer.

the start margin

Method: widget:set-margin-top self margin
Method: set-margin-top self margin

Sets the top margin of the widget.

self

Passed: a <GtkWidget>.

a widget

margin

Passed: a 32-bit integer.

the top margin

Method: widget:set-name self name
Method: set-name self 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 <GtkStyleContext>.

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.

self

Passed: a <GtkWidget>.

a widget

name

Passed: a string.

name for the widget

Method: widget:set-opacity self opacity
Method: set-opacity self opacity

Requests 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 display:is-composited?. On Windows and Wayland it will 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, <GtkPopover> instances and other <GtkNative> 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.

self

Passed: a <GtkWidget>.

a widget

opacity

Passed: a real number.

desired opacity, between 0 and 1

Method: widget:set-overflow self overflow
Method: set-overflow self overflow

Sets how the widget treats content that is drawn outside the it’s content area.

See the definition of <GtkOverflow> for details.

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

The default value is Gtk.Overflow.visible.

self

Passed: a <GtkWidget>.

a widget

overflow

Passed: a <GtkOverflow>, or one of its symbols.

desired overflow value

Method: widget:set-parent self parent
Method: set-parent self parent

Sets the parent widget of the 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 widget:unparent.

This function is useful only when implementing subclasses of <GtkWidget>.

self

Passed: a <GtkWidget>.

a widget

parent

Passed: a <GtkWidget>.

parent widget

Method: widget:set-receives-default self receives-default
Method: set-receives-default self receives-default

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

self

Passed: a <GtkWidget>.

a widget

receives-default

Passed: a boolean.

whether or not self can be a default widget

Method: widget:set-sensitive self sensitive
Method: set-sensitive self sensitive

Sets the sensitivity of the 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.

self

Passed: a <GtkWidget>.

a widget

sensitive

Passed: a boolean.

true to make the widget sensitive

Method: widget:set-size-request self width height
Method: set-size-request self width height

Sets the minimum size of the 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, window:set-default-size 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 is basically impossible to hardcode a size that will always work.

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 widget:margin-start, widget:margin-end, widget:margin-top, and widget:margin-bottom, but it does include pretty much all other padding or border properties set by any subclass of <GtkWidget>.

self

Passed: a <GtkWidget>.

a widget

width

Passed: a 32-bit integer.

width self should request, or -1 to unset

height

Passed: a 32-bit integer.

height self should request, or -1 to unset

Method: widget:set-state-flags self flags clear
Method: set-state-flags self flags clear

Turns on flag values in the current widget state.

Typical widget states are insensitive, prelighted, etc.

This function accepts the values Gtk.StateFlags.dir-ltr and Gtk.StateFlags.dir-rtl but ignores them. If you want to set the widget’s direction, use widget:set-direction.

This function is for use in widget implementations.

self

Passed: a <GtkWidget>.

a widget

flags

Passed: a <GtkStateFlags>, or a list of its symbols, or one of them.

state flags to turn on

clear

Passed: a boolean.

whether to clear state before turning on flags

Method: widget:set-tooltip-markup self [markup]
Method: set-tooltip-markup self [markup]

Sets the contents of the tooltip for widget.

markup must contain Pango markup.

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

See also tooltip:set-markup.

self

Passed: a <GtkWidget>.

a widget

markup

Passed, or left out: a string, or #f.

the contents of the tooltip for self

Method: widget:set-tooltip-text self [text]
Method: set-tooltip-text self [text]

Sets the contents of the tooltip for the widget.

If text contains any markup, it will be escaped.

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

See also tooltip:set-text.

self

Passed: a <GtkWidget>.

a widget

text

Passed, or left out: a string, or #f.

the contents of the tooltip for self

Method: widget:set-valign self align
Method: set-valign self align

Sets the vertical alignment of the widget.

self

Passed: a <GtkWidget>.

a widget

align

Passed: a <GtkAlign>, or one of its symbols.

the vertical alignment

Method: widget:set-vexpand self expand
Method: set-vexpand self expand

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

See widget:set-hexpand for more detail.

self

Passed: a <GtkWidget>.

a widget

expand

Passed: a boolean.

whether to expand

Method: widget:set-vexpand-set self set
Method: set-vexpand-set self set

Sets whether the vexpand flag will be used.

See widget:set-hexpand-set for more detail.

self

Passed: a <GtkWidget>.

the widget

set

Passed: a boolean.

value for vexpand-set property

Method: widget:set-visible self visible
Method: set-visible self visible

Sets the visibility state of self.

Note that setting this to true doesn’t mean the widget is actually viewable, see widget:get-visible?.

self

Passed: a <GtkWidget>.

a widget

visible

Passed: a boolean.

whether the widget should be shown or not

Method: widget:should-layout? self ⇒ %return
Method: should-layout? self ⇒ %return

Returns whether the 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, such as <GtkPopover> instances.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if child should be included in measuring and allocating

Method: widget:show self
Method: show self

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 widget is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel widget is realized and mapped.

self

Passed: a <GtkWidget>.

a widget

Method: widget:size-allocate self allocation baseline
Method: size-allocate self allocation baseline

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

This is a simple form of widget:allocate.

self

Passed: a <GtkWidget>.

a widget

allocation

Passed: a <GdkRectangle>.

position and size to be allocated to self

baseline

Passed: a 32-bit integer.

the baseline of the child, or -1

Method: widget:snapshot-child self child snapshot
Method: snapshot-child self child snapshot

Snapshots a child of the widget.

When a widget receives a call to the snapshot function, it must send synthetic widget:do-snapshot calls to all children. This function provides a convenient way of doing this. A widget, when it receives a call to its widget:do-snapshot function, calls widget:snapshot-child once for each child, passing in the snapshot the widget received.

This function takes care of translating the origin of snapshot, and deciding whether the child needs to be snapshot.

It does nothing for children that implement <GtkNative>.

self

Passed: a <GtkWidget>.

a widget

child

Passed: a <GtkWidget>.

a child of self

snapshot

Passed: a <GtkSnapshot>.

snapshot as passed to the widget. In particular, no calls to snapshot:translate or other transform calls should have been made

Method: widget:translate-coordinates self dest-widget src-x src-y ⇒ %return dest-x dest-y
Method: translate-coordinates self dest-widget src-x src-y ⇒ %return dest-x dest-y

Translates coordinates relative to self’s allocation to coordinates relative to dest-widget’s allocations.

In order to perform this operation, both widget must share a common ancestor. If that is not the case, dest-x and dest-y are set to 0 and false is returned.

self

Passed: a <GtkWidget>.

a widget

dest-widget

Passed: a <GtkWidget>.

another widget

src-x

Passed: a real number.

X position in widget coordinates of self

src-y

Passed: a real number.

Y position in widget coordinates of self

%return

Returned: a boolean.

true if self and dest-widget have a common ancestor, false otherwise

dest-x

Returned: a real number.

location to store X position in widget coordinates of dest-widget

dest-y

Returned: a real number.

location to store Y position in widget coordinates of dest-widget

Method: widget:trigger-tooltip-query self
Method: trigger-tooltip-query self

Triggers a tooltip query on the display of the widget.

self

Passed: a <GtkWidget>.

a widget

Method: widget:unmap self
Method: unmap self

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

This function is only for use in widget implementations.

self

Passed: a <GtkWidget>.

a widget

Method: widget:unparent self
Method: unparent self

Removes self from its parent.

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

self

Passed: a <GtkWidget>.

a widget

Method: widget:unrealize self
Method: unrealize self

Causes a widget to be unrealized.

This frees all GDK resources associated with the widget.

This function is only useful in widget implementations.

self

Passed: a <GtkWidget>.

a widget

Method: widget:unset-state-flags self flags
Method: unset-state-flags self flags

Turns off flag values for the current widget state.

See widget:set-state-flags.

This function is for use in widget implementations.

self

Passed: a <GtkWidget>.

a widget

flags

Passed: a <GtkStateFlags>, or a list of its symbols, or one of them.

state flags to turn off

Signals

Signal: widget:destroy

Connect a handler with (connect object widget:destroy handler). It is called as (handler self).

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.

self

Passed: a <GtkWidget>.

Signal: widget:direction-changed

Connect a handler with (connect object widget:direction-changed handler). It is called as (handler self previous-direction).

Emitted when the text direction of a widget changes.

self

Passed: a <GtkWidget>.

previous-direction

Passed: a <GtkTextDirection>.

the previous text direction

Signal: widget:hide

Connect a handler with (connect object widget:hide handler). It is called as (handler self).

Emitted when widget is hidden.

self

Passed: a <GtkWidget>.

Signal: widget:keynav-failed

Connect a handler with (connect object widget:keynav-failed handler). It is called as (handler self direction) ⇒ %return.

Emitted if keyboard navigation fails.

See widget:keynav-failed? for details.

self

Passed: a <GtkWidget>.

direction

Passed: a <GtkDirectionType>.

the direction of movement

%return

Returned: a boolean.

true if stopping keyboard navigation is fine, false if the emitting widget should try to handle the keyboard navigation attempt in its parent widget

Signal: widget:map

Connect a handler with (connect object widget:map handler). It is called as (handler self).

Emitted when widget is going to be mapped.

A widget is mapped when the widget is visible (which is controlled with widget: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 widget:unmap.

self

Passed: a <GtkWidget>.

Signal: widget:mnemonic-activate

Connect a handler with (connect object widget:mnemonic-activate handler). It is called as (handler self group-cycling) ⇒ %return.

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.

self

Passed: a <GtkWidget>.

group-cycling

Passed: a boolean.

true if there are other widgets with the same mnemonic

%return

Returned: a boolean.

true to stop other handlers from being invoked for the event, false to propagate the event further

Signal: widget:move-focus

Connect a handler with (connect object widget:move-focus handler). It is called as (handler self direction).

Emitted when the focus is moved.

The ::move-focus signal is a keybinding signal.

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

self

Passed: a <GtkWidget>.

direction

Passed: a <GtkDirectionType>.

the direction of the focus move

Signal: widget:query-tooltip

Connect a handler with (connect object widget:query-tooltip handler). It is called as (handler self x y keyboard-mode tooltip) ⇒ %return.

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

This happens when the widget: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.

self

Passed: a <GtkWidget>.

x

Passed: a 32-bit integer.

the x coordinate of the cursor position in widget coordinates

y

Passed: a 32-bit integer.

the y coordinate of the cursor position in widget coordinates

keyboard-mode

Passed: a boolean.

true if the tooltip was triggered using the keyboard

tooltip

Passed: a <GtkTooltip>.

a <GtkTooltip>

%return

Returned: a boolean.

true if tooltip should be shown right now, false otherwise

Signal: widget:realize

Connect a handler with (connect object widget:realize handler). It is called as (handler self).

Emitted when widget is associated with a <GdkSurface>.

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

self

Passed: a <GtkWidget>.

Signal: widget:show

Connect a handler with (connect object widget:show handler). It is called as (handler self).

Emitted when widget is shown.

self

Passed: a <GtkWidget>.

Signal: widget:state-flags-changed

Connect a handler with (connect object widget:state-flags-changed handler). It is called as (handler self flags).

Emitted when the widget state changes.

See widget:get-state-flags.

self

Passed: a <GtkWidget>.

flags

Passed: a <GtkStateFlags>.

the previous state flags

Signal: widget:unmap

Connect a handler with (connect object widget:unmap handler). It is called as (handler self).

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.

self

Passed: a <GtkWidget>.

Signal: widget:unrealize

Connect a handler with (connect object widget:unrealize handler). It is called as (handler self).

Emitted when the <GdkSurface> associated with widget is destroyed.

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

self

Passed: a <GtkWidget>.

Virtual methods

Virtual method: widget:do-compute-expand implementor self hexpand-p vexpand-p

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

To override it in a new class, give register-type #:vfuncs `((compute-expand . ,procedure)). The procedure is called as (procedure self hexpand-p vexpand-p).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

hexpand-p

Passed: a boolean.

vexpand-p

Passed: a boolean.

Virtual method: widget:do-contains implementor self x y ⇒ %return

Tests if a given point is contained in the widget.

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

To override it in a new class, give register-type #:vfuncs `((contains . ,procedure)). The procedure is called as (procedure self x y) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

the widget to query

x

Passed: a real number.

X coordinate to test, relative to self’s origin

y

Passed: a real number.

Y coordinate to test, relative to self’s origin

%return

Returned: a boolean.

true if self contains the point (x, y)

Virtual method: widget:do-direction-changed implementor self previous-direction

Signal emitted when the text direction of a widget changes.

To override it in a new class, give register-type #:vfuncs `((direction-changed . ,procedure)). The procedure is called as (procedure self previous-direction).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

previous-direction

Passed: a <GtkTextDirection>, or one of its symbols.

Virtual method: widget:do-focus implementor self direction ⇒ %return

Vfunc for widget:child-focus?

To override it in a new class, give register-type #:vfuncs `((focus . ,procedure)). The procedure is called as (procedure self direction) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

direction

Passed: a <GtkDirectionType>, or one of its symbols.

%return

Returned: a boolean.

Virtual method: widget:do-get-request-mode implementor self ⇒ %return

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.

To override it in a new class, give register-type #:vfuncs `((get-request-mode . ,procedure)). The procedure is called as (procedure self) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a <GtkWidget> instance

%return

Returned: a <GtkSizeRequestMode>.

The <GtkSizeRequestMode> preferred by self.

Virtual method: widget:do-grab-focus implementor self ⇒ %return

Causes self to have the keyboard focus for the window that it belongs to.

If self is not focusable, or its widget:do-grab-focus implementation cannot transfer the focus to a descendant of self that is focusable, it will not take focus and false will be returned.

Calling widget:grab-focus? on an already focused widget is allowed, should not have an effect, and return true.

To override it in a new class, give register-type #:vfuncs `((grab-focus . ,procedure)). The procedure is called as (procedure self) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

%return

Returned: a boolean.

true if focus is now inside self

Virtual method: widget:do-hide implementor self

Reverses the effects of [method.Gtk.Widget.show].

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

To override it in a new class, give register-type #:vfuncs `((hide . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

Virtual method: widget:do-keynav-failed implementor self direction ⇒ %return

Emits the widget: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 widget: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 widget:child-focus? on the widget’s toplevel.

The default widget:keynav-failed handler returns false for Gtk.DirectionType.tab-forward and Gtk.DirectionType.tab-backward. For the other values of <GtkDirectionType> it returns true.

Whenever the default handler returns true, it also calls widget: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 <GtkEntry> 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.

To override it in a new class, give register-type #:vfuncs `((keynav-failed . ,procedure)). The procedure is called as (procedure self direction) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

direction

Passed: a <GtkDirectionType>, or one of its symbols.

direction of focus movement

%return

Returned: a boolean.

true if stopping keyboard navigation is fine, false if the emitting widget should try to handle the keyboard navigation attempt in its parent widget

Virtual method: widget:do-map implementor self

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

This function is only for use in widget implementations.

To override it in a new class, give register-type #:vfuncs `((map . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

Virtual method: widget:do-measure implementor self orientation for-size ⇒ minimum natural minimum-baseline natural-baseline

Measures self in the orientation orientation and for the given for-size.

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

See GtkWidget’s geometry management section for a more details on implementing GtkWidgetClass.measure().

To override it in a new class, give register-type #:vfuncs `((measure . ,procedure)). The procedure is called as (procedure self orientation for-size) ⇒ minimum natural minimum-baseline natural-baseline.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

A <GtkWidget> instance

orientation

Passed: a <GtkOrientation>, or one of its symbols.

the orientation to measure

for-size

Passed: a 32-bit integer.

Size for the opposite of orientation, i.e. if orientation is horizontal, this is the height the widget should be measured with. The 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

Returned: a 32-bit integer.

location to store the minimum size

natural

Returned: a 32-bit integer.

location to store the natural size

minimum-baseline

Returned: a 32-bit integer.

location to store the baseline position for the minimum size, or -1 to report no baseline

natural-baseline

Returned: a 32-bit integer.

location to store the baseline position for the natural size, or -1 to report no baseline

Virtual method: widget:do-mnemonic-activate implementor self group-cycling ⇒ %return

Emits the widget:mnemonic-activate signal.

To override it in a new class, give register-type #:vfuncs `((mnemonic-activate . ,procedure)). The procedure is called as (procedure self group-cycling) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

group-cycling

Passed: a boolean.

true if there are other widgets with the same mnemonic

%return

Returned: a boolean.

true if the signal has been handled

Virtual method: widget:do-move-focus implementor self direction

Signal emitted when a change of focus is requested

To override it in a new class, give register-type #:vfuncs `((move-focus . ,procedure)). The procedure is called as (procedure self direction).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

direction

Passed: a <GtkDirectionType>, or one of its symbols.

Virtual method: widget:do-query-tooltip implementor self x y keyboard-tooltip tooltip ⇒ %return

Signal emitted when “has-tooltip” is #t and the hover timeout has expired with the cursor hovering “above” widget; or emitted when widget got focus in keyboard mode.

To override it in a new class, give register-type #:vfuncs `((query-tooltip . ,procedure)). The procedure is called as (procedure self x y keyboard-tooltip tooltip) ⇒ %return.

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

x

Passed: a 32-bit integer.

y

Passed: a 32-bit integer.

keyboard-tooltip

Passed: a boolean.

tooltip

Passed: a <GtkTooltip>.

%return

Returned: a boolean.

Virtual method: widget:do-realize implementor self

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 self 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 widget:realize.

To override it in a new class, give register-type #:vfuncs `((realize . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

Virtual method: widget:do-root implementor self

Called when the widget gets added to a <GtkRoot> widget. Must chain up

To override it in a new class, give register-type #:vfuncs `((root . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

Virtual method: widget:do-set-focus-child implementor self [child]

Set the focus child of the widget.

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

To override it in a new class, give register-type #:vfuncs `((set-focus-child . ,procedure)). The procedure is called as (procedure self child).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

child

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

a direct child widget of self or NULL to unset the focus child

Virtual method: widget:do-show implementor self

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 widget is shown, it is immediately realized and mapped; other shown widgets are realized and mapped when their toplevel widget is realized and mapped.

To override it in a new class, give register-type #:vfuncs `((show . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

Virtual method: widget:do-size-allocate implementor self width height baseline

Called to set the allocation, if the widget does not have a layout manager.

To override it in a new class, give register-type #:vfuncs `((size-allocate . ,procedure)). The procedure is called as (procedure self width height baseline).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

width

Passed: a 32-bit integer.

height

Passed: a 32-bit integer.

baseline

Passed: a 32-bit integer.

Virtual method: widget:do-snapshot implementor self snapshot

Vfunc called when a new snapshot of the widget has to be taken.

To override it in a new class, give register-type #:vfuncs `((snapshot . ,procedure)). The procedure is called as (procedure self snapshot).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

snapshot

Passed: a <GtkSnapshot>.

Virtual method: widget:do-state-flags-changed implementor self previous-state-flags

Signal emitted when the widget state changes, see widget:get-state-flags.

To override it in a new class, give register-type #:vfuncs `((state-flags-changed . ,procedure)). The procedure is called as (procedure self previous-state-flags).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

previous-state-flags

Passed: a <GtkStateFlags>, or a list of its symbols, or one of them.

Virtual method: widget:do-system-setting-changed implementor self settings

Emitted when a system setting was changed. Must chain up.

To override it in a new class, give register-type #:vfuncs `((system-setting-changed . ,procedure)). The procedure is called as (procedure self settings).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

settings

Passed: a <GtkSystemSetting>, or one of its symbols.

Virtual method: widget:do-unmap implementor self

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

This function is only for use in widget implementations.

To override it in a new class, give register-type #:vfuncs `((unmap . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

Virtual method: widget:do-unrealize implementor self

Causes a widget to be unrealized.

This frees all GDK resources associated with the widget.

This function is only useful in widget implementations.

To override it in a new class, give register-type #:vfuncs `((unrealize . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.

a widget

Virtual method: widget:do-unroot implementor self

Called when the widget is about to be removed from its <GtkRoot> widget. Must chain up

To override it in a new class, give register-type #:vfuncs `((unroot . ,procedure)). The procedure is called as (procedure self).

implementor

Passed: the class whose implementation to call: <GtkWidget>, or a class that derives from it, or its GType number.

self

Passed: a <GtkWidget>.