class Gtk::Window

Overview

A Gtk::Window is 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 element.

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_ACCESSIBLE_ROLE_WINDOW role.

Actions

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

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 renderer, surface : Gdk::Surface 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_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, 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, 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=, children : Iterator(Widget) children, clipboard : Gdk::Clipboard clipboard, 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, 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=, 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(x : Int32, y : Int32, width : Int32, height : Int32, baseline : Int32)
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, template_child(widget_type : UInt64, name : String) : GObject::Object
template_child(name : String) : GObject::Object
template_child
, 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, 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_role : Gtk::AccessibleRole accessible_role, accessible_role=(value : Gtk::AccessibleRole) : Gtk::AccessibleRole accessible_role=, reset_property(property : Gtk::AccessibleProperty) : Nil reset_property, reset_relation(relation : Gtk::AccessibleRelation) : Nil reset_relation, reset_state(state : Gtk::AccessibleState) : Nil reset_state, to_unsafe to_unsafe, 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 (no window borders), use Gtk::Window#decorated=.

All top-level windows created by gtk_window_new() 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, gtk_window_new() does not return a reference to the caller.

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


[View source]
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, 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, 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) #

[View source]

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 Gtk::Window, GTK calls Gdk::Display#notify_startup_complete. 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.


[View source]
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=.


[View source]
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.


[View source]
def self.g_type : UInt64 #

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


[View source]
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.


[View source]
def self.list_toplevels : GLib::List #

Returns a 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.


[View source]
def self.toplevels : Gio::ListModel #

Returns a 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.


[View source]

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 #

[View source]
def activate_focus_signal #

[View source]
def application : Gtk::Application | Nil #

Gets the Gtk::Application associated with the window.


[View source]
def application=(application : Gtk::Application | Nil) : Nil #

Sets or unsets 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 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.


[View source]
def child : Gtk::Widget | Nil #

Gets the child widget of window.


[View source]
def child=(child : Gtk::Widget | Nil) : Nil #

Sets the child widget of window.


[View source]
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.


[View source]
def close_request_signal #

[View source]
def decorated : Bool #

Returns whether the window has been set to have decorations.


[View source]
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.


[View source]
def decorated? : Bool #

[View source]
def default_height : Int32 #

[View source]
def default_height=(value : Int32) : Int32 #

[View source]
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.


[View source]
def default_widget : Gtk::Widget | Nil #

Returns the default widget for window.


[View source]
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).


[View source]
def default_width : Int32 #

[View source]
def default_width=(value : Int32) : Int32 #

[View source]
def deletable : Bool #

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


[View source]
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.


[View source]
def deletable? : Bool #

[View source]
def destroy : Nil #

Drop the internal reference GTK holds on toplevel windows.


[View source]
def destroy_with_parent : Bool #

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


[View source]
def destroy_with_parent=(setting : Bool) : Nil #

If setting is true, then destroying the transient parent of window will also destroy window itself.

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


[View source]
def destroy_with_parent? : Bool #

[View source]
def display : Gdk::Display | Nil #
Description copied from class Gtk::Widget

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

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

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


[View source]
def display=(display : Gdk::Display) : Nil #

Sets the Gdk::Display where the window is displayed.

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


[View source]
def display=(value : Gdk::Display | Nil) : Gdk::Display | Nil #

[View source]
def enable_debugging_signal #

[View source]
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 true for the widget.


[View source]
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.


[View source]
def focus_visible : Bool #

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


[View source]
def focus_visible=(setting : Bool) : Nil #

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


[View source]
def focus_visible? : Bool #

[View source]
def focus_widget : Gtk::Widget | Nil #

[View source]
def focus_widget=(value : Gtk::Widget | Nil) : Gtk::Widget | Nil #

[View source]
def fullscreen : Nil #

Asks to place 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.


[View source]
def fullscreen_on_monitor(monitor : Gdk::Monitor) : Nil #

Asks to place 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.


[View source]
def fullscreened=(value : Bool) : Bool #

[View source]
def fullscreened? : Bool #

[View source]
def group : Gtk::WindowGroup #

Returns the group for window.

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


[View source]
def handle_menubar_accel : Bool #

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


[View source]
def handle_menubar_accel=(handle_menubar_accel : Bool) : Nil #

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


