gtk.window
Module for [Window] class
Types 3
A gtk.window.Window is a toplevel window which can contain other widgets.
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.
WindowGidBuilder builder() static nothrowGet builder for [gtk.window.Window] Returns: New builder objectgtk.application.Application application() @property nothrowGet `application` property. Returns: The [gtk.application.Application] associated with the window.void application(gtk.application.Application propval) @property nothrowSet `application` property. Params: propval = The [gtk.application.Application] associated with the window.void child(gtk.widget.Widget propval) @property nothrowSet `child` property. Params: propval = The child widget.bool decorated() @property nothrowGet `decorated` property. Returns: Whether the window should have a frame (also known as decorations).void decorated(bool propval) @property nothrowSet `decorated` property. Params: propval = Whether the window should have a frame (also known as decorations).int defaultHeight() @property nothrowGet `defaultHeight` property. Returns: The default height of the window.void defaultHeight(int propval) @property nothrowSet `defaultHeight` property. Params: propval = The default height of the window.gtk.widget.Widget defaultWidget() @property nothrowGet `defaultWidget` property. Returns: The default widget.void defaultWidget(gtk.widget.Widget propval) @property nothrowSet `defaultWidget` property. Params: propval = The default widget.int defaultWidth() @property nothrowGet `defaultWidth` property. Returns: The default width of the window.void defaultWidth(int propval) @property nothrowSet `defaultWidth` property. Params: propval = The default width of the window.bool deletable() @property nothrowGet `deletable` property. Returns: Whether the window frame should have a close button.void deletable(bool propval) @property nothrowSet `deletable` property. Params: propval = Whether the window frame should have a close button.bool destroyWithParent() @property nothrowGet `destroyWithParent` property. Returns: If this window should be destroyed when the parent is destroyed.void destroyWithParent(bool propval) @property nothrowSet `destroyWithParent` property. Params: propval = If this window should be destroyed when the parent is destroyed.gdk.display.Display display() @property nothrowGet `display` property. Returns: The display that will display this window.void display(gdk.display.Display propval) @property nothrowSet `display` property. Params: propval = The display that will display this window.bool focusVisible() @property nothrowGet `focusVisible` property. Returns: Whether 'focus rectangles' are currently visible in this window.void focusVisible(bool propval) @property nothrowSet `focusVisible` property. Params: propval = Whether 'focus rectangles' are currently visible in this window.gtk.widget.Widget focusWidget() @property nothrowGet `focusWidget` property. Returns: The focus widget.void focusWidget(gtk.widget.Widget propval) @property nothrowSet `focusWidget` property. Params: propval = The focus widget.bool fullscreened() @property nothrowGet `fullscreened` property. Returns: Whether the window is fullscreen.void fullscreened(bool propval) @property nothrowSet `fullscreened` property. Params: propval = Whether the window is fullscreen.bool handleMenubarAccel() @property nothrowGet `handleMenubarAccel` property. Returns: Whether the window frame should handle F10 for activating menubars.void handleMenubarAccel(bool propval) @property nothrowSet `handleMenubarAccel` property. Params: propval = Whether the window frame should handle F10 for activating menubars.bool hideOnClose() @property nothrowGet `hideOnClose` property. Returns: If this window should be hidden when the users clicks the close button.void hideOnClose(bool propval) @property nothrowSet `hideOnClose` property. Params: propval = If this window should be hidden when the users clicks the close button.string iconName() @property nothrowGet `iconName` property. Returns: Specifies the name of the themed icon to use as the window icon.void iconName(string propval) @property nothrowSet `iconName` property. Params: propval = Specifies the name of the themed icon to use as the window icon.bool maximized() @property nothrowGet `maximized` property. Returns: Whether the window is maximized.void maximized(bool propval) @property nothrowSet `maximized` property. Params: propval = Whether the window is maximized.bool mnemonicsVisible() @property nothrowGet `mnemonicsVisible` property. Returns: Whether mnemonics are currently visible in this window.void mnemonicsVisible(bool propval) @property nothrowSet `mnemonicsVisible` property. Params: propval = Whether mnemonics are currently visible in this window.void modal(bool propval) @property nothrowSet `modal` property. Params: propval = If true, the window is modal.bool resizable() @property nothrowGet `resizable` property. Returns: If true, users can resize the window.void resizable(bool propval) @property nothrowSet `resizable` property. Params: propval = If true, users can resize the window.void startupId(string propval) @property nothrowSet `startupId` property. Params: propval = A write-only property for setting window's startup notification identifier.bool suspended() @property nothrowGet `suspended` property. Returns: Whether the window is suspended.void title(string propval) @property nothrowSet `title` property. Params: propval = The title of the window.gtk.widget.Widget titlebar() @property nothrowGet `titlebar` property. Returns: The titlebar widget.void titlebar(gtk.widget.Widget propval) @property nothrowSet `titlebar` property. Params: propval = The titlebar widget.gtk.window.Window transientFor() @property nothrowGet `transientFor` property. Returns: The transient parent of the window.void transientFor(gtk.window.Window propval) @property nothrowSet `transientFor` property. Params: propval = The transient parent of the window.gio.list_model.ListModel getToplevels() static nothrowReturns a list of all existing toplevel windows.void setAutoStartupNotification(bool setting) static nothrowSets whether the window should request startup notification.void setInteractiveDebugging(bool enable) static nothrowOpens or closes the [interactive debugger](running.html#interactive-debugging).void fullscreenOnMonitor(gdk.monitor.MonitorWrap monitor) nothrowAsks to place window in the fullscreen state on the given monitor.gtk.application.Application getApplication() nothrowGets the [gtk.application.Application] associated with the window. Returns: a [gtk.application.Application]gtk.widget.Widget getChild() nothrowGets the child widget of window. Returns: the child widget of windowbool getDecorated() nothrowReturns whether the window has been set to have decorations. Returns: true if the window has been set to have decorationsgtk.widget.Widget getDefaultWidget() nothrowReturns the default widget for window. Returns: the default widgetbool getDeletable() nothrowReturns whether the window has been set to have a close button. Returns: true if the window has been set to have a close buttonbool getDestroyWithParent() nothrowReturns whether the window will be destroyed with its transient parent. Returns: true if the window will be destroyed with its transient parent.bool getFocusVisible() nothrowGets whether “focus rectangles” are supposed to be visible. Returns: true if “focus rectangles” are supposed to be visible in this window.bool getHandleMenubarAccel() nothrowReturns whether this window reacts to F10 key presses by activating a menubar it contains. Returns: true if the window handles F10bool getHideOnClose() nothrowReturns whether the window will be hidden when the close button is clicked. Returns: true if the window will be hiddenstring getIconName() nothrowReturns the name of the themed icon for the window. Returns: the icon namebool getMnemonicsVisible() nothrowGets whether mnemonics are supposed to be visible. Returns: true if mnemonics are supposed to be visible in this window.bool getModal() nothrowReturns whether the window is modal. Returns: true if the window is set to be modal and establishes a grab when shownbool getResizable() nothrowGets the value set by [gtk.window.Window.setResizable]. Returns: true if the user can resize the windowgtk.widget.Widget getTitlebar() nothrowReturns the custom titlebar that has been set with [gtk.window.Window.setTitlebar]. Returns: the custom titlebargtk.window.Window getTransientFor() nothrowFetches the transient parent for this window. Returns: the transient parent for this windowbool hasGroup() nothrowReturns whether window has an explicit window group. Returns: true if window has an explicit window group.void presentWithTime(uint timestamp) nothrowPresents a window to the user in response to an user interaction.void setApplication(gtk.application.Application application = null) nothrowSets or unsets the [gtk.application.Application] associated with the window.void setDestroyWithParent(bool setting) nothrowIf setting is true, then destroying the transient parent of window will also destroy window itself.void setDisplay(gdk.display.Display display) nothrowSets the [gdk.display.Display] where the window is displayed.void setFocusVisible(bool setting) nothrowSets whether “focus rectangles” are supposed to be visible.void setHandleMenubarAccel(bool handleMenubarAccel) nothrowSets whether this window should react to F10 key presses by activating a menubar it contains.void setHideOnClose(bool setting) nothrowIf setting is true, then clicking the close button on the window will not destroy it, but only hide it.void setTransientFor(gtk.window.Window parent = null) nothrowDialog 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() nothrowAsks to remove the fullscreen state for window, and return to its previous state.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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect 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) nothrowConnect to `KeysChanged` signal.Fluent builder implementation template for gtk.window.Window
T application(gtk.application.Application propval) nothrowSet `application` property. Params: propval = The [gtk.application.Application] associated with the window.T child(gtk.widget.Widget propval) nothrowSet `child` property. Params: propval = The child widget. Returns: Builder instance for fluent chainingT decorated(bool propval) nothrowSet `decorated` property. Params: propval = Whether the window should have a frame (also known as decorations). Returns: Builder instance for fluent chainingT defaultHeight(int propval) nothrowSet `defaultHeight` property. Params: propval = The default height of the window. Returns: Builder instance for fluent chainingT defaultWidget(gtk.widget.Widget propval) nothrowSet `defaultWidget` property. Params: propval = The default widget. Returns: Builder instance for fluent chainingT defaultWidth(int propval) nothrowSet `defaultWidth` property. Params: propval = The default width of the window. Returns: Builder instance for fluent chainingT deletable(bool propval) nothrowSet `deletable` property. Params: propval = Whether the window frame should have a close button. Returns: Builder instance for fluent chainingT destroyWithParent(bool propval) nothrowSet `destroyWithParent` property. Params: propval = If this window should be destroyed when the parent is destroyed. Returns: Builder instance for fluent chainingT display(gdk.display.Display propval) nothrowSet `display` property. Params: propval = The display that will display this window. Returns: Builder instance for fluent chainingT focusVisible(bool propval) nothrowSet `focusVisible` property. Params: propval = Whether 'focus rectangles' are currently visible in this window.T focusWidget(gtk.widget.Widget propval) nothrowSet `focusWidget` property. Params: propval = The focus widget. Returns: Builder instance for fluent chainingT fullscreened(bool propval) nothrowSet `fullscreened` property. Params: propval = Whether the window is fullscreen.T handleMenubarAccel(bool propval) nothrowSet `handleMenubarAccel` property. Params: propval = Whether the window frame should handle F10 for activating menubars. Returns: Builder instance for fluent chainingT hideOnClose(bool propval) nothrowSet `hideOnClose` property. Params: propval = If this window should be hidden when the users clicks the close button. Returns: Builder instance for fluent chainingT iconName(string propval) nothrowSet `iconName` property. Params: propval = Specifies the name of the themed icon to use as the window icon.T maximized(bool propval) nothrowSet `maximized` property. Params: propval = Whether the window is maximized.T mnemonicsVisible(bool propval) nothrowSet `mnemonicsVisible` property. Params: propval = Whether mnemonics are currently visible in this window.T modal(bool propval) nothrowSet `modal` property. Params: propval = If true, the window is modal. Returns: Builder instance for fluent chainingT resizable(bool propval) nothrowSet `resizable` property. Params: propval = If true, users can resize the window. Returns: Builder instance for fluent chainingT startupId(string propval) nothrowSet `startupId` property. Params: propval = A write-only property for setting window's startup notification identifier. Returns: Builder instance for fluent chainingT title(string propval) nothrowSet `title` property. Params: propval = The title of the window. Returns: Builder instance for fluent chainingT titlebar(gtk.widget.Widget propval) nothrowSet `titlebar` property. Params: propval = The titlebar widget. Returns: Builder instance for fluent chainingT transientFor(gtk.window.Window propval) nothrowSet `transientFor` property. Params: propval = The transient parent of the window. Returns: Builder instance for fluent chainingFluent builder for gtk.window.Window