gtk.window

Module for [Window] class

Types 3

A [gtk.window.Window] is a toplevel window which can contain other widgets.

!An example GtkWindow

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 [gtk.window.Window] implementation of the [gtk.buildable.Buildable] interface supports setting a child as the titlebar by specifying “titlebar” as the “type” attribute of a <child> element.

CSS nodes

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

[gtk.window.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). 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).

[gtk.window.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.Window] adds the .titlebar and .default-decoration style classes to the widget that is added as a titlebar child.

Accessibility

Until GTK 4.10, [gtk.window.Window] used the [gtk.types.AccessibleRole.Window] role.

Since GTK 4.12, [gtk.window.Window] uses the [gtk.types.AccessibleRole.Application] role.

Actions

[gtk.window.Window] defines a set of built-in actions:

  • default.activate: Activate the default widget.
  • window.minimize: Minimize the window.
  • window.toggle-maximized: Maximize or restore the window.
  • window.close: Close the window.
Methods
GType _gType() @property
Window self()Returns `this`, for use in `with` statements.
WindowGidBuilder builder()Get builder for [gtk.window.Window] Returns: New builder object
gtk.application.Application application() @propertyGet `application` property. Returns: The [gtk.application.Application] associated with the window.
void application(gtk.application.Application propval) @propertySet `application` property. Params: propval = The [gtk.application.Application] associated with the window.
gtk.widget.Widget child() @propertyGet `child` property. Returns: The child widget.
void child(gtk.widget.Widget propval) @propertySet `child` property. Params: propval = The child widget.
bool decorated() @propertyGet `decorated` property. Returns: Whether the window should have a frame (also known as decorations).
void decorated(bool propval) @propertySet `decorated` property. Params: propval = Whether the window should have a frame (also known as decorations).
int defaultHeight() @propertyGet `defaultHeight` property. Returns: The default height of the window.
void defaultHeight(int propval) @propertySet `defaultHeight` property. Params: propval = The default height of the window.
gtk.widget.Widget defaultWidget() @propertyGet `defaultWidget` property. Returns: The default widget.
void defaultWidget(gtk.widget.Widget propval) @propertySet `defaultWidget` property. Params: propval = The default widget.
int defaultWidth() @propertyGet `defaultWidth` property. Returns: The default width of the window.
void defaultWidth(int propval) @propertySet `defaultWidth` property. Params: propval = The default width of the window.
bool deletable() @propertyGet `deletable` property. Returns: Whether the window frame should have a close button.
void deletable(bool propval) @propertySet `deletable` property. Params: propval = Whether the window frame should have a close button.
bool destroyWithParent() @propertyGet `destroyWithParent` property. Returns: If this window should be destroyed when the parent is destroyed.
void destroyWithParent(bool propval) @propertySet `destroyWithParent` property. Params: propval = If this window should be destroyed when the parent is destroyed.
gdk.display.Display display() @propertyGet `display` property. Returns: The display that will display this window.
void display(gdk.display.Display propval) @propertySet `display` property. Params: propval = The display that will display this window.
bool focusVisible() @propertyGet `focusVisible` property. Returns: Whether 'focus rectangles' are currently visible in this window.
void focusVisible(bool propval) @propertySet `focusVisible` property. Params: propval = Whether 'focus rectangles' are currently visible in this window.
gtk.widget.Widget focusWidget() @propertyGet `focusWidget` property. Returns: The focus widget.
void focusWidget(gtk.widget.Widget propval) @propertySet `focusWidget` property. Params: propval = The focus widget.
bool fullscreened() @propertyGet `fullscreened` property. Returns: Whether the window is fullscreen.
void fullscreened(bool propval) @propertySet `fullscreened` property. Params: propval = Whether the window is fullscreen.
bool handleMenubarAccel() @propertyGet `handleMenubarAccel` property. Returns: Whether the window frame should handle F10 for activating menubars.
void handleMenubarAccel(bool propval) @propertySet `handleMenubarAccel` property. Params: propval = Whether the window frame should handle F10 for activating menubars.
bool hideOnClose() @propertyGet `hideOnClose` property. Returns: If this window should be hidden when the users clicks the close button.
void hideOnClose(bool propval) @propertySet `hideOnClose` property. Params: propval = If this window should be hidden when the users clicks the close button.
string iconName() @propertyGet `iconName` property. Returns: Specifies the name of the themed icon to use as the window icon.
void iconName(string propval) @propertySet `iconName` property. Params: propval = Specifies the name of the themed icon to use as the window icon.
bool maximized() @propertyGet `maximized` property. Returns: Whether the window is maximized.
void maximized(bool propval) @propertySet `maximized` property. Params: propval = Whether the window is maximized.
bool mnemonicsVisible() @propertyGet `mnemonicsVisible` property. Returns: Whether mnemonics are currently visible in this window.
void mnemonicsVisible(bool propval) @propertySet `mnemonicsVisible` property. Params: propval = Whether mnemonics are currently visible in this window.
bool modal() @propertyGet `modal` property. Returns: If true, the window is modal.
void modal(bool propval) @propertySet `modal` property. Params: propval = If true, the window is modal.
bool resizable() @propertyGet `resizable` property. Returns: If true, users can resize the window.
void resizable(bool propval) @propertySet `resizable` property. Params: propval = If true, users can resize the window.
void startupId(string propval) @propertySet `startupId` property. Params: propval = A write-only property for setting window's startup notification identifier.
bool suspended() @propertyGet `suspended` property. Returns: Whether the window is suspended.
string title() @propertyGet `title` property. Returns: The title of the window.
void title(string propval) @propertySet `title` property. Params: propval = The title of the window.
gtk.widget.Widget titlebar() @propertyGet `titlebar` property. Returns: The titlebar widget.
void titlebar(gtk.widget.Widget propval) @propertySet `titlebar` property. Params: propval = The titlebar widget.
gtk.window.Window transientFor() @propertyGet `transientFor` property. Returns: The transient parent of the window.
void transientFor(gtk.window.Window propval) @propertySet `transientFor` property. Params: propval = The transient parent of the window.
string getDefaultIconName()Returns the fallback icon name for windows.
gio.list_model.ListModel getToplevels()Returns a list of all existing toplevel windows.
gtk.widget.Widget[] listToplevels()Returns a list of all existing toplevel windows.
void setAutoStartupNotification(bool setting)Sets whether the window should request startup notification.
void setDefaultIconName(string name)Sets an icon to be used as fallback.
void setInteractiveDebugging(bool enable)Opens or closes the [interactive debugger](running.html#interactive-debugging).
void close()Requests that the window is closed.
void destroy()Drop the internal reference GTK holds on toplevel windows.
void fullscreen()Asks to place window in the fullscreen state.
void fullscreenOnMonitor(gdk.monitor.MonitorWrap monitor)Asks to place window in the fullscreen state on the given monitor.
gtk.application.Application getApplication()Gets the [gtk.application.Application] associated with the window. Returns: a [gtk.application.Application]
gtk.widget.Widget getChild()Gets the child widget of window. Returns: the child widget of window
bool getDecorated()Returns whether the window has been set to have decorations. Returns: true if the window has been set to have decorations
void getDefaultSize(out int width, out int height)Gets the default size of the window.
gtk.widget.Widget getDefaultWidget()Returns the default widget for window. Returns: the default widget
bool getDeletable()Returns whether the window has been set to have a close button. Returns: true if the window has been set to have a close button
bool getDestroyWithParent()Returns whether the window will be destroyed with its transient parent. Returns: true if the window will be destroyed with its transient parent.
gtk.widget.Widget getFocus()Retrieves the current focused widget within the window.
bool getFocusVisible()Gets whether “focus rectangles” are supposed to be visible. Returns: true if “focus rectangles” are supposed to be visible in this window.
gtk.window_group.WindowGroup getGroup()Returns the group for window.
bool getHandleMenubarAccel()Returns whether this window reacts to F10 key presses by activating a menubar it contains. Returns: true if the window handles F10
bool getHideOnClose()Returns whether the window will be hidden when the close button is clicked. Returns: true if the window will be hidden
string getIconName()Returns the name of the themed icon for the window. Returns: the icon name
bool getMnemonicsVisible()Gets whether mnemonics are supposed to be visible. Returns: true if mnemonics are supposed to be visible in this window.
bool getModal()Returns whether the window is modal. Returns: true if the window is set to be modal and establishes a grab when shown
bool getResizable()Gets the value set by [gtk.window.Window.setResizable]. Returns: true if the user can resize the window
string getTitle()Retrieves the title of the window. Returns: the title of the window
gtk.widget.Widget getTitlebar()Returns the custom titlebar that has been set with [gtk.window.Window.setTitlebar]. Returns: the custom titlebar
gtk.window.Window getTransientFor()Fetches the transient parent for this window. Returns: the transient parent for this window
bool hasGroup()Returns whether window has an explicit window group. Returns: true if window has an explicit window group.
bool isActive()Returns whether the window is part of the current active toplevel.
bool isFullscreen()Retrieves the current fullscreen state of window.
bool isMaximized()Retrieves the current maximized state of window.
bool isSuspended()Retrieves the current suspended state of window.
void maximize()Asks to maximize window, so that it fills the screen.
void minimize()Asks to minimize the specified window.
void present()Presents a window to the user.
void presentWithTime(uint timestamp)Presents a window to the user in response to an user interaction.
void setApplication(gtk.application.Application application = null)Sets or unsets the [gtk.application.Application] associated with the window.
void setChild(gtk.widget.Widget child = null)Sets the child widget of window.
void setDecorated(bool setting)Sets whether the window should be decorated.
void setDefaultSize(int width, int height)Sets the default size of a window.
void setDefaultWidget(gtk.widget.Widget defaultWidget = null)Sets the default widget.
void setDeletable(bool setting)Sets whether the window should be deletable.
void setDestroyWithParent(bool setting)If setting is true, then destroying the transient parent of window will also destroy window itself.
void setDisplay(gdk.display.Display display)Sets the [gdk.display.Display] where the window is displayed.
void setFocus(gtk.widget.Widget focus = null)Sets the focus widget.
void setFocusVisible(bool setting)Sets whether “focus rectangles” are supposed to be visible.
void setHandleMenubarAccel(bool handleMenubarAccel)Sets whether this window should react to F10 key presses by activating a menubar it contains.
void setHideOnClose(bool setting)If setting is true, then clicking the close button on the window will not destroy it, but only hide it.
void setIconName(string name = null)Sets the icon for the window from a named themed icon.
void setMnemonicsVisible(bool setting)Sets whether mnemonics are supposed to be visible.
void setModal(bool modal)Sets a window modal or non-modal.
void setResizable(bool resizable)Sets whether the user can resize a window.
void setStartupId(string startupId)Sets the startup notification ID.
void setTitle(string title = null)Sets the title of the [gtk.window.Window].
void setTitlebar(gtk.widget.Widget titlebar = null)Sets a custom titlebar for window.
void setTransientFor(gtk.window.Window parent = null)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 ov...
void unfullscreen()Asks to remove the fullscreen state for window, and return to its previous state.
void unmaximize()Asks to unmaximize window.
void unminimize()Asks to unminimize the specified window.
gulong connectActivateDefault(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.window.Window))) && Parameters!T.length < 2)Connect to `ActivateDefault` signal.
gulong connectActivateFocus(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.window.Window))) && Parameters!T.length < 2)Connect to `ActivateFocus` signal.
gulong connectCloseRequest(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.window.Window))) && Parameters!T.length < 2)Connect to `CloseRequest` signal.
gulong connectEnableDebugging(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == bool) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == bool))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gtk.window.Window))) && Parameters!T.length < 3)Connect to `EnableDebugging` signal.
gulong connectKeysChanged(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] : gtk.window.Window))) && Parameters!T.length < 2)Connect to `KeysChanged` signal.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.window.Window].
Methods
T application(gtk.application.Application propval)Set `application` property. Params: propval = The [gtk.application.Application] associated with the window.
T child(gtk.widget.Widget propval)Set `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chaining
T decorated(bool propval)Set `decorated` property. Params: propval = Whether the window should have a frame (also known as decorations). Returns: Builder instance for fluent chaining
T defaultHeight(int propval)Set `defaultHeight` property. Params: propval = The default height of the window. Returns: Builder instance for fluent chaining
T defaultWidget(gtk.widget.Widget propval)Set `defaultWidget` property. Params: propval = The default widget. Returns: Builder instance for fluent chaining
T defaultWidth(int propval)Set `defaultWidth` property. Params: propval = The default width of the window. Returns: Builder instance for fluent chaining
T deletable(bool propval)Set `deletable` property. Params: propval = Whether the window frame should have a close button. Returns: Builder instance for fluent chaining
T destroyWithParent(bool propval)Set `destroyWithParent` property. Params: propval = If this window should be destroyed when the parent is destroyed. Returns: Builder instance for fluent chaining
T display(gdk.display.Display propval)Set `display` property. Params: propval = The display that will display this window. Returns: Builder instance for fluent chaining
T focusVisible(bool propval)Set `focusVisible` property. Params: propval = Whether 'focus rectangles' are currently visible in this window.
T focusWidget(gtk.widget.Widget propval)Set `focusWidget` property. Params: propval = The focus widget. Returns: Builder instance for fluent chaining
T fullscreened(bool propval)Set `fullscreened` property. Params: propval = Whether the window is fullscreen.
T handleMenubarAccel(bool propval)Set `handleMenubarAccel` property. Params: propval = Whether the window frame should handle F10 for activating menubars. Returns: Builder instance for fluent chaining
T hideOnClose(bool propval)Set `hideOnClose` property. Params: propval = If this window should be hidden when the users clicks the close button. Returns: Builder instance for fluent chaining
T iconName(string propval)Set `iconName` property. Params: propval = Specifies the name of the themed icon to use as the window icon.
T maximized(bool propval)Set `maximized` property. Params: propval = Whether the window is maximized.
T mnemonicsVisible(bool propval)Set `mnemonicsVisible` property. Params: propval = Whether mnemonics are currently visible in this window.
T modal(bool propval)Set `modal` property. Params: propval = If true, the window is modal. Returns: Builder instance for fluent chaining
T resizable(bool propval)Set `resizable` property. Params: propval = If true, users can resize the window. Returns: Builder instance for fluent chaining
T startupId(string propval)Set `startupId` property. Params: propval = A write-only property for setting window's startup notification identifier. Returns: Builder instance for fluent chaining
T title(string propval)Set `title` property. Params: propval = The title of the window. Returns: Builder instance for fluent chaining
T titlebar(gtk.widget.Widget propval)Set `titlebar` property. Params: propval = The titlebar widget. Returns: Builder instance for fluent chaining
T transientFor(gtk.window.Window propval)Set `transientFor` property. Params: propval = The transient parent of the window. Returns: Builder instance for fluent chaining

Fluent builder for [gtk.window.Window]

Methods
Window build()