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 bool activate_default ()
- public bool activate_focus ()
- public bool activate_key (EventKey event)
Activates mnemonics and accelerators for this
Window.
- public void add_accel_group (AccelGroup accel_group)
Associate accel_group with
this, such that calling accel_groups_activate on
this will activate accelerators in accel_group.
- public void add_embedded_xid (NativeWindow xid)
- public void add_mnemonic (uint keyval, Widget target)
Adds a mnemonic to this window.
- public void begin_move_drag (int button, int root_x, int root_y, uint32 timestamp)
Starts moving a window.
- public void begin_resize_drag (WindowEdge edge, int button, int root_x, int root_y, uint32 timestamp)
Starts resizing a window.
- public void deiconify ()
Asks to deiconify (i.
- public void fullscreen ()
Asks to place the window in the fullscreen state.
- public bool get_accept_focus ()
- public bool get_decorated ()
Returns whether the window has been set to have decorations.
- public void get_default_size (out int width, out int height)
Gets the default size of the window.
- public unowned Widget get_default_widget ()
Returns the default widget for this.
- public bool get_deletable ()
Returns whether the window has been set to have a close button.
- public bool get_destroy_with_parent ()
Returns whether the window will be destroyed with its transient
parent.
- public unowned Widget get_focus ()
Retrieves the current focused widget within the window.
- public bool get_focus_on_map ()
- public void get_frame_dimensions (int left, int top, int right, int bottom)
- public Gravity get_gravity ()
Returns the gravity that is used when changing the window size
programmatically.
- public unowned WindowGroup get_group ()
Returns the group for the window.
- public bool get_has_frame ()
- public unowned Pixbuf get_icon ()
Gets the value set by
set_icon (or if you've called
set_icon_list, gets the first icon in the icon list).
- public List<unowned Pixbuf> get_icon_list ()
- public unowned string get_icon_name ()
Returns the name of the themed icon for the window.
- public ModifierType get_mnemonic_modifier ()
Returns the mnemonic modifier for this window.
- public bool get_mnemonics_visible ()
Gets whether mnemonics are supposed to be visible.
- public bool get_modal ()
Returns whether the window is modal.
- public double get_opacity ()
Fetches the requested opacity for this window.
- public void get_position (out int root_x, out int root_y)
This function returns the position you need to pass to
move to keep this in its current position.
- public bool get_resizable ()
Gets whether the user can resize the window.
- public unowned string get_role ()
Returns the role of the window.
- public unowned Screen get_screen ()
Returns the Screen
associated with this.
- public void get_size (out int width, out int height)
Obtains the current size of this.
- public bool get_skip_pager_hint ()
- public bool get_skip_taskbar_hint ()
- public unowned string get_title ()
Retrieves the title of the window.
- public unowned Window get_transient_for ()
Fetches the transient parent for this window.
- public WindowTypeHint get_type_hint ()
Gets the type hint for this window.
- public bool get_urgency_hint ()
- public WindowType get_window_type ()
Gets the type of the window.
- public bool has_group ()
Returns whether the window has an explicit window group.
- public void iconify ()
Asks to iconify (i.
- public void maximize ()
Asks to maximize the window, so that it fills the screen.
- public bool mnemonic_activate (uint keyval, ModifierType modifier)
Activates the targets associated with the mnemonic.
- public void move (int x, int y)
Asks the window manager to move this
to the given position.
- public virtual void move_focus (DirectionType direction)
- public bool parse_geometry (string geometry)
Parses a standard X Window System geometry string - see the manual
page for X (type “man X”) for details on this.
- public void present ()
Presents a window to the user.
- public void present_with_time (uint32 timestamp)
Presents a window to the user in response to an user interaction.
- public bool propagate_key_event (EventKey event)
Propagate a key press or release event to the focus widget and up the
focus container chain until a widget handles event.
- public void remove_accel_group (AccelGroup accel_group)
- public void remove_embedded_xid (NativeWindow xid)
- public void remove_mnemonic (uint keyval, Widget target)
Removes a mnemonic from this window.
- public void reshow_with_initial_size ()
Hides this, then reshows it,
resetting the default size and position of the window.
- public void resize (int width, int height)
Resizes the window as if the user had done so, obeying geometry
constraints.
- public void set_accept_focus (bool setting)
Windows may set a hint asking the desktop environment not to receive
the input focus.
- public void set_decorated (bool setting)
Sets whether the window should be decorated.
- public void set_default (Widget default_widget)
The default widget is the widget that’s activated when the user
presses Enter in a dialog (for example).
- public void set_default_size (int width, int height)
Sets the default size of a window.
- public void set_deletable (bool setting)
Sets whether the window should be deletable.
- public void set_destroy_with_parent (bool setting)
Sets whether to destroy the window when the transient parent is
destroyed.
- public void set_focus_on_map (bool setting)
Windows may set a hint asking the desktop environment not to receive
the input focus when the window is mapped.
- public void set_frame_dimensions (int left, int top, int right, int bottom)
- public void set_geometry_hints (Widget geometry_widget, Geometry geometry, WindowHints geom_mask)
This function sets up hints about how a window can be resized by the
user.
- public void set_gravity (Gravity gravity)
Sets the gravity that is used when changing the window size
programmatically.
- public void set_has_frame (bool setting)
- public void set_icon (Pixbuf icon)
Sets up the icon representing a Window.
- public bool set_icon_from_file (string filename) throws Error
Sets the icon for this.
- public void set_icon_list (List<Pixbuf> list)
Sets up the icon representing a Window.
- public void set_icon_name (string name)
Sets the icon for the window from a named themed icon.
- public void set_keep_above (bool setting)
Asks to keep this above, so that it
stays on top.
- public void set_keep_below (bool setting)
Asks to keep this below, so that it
stays in bottom.
- public void set_mnemonic_modifier (ModifierType modifier)
Sets the mnemonic modifier for this window.
- public void set_mnemonics_visible (bool setting)
Sets whether mnemonics are supposed to be visible.
- public void set_modal (bool modal)
Sets a window modal or non-modal.
- public void set_opacity (double opacity)
Request the windowing system to make this
partially transparent, with opacity 0 being fully transparent and 1 fully opaque.
- public void set_position (WindowPosition position)
Sets a position constraint for this window.
- public void set_resizable (bool resizable)
Sets whether the user can resize a window.
- public void set_role (string role)
This function is only useful on X11, not with other GTK+ targets.
- public void set_screen (Screen screen)
Sets the Screen
where the this is displayed; if the window is already mapped, it will be unmapped, and then
remapped on the new screen.
- public void set_skip_pager_hint (bool setting)
Windows may set a hint asking the desktop environment not to display
the window in the pager.
- public void set_skip_taskbar_hint (bool setting)
Windows may set a hint asking the desktop environment not to display
the window in the task bar.
- public void set_startup_id (string startup_id)
Sets the startup notification ID.
- public void set_title (string title)
Sets the title of the window.
- public void set_transient_for (Window parent)
Sets a transient parent for the window.
- public void set_type_hint (WindowTypeHint hint)
By setting the type hint for the window, you allow the window manager
to decorate and handle the window in a way which is suitable to the function of the window in your application.
- public void set_urgency_hint (bool setting)
Windows may set a hint asking the desktop environment to draw the
users attention to the window.
- public void set_wmclass (string wmclass_name, string wmclass_class)
Don’t use this function.
- public void stick ()
Asks to stick this, which means that
it will appear on all user desktops.
- public void unfullscreen ()
Asks to remove the fullscreen state for the window, and return to its
previous state.
- public void unmaximize ()
Asks to unmaximize the window.
- public void unstick ()
Asks to unstick this, which means
that it will appear on only one of the user’s desktops.