class Gtk::Window

Overview

A toplevel window which can contain other widgets.

An example Gtk::Window

Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it,...).

Gtk::Window as Gtk::Buildable

The Gtk::Window implementation of the Gtk::Buildable interface supports setting a child as the titlebar by specifying “titlebar” as the “type” attribute of a <child> element.

Shortcuts and Gestures

Gtk::Window supports the following keyboard shortcuts:

The following signals have default keybindings:

Actions

Gtk::Window defines a set of built-in actions:

CSS nodes

window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled]
├── <child>
╰── <titlebar child>.titlebar [.default-decoration]

Gtk::Window has a main CSS node with name window and style class .background.

Style classes that are typically used with the main CSS node are .csd (when client-side decorations are in use), .solid-csd (for client-side decorations without invisible borders), .ssd (used by mutter when rendering server-side decorations). Gtk::Window also represents window states with the following style classes on the main node: .maximized, .fullscreen, .tiled (when supported, also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom).

Gtk::Window subclasses often add their own discriminating style classes, such as .dialog, .popup or .tooltip.

Generally, some CSS properties don't make sense on the toplevel window node, such as margins or padding. When client-side decorations without invisible borders are in use (i.e. the .solid-csd style class is added to the main window node), the CSS border of the toplevel window is used for resize drags. In the .csd case, the shadow area outside of the window can be used to resize it.

Gtk::Window adds the .titlebar and .default-decoration style classes to the widget that is added as a titlebar child.

Accessibility

Gtk::Window uses the Gtk::AccessibleRole#window role.

From GTK 4.12 to 4.18, it used the Gtk::AccessibleRole#application role.

Included Modules

Direct Known Subclasses

Defined in:

lib/gi-crystal/src/auto/gtk-4.0/window.cr

Constructors

Class Method Summary

Instance Method Summary

Instance methods inherited from module Gtk::ShortcutManager

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ShortcutManager

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ShortcutManager

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Root

display : Gdk::Display display, focus : Gtk::Widget | Nil focus, focus=(focus : Gtk::Widget | Nil) : Nil focus=, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Root

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Root

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Native

realize : Nil realize, renderer : Gsk::Renderer | Nil renderer, surface : Gdk::Surface | Nil surface, surface_transform(x : Float64, y : Float64) : Nil surface_transform, to_unsafe to_unsafe, unrealize : Nil unrealize

Constructor methods inherited from module Gtk::Native

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Native

cast?(obj : GObject::Object) : self | Nil cast?, for_surface(surface : Gdk::Surface) : Gtk::Native | Nil for_surface, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_parent : Gtk::Accessible | Nil accessible_parent, accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, announce(message : String, priority : Gtk::AccessibleAnnouncementPriority) : Nil announce, at_context : Gtk::ATContext at_context, bounds(x : Int32, y : Int32, width : Int32, height : Int32) : Bool bounds, first_accessible_child : Gtk::Accessible | Nil first_accessible_child, next_accessible_sibling : Gtk::Accessible | Nil next_accessible_sibling, platform_state(state : Gtk::AccessiblePlatformState) : Bool platform_state, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, set_accessible_parent(parent : Gtk::Accessible | Nil, next_sibling : Gtk::Accessible | Nil) : Nil set_accessible_parent, to_unsafe to_unsafe, update_next_accessible_sibling(new_sibling : Gtk::Accessible | Nil) : Nil update_next_accessible_sibling, update_platform_state(state : Gtk::AccessiblePlatformState) : Nil update_platform_state, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class Gtk::Widget

