Class (GI Class)

Gtk-4.0GtkApplicationWindow

A Gtk.Window subclass that integrates with Gtk.Application.

Notably, Gtk.ApplicationWindow can handle an application menubar.

This class implements the Gio.ActionGroup and Gio.ActionMap interfaces, to let you add window-specific actions that will be exported by the associated Gtk.Application, together with its application-wide actions. Window-specific actions are prefixed with the “win.” prefix and application-wide actions are prefixed with the “app.” prefix. Actions must be addressed with the prefixed name when referring to them from a menu model.

Note that widgets that are placed inside a Gtk.ApplicationWindow can also activate these actions, if they implement the Gtk.Actionable interface.

The settings Gtk.Settings.gtk_shell_shows_app_menu and Gtk.Settings.gtk_shell_shows_menubar tell GTK whether the desktop environment is showing the application menu and menubar models outside the application as part of the desktop shell. For instance, on OS X, both menus will be displayed remotely; on Windows neither will be.

If the desktop environment does not display the menubar, it can be shown in the Gtk.ApplicationWindow by setting the Gtk.ApplicationWindow.show_menubar property to true. If the desktop environment does not display the application menu, then it will automatically be included in the menubar or in the window’s client-side decorations.

See Gtk.PopoverMenu for information about the XML language used by Gtk.Builder for menu models.

See also: Gtk.Application.set_menubar.

The code sample below shows how to set up a Gtk.ApplicationWindow with a menu bar defined on the Gtk.Application:

GtkApplication *app = gtk_application_new ("org.gtk.test", 0);

GtkBuilder *builder = gtk_builder_new_from_string (
"<interface>"
" <menu id='menubar'>"
" <submenu>"
" <attribute name='label' translatable='yes'>_Edit</attribute>"
" <item>"
" <attribute name='label' translatable='yes'>_Copy</attribute>"
" <attribute name='action'>win.copy</attribute>"
" </item>"
" <item>"
" <attribute name='label' translatable='yes'>_Paste</attribute>"
" <attribute name='action'>win.paste</attribute>"
" </item>"
" </submenu>"
" </menu>"
"</interface>",
-1);

GMenuModel *menubar = G_MENU_MODEL (gtk_builder_get_object (builder, "menubar"));
gtk_application_set_menubar (GTK_APPLICATION (app), menubar);
g_object_unref (builder);

// ...

GtkWidget *window = gtk_application_window_new (app);

Hierarchy (View Summary)

Implements

Index

Constructors

Properties

Properties - Inherited from Gtk.Window

Accessors

Accessors - Inherited from Gtk.Accessible

Accessors - Inherited from Gtk.Widget

Accessors - Inherited from Gtk.Window

Methods

_init action_added action_enabled_changed action_removed action_set_enabled action_state_changed activate activate_action activate_default add_action add_action_entries add_controller add_css_class add_mnemonic_label add_tick_callback allocate bind_property bind_property_full block_signal_handler change_action_state child_focus compute_bounds compute_expand compute_point compute_transform connect connect_after contains create_pango_context create_pango_layout disconnect dispose_template drag_check_threshold emit error_bell force_floating freeze_notify get_action_enabled get_action_parameter_type get_action_state get_action_state_hint get_action_state_type get_allocated_baseline get_allocated_height get_allocated_width get_allocation get_ancestor get_baseline get_can_focus get_can_target get_child_visible get_clipboard get_color get_css_classes get_css_name get_cursor get_data get_direction get_display get_first_child get_focus get_focus_child get_focus_on_click get_focusable get_font_map get_font_options get_frame_clock get_halign get_has_tooltip get_height get_help_overlay get_hexpand get_hexpand_set get_id get_last_child get_layout_manager get_limit_events get_mapped get_margin_bottom get_margin_end get_margin_start get_margin_top get_name get_native get_next_sibling get_opacity get_overflow get_pango_context get_parent get_preferred_size get_prev_sibling get_primary_clipboard get_property get_qdata get_realized get_receives_default get_renderer get_request_mode get_root get_scale_factor get_sensitive get_settings get_show_menubar get_size get_size_request get_state_flags get_style_context get_surface get_surface_transform get_template_child get_tooltip_markup get_tooltip_text get_valign get_vexpand get_vexpand_set get_visible get_width getv grab_focus has_action has_css_class has_visible_focus hide in_destruction init_template insert_action_group insert_after insert_before is_ancestor is_drawable is_floating is_focus is_sensitive is_visible keynav_failed list_actions list_mnemonic_labels lookup_action map measure mnemonic_activate notify notify_by_pspec observe_children observe_controllers pick query_action queue_allocate queue_draw queue_resize realize ref ref_sink remove_action remove_action_entries remove_controller remove_css_class remove_mnemonic_label remove_tick_callback run_dispose set set_can_focus set_can_target set_child_visible set_css_classes set_cursor set_cursor_from_name set_data set_direction set_focus set_focus_child set_focus_on_click set_focusable set_font_map set_font_options set_halign set_has_tooltip set_help_overlay set_hexpand set_hexpand_set set_layout_manager set_limit_events set_margin_bottom set_margin_end set_margin_start set_margin_top set_name set_opacity set_overflow set_parent set_property set_receives_default set_sensitive set_show_menubar set_size_request set_state_flags set_tooltip_markup set_tooltip_text set_valign set_vexpand set_vexpand_set set_visible should_layout show size_allocate snapshot_child steal_data steal_qdata stop_emission_by_name thaw_notify translate_coordinates trigger_tooltip_query unblock_signal_handler unmap unparent unrealize unref unset_state_flags vfunc_action_added vfunc_action_enabled_changed vfunc_action_removed vfunc_action_state_changed vfunc_activate_action vfunc_add_action vfunc_add_controller vfunc_change_action_state vfunc_compute_expand vfunc_constructed vfunc_contains vfunc_css_changed vfunc_direction_changed vfunc_dispatch_properties_changed vfunc_dispose vfunc_finalize vfunc_focus vfunc_get_action_enabled vfunc_get_action_parameter_type vfunc_get_action_state vfunc_get_action_state_hint vfunc_get_action_state_type vfunc_get_property vfunc_get_request_mode vfunc_grab_focus vfunc_has_action vfunc_hide vfunc_keynav_failed vfunc_list_actions vfunc_lookup_action vfunc_map vfunc_measure vfunc_mnemonic_activate vfunc_move_focus vfunc_notify vfunc_query_action vfunc_query_tooltip vfunc_realize vfunc_remove_action vfunc_remove_controller vfunc_root vfunc_set_focus_child vfunc_set_property vfunc_show vfunc_size_allocate vfunc_snapshot vfunc_state_flags_changed vfunc_system_setting_changed vfunc_unmap vfunc_unrealize vfunc_unroot watch_closure new

Methods - Inherited from Gtk.Window

announce close destroy fullscreen fullscreen_on_monitor get_accessible_parent get_accessible_role get_application get_at_context get_bounds get_buildable_id get_child get_decorated get_default_size get_default_widget get_deletable get_destroy_with_parent get_first_accessible_child get_focus_visible get_gravity get_group get_handle_menubar_accel get_hide_on_close get_icon_name get_mnemonics_visible get_modal get_next_accessible_sibling get_platform_state get_resizable get_title get_titlebar get_transient_for has_group is_fullscreen is_maximized is_suspended maximize minimize present present_with_time reset_property reset_relation reset_state set_accessible_parent set_application set_child set_decorated set_default_size set_default_widget set_deletable set_destroy_with_parent set_display set_focus_visible set_gravity set_handle_menubar_accel set_hide_on_close set_icon_name set_mnemonics_visible set_modal set_resizable set_startup_id set_title set_titlebar set_transient_for unfullscreen unmaximize unminimize update_next_accessible_sibling update_platform_state update_property update_relation update_state vfunc_activate_default vfunc_activate_focus vfunc_add_child vfunc_close_request vfunc_custom_finished vfunc_custom_tag_end vfunc_custom_tag_start vfunc_enable_debugging vfunc_get_accessible_parent vfunc_get_at_context vfunc_get_bounds vfunc_get_first_accessible_child vfunc_get_id vfunc_get_internal_child vfunc_get_next_accessible_sibling vfunc_get_platform_state vfunc_keys_changed vfunc_parser_finished vfunc_set_buildable_property vfunc_set_id _classInit add_shortcut bind_template_callback_full bind_template_child_full compat_control find_property get_accessible_role get_activate_signal get_css_name get_default_direction get_default_icon_name get_layout_manager_type get_toplevels install_action install_properties install_property install_property_action interface_find_property interface_install_property interface_list_properties list_properties list_toplevels newv override_property query_action set_accessible_role set_activate_signal set_activate_signal_from_name set_auto_startup_notification set_css_name set_default_direction set_default_icon_name set_interactive_debugging set_layout_manager_type set_template set_template_from_resource set_template_scope