[View source]
def handle_menubar_accel? : Bool #

[View source]
def has_group : Bool #

Returns whether window has an explicit window group.


[View source]
def hash(hasher) #
Description copied from class Reference

See Object#hash(hasher)


def hide_on_close : Bool #

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


[View source]
def hide_on_close=(setting : Bool) : Nil #

If setting is true, then clicking the close button on the window will not destroy it, but only hide it.


[View source]
def hide_on_close? : Bool #

[View source]
def icon_name : String | Nil #

Returns the name of the themed icon for the window.


[View source]
def icon_name=(value : String) : String #

[View source]
def icon_name=(value : Nil) : Nil #

Set #icon_name property to nil.


[View source]
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.


[View source]
def icon_name? : String | Nil #

Same as #icon_name, but can return nil.


[View source]
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.


[View source]
def is_fullscreen : Bool #

Retrieves the current fullscreen state of 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.


[View source]
def is_maximized : Bool #

Retrieves the current maximized state of 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.


[View source]
def keys_changed_signal #

[View source]
def maximize : Nil #

Asks to maximize 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.


[View source]
def maximized=(value : Bool) : Bool #

[View source]
def maximized? : Bool #

[View source]
def minimize : Nil #

Asks to minimize the specified 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.


[View source]
def mnemonics_visible : Bool #

Gets whether mnemonics are supposed to be visible.


[View source]
def mnemonics_visible=(setting : Bool) : Nil #

Sets whether mnemonics are supposed to be visible.


[View source]
def mnemonics_visible? : Bool #

[View source]
def modal : Bool #

Returns whether the window is modal.


[View source]
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.


[View source]
def modal? : Bool #

[View source]
def present : Nil #

Presents a window to the user.

This function should not be used as when it is called, it is too late to gather a valid timestamp to allow focus stealing prevention to work correctly.


[View source]
def present_with_time(timestamp : UInt32) : 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 calls Gtk::Widget#show as well.

This function should be used when the user tries to open a window that’s already open. Say for example the preferences dialog is currently open, and the user chooses Preferences from the menu a second time; use Gtk::Window#present to move the already-open dialog where the user can see it.

Presents a window to the user in response to a user interaction. 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.


[View source]
def resizable : Bool #

Gets the value set by gtk_window_set_resizable().


[View source]
def resizable=(resizable : Bool) : Nil #

Sets whether the user can resize a window.

Windows are user resizable by default.


[View source]
def resizable? : Bool #

[View source]
def set_default_size(width : Int32, height : Int32) : Nil #

Sets the default size of a window.

If the window’s “natural” size (its size request) is larger than the default, the default will be ignored.

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

The default size of a window only affects the first time a window is shown; if a window is hidden and re-shown, it will remember the size it had prior to hiding, rather than using the default size.

Windows can’t actually be 0x0 in size, they must be at least 1x1, but passing 0 for width and height is OK, resulting in a 1x1 default size.

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.


[View source]
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.


[View source]
def startup_id=(value : Nil) : Nil #

Set #startup_id property to nil.


[View source]
def title : String | Nil #

Retrieves the title of the window.


[View source]
def title=(value : String) : String #

[View source]
def title=(value : Nil) : Nil #

Set #title property to nil.


[View source]
def title=(title : String | Nil) : Nil #

Sets the title of the Gtk::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 nil does the same as setting the title to an empty string.


[View source]
def title? : String | Nil #

Same as #title, but can return nil.


[View source]
def titlebar : Gtk::Widget | Nil #

Returns the custom titlebar that has been set with gtk_window_set_titlebar().


[View source]
def titlebar=(titlebar : Gtk::Widget | Nil) : Nil #

Sets a custom titlebar for 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.


[View source]
def transient_for : Gtk::Window | Nil #

Fetches the transient parent for this window.


[View source]
def transient_for=(parent : Gtk::Window | Nil) : Nil #

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 gtk_window_set_transient_for() on your behalf.

Passing nil 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.


[View source]
def unfullscreen : Nil #

Asks to remove the fullscreen state for 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.


[View source]
def unmaximize : Nil #

Asks to unmaximize 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.


[View source]
def unminimize : Nil #

Asks to unminimize the specified 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.


[View source]