==(other : self) ==, action_set_enabled(action_name : String, enabled : Bool) : Nil action_set_enabled, activate : Bool activate, activate_action(name : String, args : _ | Nil) : Bool activate_action, activate_default : Nil activate_default, add_controller(controller : Gtk::EventController) : Nil add_controller, add_css_class(css_class : String) : Nil add_css_class, add_mnemonic_label(label : Gtk::Widget) : Nil add_mnemonic_label, add_tick_callback(callback : Gtk::TickCallback) : UInt32 add_tick_callback, allocate(width : Int32, height : Int32, baseline : Int32, transform : Gsk::Transform | Nil) : Nil allocate, allocated_baseline : Int32 allocated_baseline, allocated_height : Int32 allocated_height, allocated_width : Int32 allocated_width, allocation : Gdk::Rectangle allocation, ancestor(widget_type : UInt64) : Gtk::Widget | Nil ancestor, baseline : Int32 baseline, can_focus : Bool can_focus, can_focus=(can_focus : Bool) : Nil can_focus=, can_focus? : Bool can_focus?, can_target : Bool can_target, can_target=(can_target : Bool) : Nil can_target=, can_target? : Bool can_target?, child_focus(direction : Gtk::DirectionType) : Bool child_focus, child_visible : Bool child_visible, child_visible=(child_visible : Bool) : Nil child_visible=, clipboard : Gdk::Clipboard clipboard, color : Gdk::RGBA color, compute_bounds(target : Gtk::Widget) : Graphene::Rect compute_bounds, compute_expand(orientation : Gtk::Orientation) : Bool compute_expand, compute_point(target : Gtk::Widget, point : Graphene::Point) : Graphene::Point compute_point, compute_transform(target : Gtk::Widget) : Graphene::Matrix compute_transform, contains(x : Float64, y : Float64) : Bool contains, create_pango_context : Pango::Context create_pango_context, create_pango_layout(text : String | Nil) : Pango::Layout create_pango_layout, css_classes : Enumerable(String) css_classes, css_classes=(classes : Enumerable(String)) : Nil css_classes=, css_name : String css_name, css_name=(value : String) : String
css_name=(value : Nil) : Nil
css_name=
, css_name? : String | Nil css_name?, cursor : Gdk::Cursor | Nil cursor, cursor=(cursor : Gdk::Cursor | Nil) : Nil cursor=, cursor_from_name=(name : String | Nil) : Nil cursor_from_name=, destroy_signal destroy_signal, direction : Gtk::TextDirection direction, direction=(dir : Gtk::TextDirection) : Nil direction=, direction_changed_signal direction_changed_signal, display : Gdk::Display display, dispose_template(widget_type : UInt64) : Nil dispose_template, drag_check_threshold(start_x : Int32, start_y : Int32, current_x : Int32, current_y : Int32) : Bool drag_check_threshold, error_bell : Nil error_bell, first_child : Gtk::Widget | Nil first_child, focus_child : Gtk::Widget | Nil focus_child, focus_child=(child : Gtk::Widget | Nil) : Nil focus_child=, focus_on_click : Bool focus_on_click, focus_on_click=(focus_on_click : Bool) : Nil focus_on_click=, focus_on_click? : Bool focus_on_click?, focusable : Bool focusable, focusable=(focusable : Bool) : Nil focusable=, focusable? : Bool focusable?, font_map : Pango::FontMap | Nil font_map, font_map=(font_map : Pango::FontMap | Nil) : Nil font_map=, font_options : Cairo::FontOptions | Nil font_options, font_options=(options : Cairo::FontOptions | Nil) : Nil font_options=, frame_clock : Gdk::FrameClock | Nil frame_clock, grab_focus : Bool grab_focus, halign : Gtk::Align halign, halign=(align : Gtk::Align) : Nil halign=, has_css_class(css_class : String) : Bool has_css_class, has_default : Bool has_default, has_default? : Bool has_default?, has_focus : Bool has_focus, has_focus? : Bool has_focus?, has_tooltip : Bool has_tooltip, has_tooltip=(has_tooltip : Bool) : Nil has_tooltip=, has_tooltip? : Bool has_tooltip?, has_visible_focus : Bool has_visible_focus, hash(hasher) hash, height : Int32 height, height_request : Int32 height_request, height_request=(value : Int32) : Int32 height_request=, hexpand : Bool hexpand, hexpand=(expand : Bool) : Nil hexpand=, hexpand? : Bool hexpand?, hexpand_set : Bool hexpand_set, hexpand_set=(set : Bool) : Nil hexpand_set=, hexpand_set? : Bool hexpand_set?, hide : Nil hide, hide_signal hide_signal, in_destruction : Bool in_destruction, init_template : Nil init_template, insert_action_group(name : String, group : Gio::ActionGroup | Nil) : Nil insert_action_group, insert_after(parent : Gtk::Widget, previous_sibling : Gtk::Widget | Nil) : Nil insert_after, insert_before(parent : Gtk::Widget, next_sibling : Gtk::Widget | Nil) : Nil insert_before, is_ancestor(ancestor : Gtk::Widget) : Bool is_ancestor, is_drawable : Bool is_drawable, is_focus : Bool is_focus, is_sensitive? : Bool is_sensitive?, is_visible? : Bool is_visible?, keynav_failed(direction : Gtk::DirectionType) : Bool keynav_failed, keynav_failed_signal keynav_failed_signal, last_child : Gtk::Widget | Nil last_child, layout_manager : Gtk::LayoutManager | Nil layout_manager, layout_manager=(layout_manager : Gtk::LayoutManager | Nil) : Nil layout_manager=, limit_events : Bool limit_events, limit_events=(limit_events : Bool) : Nil limit_events=, limit_events? : Bool limit_events?, list_mnemonic_labels : GLib::List list_mnemonic_labels, map : Nil map, map_signal map_signal, mapped : Bool mapped, margin_bottom : Int32 margin_bottom, margin_bottom=(margin : Int32) : Nil margin_bottom=, margin_end : Int32 margin_end, margin_end=(margin : Int32) : Nil margin_end=, margin_start : Int32 margin_start, margin_start=(margin : Int32) : Nil margin_start=, margin_top : Int32 margin_top, margin_top=(margin : Int32) : Nil margin_top=, measure(orientation : Gtk::Orientation, for_size : Int32) : Nil measure, mnemonic_activate(group_cycling : Bool) : Bool mnemonic_activate, mnemonic_activate_signal mnemonic_activate_signal, move_focus_signal move_focus_signal, name : String name, name=(name : String) : Nil
name=(value : Nil) : Nil
name=
, name? : String | Nil name?, native : Gtk::Native | Nil native, next_sibling : Gtk::Widget | Nil next_sibling, observe_children : Gio::ListModel observe_children, observe_controllers : Gio::ListModel observe_controllers, opacity : Float64 opacity, opacity=(opacity : Float64) : Nil opacity=, overflow : Gtk::Overflow overflow, overflow=(overflow : Gtk::Overflow) : Nil overflow=, pango_context : Pango::Context pango_context, parent : Gtk::Widget | Nil parent, parent=(parent : Gtk::Widget) : Nil parent=, pick(x : Float64, y : Float64, flags : Gtk::PickFlags) : Gtk::Widget | Nil pick, preferred_size : Gtk::Requisition preferred_size, prev_sibling : Gtk::Widget | Nil prev_sibling, primary_clipboard : Gdk::Clipboard primary_clipboard, query_tooltip_signal query_tooltip_signal, queue_allocate : Nil queue_allocate, queue_draw : Nil queue_draw, queue_resize : Nil queue_resize, realize : Nil realize, realize_signal realize_signal, realized : Bool realized, receives_default : Bool receives_default, receives_default=(receives_default : Bool) : Nil receives_default=, receives_default? : Bool receives_default?, remove_controller(controller : Gtk::EventController) : Nil remove_controller, remove_css_class(css_class : String) : Nil remove_css_class, remove_mnemonic_label(label : Gtk::Widget) : Nil remove_mnemonic_label, remove_tick_callback(id : UInt32) : Nil remove_tick_callback, request_mode : Gtk::SizeRequestMode request_mode, root : Gtk::Root | Nil root, scale_factor : Int32 scale_factor, sensitive : Bool sensitive, sensitive=(sensitive : Bool) : Nil sensitive=, sensitive? : Bool sensitive?, set_size_request(width : Int32, height : Int32) : Nil set_size_request, set_state_flags(flags : Gtk::StateFlags, clear : Bool) : Nil set_state_flags, settings : Gtk::Settings settings, should_layout : Bool should_layout, show : Nil show, show_signal show_signal, size(orientation : Gtk::Orientation) : Int32 size, size_allocate(allocation : Gdk::Rectangle, baseline : Int32) : Nil size_allocate, size_request : Nil size_request, snapshot_child(child : Gtk::Widget, snapshot : Gtk::Snapshot) : Nil snapshot_child, state_flags : Gtk::StateFlags state_flags, state_flags_changed_signal state_flags_changed_signal, style_context : Gtk::StyleContext style_context, tooltip_markup : String | Nil tooltip_markup, tooltip_markup=(value : String) : String
tooltip_markup=(value : Nil) : Nil
tooltip_markup=(markup : String | Nil) : Nil
tooltip_markup=
, tooltip_markup? : String | Nil tooltip_markup?, tooltip_text : String | Nil tooltip_text, tooltip_text=(value : String) : String
tooltip_text=(value : Nil) : Nil
tooltip_text=(text : String | Nil) : Nil
tooltip_text=
, tooltip_text? : String | Nil tooltip_text?, translate_coordinates(dest_widget : Gtk::Widget, src_x : Float64, src_y : Float64) : Bool translate_coordinates, trigger_tooltip_query : Nil trigger_tooltip_query, unmap : Nil unmap, unmap_signal unmap_signal, unparent : Nil unparent, unrealize : Nil unrealize, unrealize_signal unrealize_signal, unset_state_flags(flags : Gtk::StateFlags) : Nil unset_state_flags, valign : Gtk::Align valign, valign=(align : Gtk::Align) : Nil valign=, vexpand : Bool vexpand, vexpand=(expand : Bool) : Nil vexpand=, vexpand? : Bool vexpand?, vexpand_set : Bool vexpand_set, vexpand_set=(set : Bool) : Nil vexpand_set=, vexpand_set? : Bool vexpand_set?, visible : Bool visible, visible=(visible : Bool) : Nil visible=, visible? : Bool visible?, width : Int32 width, width_request : Int32 width_request, width_request=(value : Int32) : Int32 width_request=