Constructors

Properties

Compile-time signal type information.

This instance property is generated only for TypeScript type checking. It is not defined at runtime and should not be accessed in JS code.

Properties - Inherited from Gtk.Window

"[iterator]": () => IterableIterator<Gtk.Widget>

Gtk.Widget is an iterable of its children.

Accessors

  • get show_menubar(): boolean

    If this property is true, the window will display a menubar unless it is shown by the desktop shell.

    See Gtk.Application.set_menubar.

    If false, the window will not display a menubar, regardless of whether the desktop shell is showing it or not.

    Returns boolean

  • set show_menubar(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get showMenubar(): boolean

    If this property is true, the window will display a menubar unless it is shown by the desktop shell.

    See Gtk.Application.set_menubar.

    If false, the window will not display a menubar, regardless of whether the desktop shell is showing it or not.

    Returns boolean

  • set showMenubar(val: boolean): void

    Parameters

    • val: boolean

    Returns void

Accessors - Inherited from Gtk.Accessible

Accessors - Inherited from Gtk.Widget

  • get can_focus(): boolean

    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.

    Returns boolean

  • set can_focus(val: boolean): void

    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.

    Parameters

    • val: boolean

    Returns void

  • get can_target(): boolean

    Whether the widget can receive pointer events.

    Returns boolean

  • set can_target(val: boolean): void

    Whether the widget can receive pointer events.

    Parameters

    • val: boolean

    Returns void

  • get canFocus(): boolean

    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.

    Returns boolean

  • set canFocus(val: boolean): void

    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.

    Parameters

    • val: boolean

    Returns void

  • get canTarget(): boolean

    Whether the widget can receive pointer events.

    Returns boolean

  • set canTarget(val: boolean): void

    Whether the widget can receive pointer events.

    Parameters

    • val: boolean

    Returns void

  • get css_classes(): string[]

    A list of css classes applied to this widget.

    Returns string[]

  • set css_classes(val: string[]): void

    A list of css classes applied to this widget.

    Parameters

    • val: string[]

    Returns void

  • get css_name(): string

    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.

    Returns string

  • get cssClasses(): string[]

    A list of css classes applied to this widget.

    Returns string[]

  • set cssClasses(val: string[]): void

    A list of css classes applied to this widget.

    Parameters

    • val: string[]

    Returns void

  • get cssName(): string

    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.

    Returns string

  • get focus_on_click(): boolean

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

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

    Returns boolean

  • set focus_on_click(val: boolean): void

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

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

    Parameters

    • val: boolean

    Returns void

  • get focusable(): boolean

    Whether this widget itself will accept the input focus.

    Returns boolean

  • set focusable(val: boolean): void

    Whether this widget itself will accept the input focus.

    Parameters

    • val: boolean

    Returns void

  • get focusOnClick(): boolean

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

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

    Returns boolean

  • set focusOnClick(val: boolean): void

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

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

    Parameters

    • val: boolean

    Returns void

  • get has_default(): boolean

    Whether the widget is the default widget.

    Returns boolean

  • get has_focus(): boolean

    Whether the widget has the input focus.

    Returns boolean

  • get has_tooltip(): boolean

    Enables or disables the emission of the Gtk.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 Gtk.Widget::query-tooltip to determine whether it will provide a tooltip or not.

    Returns boolean

  • set has_tooltip(val: boolean): void

    Enables or disables the emission of the Gtk.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 Gtk.Widget::query-tooltip to determine whether it will provide a tooltip or not.

    Parameters

    • val: boolean

    Returns void

  • get hasDefault(): boolean

    Whether the widget is the default widget.

    Returns boolean

  • get hasFocus(): boolean

    Whether the widget has the input focus.

    Returns boolean

  • get hasTooltip(): boolean

    Enables or disables the emission of the Gtk.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 Gtk.Widget::query-tooltip to determine whether it will provide a tooltip or not.

    Returns boolean

  • set hasTooltip(val: boolean): void

    Enables or disables the emission of the Gtk.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 Gtk.Widget::query-tooltip to determine whether it will provide a tooltip or not.

    Parameters

    • val: boolean

    Returns void

  • get height_request(): number

    Overrides for height request of the widget.

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

    Returns number

  • set height_request(val: number): void

    Overrides for height request of the widget.

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

    Parameters

    • val: number

    Returns void

  • get heightRequest(): number

    Overrides for height request of the widget.

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

    Returns number

  • set heightRequest(val: number): void

    Overrides for height request of the widget.

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

    Parameters

    • val: number

    Returns void

  • get hexpand(): boolean

    Whether to expand horizontally.

    Returns boolean

  • set hexpand(val: boolean): void

    Whether to expand horizontally.

    Parameters

    • val: boolean

    Returns void

  • get hexpand_set(): boolean

    Whether to use the hexpand property.

    Returns boolean

  • set hexpand_set(val: boolean): void

    Whether to use the hexpand property.

    Parameters

    • val: boolean

    Returns void

  • get hexpandSet(): boolean

    Whether to use the hexpand property.

    Returns boolean

  • set hexpandSet(val: boolean): void

    Whether to use the hexpand property.

    Parameters

    • val: boolean

    Returns void

  • get layout_manager(): Gtk.LayoutManager

    The Gtk.LayoutManager 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.

    Returns Gtk.LayoutManager

  • set layout_manager(val: Gtk.LayoutManager): void

    The Gtk.LayoutManager 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.

    Parameters

    Returns void

  • get layoutManager(): Gtk.LayoutManager

    The Gtk.LayoutManager 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.

    Returns Gtk.LayoutManager

  • set layoutManager(val: Gtk.LayoutManager): void

    The Gtk.LayoutManager 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.

    Parameters

    Returns void

  • get limit_events(): boolean

    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 Gtk.EventController.set_propagation_limit.

    Returns boolean

    4.18

  • set limit_events(val: boolean): void

    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 Gtk.EventController.set_propagation_limit.

    Parameters

    • val: boolean

    Returns void

    4.18

  • get limitEvents(): boolean

    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 Gtk.EventController.set_propagation_limit.

    Returns boolean

    4.18

  • set limitEvents(val: boolean): void

    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 Gtk.EventController.set_propagation_limit.

    Parameters

    • val: boolean

    Returns void

    4.18

  • get margin_bottom(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set margin_bottom(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get margin_end(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set margin_end(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get margin_start(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set margin_start(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get margin_top(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set margin_top(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get marginBottom(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set marginBottom(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get marginEnd(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set marginEnd(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get marginStart(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set marginStart(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get marginTop(): number

    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 Gtk.Widget.set_size_request for example.

    Returns number

  • set marginTop(val: number): void

    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 Gtk.Widget.set_size_request for example.

    Parameters

    • val: number

    Returns void

  • get name(): string

    The name of the widget.

    Returns string

  • set name(val: string): void

    The name of the widget.

    Parameters

    • val: string

    Returns void

  • get opacity(): number

    The requested opacity of the widget.

    Returns number

  • set opacity(val: number): void

    The requested opacity of the widget.

    Parameters

    • val: number

    Returns void

  • get overflow(): Gtk.Overflow

    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.

    Returns Gtk.Overflow

  • set overflow(val: Gtk.Overflow): void

    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.

    Parameters

    Returns void

  • get receives_default(): boolean

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

    Returns boolean

  • set receives_default(val: boolean): void

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

    Parameters

    • val: boolean

    Returns void

  • get receivesDefault(): boolean

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

    Returns boolean

  • set receivesDefault(val: boolean): void

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

    Parameters

    • val: boolean

    Returns void

  • get root(): Gtk.Root

    The Gtk.Root widget of the widget tree containing this widget.

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

    Returns Gtk.Root

  • get scale_factor(): number

    The scale factor of the widget.

    Returns number

  • get scaleFactor(): number

    The scale factor of the widget.

    Returns number

  • get sensitive(): boolean

    Whether the widget responds to input.

    Returns boolean

  • set sensitive(val: boolean): void

    Whether the widget responds to input.

    Parameters

    • val: boolean

    Returns void

  • get tooltip_markup(): string

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

    Also see Gtk.Tooltip.set_markup.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Returns string

  • set tooltip_markup(val: string): void

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

    Also see Gtk.Tooltip.set_markup.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Parameters

    • val: string

    Returns void

  • get tooltip_text(): string

    Sets the text of tooltip to be the given string.

    Also see Gtk.Tooltip.set_text.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Returns string

  • set tooltip_text(val: string): void

    Sets the text of tooltip to be the given string.

    Also see Gtk.Tooltip.set_text.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Parameters

    • val: string

    Returns void

  • get tooltipMarkup(): string

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

    Also see Gtk.Tooltip.set_markup.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Returns string

  • set tooltipMarkup(val: string): void

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

    Also see Gtk.Tooltip.set_markup.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Parameters

    • val: string

    Returns void

  • get tooltipText(): string

    Sets the text of tooltip to be the given string.

    Also see Gtk.Tooltip.set_text.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Returns string

  • set tooltipText(val: string): void

    Sets the text of tooltip to be the given string.

    Also see Gtk.Tooltip.set_text.

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

    Note that if both Gtk.Widget.tooltip_text and Gtk.Widget.tooltip_markup are set, the last one wins.

    Parameters

    • val: string

    Returns void

  • get vexpand(): boolean

    Whether to expand vertically.

    Returns boolean

  • set vexpand(val: boolean): void

    Whether to expand vertically.

    Parameters

    • val: boolean

    Returns void

  • get vexpand_set(): boolean

    Whether to use the vexpand property.

    Returns boolean

  • set vexpand_set(val: boolean): void

    Whether to use the vexpand property.

    Parameters

    • val: boolean

    Returns void

  • get vexpandSet(): boolean

    Whether to use the vexpand property.

    Returns boolean

  • set vexpandSet(val: boolean): void

    Whether to use the vexpand property.

    Parameters

    • val: boolean

    Returns void

  • get visible(): boolean

    Whether the widget is visible.

    Returns boolean

  • set visible(val: boolean): void

    Whether the widget is visible.

    Parameters

    • val: boolean

    Returns void

  • get width_request(): number

    Overrides for width request of the widget.

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

    Returns number

  • set width_request(val: number): void

    Overrides for width request of the widget.

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

    Parameters

    • val: number

    Returns void

  • get widthRequest(): number

    Overrides for width request of the widget.

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

    Returns number

  • set widthRequest(val: number): void

    Overrides for width request of the widget.

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

    Parameters

    • val: number

    Returns void

Accessors - Inherited from Gtk.Window

  • get application(): Gtk.Application

    The Gtk.Application associated with the window.

    The application will be kept alive for at least as long as it has any windows associated with it (see g_application_hold() for a way to keep it alive without windows).

    Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it by setting the this property to NULL.

    Returns Gtk.Application

  • set application(val: Gtk.Application): void

    Parameters

    Returns void

  • get decorated(): boolean

    Whether the window should have a frame (also known as decorations).

    Returns boolean

  • set decorated(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get default_height(): number

    The default height of the window.

    Returns number

  • set default_height(val: number): void

    Parameters

    • val: number

    Returns void

  • get default_width(): number

    The default width of the window.

    Returns number

  • set default_width(val: number): void

    Parameters

    • val: number

    Returns void

  • get defaultHeight(): number

    The default height of the window.

    Returns number

  • set defaultHeight(val: number): void

    Parameters

    • val: number

    Returns void

  • get defaultWidth(): number

    The default width of the window.

    Returns number

  • set defaultWidth(val: number): void

    Parameters

    • val: number

    Returns void

  • get deletable(): boolean

    Whether the window frame should have a close button.

    Returns boolean

  • set deletable(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get destroy_with_parent(): boolean

    If this window should be destroyed when the parent is destroyed.

    Returns boolean

  • set destroy_with_parent(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get destroyWithParent(): boolean

    If this window should be destroyed when the parent is destroyed.

    Returns boolean

  • set destroyWithParent(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get focus_visible(): boolean

    Whether 'focus rectangles' are currently visible in this window.

    This property is maintained by GTK based on user input and should not be set by applications.

    Returns boolean

  • set focus_visible(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get focusVisible(): boolean

    Whether 'focus rectangles' are currently visible in this window.

    This property is maintained by GTK based on user input and should not be set by applications.

    Returns boolean

  • set focusVisible(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get fullscreened(): boolean

    Whether the window is fullscreen.

    Setting this property is the equivalent of calling Gtk.Window.fullscreen or Gtk.Window.unfullscreen; either operation is asynchronous, which means you will need to connect to the ::notify signal in order to know whether the operation was successful.

    Returns boolean

  • set fullscreened(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get gravity(): Gtk.WindowGravity

    The gravity to use when resizing the window programmatically.

    Gravity describes which point of the window we want to keep fixed (meaning that the window will grow in the opposite direction). For example, a gravity of GTK_WINDOW_GRAVITY_TOP_RIGHT means that we want the to fix top right corner of the window.

    Returns Gtk.WindowGravity

    4.20

  • set gravity(val: Gtk.WindowGravity): void

    Parameters

    Returns void

  • get handle_menubar_accel(): boolean

    Whether the window frame should handle F10 for activating menubars.

    Returns boolean

    4.2

  • set handle_menubar_accel(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get handleMenubarAccel(): boolean

    Whether the window frame should handle F10 for activating menubars.

    Returns boolean

    4.2

  • set handleMenubarAccel(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get hide_on_close(): boolean

    If this window should be hidden instead of destroyed when the user clicks the close button.

    Returns boolean

  • set hide_on_close(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get hideOnClose(): boolean

    If this window should be hidden instead of destroyed when the user clicks the close button.

    Returns boolean

  • set hideOnClose(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get icon_name(): string

    Specifies the name of the themed icon to use as the window icon.

    See Gtk.IconTheme for more details.

    Returns string

  • set icon_name(val: string): void

    Parameters

    • val: string

    Returns void

  • get iconName(): string

    Specifies the name of the themed icon to use as the window icon.

    See Gtk.IconTheme for more details.

    Returns string

  • set iconName(val: string): void

    Parameters

    • val: string

    Returns void

  • get is_active(): boolean

    Whether the toplevel is the currently active window.

    Returns boolean

  • get isActive(): boolean

    Whether the toplevel is the currently active window.

    Returns boolean

  • get maximized(): boolean

    Whether the window is maximized.

    Setting this property is the equivalent of calling Gtk.Window.maximize or Gtk.Window.unmaximize; either operation is asynchronous, which means you will need to connect to the ::notify signal in order to know whether the operation was successful.

    Returns boolean

  • set maximized(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get mnemonics_visible(): boolean

    Whether mnemonics are currently visible in this window.

    This property is maintained by GTK based on user input, and should not be set by applications.

    Returns boolean

  • set mnemonics_visible(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get mnemonicsVisible(): boolean

    Whether mnemonics are currently visible in this window.

    This property is maintained by GTK based on user input, and should not be set by applications.

    Returns boolean

  • set mnemonicsVisible(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • get resizable(): boolean

    If true, users can resize the window.

    Returns boolean

  • set resizable(val: boolean): void

    Parameters

    • val: boolean

    Returns void

  • set startup_id(val: string): void

    A write-only property for setting window's startup notification identifier.

    Parameters

    • val: string

    Returns void

  • set startupId(val: string): void

    A write-only property for setting window's startup notification identifier.

    Parameters

    • val: string

    Returns void

Methods

  • Emits the Gio.ActionGroup::action-added signal on action_group.

    This function should only be called by Gio.ActionGroup implementations.

    Parameters

    • action_name: string

      the name of an action in the group

    Returns void

  • Emits the Gio.ActionGroup::action-enabled-changed signal on action_group.

    This function should only be called by Gio.ActionGroup implementations.

    Parameters

    • action_name: string

      the name of an action in the group

    • enabled: boolean

      whether the action is now enabled

    Returns void

  • Emits the Gio.ActionGroup::action-removed signal on action_group.

    This function should only be called by Gio.ActionGroup implementations.

    Parameters

    • action_name: string

      the name of an action in the group

    Returns void

  • Activate the named action within action_group.

    If the action is expecting a parameter, then the correct type of parameter must be given as parameter. If the action is expecting no parameters then parameter must be NULL. See Gio.ActionGroup.get_action_parameter_type.

    If the Gio.ActionGroup implementation supports asynchronous remote activation over D-Bus, this call may return before the relevant D-Bus traffic has been sent, or any replies have been received. In order to block on such asynchronous activation calls, Gio.DBusConnection.flush should be called prior to the code, which depends on the result of the action activation. Without flushing the D-Bus connection, there is no guarantee that the action would have been activated.

    The following code which runs in a remote app instance, shows an example of a ‘quit’ action being activated on the primary app instance over D-Bus. Here Gio.DBusConnection.flush is called before exit(). Without g_dbus_connection_flush(), the ‘quit’ action may fail to be activated on the primary instance.

    // call ‘quit’ action on primary instance
    g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL);

    // make sure the action is activated now
    g_dbus_connection_flush (…);

    g_debug ("Application has been terminated. Exiting.");

    exit (0);

    Parameters

    • action_name: string

      the name of the action to activate

    • Optionalparameter: GLib.Variant<any>

      parameters to the activation

    Returns void

  • Parameters

    • ...args: never[]

    Returns any

  • Adds an action to the action_map.

    If the action map already contains an action with the same name as action then the old action is dropped from the action map.

    The action map takes its own reference on action.

    Parameters

    Returns void

  • 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 Gtk.Widget.queue_resize or Gtk.Widget.queue_draw yourself.

    Gdk.FrameClock.get_frame_time should generally be used for timing continuous animations and Gdk.FrameTimings.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 Gdk.FrameClock::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 Gtk.Widget.remove_tick_callback.

    Parameters

    Returns number

    an ID for this callback

  • 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 Gtk.Widget.size_allocate.

    Parameters

    • width: number

      new width

    • height: number

      new height

    • baseline: number

      new baseline, or -1

    • Optionaltransform: Transform

      transformation to be applied

    Returns void

  • Creates a binding between source_property on source and target_property on target.

    Whenever the source_property is changed the target_property is updated using the same value. For instance:

      g_object_bind_property (action, "active", widget, "sensitive", 0);
    

    Will result in the "sensitive" property of the widget GObject.Object instance to be updated with the same value of the "active" property of the action GObject.Object instance.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well.

    The binding will automatically be removed when either the source or the target instances are finalized. To remove the binding without affecting the source and the target you can just call g_object_unref() on the returned GObject.Binding instance.

    Removing the binding by calling g_object_unref() on it must only be done if the binding, source and target are only used from a single thread and it is clear that both source and target outlive the binding. Especially it is not safe to rely on this if the binding, source or target can be finalized from different threads. Keep another reference to the binding and use g_binding_unbind() instead to be on the safe side.

    A GObject.Object can have multiple bindings.

    Parameters

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Complete version of g_object_bind_property().

    Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    If flags contains GObject.BindingFlags.BIDIRECTIONAL then the binding will be mutual: if target_property on target changes then the source_property on source will be updated as well. The transform_from function is only used in case of bidirectional bindings, otherwise it will be ignored

    The binding will automatically be removed when either the source or the target instances are finalized. This will release the reference that is being held on the GObject.Binding instance; if you want to hold on to the GObject.Binding instance, you will need to hold a reference to it.

    To remove the binding, call g_binding_unbind().

    A GObject.Object can have multiple bindings.

    The same user_data parameter will be used for both transform_to and transform_from transformation functions; the notify function will be called once, when the binding is removed. If you need different data for each transformation function, please use g_object_bind_property_with_closures() instead.

    Parameters

    • source_property: string

      the property on source to bind

    • target: GObject.Object

      the target GObject.Object

    • target_property: string

      the property on target to bind

    • flags: GObject.BindingFlags

      flags to pass to GObject.Binding

    • Optionaltransform_to: BindingTransformFunc

      the transformation function from the source to the target, or null to use the default

    • Optionaltransform_from: BindingTransformFunc

      the transformation function from the target to the source, or null to use the default

    • Optionalnotify: DestroyNotify

      a function to call when disposing the binding, to free resources used by the transformation functions, or null if not required

    Returns GObject.Binding

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • Creates a binding between source_property on source and target_property on target, allowing you to set the transformation functions to be used by the binding.

    This function is the language bindings friendly version of g_object_bind_property_full(), using GClosures instead of function pointers.

    Parameters

    • ...args: never[]

      the property on source to bind

    Returns any

    the GObject.Binding instance representing the binding between the two GObject.Object instances. The binding is released whenever the GObject.Binding reference count reaches zero.

  • 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 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 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 Gtk.Widget.grab_focus to move the focus to a particular widget.

    Parameters

    Returns boolean

    true if focus ended up inside widget

  • 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 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.

    Parameters

    Returns [boolean, Graphene.Rect]

    true if the bounds could be computed

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

    Widgets with children should check this, rather than looking at Gtk.Widget.get_hexpand or 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.

    Parameters

    Returns boolean

    whether widget tree rooted here should be expanded

  • Translates the given point in widget'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.

    Parameters

    Returns [boolean, Graphene.Point]

    true if src_widget and dest_widget have a common ancestor, false otherwise

  • 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.

    Parameters

    • target: Gtk.Widget

      the target widget that the matrix will transform to

    Returns [boolean, Graphene.Matrix]

    true if the transform could be computed

  • 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 widget's content area.

    Parameters

    • x: number

      X coordinate to test, relative to widget's origin

    • y: number

      Y coordinate to test, relative to widget's origin

    Returns boolean

    true if widget contains the point (x, y)

  • Disconnects a handler from an instance so it will not be called during any future or currently ongoing emissions of the signal it has been connected to.

    Parameters

    • id: number

      Handler ID of the handler to be disconnected

    Returns void

  • Clears the template children for the widget.

    This function is the opposite of 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 GObject.Object.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.

    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);
    }

    Parameters

    • widget_type: GType

      the type of the widget to finalize the template for

    Returns void

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

    Parameters

    • start_x: number

      X coordinate of start of drag

    • start_y: number

      Y coordinate of start of drag

    • current_x: number

      current X coordinate

    • current_y: number

      current Y coordinate

    Returns boolean

    true if the drag threshold has been passed

  • Increases the freeze count on object. If the freeze count is non-zero, the emission of "notify" signals on object is stopped. The signals are queued until the freeze count is decreased to zero. Duplicate notifications are squashed so that at most one GObject.Object::notify signal is emitted for each property modified while the object is frozen.

    This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.

    Returns void

  • Checks if the named action within action_group is currently enabled.

    An action must be enabled in order to be activated or in order to have its state changed from outside callers.

    Parameters

    • action_name: string

      the name of the action to query

    Returns boolean

    whether the action is currently enabled

  • Queries the type of the parameter that must be given when activating the named action within action_group.

    When activating the action using Gio.ActionGroup.activate_action, the GLib.Variant given to that function must be of the type returned by this function.

    In the case that this function returns NULL, you must not give any GLib.Variant, but NULL instead.

    The parameter type of a particular action will never change but it is possible for an action to be removed and for a new action to be added with the same name but a different parameter type.

    Parameters

    • action_name: string

      the name of the action to query

    Returns GLib.VariantType<any>

    the parameter type

  • Requests a hint about the valid range of values for the state of the named action within action_group.

    If NULL is returned it either means that the action is not stateful or that there is no hint about the valid range of values for the state of the action.

    If a GLib.Variant array is returned then each item in the array is a possible value for the state. If a GLib.Variant pair (ie: two-tuple) is returned then the tuple specifies the inclusive lower and upper bound of valid values for the state.

    In any case, the information is merely a hint. It may be possible to have a state value outside of the hinted range and setting a value within the range may fail.

    The return value (if non-NULL) should be freed with GLib.Variant.unref when it is no longer required.

    Parameters

    • action_name: string

      the name of the action to query

    Returns GLib.Variant<any>

    the state range hint

  • 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 Gtk.Widget.size_allocate with an allocation, and that allocation is then adjusted (to handle margin and alignment for example) before assignment to the widget. Gtk.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 Gtk.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.

    Returns Gdk.Rectangle

  • Gets a named field from the objects table of associations (see g_object_set_data()).

    Parameters

    • key: string

      name of the key for that association

    Returns any

    the data if found, or null if no such data exists.

  • Retrieves the current focused widget within the root.

    Note that this is the widget that would have the focus if the root is active; if the root is not focused then gtk_widget_has_focus (widget) will be false for the widget.

    Returns Gtk.Widget

    the currently focused widget

  • 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 Gtk.Widget.snapshot.

    For pointer events, see Gtk.Widget.contains.

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

    Returns number

    The height of widget

  • 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 Gtk.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.

    Returns boolean

    whether hexpand flag is set

  • Gets whether the hexpand flag has been explicitly set.

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

    Returns boolean

    whether hexpand has been explicitly set

  • Returns the unique ID of the window.

    If the window has not yet been added to a Gtk.Application, returns 0.

    Returns number

    the unique ID for the window, or 0 if the window has not yet been added to an application

  • 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 Gtk.Fixed.

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

    Use Gtk.Widget.measure if you want to support baseline alignment.

    Returns [Gtk.Requisition, Gtk.Requisition]

  • Gets a property of an object.

    The value can be:

    • an empty GObject.Value initialized by G_VALUE_INIT, which will be automatically initialized with the expected type of the property (since GLib 2.60)
    • a GObject.Value initialized with the expected type of the property
    • a GObject.Value initialized with a type to which the expected type of the property can be transformed

    In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling GObject.Value.unset.

    Note that GObject.Object.get_property is really intended for language bindings, GObject.Object.get is much more convenient for C programming.

    Parameters

    • property_name: string

      The name of the property to get

    • value: any

      Return location for the property value. Can be an empty GObject.Value initialized by G_VALUE_INIT (auto-initialized with expected type since GLib 2.60), a GObject.Value initialized with the expected property type, or a GObject.Value initialized with a transformable type

    Returns any

  • 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 Gdk.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 Gdk.Surface.get_scale to get the fractional scale value.

    Returns number

    the scale factor for widget

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

    Note that this function can only be called when the Gtk.Widget 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.

    Returns Gtk.Settings

    the relevant settings object

  • Returns whether the window will display a menubar for the app menu and menubar as needed.

    Returns boolean

    True if the window will display a menubar when needed

  • Fetches an object build from the template XML for widget_type in the widget.

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

    Type Parameters

    Parameters

    • widget_type: GType

      The GObject.GType to get a template child for

    • name: string

      ID of the child defined in the template XML

    Returns T

    the object built in the template XML with the id name

  • 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 Gtk.Widget.snapshot.

    For pointer events, see Gtk.Widget.contains.

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

    Returns number

    The width of widget

  • Gets n_properties properties for an object. Obtained properties will be set to values. All properties must be valid. Warnings will be emitted and undefined behaviour may result if invalid properties are passed in.

    Parameters

    • names: string[]

      the names of each property to get

    • values: any[]

      the values of each property to get

    Returns void

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

    If widget is not focusable, or its 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 Gtk.Widget.grab_focus on an already focused widget is allowed, should not have an effect, and return true.

    Returns boolean

    true if focus is now inside widget

  • Checks if the named action exists within action_group.

    Parameters

    • action_name: string

      the name of the action to check for

    Returns boolean

    whether the named action exists

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

    Parameters

    • css_class: string

      style class, without the leading period

    Returns boolean

    true if css_class is currently applied to widget

  • 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 Gtk.Window.get_focus_visible for more information about focus indication.

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

    Returns boolean

    true if the widget should display a “focus rectangle”

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

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

    Returns void

  • 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 Gtk.WidgetClass.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.

    Returns void

  • Inserts an action group into the widget's actions.

    Children of widget that implement 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.

    Parameters

    • name: string

      the prefix for actions in group

    • Optionalgroup: Gio.ActionGroup

      an action group

    Returns void

  • Sets the parent widget of the widget.

    In contrast to Gtk.Widget.set_parent, this function inserts widget 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 widget, this function can also be used to reorder widget 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.

    Parameters

    • parent: Gtk.Widget

      the parent widget to insert widget into

    • Optionalprevious_sibling: Gtk.Widget

      the new previous sibling of widget

    Returns void

  • Sets the parent widget of the widget.

    In contrast to Gtk.Widget.set_parent, this function inserts widget 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 widget, this function can also be used to reorder widget 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.

    Parameters

    • parent: Gtk.Widget

      the parent widget to insert widget into

    • Optionalnext_sibling: Gtk.Widget

      the new next sibling of widget

    Returns void

  • Returns the widget’s effective sensitivity.

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

    Returns boolean

    true if the widget is effectively sensitive

  • Emits the Gtk.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 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 Gtk.Widget.child_focus on the widget’s toplevel.

    The default Gtk.Widget::keynav-failed handler returns false for Gtk.DirectionType.TAB-FORWARD and Gtk.DirectionType.TAB-BACKWARD. For the other values of Gtk.DirectionType it returns true.

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

    Parameters

    Returns 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

  • Lists the actions contained within action_group.

    The caller is responsible for freeing the list with GLib.strfreev when it is no longer required.

    Returns string[]

    a NULL-terminated array of the names of the actions in the group

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

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

    Returns Gtk.Widget[]

    the list of mnemonic labels

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

    This function is only for use in widget implementations.

    Returns void

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    • property_name: string

      the name of a property installed on the class of object.

    Returns void

  • Emits a "notify" signal for the property specified by pspec on object.

    This function omits the property name lookup, hence it is faster than g_object_notify().

    One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:

      typedef enum
    {
    PROP_FOO = 1,
    PROP_LAST
    } MyObjectProperty;

    static GParamSpec *properties[PROP_LAST];

    static void
    my_object_class_init (MyObjectClass *klass)
    {
    properties[PROP_FOO] = g_param_spec_int ("foo", NULL, NULL,
    0, 100,
    50,
    G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
    g_object_class_install_property (gobject_class,
    PROP_FOO,
    properties[PROP_FOO]);
    }

    and then notify a change on the "foo" property with:

      g_object_notify_by_pspec (self, properties[PROP_FOO]);
    

    Parameters

    Returns void

  • 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.

    Returns Gio.ListModel

    a list model tracking widget's children

  • 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.

    Returns Gio.ListModel

    a list model tracking widget's controllers

  • 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 widget's content area.

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

    Parameters

    • x: number

      x coordinate to test, relative to widget's origin

    • y: number

      y coordinate to test, relative to widget's origin

    • flags: Gtk.PickFlags

      flags to influence what is picked

    Returns Gtk.Widget

    the widget's descendant at (x, y)

  • Schedules this widget to be redrawn.

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

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

    Returns void

  • 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 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 Gtk.Widget.size_allocate virtual method. Calls to gtk_widget_queue_resize() from inside Gtk.Widget.size_allocate will be silently ignored.

    This function is only for use in widget implementations.

    Returns void

  • Increases the reference count of object.

    Since GLib 2.56, if GLIB_VERSION_MAX_ALLOWED is 2.56 or greater, the type of object will be propagated to the return type (using the GCC typeof() extension), so any casting the caller needs to do on the return type must be explicit.

    Returns GObject.Object

    the same object

  • Increase the reference count of object, and possibly remove the [floating][floating-ref] reference, if object has a floating reference.

    In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.

    Since GLib 2.56, the type of object will be propagated to the return type under the same conditions as for g_object_ref().

    Returns GObject.Object

    object

  • Removes the named action from the action map.

    If no action of this name is in the map then nothing happens.

    Parameters

    • action_name: string

      the name of the action

    Returns void

  • Removes a style from the widget.

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

    Parameters

    • css_class: string

      style class to remove from widget, without the leading period

    Returns void

  • Sets multiple properties of an object at once. The properties argument should be a dictionary mapping property names to values.

    Parameters

    • properties: { [key: string]: any }

      Object containing the properties to set

    Returns void

  • 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 Gtk.Widget.grab_focus for actually setting the input focus on a widget.

    Parameters

    • can_focus: boolean

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

    Returns void

  • 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 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 widget implementations and should never be called by an application.

    Parameters

    • child_visible: boolean

      whether widget should be mapped along with its parent

    Returns void

  • Each object carries around a table of associations from strings to pointers. This function lets you set an association.

    If the object already had an association with that name, the old association will be destroyed.

    Internally, the key is converted to a GLib.Quark using g_quark_from_string(). This means a copy of key is kept permanently (even after object has been finalized) — so it is recommended to only use a small, bounded set of values for key in your program, to avoid the GLib.Quark storage growing unbounded.

    Parameters

    • key: string

      name of the key

    • Optionaldata: any

      data to associate with that key

    Returns void

  • 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 Gtk.Widget.set_default_direction will be used.

    Parameters

    Returns void

  • If focus is not the current focus widget, and is focusable, sets it as the focus widget for the root.

    If focus is null, unsets the focus widget for the root.

    To set the focus to a particular widget in the root, it is usually more convenient to use Gtk.Widget.grab_focus instead of this function.

    Parameters

    • Optionalfocus: Gtk.Widget

      widget to be the new focus widget, or null to unset the focus widget

    Returns void

  • 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.

    Parameters

    • focus_on_click: boolean

      whether the widget should grab focus when clicked with the mouse

    Returns void

  • 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 Gtk.Widget.grab_focus for actually setting the input focus on a widget.

    Parameters

    • focusable: boolean

      whether or not widget can own the input focus

    Returns void

  • Associates a shortcuts window with the application window.

    Additionally, sets up an action with the name win.show-help-overlay to present it.

    The window takes responsibility for destroying the help overlay.

    Parameters

    Returns void

  • 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 Gtk.Widget.compute_expand. A widget can decide how the expandability of children affects its own expansion by overriding the compute_expand virtual method on Gtk.Widget.).

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

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

    Parameters

    • expand: boolean

      whether to expand

    Returns void

  • Sets whether the hexpand flag will be used.

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

    Parameters

    • set: boolean

      value for hexpand-set property

    Returns void

  • 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 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.

    Parameters

    • name: string

      name for the widget

    Returns void

  • 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 Gdk.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, Gtk.Popover instances and other 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.

    Parameters

    • opacity: number

      desired opacity, between 0 and 1

    Returns void

  • 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.

    Parameters

    • receives_default: boolean

      whether or not widget can be a default widget

    Returns void

  • 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.

    Parameters

    • sensitive: boolean

      true to make the widget sensitive

    Returns void

  • Sets whether the window will display a menubar for the app menu and menubar as needed.

    Parameters

    • show_menubar: boolean

      whether to show a menubar when needed

    Returns void

  • 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, 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 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 Gtk.Widget.margin_start, Gtk.Widget.margin_end, Gtk.Widget.margin_top, and Gtk.Widget.margin_bottom, but it does include pretty much all other padding or border properties set by any subclass of Gtk.Widget.

    Parameters

    • width: number

      width widget should request, or -1 to unset

    • height: number

      height widget should request, or -1 to unset

    Returns void

  • 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 Gtk.Widget.set_direction.

    This function is for use in widget implementations.

    Parameters

    • flags: Gtk.StateFlags

      state flags to turn on

    • clear: boolean

      whether to clear state before turning on flags

    Returns void

  • 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 Gtk.Popover instances.

    Returns boolean

    true if child should be included in measuring and allocating

  • 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.

    Returns void

  • Snapshots a child of the widget.

    When a widget receives a call to the snapshot function, it must send synthetic 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 Gtk.Widget.snapshot function, calls gtk_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 Gtk.Native.

    Parameters

    Returns void

  • Remove a specified datum from the object's data associations, without invoking the association's destroy handler.

    Parameters

    • key: string

      name of the key

    Returns any

    the data if found, or null if no such data exists.

  • This function gets back user data pointers stored via g_object_set_qdata() and removes the data from object without invoking its destroy() function (if any was set). Usually, calling this function is only required to update user data pointers with a destroy notifier, for example:

    void
    object_add_to_user_list (GObject *object,
    const gchar *new_string)
    {
    // the quark, naming the object data
    GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
    // retrieve the old string list
    GList *list = g_object_steal_qdata (object, quark_string_list);

    // prepend new string
    list = g_list_prepend (list, g_strdup (new_string));
    // this changed 'list', so we need to set it again
    g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
    }
    static void
    free_string_list (gpointer data)
    {
    GList *node, *list = data;

    for (node = list; node; node = node->next)
    g_free (node->data);
    g_list_free (list);
    }

    Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().

    Parameters

    • quark: number

      A GLib.Quark, naming the user data pointer

    Returns any

    The user data pointer set, or null

  • Reverts the effect of a previous call to g_object_freeze_notify(). The freeze count is decreased on object and when it reaches zero, queued "notify" signals are emitted.

    Duplicate notifications for each property are squashed so that at most one GObject.Object::notify signal is emitted for each property, in the reverse order in which they have been queued.

    It is an error to call this function when the freeze count is zero.

    Returns void

  • Translates 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. If that is not the case, dest_x and dest_y are set to 0 and false is returned.

    Parameters

    • dest_widget: Gtk.Widget

      another widget

    • src_x: number

      X position in widget coordinates of src_widget

    • src_y: number

      Y position in widget coordinates of src_widget

    Returns [boolean, number, number]

    true if src_widget and dest_widget have a common ancestor, false otherwise

  • Decreases the reference count of object. When its reference count drops to 0, the object is finalized (i.e. its memory is freed).

    If the pointer to the GObject.Object may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to null rather than retain a dangling pointer to a potentially invalid GObject.Object instance. Use g_clear_object() for this.

    Returns void

  • Emits the Gio.ActionGroup::action-enabled-changed signal on action_group.

    This function should only be called by Gio.ActionGroup implementations.

    Parameters

    • action_name: string

      the name of an action in the group

    • enabled: boolean

      whether the action is now enabled

    Returns void

  • Activate the named action within action_group.

    If the action is expecting a parameter, then the correct type of parameter must be given as parameter. If the action is expecting no parameters then parameter must be NULL. See Gio.ActionGroup.get_action_parameter_type.

    If the Gio.ActionGroup implementation supports asynchronous remote activation over D-Bus, this call may return before the relevant D-Bus traffic has been sent, or any replies have been received. In order to block on such asynchronous activation calls, Gio.DBusConnection.flush should be called prior to the code, which depends on the result of the action activation. Without flushing the D-Bus connection, there is no guarantee that the action would have been activated.

    The following code which runs in a remote app instance, shows an example of a ‘quit’ action being activated on the primary app instance over D-Bus. Here Gio.DBusConnection.flush is called before exit(). Without g_dbus_connection_flush(), the ‘quit’ action may fail to be activated on the primary instance.

    // call ‘quit’ action on primary instance
    g_action_group_activate_action (G_ACTION_GROUP (app), "quit", NULL);

    // make sure the action is activated now
    g_dbus_connection_flush (…);

    g_debug ("Application has been terminated. Exiting.");

    exit (0);

    Parameters

    • action_name: string

      the name of the action to activate

    • Optionalparameter: GLib.Variant<any>

      parameters to the activation

    Returns void

  • the constructed function is called by g_object_new() as the final step of the object creation process. At the point of the call, all construction properties have been set on the object. The purpose of this call is to allow for object initialisation steps that can only be performed after construction properties have been set. constructed implementors should chain up to the constructed call of their parent class to allow it to complete its initialisation.

    Returns void

  • 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 widget's content area.

    Parameters

    • x: number

      X coordinate to test, relative to widget's origin

    • y: number

      Y coordinate to test, relative to widget's origin

    Returns boolean

  • the dispose function is supposed to drop all references to other objects, but keep the instance otherwise intact, so that client method invocations still work. It may be run multiple times (due to reference loops). Before returning, dispose should chain up to the dispose method of the parent class.

    Returns void

  • Checks if the named action within action_group is currently enabled.

    An action must be enabled in order to be activated or in order to have its state changed from outside callers.

    Parameters

    • action_name: string

      the name of the action to query

    Returns boolean

  • Queries the type of the parameter that must be given when activating the named action within action_group.

    When activating the action using Gio.ActionGroup.activate_action, the GLib.Variant given to that function must be of the type returned by this function.

    In the case that this function returns NULL, you must not give any GLib.Variant, but NULL instead.

    The parameter type of a particular action will never change but it is possible for an action to be removed and for a new action to be added with the same name but a different parameter type.

    Parameters

    • action_name: string

      the name of the action to query

    Returns GLib.VariantType<any>

  • Requests a hint about the valid range of values for the state of the named action within action_group.

    If NULL is returned it either means that the action is not stateful or that there is no hint about the valid range of values for the state of the action.

    If a GLib.Variant array is returned then each item in the array is a possible value for the state. If a GLib.Variant pair (ie: two-tuple) is returned then the tuple specifies the inclusive lower and upper bound of valid values for the state.

    In any case, the information is merely a hint. It may be possible to have a state value outside of the hinted range and setting a value within the range may fail.

    The return value (if non-NULL) should be freed with GLib.Variant.unref when it is no longer required.

    Parameters

    • action_name: string

      the name of the action to query

    Returns GLib.Variant<any>

  • Emits the Gtk.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 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 Gtk.Widget.child_focus on the widget’s toplevel.

    The default Gtk.Widget::keynav-failed handler returns false for Gtk.DirectionType.TAB-FORWARD and Gtk.DirectionType.TAB-BACKWARD. For the other values of Gtk.DirectionType it returns true.

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

    Parameters

    Returns boolean

  • Emits a "notify" signal for the property property_name on object.

    When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.

    Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.

    Parameters

    Returns void

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

    Parameters

    • x: number
    • y: number
    • keyboard_tooltip: boolean
    • tooltip: Gtk.Tooltip

    Returns boolean

  • 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 Gtk.Widget::realize.

    Returns void

  • Removes the named action from the action map.

    If no action of this name is in the map then nothing happens.

    Parameters

    • action_name: string

      the name of the action

    Returns void

  • the generic setter for all properties of this type. Should be overridden for every type with properties. If implementations of set_property don't emit property change notification explicitly, this will be done implicitly by the type system. However, if the notify signal is emitted explicitly, the type system will not emit it a second time.

    Parameters

    Returns void

  • 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.

    Returns void

  • This function essentially limits the life time of the closure to the life time of the object. That is, when the object is finalized, the closure is invalidated by calling g_closure_invalidate() on it, in order to prevent invocations of the closure with a finalized (nonexisting) object. Also, g_object_ref() and g_object_unref() are added as marshal guards to the closure, to ensure that an extra reference count is held on object during invocation of the closure. Usually, this function will be called on closures that use this object as closure data.

    Parameters

    Returns void

Methods - Inherited from Gtk.Window

  • Requests the user's screen reader to announce the given message.

    This kind of notification is useful for messages that either have only a visual representation or that are not exposed visually at all, e.g. a notification about a successful operation.

    Also, by using this API, you can ensure that the message does not interrupts the user's current screen reader output.

    Parameters

    Returns void

  • Requests that the window is closed.

    This is similar to what happens when a window manager close button is clicked.

    This function can be used with close buttons in custom titlebars.

    Returns void

  • Asks to place the window in the fullscreen state.

    Note that you shouldn’t assume the window is definitely fullscreen afterward, because other entities (e.g. the user or window manager) unfullscreen it again, and not all window managers honor requests to fullscreen windows.

    If a window is not explicitly fullscreened or unfullscreened before it is shown, the initial state is at the window managers discretion.

    You can track the result of this operation via the Gdk.Toplevel.state property, or by listening to notifications of the Gtk.Window.fullscreened property.

    Returns void

  • Asks to place the window in the fullscreen state on the given monitor.

    Note that you shouldn't assume the window is definitely fullscreen afterward, or that the windowing system allows fullscreen windows on any given monitor.

    You can track the result of this operation via the Gdk.Toplevel.state property, or by listening to notifications of the Gtk.Window.fullscreened property.

    Parameters

    • monitor: Gdk.Monitor

      which monitor to go fullscreen on

    Returns void

  • Queries the coordinates and dimensions of this accessible

    This functionality can be overridden by Gtk.Accessible implementations, e.g. to get the bounds from an ignored child widget.

    Returns [boolean, number, number, number, number]

    true if the bounds are valid, and false otherwise

  • Returns whether the window has been set to have a close button.

    Returns boolean

    true if the window has been set to have a close button

  • Gets whether “focus rectangles” are supposed to be visible.

    Returns boolean

    true if “focus rectangles” are supposed to be visible in this window

  • Returns whether the window will be hidden instead of destroyed when the close button is clicked.

    Returns boolean

    true if the window will be hidden

  • Returns whether the window is modal.

    Returns boolean

    true if the window is set to be modal and establishes a grab when shown

  • Retrieves the current fullscreen state of the window.

    Note that since fullscreening is ultimately handled by the window manager and happens asynchronously to an application request, you shouldn’t assume the return value of this function changing immediately (or at all), as an effect of calling Gtk.Window.fullscreen or Gtk.Window.unfullscreen.

    If the window isn't yet mapped, the value returned will whether the initial requested state is fullscreen.

    Returns boolean

    whether the window is fullscreen

  • Retrieves the current maximized state of the window.

    Note that since maximization is ultimately handled by the window manager and happens asynchronously to an application request, you shouldn’t assume the return value of this function changing immediately (or at all), as an effect of calling Gtk.Window.maximize or Gtk.Window.unmaximize.

    If the window isn't yet mapped, the value returned will whether the initial requested state is maximized.

    Returns boolean

    whether the window is maximized

  • Retrieves the current suspended state of the window.

    A window being suspended means it's currently not visible to the user, for example by being on a inactive workspace, minimized, obstructed.

    Returns boolean

    whether the window is suspended

  • Asks to maximize the window, so that it fills the screen.

    Note that you shouldn’t assume the window is definitely maximized afterward, because other entities (e.g. the user or window manager) could unmaximize it again, and not all window managers support maximization.

    It’s permitted to call this function before showing a window, in which case the window will be maximized when it appears onscreen initially.

    If a window is not explicitly maximized or unmaximized before it is shown, the initial state is at the window managers discretion. For example, it might decide to maximize a window that almost fills the screen.

    You can track the result of this operation via the Gdk.Toplevel.state property, or by listening to notifications on the Gtk.Window.maximized property.

    Returns void

  • Asks to minimize the window.

    Note that you shouldn’t assume the window is definitely minimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager) could unminimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.

    It’s permitted to call this function before showing a window, in which case the window will be minimized before it ever appears onscreen.

    You can track result of this operation via the Gdk.Toplevel.state property.

    Returns void

  • Presents a window to the user.

    This may mean raising the window in the stacking order, unminimizing it, moving it to the current desktop and/or giving it the keyboard focus (possibly dependent on the user’s platform, window manager and preferences).

    If window is hidden, this function also makes it visible.

    Returns void

  • Presents a window to the user in response to an user interaction.

    See Gtk.Window.present for more details.

    The timestamp should be gathered when the window was requested to be shown (when clicking a link for example), rather than once the window is ready to be shown.

    Parameters

    • timestamp: number

      the timestamp of the user interaction (typically a button or key press event) which triggered this call

    Returns void

  • Sets the parent and sibling of an accessible object.

    This function is meant to be used by accessible implementations that are not part of the widget hierarchy, and but act as a logical bridge between widgets. For instance, if a widget creates an object that holds metadata for each child, and you want that object to implement the Gtk.Accessible interface, you will use this function to ensure that the parent of each child widget is the metadata object, and the parent of each metadata object is the container widget.

    Parameters

    Returns void

  • Sets whether the window should be decorated.

    By default, windows are decorated with a title bar, resize controls, etc. Some window managers allow GTK to disable these decorations, creating a borderless window. If you set the decorated property to false using this function, GTK will do its best to convince the window manager not to decorate the window. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling Gtk.Widget.show.

    On Windows, this function always works, since there’s no window manager policy involved.

    Parameters

    • setting: boolean

      true to decorate the window

    Returns void

  • Sets the default size of a window.

    The default size of a window is the size that will be used if no other constraints apply.

    The default size will be updated whenever the window is resized to reflect the new size, unless the window is forced to a size, like when it is maximized or fullscreened.

    If the window’s minimum size request is larger than the default, the default will be ignored.

    Setting the default size to a value <= 0 will cause it to be ignored and the natural size request will be used instead. It is possible to do this while the window is showing to "reset" it to its initial size.

    Unlike Gtk.Widget.set_size_request, which sets a size request for a widget and thus would keep users from shrinking the window, this function only sets the initial size, just as if the user had resized the window themselves. Users can still shrink the window again as they normally would. Setting a default size of -1 means to use the “natural” default size (the size request of the window).

    If you use this function to reestablish a previously saved window size, note that the appropriate size to save is the one returned by Gtk.Window.get_default_size. Using the window allocation directly will not work in all circumstances and can lead to growing or shrinking windows.

    Parameters

    • width: number

      width in pixels, or -1 to unset the default width

    • height: number

      height in pixels, or -1 to unset the default height

    Returns void

  • Sets whether the window should be deletable.

    By default, windows have a close button in the window frame. Some window managers allow GTK to disable this button. If you set the deletable property to false using this function, GTK will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling Gtk.Widget.show.

    On Windows, this function always works, since there’s no window manager policy involved.

    Parameters

    • setting: boolean

      true to decorate the window as deletable

    Returns void

  • Sets whether to destroy the window when the transient parent is destroyed.

    This is useful for dialogs that shouldn’t persist beyond the lifetime of the main window they are associated with, for example.

    Parameters

    • setting: boolean

      whether to destroy the window with its transient parent

    Returns void

  • Sets whether “focus rectangles” are supposed to be visible.

    This property is maintained by GTK based on user input, and should not be set by applications.

    Parameters

    • setting: boolean

      the new value

    Returns void

  • Sets whether this window should react to F10 presses by activating a menubar it contains.

    Parameters

    • handle_menubar_accel: boolean

      true to make window handle F10

    Returns void

  • Sets whether clicking the close button will hide the window instead of destroying it.

    Parameters

    • setting: boolean

      whether to hide the window when it is closed

    Returns void

  • Sets the icon for the window from a named themed icon.

    See the docs for Gtk.IconTheme for more details. On some platforms, the window icon is not used at all.

    Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.

    Parameters

    • Optionalname: string

      the name of the themed icon

    Returns void

  • Sets whether mnemonics are supposed to be visible.

    This property is maintained by GTK based on user input, and should not be set by applications.

    Parameters

    • setting: boolean

      the new value

    Returns void

  • Sets a window modal or non-modal.

    Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use Gtk.Window.set_transient_for to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.

    Parameters

    • modal: boolean

      whether the window is modal

    Returns void

  • Sets whether the user can resize a window.

    Windows are user resizable by default.

    Parameters

    • resizable: boolean

      true if the user can resize this window

    Returns void

  • Sets the startup notification ID.

    Startup notification identifiers are used by desktop environment to track application startup, to provide user feedback and other features. This function changes the corresponding property on the underlying Gdk.Surface.

    Normally, startup identifier is managed automatically and you should only use this function in special cases like transferring focus from other processes. You should use this function before calling Gtk.Window.present or any equivalent function generating a window map event.

    This function is only useful on Wayland or X11, not with other GDK backends.

    Parameters

    • startup_id: string

      a string with startup-notification identifier

    Returns void

  • Sets the title of the window.

    The title of a window will be displayed in its title bar; on the X Window System, the title bar is rendered by the window manager so exactly how the title appears to users may vary according to a user’s exact configuration. The title should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document filename, for example.

    Passing NULL does the same as setting the title to an empty string.

    Parameters

    • Optionaltitle: string

      title of the window

    Returns void

  • Sets a custom titlebar for the window.

    A typical widget used here is Gtk.HeaderBar, as it provides various features expected of a titlebar while allowing the addition of child widgets to it.

    If you set a custom titlebar, GTK will do its best to convince the window manager not to put its own titlebar on the window. Depending on the system, this function may not work for a window that is already visible, so you set the titlebar before calling Gtk.Widget.show.

    Parameters

    • Optionaltitlebar: Gtk.Widget

      the widget to use as titlebar

    Returns void

  • Sets a transient parent for the window.

    Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window. Gtk.Dialog.new_with_buttons and other convenience functions in GTK will sometimes call this function on your behalf.

    Passing NULL for parent unsets the current transient window.

    On Windows, this function puts the child window on top of the parent, much as the window manager would have done on X.

    Parameters

    Returns void

  • Asks to remove the fullscreen state for the window, and return to its previous state.

    Note that you shouldn’t assume the window is definitely not fullscreen afterward, because other entities (e.g. the user or window manager) could fullscreen it again, and not all window managers honor requests to unfullscreen windows; normally the window will end up restored to its normal state. Just don’t write code that crashes if not.

    If a window is not explicitly fullscreened or unfullscreened before it is shown, the initial state is at the window managers discretion.

    You can track the result of this operation via the Gdk.Toplevel.state property, or by listening to notifications of the Gtk.Window.fullscreened property.

    Returns void

  • Asks to unmaximize the window.

    Note that you shouldn’t assume the window is definitely unmaximized afterward, because other entities (e.g. the user or window manager) maximize it again, and not all window managers honor requests to unmaximize.

    If a window is not explicitly maximized or unmaximized before it is shown, the initial state is at the window managers discretion. For example, it might decide to maximize a window that almost fills the screen.

    You can track the result of this operation via the Gdk.Toplevel.state property, or by listening to notifications on the Gtk.Window.maximized property.

    Returns void

  • Asks to unminimize the window.

    Note that you shouldn’t assume the window is definitely unminimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager) could minimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.

    You can track result of this operation via the Gdk.Toplevel.state property.

    Returns void

  • Updates an array of accessible states.

    This function should be called by Gtk.Widget types whenever an accessible state change must be communicated to assistive technologies.

    This function is meant to be used by language bindings.

    Parameters

    • states: Gtk.AccessibleState[]

      an array of accessible states

    • values: any[]

      an array of GValues, one for each state

    Returns void

  • Parameters

    • name: string

      ID of the child defined in the template XML

    • internal_child: boolean

      whether the child should be accessible as an “internal-child” when this class is used in GtkBuilder XML

    • struct_offset: number

      The offset into the composite widget’s instance public or private structure where the automated child pointer should be set, or 0 to not assign the pointer

    Returns void

  • Returns the list of all existing toplevel windows.

    If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets or add new ones, be aware that the list of toplevels will change and emit the "items-changed" signal.

    Returns Gio.ListModel

  • Parameters

    • action_name: string

      name of the action

    • property_name: string

      name of a property in instances of widget_class or any parent class

    Returns void

  • Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created GObject.ParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property.

    This function is meant to be called from the interface's default vtable initialization function (the class_init member of GObject.TypeInfo.) It must not be called after after class_init has been called for any object types implementing this interface.

    If pspec is a floating reference, it will be consumed.

    Parameters

    Returns void

  • Returns the list of all existing toplevel windows.

    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.

    Returns Gtk.Widget[]

  • Parameters

    • property_id: number

      the new property ID

    • name: string

      the name of a property registered in a parent class or in an interface of this class.

    Returns void

  • Sets whether the window should request startup notification.

    By default, after showing the first window, GTK calls Gdk.Toplevel.set_startup_id. Call this function to disable the automatic startup notification. You might do this if your first window is a splash screen, and you want to delay notification until after your real main window has been shown, for example.

    In that example, you would disable startup notification temporarily, show your splash screen, then re-enable it so that showing the main window would automatically result in notification.

    Parameters

    • setting: boolean

      true to automatically do startup notification

    Returns void

  • Opens or closes the interactive debugger.

    The debugger offers access to the widget hierarchy of the application and to useful debugging tools.

    This function allows applications that already use Ctrl+Shift+I (or Ctrl+Shift+D) for their own key shortcuts to add a different shortcut to open the Inspector.

    If you are not overriding the default key shortcuts for the Inspector, you should not use this function.

    Parameters

    • enable: boolean

      true to enable interactive debugging

    Returns void

Interfaces

ConstructorProps
SignalSignatures