package ocgtk

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Wrappers.Widget

type t = [ `widget | `initially_unowned | `object_ ] Gobject.obj
val unset_state_flags : t -> Gtk_enums.stateflags -> unit

Turns off flag values for the current widget state.

See method@Gtk.Widget.set_state_flags.

This function is for use in widget implementations.

val unrealize : t -> unit

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

This function is only useful in widget implementations.

val unparent : t -> unit

Dissociate @widget from its parent.

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

val unmap : t -> unit

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

This function is only for use in widget implementations.

val trigger_tooltip_query : t -> unit

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

val translate_coordinates : t -> t -> float -> float -> bool * float * float

Translate coordinates relative to @src_widget’s allocation to coordinates relative to @dest_widget’s allocations.

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

val snapshot_child : t -> t -> [ `snapshot | `object_ ] Gobject.obj -> unit

Snapshot the a child of @widget.

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

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

This function does nothing for children that implement `GtkNative`.

val show : t -> unit

Flags a widget to be displayed.

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

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

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

val should_layout : t -> bool

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

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

val set_visible : t -> bool -> unit

Sets the visibility state of @widget.

Note that setting this to %TRUE doesn’t mean the widget is actually viewable, see method@Gtk.Widget.get_visible.

val set_vexpand_set : t -> bool -> unit

Sets whether the vexpand flag will be used.

See method@Gtk.Widget.set_hexpand_set for more detail.

val set_vexpand : t -> bool -> unit

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

See method@Gtk.Widget.set_hexpand for more detail.

val set_valign : t -> Gtk_enums.align -> unit

Sets the vertical alignment of @widget.

val set_tooltip_text : t -> string option -> unit

Sets @text as the contents of the tooltip.

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

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

See also method@Gtk.Tooltip.set_text.

val set_tooltip_markup : t -> string option -> unit

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

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

See also method@Gtk.Tooltip.set_markup.

val set_state_flags : t -> Gtk_enums.stateflags -> bool -> unit

Turns on flag values in the current widget state.

Typical widget states are insensitive, prelighted, etc.

This function accepts the values %GTK_STATE_FLAG_DIR_LTR and %GTK_STATE_FLAG_DIR_RTL but ignores them. If you want to set the widget's direction, use method@Gtk.Widget.set_direction.

This function is for use in widget implementations.

val set_size_request : t -> int -> int -> unit

Sets the minimum size of a widget.

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

In most cases, method@Gtk.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's basically impossible to hardcode a size that will always be correct.

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

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

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

val set_sensitive : t -> bool -> unit

Sets the sensitivity of a widget.

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

val set_receives_default : t -> bool -> unit

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

val set_parent : t -> t -> unit

Sets @parent as the parent widget of @widget.

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

This function is useful only when implementing subclasses of `GtkWidget`.

val set_overflow : t -> Gtk_enums.overflow -> unit

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

See the definition of enum@Gtk.Overflow for details.

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

The default value is %GTK_OVERFLOW_VISIBLE.

val set_opacity : t -> float -> unit

Request the @widget to be rendered partially transparent.

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

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

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

val set_name : t -> string -> unit

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 class@Gtk.StyleContext.

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

val set_margin_top : t -> int -> unit

Sets the top margin of @widget.

val set_margin_start : t -> int -> unit

Sets the start margin of @widget.

val set_margin_end : t -> int -> unit

Sets the end margin of @widget.

val set_margin_bottom : t -> int -> unit

Sets the bottom margin of @widget.

val set_layout_manager : t -> [ `layout_manager | `object_ ] Gobject.obj option -> unit

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

val set_hexpand_set : t -> bool -> unit

Sets whether the hexpand flag will be used.

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

val set_hexpand : t -> bool -> unit

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

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

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

By default, widgets automatically expand if any of their children want to expand. (To see if a widget will automatically expand given its current children and state, call method@Gtk.Widget.compute_expand. A container can decide how the expandability of children affects the expansion of the container by overriding the compute_expand virtual method on `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 method@Gtk.Widget.set_hexpand sets the hexpand-set property (see method@Gtk.Widget.set_hexpand_set) which causes the widget’s hexpand value to be used, rather than looking at children and widget state.

val set_has_tooltip : t -> bool -> unit

Sets the `has-tooltip` property on @widget to @has_tooltip.

val set_halign : t -> Gtk_enums.align -> unit

Sets the horizontal alignment of @widget.

val set_font_options : t -> Ocgtk_cairo.Cairo.Wrappers.Font_options.t option -> unit

Sets the `cairo_font_options_t` used for Pango rendering in this widget.

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

val set_font_map : t -> Ocgtk_pango.Pango.Wrappers.Font_map.t option -> unit

Sets the font map to use for Pango rendering.

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

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

val set_focusable : t -> bool -> unit

Specifies whether @widget can own the input focus.

Widget implementations should set @focusable to %TRUE in their init() function if they want to receive keyboard input.

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

See method@Gtk.Widget.grab_focus for actually setting the input focus on a widget.

val set_focus_on_click : t -> bool -> unit

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.

val set_focus_child : t -> t option -> unit

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

This function is only suitable for widget implementations. If you want a certain widget to get the input focus, call method@Gtk.Widget.grab_focus on it.

val set_direction : t -> Gtk_enums.textdirection -> unit

Sets the reading direction on a particular widget.

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

If the direction is set to %GTK_TEXT_DIR_NONE, then the value set by func@Gtk.Widget.set_default_direction will be used.

val set_cursor_from_name : t -> string option -> unit

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

This is a utility function that creates a cursor via ctor@Gdk.Cursor.new_from_name and then sets it on @widget with method@Gtk.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 method@Gtk.Widget.set_cursor with a %NULL cursor.

val set_cursor : t -> Ocgtk_gdk.Gdk.Wrappers.Cursor.t option -> unit

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

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

val set_css_classes : t -> string array -> unit

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

val set_child_visible : t -> bool -> unit

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

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

val set_can_target : t -> bool -> unit

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

val set_can_focus : t -> bool -> unit

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

Applications should set @can_focus to %FALSE to mark a widget as for pointer/touch use only.

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

See method@Gtk.Widget.grab_focus for actually setting the input focus on a widget.

val remove_tick_callback : t -> int -> unit

Removes a tick callback previously registered with gtk_widget_add_tick_callback().

val remove_mnemonic_label : t -> t -> unit

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

See method@Gtk.Widget.list_mnemonic_labels. The widget must have previously been added to the list with method@Gtk.Widget.add_mnemonic_label.

val remove_css_class : t -> string -> unit

Removes a style from @widget.

After this, the style of @widget will stop matching for @css_class.

val remove_controller : t -> [ `event_controller | `object_ ] Gobject.obj -> unit

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

It should not be used again.

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

val realize : t -> unit

Creates the GDK resources associated with a widget.

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

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

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

val queue_resize : t -> unit

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

Note that you cannot call gtk_widget_queue_resize() on a widget from inside its implementation of the vfunc@Gtk.Widget.size_allocate virtual method. Calls to gtk_widget_queue_resize() from inside vfunc@Gtk.Widget.size_allocate will be silently ignored.

This function is only for use in widget implementations.

val queue_draw : t -> unit

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

This means @widget's vfunc@Gtk.Widget.snapshot implementation will be called.

val queue_allocate : t -> unit

Flags the widget for a rerun of the vfunc@Gtk.Widget.size_allocate function.

Use this function instead of method@Gtk.Widget.queue_resize when the @widget's size request didn't change but it wants to reposition its contents.

An example user of this function is method@Gtk.Widget.set_halign.

This function is only for use in widget implementations.

val pick : t -> float -> float -> Gtk_enums.pickflags -> t option

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

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

Usually widgets will return %NULL if the given coordinate is not contained in @widget checked via method@Gtk.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.

val observe_controllers : t -> Ocgtk_gio.Gio.Wrappers.List_model.t

Returns a `GListModel` to track the class@Gtk.EventControllers of @widget.

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

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

val observe_children : t -> Ocgtk_gio.Gio.Wrappers.List_model.t

Returns a `GListModel` to track the children of @widget.

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

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

val mnemonic_activate : t -> bool -> bool

Emits the ::mnemonic-activate signal.

See signal@Gtk.Widget::mnemonic-activate.

val measure : t -> Gtk_enums.orientation -> int -> int * int * int * int

Measures @widget in the orientation @orientation and for the given @for_size.

As an example, if @orientation is %GTK_ORIENTATION_HORIZONTAL and @for_size is 300, this functions will compute the minimum and natural width of @widget if it is allocated at a height of 300 pixels.

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

val map : t -> unit

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

This function is only for use in widget implementations.

val list_mnemonic_labels : t -> t list

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

Typically, these widgets will be labels. See, for example, method@Gtk.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.

val keynav_failed : t -> Gtk_enums.directiontype -> bool

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

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

The return value of this function should be interpreted in a way similar to the return value of method@Gtk.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 method@Gtk.Widget.child_focus on the widget’s toplevel.

The default signal@Gtk.Widget::keynav-failed handler returns %FALSE for %GTK_DIR_TAB_FORWARD and %GTK_DIR_TAB_BACKWARD. For the other values of `GtkDirectionType` it returns %TRUE.

Whenever the default handler returns %TRUE, it also calls method@Gtk.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 class@Gtk.Entry widgets where the user should be able to navigate the entire row with the cursor keys, as e.g. known from user interfaces that require entering license keys.

val is_visible : t -> bool

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 method@Gtk.Widget.get_visible and method@Gtk.Widget.set_visible.

val is_sensitive : t -> bool

Returns the widget’s effective sensitivity.

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

val is_focus : t -> bool

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

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

val is_drawable : t -> bool

Determines whether @widget can be drawn to.

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

val is_ancestor : t -> t -> bool

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

val insert_before : t -> t -> t option -> unit

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

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 @widget, this function can also be used to reorder @widget in the child widget list of @parent.

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

val insert_after : t -> t -> t option -> unit

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

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 @widget, this function can also be used to reorder @widget in the child widget list of @parent.

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

val insert_action_group : t -> string -> Ocgtk_gio.Gio.Wrappers.Action_group.t option -> unit

Inserts @group into @widget.

Children of @widget that implement iface@Gtk.Actionable can then be associated with actions in @group by setting their “action-name” to @prefix.`action-name`.

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

If @group is %NULL, a previously inserted group for @name is removed from @widget.

val init_template : t -> unit

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 method@Gtk.WidgetClass.set_template.

It is important to call this function in the instance initializer of a `GtkWidget` 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.

val in_destruction : t -> bool

Returns whether the widget is currently being destroyed.

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

val hide : t -> unit

Reverses the effects of gtk_widget_show().

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

val has_visible_focus : t -> bool

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

This is a convenience function that takes into account whether focus indication should currently be shown in the toplevel window of @widget. See method@Gtk.Window.get_focus_visible for more information about focus indication.

To find out if the widget has the global input focus, use method@Gtk.Widget.has_focus.

val has_focus : t -> bool

Determines if the widget has the global input focus.

See method@Gtk.Widget.is_focus for the difference between having the global input focus, and only having the focus within a toplevel.

val has_default : t -> bool

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

val has_css_class : t -> string -> bool

Returns whether @css_class is currently applied to @widget.

val grab_focus : t -> bool

Causes @widget to have the keyboard focus for the `GtkWindow` it's inside.

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

Calling method@Gtk.Widget.grab_focus on an already focused widget is allowed, should not have an effect, and return %TRUE.

val get_width : t -> int

Returns the content width of the widget.

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

For pointer events, see method@Gtk.Widget.contains.

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

val get_visible : t -> bool

Determines whether the widget is visible.

If you want to take into account whether the widget’s parent is also marked as visible, use method@Gtk.Widget.is_visible instead.

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

See method@Gtk.Widget.set_visible.

val get_vexpand_set : t -> bool

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

See method@Gtk.Widget.get_hexpand_set for more detail.

val get_vexpand : t -> bool

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

See method@Gtk.Widget.get_hexpand for more detail.

val get_valign : t -> Gtk_enums.align

Gets the vertical alignment of @widget.

val get_tooltip_text : t -> string option

Gets the contents of the tooltip for @widget.

If the @widget's tooltip was set using method@Gtk.Widget.set_tooltip_markup, this function will return the escaped text.

val get_tooltip_markup : t -> string option

Gets the contents of the tooltip for @widget.

If the tooltip has not been set using method@Gtk.Widget.set_tooltip_markup, this function returns %NULL.

val get_template_child : t -> Gobject.Type.t -> string -> [ `object_ ] Gobject.obj

Fetch an object build from the template XML for @widget_type in this @widget instance.

This will only report children which were previously declared with method@Gtk.WidgetClass.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.

val get_style_context : t -> [ `style_context | `object_ ] Gobject.obj

Returns the style context associated to @widget.

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

val get_state_flags : t -> Gtk_enums.stateflags

Returns the widget state as a flag set.

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

Also note that if you are looking for a way to obtain the flags@Gtk.StateFlags to pass to a class@Gtk.StyleContext method, you should look at method@Gtk.StyleContext.get_state.

val get_size_request : t -> int * int

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

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

val get_size : t -> Gtk_enums.orientation -> int

Returns the content width or height of the widget.

Which dimension is returned depends on @orientation.

This is equivalent to calling method@Gtk.Widget.get_width for %GTK_ORIENTATION_HORIZONTAL or method@Gtk.Widget.get_height for %GTK_ORIENTATION_VERTICAL, but can be used when writing orientation-independent code, such as when implementing iface@Gtk.Orientable widgets.

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

val get_settings : t -> [ `settings | `object_ ] Gobject.obj

Gets the settings object holding the settings used for this 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 `GdkDisplay`. If you want to monitor the widget for changes in its settings, connect to the `notify::display` signal.

val get_sensitive : t -> bool

Returns the widget’s sensitivity.

This function returns the value that has been set using method@Gtk.Widget.set_sensitive).

The effective sensitivity of a widget is however determined by both its own and its parent widget’s sensitivity. See method@Gtk.Widget.is_sensitive.

val get_scale_factor : t -> int

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 method@Gdk.Surface.get_scale_factor.

val get_root : t -> [ `root ] Gobject.obj option

Returns the `GtkRoot` widget of @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.

val get_request_mode : t -> Gtk_enums.sizerequestmode

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.

val get_receives_default : t -> bool

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

See method@Gtk.Widget.set_receives_default.

val get_realized : t -> bool

Determines whether @widget is realized.

val get_primary_clipboard : t -> Ocgtk_gdk.Gdk.Wrappers.Clipboard.t

Gets the primary clipboard of @widget.

This is a utility function to get the primary clipboard object for the `GdkDisplay` that @widget is using.

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

val get_prev_sibling : t -> t option

Returns the widget’s previous sibling.

This API is primarily meant for widget implementations.

val get_preferred_size : t -> [ `requisition ] Gobject.obj * [ `requisition ] Gobject.obj

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 method@Gtk.Widget.measure if you want to support baseline alignment.

val get_parent : t -> t option

Returns the parent widget of @widget.

val get_pango_context : t -> Ocgtk_pango.Pango.Wrappers.Context.t

Gets a `PangoContext` with the appropriate font map, font description, and base direction for this widget.

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

val get_overflow : t -> Gtk_enums.overflow

Returns the widget’s overflow value.

val get_opacity : t -> float

#Fetches the requested opacity for this widget.

See method@Gtk.Widget.set_opacity.

val get_next_sibling : t -> t option

Returns the widget’s next sibling.

This API is primarily meant for widget implementations.

val get_native : t -> [ `native ] Gobject.obj option

Returns the nearest `GtkNative` ancestor of @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.

val get_name : t -> string

Retrieves the name of a widget.

See method@Gtk.Widget.set_name for the significance of widget names.

val get_margin_top : t -> int

Gets the top margin of @widget.

val get_margin_start : t -> int

Gets the start margin of @widget.

val get_margin_end : t -> int

Gets the end margin of @widget.

val get_margin_bottom : t -> int

Gets the bottom margin of @widget.

val get_mapped : t -> bool

Whether the widget is mapped.

val get_layout_manager : t -> [ `layout_manager | `object_ ] Gobject.obj option

Retrieves the layout manager used by @widget.

See method@Gtk.Widget.set_layout_manager.

val get_last_child : t -> t option

Returns the widget’s last child.

This API is primarily meant for widget implementations.

val get_hexpand_set : t -> bool

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

If property@Gtk.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.

val get_hexpand : t -> bool

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

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

Containers should use method@Gtk.Widget.compute_expand rather than this function, to see whether a widget, or any of its children, has the expand flag set. If any child of a widget wants to expand, the parent may ask to expand also.

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

val get_height : t -> int

Returns the content height of the widget.

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

For pointer events, see method@Gtk.Widget.contains.

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

val get_has_tooltip : t -> bool

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

val get_halign : t -> Gtk_enums.align

Gets the horizontal alignment of @widget.

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

Baselines are not supported for horizontal alignment.

val get_frame_clock : t -> Ocgtk_gdk.Gdk.Wrappers.Frame_clock.t option

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 method@Gdk.FrameClock.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 method@Gdk.FrameClock.get_frame_time, and then update the animation by calling method@Gdk.FrameClock.get_frame_time again during each repaint.

method@Gdk.FrameClock.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 method@Gtk.Widget.queue_draw which invalidates the widget (thus scheduling it to receive a draw on the next frame). gtk_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.

val get_font_options : t -> Ocgtk_cairo.Cairo.Wrappers.Font_options.t option

Returns the `cairo_font_options_t` of widget.

Seee method@Gtk.Widget.set_font_options.

val get_font_map : t -> Ocgtk_pango.Pango.Wrappers.Font_map.t option

Gets the font map of @widget.

See method@Gtk.Widget.set_font_map.

val get_focusable : t -> bool

Determines whether @widget can own the input focus.

See method@Gtk.Widget.set_focusable.

val get_focus_on_click : t -> bool

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

See method@Gtk.Widget.set_focus_on_click.

val get_focus_child : t -> t option

Returns the current focus child of @widget.

val get_first_child : t -> t option

Returns the widget’s first child.

This API is primarily meant for widget implementations.

val get_display : t -> Ocgtk_gdk.Gdk.Wrappers.Display.t

Get the `GdkDisplay` for the toplevel window associated with this widget.

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

val get_direction : t -> Gtk_enums.textdirection

Gets the reading direction for a particular widget.

See method@Gtk.Widget.set_direction.

val get_cursor : t -> Ocgtk_gdk.Gdk.Wrappers.Cursor.t option

Queries the cursor set on @widget.

See method@Gtk.Widget.set_cursor for details.

val get_css_name : t -> string

Returns the CSS name that is used for @self.

val get_css_classes : t -> string array

Returns the list of style classes applied to @widget.

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

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

val get_clipboard : t -> Ocgtk_gdk.Gdk.Wrappers.Clipboard.t

Gets the clipboard object for @widget.

This is a utility function to get the clipboard object for the `GdkDisplay` that @widget is using.

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

val get_child_visible : t -> bool

Gets the value set with gtk_widget_set_child_visible().

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

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

val get_can_target : t -> bool

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

val get_can_focus : t -> bool

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

See method@Gtk.Widget.set_focusable.

val get_baseline : t -> int

Returns the baseline that has currently been allocated to @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().

val get_ancestor : t -> Gobject.Type.t -> t option

Gets the first ancestor of @widget with type @widget_type.

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

Note that unlike method@Gtk.Widget.is_ancestor, this function considers @widget to be an ancestor of itself.

val get_allocated_width : t -> int

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

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

val get_allocated_height : t -> int

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

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

val get_allocated_baseline : t -> int

Returns the baseline that has currently been allocated to @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().

val error_bell : t -> unit

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

If the property@Gtk.Settings:gtk-error-bell setting is %TRUE, it calls method@Gdk.Surface.beep, otherwise it does nothing.

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

val drag_check_threshold : t -> int -> int -> int -> int -> bool

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

val dispose_template : t -> Gobject.Type.t -> unit

Clears the template children for the given widget.

This function is the opposite of method@Gtk.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 `gtk_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.

```c 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); ```

val create_pango_layout : t -> string option -> Ocgtk_pango.Pango.Wrappers.Layout.t

Creates a new `PangoLayout` with the appropriate font map, font description, and base direction for drawing text for this widget.

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

val create_pango_context : t -> Ocgtk_pango.Pango.Wrappers.Context.t

Creates a new `PangoContext` with the appropriate font map, font options, font description, and base direction for drawing text for this widget.

See also method@Gtk.Widget.get_pango_context.

val contains : t -> float -> float -> bool

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

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

val compute_transform : t -> t -> bool * Ocgtk_graphene.Graphene.Wrappers.Matrix.t

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

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

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

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

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

val compute_expand : t -> Gtk_enums.orientation -> bool

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

Containers should check this, rather than looking at method@Gtk.Widget.get_hexpand or method@Gtk.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.

val compute_bounds : t -> t -> bool * Ocgtk_graphene.Graphene.Wrappers.Rect.t

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

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

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

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

val child_focus : t -> Gtk_enums.directiontype -> bool

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

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

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

The default `focus()` virtual function for a widget should return `TRUE` if moving in @direction left the focus on a focusable location inside that widget, and `FALSE` if moving in @direction moved the focus outside the widget. When returning `TRUE`, widgets normally call method@Gtk.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 method@Gtk.Widget.grab_focus to move the focus to a particular widget.

val allocate : t -> int -> int -> int -> Ocgtk_gsk.Gsk.Wrappers.Transform.t option -> unit

This function is only used by `GtkWidget` subclasses, to assign a size, position and (optionally) baseline to their child widgets.

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

For a version that does not take a transform, see method@Gtk.Widget.size_allocate.

val add_mnemonic_label : t -> t -> unit

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

See method@Gtk.Widget.list_mnemonic_labels. Note the list of mnemonic labels for the widget is cleared when the widget is destroyed, so the caller must make sure to update its internal state at this point as well.

val add_css_class : t -> string -> unit

Adds a style class to @widget.

After calling this function, the widget’s style will match for @css_class, according to CSS matching rules.

Use method@Gtk.Widget.remove_css_class to remove the style again.

val add_controller : t -> [ `event_controller | `object_ ] Gobject.obj -> unit

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

You will usually want to call this function right after creating any kind of class@Gtk.EventController.

val activate_default : t -> unit

Activates the `default.activate` action from @widget.

val activate_action_variant : t -> string -> Gvariant.t option -> bool

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

If the action is in an action group added with method@Gtk.Widget.insert_action_group, the @name is expected to be prefixed with the prefix that was used when the group was inserted.

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

val activate : t -> bool

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

The activation will emit the signal set using method@Gtk.WidgetClass.set_activate_signal during class initialization.

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

If you wish to handle the activation keybinding yourself, it is recommended to use method@Gtk.WidgetClass.add_shortcut with an action created with ctor@Gtk.SignalAction.new.

If @widget isn't activatable, the function returns %FALSE.

val action_set_enabled : t -> string -> bool -> unit

Enable or disable an action installed with gtk_widget_class_install_action().

val get_height_request : t -> int

Get property: height-request

val set_height_request : t -> int -> unit

Set property: height-request

val get_width_request : t -> int

Get property: width-request

val set_width_request : t -> int -> unit

Set property: width-request

val on_destroy : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_direction_changed : ?after:bool -> t -> callback:(previous_direction:Gtk_enums.textdirection -> unit) -> Gobject.Signal.handler_id
val on_hide : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_keynav_failed : ?after:bool -> t -> callback:(direction:Gtk_enums.directiontype -> bool) -> Gobject.Signal.handler_id
val on_map : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_mnemonic_activate : ?after:bool -> t -> callback:(group_cycling:bool -> bool) -> Gobject.Signal.handler_id
val on_move_focus : ?after:bool -> t -> callback:(direction:Gtk_enums.directiontype -> unit) -> Gobject.Signal.handler_id
val on_query_tooltip : ?after:bool -> t -> callback: (x:int -> y:int -> keyboard_mode:bool -> tooltip:[ `tooltip | `object_ ] Gobject.obj -> bool) -> Gobject.Signal.handler_id
val on_realize : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_show : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_state_flags_changed : ?after:bool -> t -> callback:(flags:Gtk_enums.stateflags -> unit) -> Gobject.Signal.handler_id
val on_unmap : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id
val on_unrealize : ?after:bool -> t -> callback:(unit -> unit) -> Gobject.Signal.handler_id