Constructor methods inherited from class Gtk::Widget

new
new(*, accessible_role : Gtk::AccessibleRole | Nil = nil, can_focus : Bool | Nil = nil, can_target : Bool | Nil = nil, css_classes : Enumerable(String) | Nil = nil, css_name : String | Nil = nil, cursor : Gdk::Cursor | Nil = nil, focus_on_click : Bool | Nil = nil, focusable : Bool | Nil = nil, halign : Gtk::Align | Nil = nil, has_default : Bool | Nil = nil, has_focus : Bool | Nil = nil, has_tooltip : Bool | Nil = nil, height_request : Int32 | Nil = nil, hexpand : Bool | Nil = nil, hexpand_set : Bool | Nil = nil, layout_manager : Gtk::LayoutManager | Nil = nil, limit_events : Bool | Nil = nil, margin_bottom : Int32 | Nil = nil, margin_end : Int32 | Nil = nil, margin_start : Int32 | Nil = nil, margin_top : Int32 | Nil = nil, name : String | Nil = nil, opacity : Float64 | Nil = nil, overflow : Gtk::Overflow | Nil = nil, parent : Gtk::Widget | Nil = nil, receives_default : Bool | Nil = nil, root : Gtk::Root | Nil = nil, scale_factor : Int32 | Nil = nil, sensitive : Bool | Nil = nil, tooltip_markup : String | Nil = nil, tooltip_text : String | Nil = nil, valign : Gtk::Align | Nil = nil, vexpand : Bool | Nil = nil, vexpand_set : Bool | Nil = nil, visible : Bool | Nil = nil, width_request : Int32 | Nil = nil)
new

