A toplevel window which can contain other widgets.
<picture> <source srcset="window-dark.png" media="(prefers-color-scheme: dark)"> <img alt="An example GtkWindow"
src="window.png"> </picture>
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,...).
GtkWindow as GtkBuildable
The `GtkWindow` implementation of the [iface@Gtk.Buildable] interface supports setting a child as the titlebar by specifying
“titlebar” as the “type” attribute of a `<child>` element.
Shortcuts and Gestures
`GtkWindow` supports the following keyboard shortcuts:
- <kbd>F10</kbd> activates the menubar, if present.
- <kbd>Alt</kbd> makes the mnemonics visible while pressed.
The following signals have default keybindings:
- [signal@Gtk.Window:
GtkWindow:activate-default]
- [signal@Gtk.Window:
GtkWindow:activate-focuss]
- [signal@Gtk.Window:
GtkWindow:enable-debugging]
Actions
`GtkWindow` defines a set of built-in actions:
- `default.activate` activates the default widget.
- `window.minimize` minimizes the window.
- `window.toggle-maximized` maximizes or restores the window.
- `window.close` closes the window.
CSS nodes
``` window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled] ├── <child> ╰── <titlebar child
>.titlebar [.default-decoration] ```
`GtkWindow` 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). GtkWindow 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).
`GtkWindow` 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.
`GtkWindow` adds the .titlebar and .default-decoration style classes to the widget that is added as a titlebar child.
Accessibility
`GtkWindow` uses the [enum@Gtk.AccessibleRole.window] role.
From GTK 4.12 to 4.18, it used the [enum@Gtk.AccessibleRole.application] role.
- public Application application { get; set; }
The `GtkApplication` associated with the window.
- public Widget child { get; set; }
The child widget.
- public bool decorated { get; set; }
Whether the window should have a frame (also known as *decorations*).
- public int default_height { get; set; }
The default height of the window.
- public Widget default_widget { get; set; }
The default widget.
- public int default_width { get; set; }
The default width of the window.
- public bool deletable { get; set; }
Whether the window frame should have a close button.
- public bool destroy_with_parent { get; set; }
If this window should be destroyed when the parent is destroyed.
- public Display display { owned get; set; }
The display that will display this window.
- public bool focus_visible { get; set; }
Whether 'focus rectangles' are currently visible in this window.
- public Widget focus_widget { owned get; set; }
The focus widget.
- public bool fullscreened { get; set; }
Whether the window is fullscreen.
- public WindowGravity gravity { get; set; }
The gravity to use when resizing the window programmatically.
- public bool handle_menubar_accel { get; set; }
Whether the window frame should handle <kbd>F10</kbd> for
activating menubars.
- public bool hide_on_close { get; set; }
If this window should be hidden instead of destroyed when the user
clicks the close button.
- public string icon_name { get; set; }
Specifies the name of the themed icon to use as the window icon.
- public bool is_active { get; }
Whether the toplevel is the currently active window.
- public bool maximized { get; set; }
Whether the window is maximized.
- public bool mnemonics_visible { get; set; }
Whether mnemonics are currently visible in this window.
- public bool modal { get; set; }
If true, the window is modal.
- public bool resizable { get; set; }
If true, users can resize the window.
- public string startup_id { set; }
A write-only property for setting window's startup notification
identifier.
- public bool suspended { get; }
Whether the window is suspended.
- public string title { get; set; }
The title of the window.
- public Widget titlebar { get; set; }
The titlebar widget.
- public Window transient_for { get; set construct; }
The transient parent of the window.