Class methods inherited from class Gtk::Widget

default_direction : Gtk::TextDirection default_direction, default_direction=(dir : Gtk::TextDirection) : Nil default_direction=, g_type : UInt64 g_type

Instance methods inherited from module Gtk::ConstraintTarget

to_unsafe to_unsafe

Constructor methods inherited from module Gtk::ConstraintTarget

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::ConstraintTarget

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Buildable

buildable_id : String | Nil buildable_id, to_unsafe to_unsafe

Constructor methods inherited from module Gtk::Buildable

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Buildable

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from module Gtk::Accessible

accessible_parent : Gtk::Accessible | Nil accessible_parent, accessible_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, announce(message : String, priority : Gtk::AccessibleAnnouncementPriority) : Nil announce, at_context : Gtk::ATContext at_context, bounds(x : Int32, y : Int32, width : Int32, height : Int32) : Bool bounds, first_accessible_child : Gtk::Accessible | Nil first_accessible_child, next_accessible_sibling : Gtk::Accessible | Nil next_accessible_sibling, platform_state(state : Gtk::AccessiblePlatformState) : Bool platform_state, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, set_accessible_parent(parent : Gtk::Accessible | Nil, next_sibling : Gtk::Accessible | Nil) : Nil set_accessible_parent, to_unsafe to_unsafe, update_next_accessible_sibling(new_sibling : Gtk::Accessible | Nil) : Nil update_next_accessible_sibling, update_platform_state(state : Gtk::AccessiblePlatformState) : Nil update_platform_state, update_property(properties : Enumerable(Gtk::AccessibleProperty), values : Enumerable(_)) : Nil update_property, update_relation(relations : Enumerable(Gtk::AccessibleRelation), values : Enumerable(_)) : Nil update_relation, update_state(states : Enumerable(Gtk::AccessibleState), values : Enumerable(_)) : Nil update_state

Constructor methods inherited from module Gtk::Accessible

cast(obj : GObject::Object) : self cast

Class methods inherited from module Gtk::Accessible

cast?(obj : GObject::Object) : self | Nil cast?, g_type : UInt64 g_type

Instance methods inherited from class GObject::InitiallyUnowned

==(other : self) ==, hash(hasher) hash

Constructor methods inherited from class GObject::InitiallyUnowned

new new

Class methods inherited from class GObject::InitiallyUnowned

g_type : UInt64 g_type

Instance methods inherited from class GObject::Object

==(other : self) ==, bind_property(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags) : GObject::Binding bind_property, bind_property_full(source_property : String, target : GObject::Object, target_property : String, flags : GObject::BindingFlags, transform_to : GObject::Closure, transform_from : GObject::Closure) : GObject::Binding bind_property_full, data(key : String) : Pointer(Void) | Nil data, finalize finalize, freeze_notify : Nil freeze_notify, getv(names : Enumerable(String), values : Enumerable(_)) : Nil getv, hash(hasher) hash, notify(property_name : String) : Nil notify, notify_by_pspec(pspec : GObject::ParamSpec) : Nil notify_by_pspec, notify_signal notify_signal, property(property_name : String, value : _) : Nil property, qdata(quark : UInt32) : Pointer(Void) | Nil qdata, ref_count : UInt32 ref_count, run_dispose : Nil run_dispose, set_data(key : String, data : Pointer(Void) | Nil) : Nil set_data, set_property(property_name : String, value : _) : Nil set_property, steal_data(key : String) : Pointer(Void) | Nil steal_data, steal_qdata(quark : UInt32) : Pointer(Void) | Nil steal_qdata, thaw_notify : Nil thaw_notify, to_unsafe : Pointer(Void) to_unsafe, watch_closure(closure : GObject::Closure) : Nil watch_closure

Constructor methods inherited from class GObject::Object

cast(obj : GObject::Object) : self cast, new(pointer : Pointer(Void), transfer : GICrystal::Transfer)
new
new
, newv(object_type : UInt64, parameters : Enumerable(GObject::Parameter)) : self newv

Class methods inherited from class GObject::Object

cast?(obj : GObject::Object) : self | Nil cast?, compat_control(what : UInt64, data : Pointer(Void) | Nil) : UInt64 compat_control, g_type : UInt64 g_type, interface_find_property(g_iface : GObject::TypeInterface, property_name : String) : GObject::ParamSpec interface_find_property, interface_list_properties(g_iface : GObject::TypeInterface) : Enumerable(GObject::ParamSpec) interface_list_properties

Macros inherited from class GObject::Object

previous_vfunc(*args) previous_vfunc, previous_vfunc!(*args) previous_vfunc!, signal(signature) signal

Constructor Detail

def self.new : self #

Creates a new Gtk::Window.

To get an undecorated window (without window borders), use Gtk::Window#decorated=.

All top-level windows created by this function are stored in an internal top-level window list. This list can be obtained from Gtk::Window#list_toplevels. Due to GTK keeping a reference to the window internally, this function does not return a reference to the caller.

To delete a Gtk::Window, call Gtk::Window#destroy.


def self.new(*, accessible_role : Gtk::AccessibleRole | Nil = nil, application : Gtk::Application | Nil = nil, can_focus : Bool | Nil = nil, can_target : Bool | Nil = nil, child : Gtk::Widget | Nil = nil, css_classes : Enumerable(String) | Nil = nil, css_name : String | Nil = nil, cursor : Gdk::Cursor | Nil = nil, decorated : Bool | Nil = nil, default_height : Int32 | Nil = nil, default_widget : Gtk::Widget | Nil = nil, default_width : Int32 | Nil = nil, deletable : Bool | Nil = nil, destroy_with_parent : Bool | Nil = nil, display : Gdk::Display | Nil = nil, focus_on_click : Bool | Nil = nil, focus_visible : Bool | Nil = nil, focus_widget : Gtk::Widget | Nil = nil, focusable : Bool | Nil = nil, fullscreened : Bool | Nil = nil, halign : Gtk::Align | Nil = nil, handle_menubar_accel : Bool | Nil = nil, has_default : Bool | Nil = nil, has_focus : Bool | Nil = nil, has_tooltip : Bool | Nil = nil, height_request : Int32 | Nil = nil, hexpand : Bool | Nil = nil, hexpand_set : Bool | Nil = nil, hide_on_close : Bool | Nil = nil, icon_name : String | Nil = nil, is_active : Bool | Nil = nil, layout_manager : Gtk::LayoutManager | Nil = nil, limit_events : Bool | Nil = nil, margin_bottom : Int32 | Nil = nil, margin_end : Int32 | Nil = nil, margin_start : Int32 | Nil = nil, margin_top : Int32 | Nil = nil, maximized : Bool | Nil = nil, mnemonics_visible : Bool | Nil = nil, modal : Bool | Nil = nil, name : String | Nil = nil, opacity : Float64 | Nil = nil, overflow : Gtk::Overflow | Nil = nil, parent : Gtk::Widget | Nil = nil, receives_default : Bool | Nil = nil, resizable : Bool | Nil = nil, root : Gtk::Root | Nil = nil, scale_factor : Int32 | Nil = nil, sensitive : Bool | Nil = nil, startup_id : String | Nil = nil, suspended : Bool | Nil = nil, title : String | Nil = nil, titlebar : Gtk::Widget | Nil = nil, tooltip_markup : String | Nil = nil, tooltip_text : String | Nil = nil, transient_for : Gtk::Window | Nil = nil, valign : Gtk::Align | Nil = nil, vexpand : Bool | Nil = nil, vexpand_set : Bool | Nil = nil, visible : Bool | Nil = nil, width_request : Int32 | Nil = nil) #

Class Method Detail

def self.auto_startup_notification=(setting : Bool) : Nil #

Sets whether the window should request startup notification.

By default, after showing the first window, GTK calls Gdk::Toplevel#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.


def self.default_icon_name : String | Nil #

Returns the fallback icon name for windows.

The returned string is owned by GTK and should not be modified. It is only valid until the next call to Gtk::Window#default_icon_name=.


def self.default_icon_name=(name : String) : Nil #

Sets an icon to be used as fallback.

The fallback icon is used for windows that haven't had Gtk::Window#icon_name= called on them.


def self.g_type : UInt64 #

Returns the type id (GType) registered in GLib type system.


def self.interactive_debugging=(enable : Bool) : Nil #

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.


def self.list_toplevels : GLib::List #

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.


def self.toplevels : Gio::ListModel #

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.


Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns true if this reference is the same as other. Invokes same?.


def activate_default_signal #

def activate_focus_signal #

def application : Gtk::Application | Nil #

Gets the application object associated with the window.


def application=(application : Gtk::Application | Nil) : Nil #

Sets or unsets the application object associated with the window.

The application will be kept alive for at least as long as it has any windows associated with it (see Gio::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 application to nil.

This is equivalent to calling Gtk::Application#remove_window and/or Gtk::Application#add_window on the old/new applications as relevant.


def child : Gtk::Widget | Nil #

Gets the child widget of the window.


def child=(child : Gtk::Widget | Nil) : Nil #

Sets the child widget of the window.


def close : Nil #

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.


def close_request_signal #

def decorated : Bool #

Returns whether the window has been set to have decorations.


def decorated=(setting : Bool) : Nil #

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.


def decorated? : Bool #

def default_height : Int32 #

def default_height=(value : Int32) : Int32 #

def default_size : Nil #

Gets the default size of the window.

A value of 0 for the width or height indicates that a default size has not been explicitly set for that dimension, so the “natural” size of the window will be used.

This function is the recommended way for saving window state across restarts of applications.


def default_widget : Gtk::Widget | Nil #

Returns the default widget for window.


def default_widget=(default_widget : Gtk::Widget | Nil) : Nil #

Sets the default widget.

The default widget is the widget that is activated when the user presses Enter in a dialog (for example).


def default_width : Int32 #

def default_width=(value : Int32) : Int32 #

def deletable : Bool #

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


def deletable=(setting : Bool) : Nil #

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.


def deletable? : Bool #

def destroy : Nil #

Drops the internal reference GTK holds on toplevel windows.


def destroy_with_parent : Bool #

Returns whether the window will be destroyed with its transient parent.


def destroy_with_parent=(setting : Bool) : Nil #

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.


def destroy_with_parent? : Bool #

def display : Gdk::Display | Nil #
Description copied from class Gtk::Widget

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

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

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


def display=(display : Gdk::Display) : Nil #

Sets the display where the window is displayed.

If the window is already mapped, it will be unmapped, and then remapped on the new display.


def display=(value : Gdk::Display | Nil) : Gdk::Display | Nil #

def enable_debugging_signal #

def focus : Gtk::Widget | Nil #

Retrieves the current focused widget within the window.

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


def focus=(focus : Gtk::Widget | Nil) : Nil #

Sets the focus widget.

If focus is not the current focus widget, and is focusable, sets it as the focus widget for the window. If focus is nil, unsets the focus widget for this window. To set the focus to a particular widget in the toplevel, it is usually more convenient to use Gtk::Widget#grab_focus instead of this function.


def focus_visible : Bool #

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


def focus_visible=(setting : Bool) : Nil #

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.


def focus_visible? : Bool #

def focus_widget : Gtk::Widget | Nil #

def focus_widget=(value : Gtk::Widget | Nil) : Gtk::Widget | Nil #

def fullscreen : Nil #

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.

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.


def fullscreen_on_monitor(monitor : Gdk::Monitor) : Nil #

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.


def fullscreened=(value : Bool) : Bool #

def fullscreened? : Bool #

def group : Gtk::WindowGroup #

Returns the group for the window.

If the window has no group, then the default group is returned.


def handle_menubar_accel : Bool #

Returns whether this window reacts to F10 presses by activating a menubar it contains.


def handle_menubar_accel=(handle_menubar_accel : Bool) : Nil #

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


def handle_menubar_accel? : Bool #

def has_group : Bool #

Returns whether the window has an explicit window group.


def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def hide_on_close : Bool #

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


def hide_on_close=(setting : Bool) : Nil #

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


def hide_on_close? : Bool #

def icon_name : String | Nil #

Returns the name of the themed icon for the window.


def icon_name=(value : String) : String #

def icon_name=(value : Nil) : Nil #

Set #icon_name property to nil.


def icon_name=(name : String | Nil) : Nil #

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.


def icon_name? : String | Nil #

Same as #icon_name, but can return nil.


def is_active? : Bool #

Returns whether the window is part of the current active toplevel.

The active toplevel is the window receiving keystrokes.

The return value is true if the window is active toplevel itself. You might use this function if you wanted to draw a widget differently in an active window from a widget in an inactive window.


def is_fullscreen? : Bool #

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.


def is_maximized? : Bool #

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.


def is_suspended? : Bool #

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.


def keys_changed_signal #

def maximize : Nil #

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.

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.


def maximized=(value : Bool) : Bool #

def maximized? : Bool #

def minimize : Nil #

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.


def mnemonics_visible : Bool #

Gets whether mnemonics are supposed to be visible.


def mnemonics_visible=(setting : Bool) : Nil #

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.


def mnemonics_visible? : Bool #

def modal : Bool #

Returns whether the window is modal.


def modal=(modal : Bool) : Nil #

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#transient_for= to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.


def modal? : Bool #

def present : Nil #

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.


def present_with_time(timestamp : UInt32) : Nil #

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.

DEPRECATED


def resizable : Bool #

Gets whether the user can resize the window.


def resizable=(resizable : Bool) : Nil #

Sets whether the user can resize a window.

Windows are user resizable by default.


def resizable? : Bool #

def set_default_size(width : Int32, height : Int32) : Nil #

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#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#default_size. Using the window allocation directly will not work in all circumstances and can lead to growing or shrinking windows.


def startup_id=(startup_id : String) : Nil #

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 X11, not with other GTK targets.


def startup_id=(value : Nil) : Nil #

Set #startup_id property to nil.


def suspended? : Bool #

def title : String | Nil #

Retrieves the title of the window.


def title=(value : String) : String #

def title=(value : Nil) : Nil #

Set #title property to nil.


def title=(title : String | Nil) : Nil #

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.


def title? : String | Nil #

Same as #title, but can return nil.


def titlebar : Gtk::Widget | Nil #

Returns the titlebar that has been set with Gtk::Window#titlebar=.


def titlebar=(titlebar : Gtk::Widget | Nil) : Nil #

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.


def transient_for : Gtk::Window | Nil #

Fetches the transient parent for this window.


def transient_for=(parent : Gtk::Window | Nil) : Nil #

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.


def unfullscreen : Nil #

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.

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.


def unmaximize : Nil #

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.

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.


def unminimize : Nil #

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.