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 _getGType() static nothrow
GType _gType() @property nothrow
Window self() nothrowReturns `this`, for use in `with` statements.
WindowGidBuilder builder() static nothrowGet builder for [gtk.window.Window] Returns: New builder object
gtk.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.
gtk.widget.Widget child() @property nothrowGet `child` property. Returns: The child widget.
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.
bool modal() @property nothrowGet `modal` property. Returns: If true, the window is modal.
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.
string title() @property nothrowGet `title` property. Returns: The title of the window.
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.
string getDefaultIconName() static nothrowReturns the fallback icon name for windows.
gio.list_model.ListModel getToplevels() static nothrowReturns a list of all existing toplevel windows.
gtk.widget.Widget[] listToplevels() static nothrowReturns a list of all existing toplevel windows.
void setAutoStartupNotification(bool setting) static nothrowSets whether the window should request startup notification.
void setDefaultIconName(string name) static nothrowSets an icon to be used as fallback.
void setInteractiveDebugging(bool enable) static nothrowOpens or closes the [interactive debugger](running.html#interactive-debugging).
void close() nothrowRequests that the window is closed.
void destroy() nothrowDrop the internal reference GTK holds on toplevel windows.
void fullscreen() nothrowAsks to place window in the fullscreen state.
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 window
bool getDecorated() nothrowReturns 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) nothrowGets the default size of the window.
gtk.widget.Widget getDefaultWidget() nothrowReturns the default widget for window. Returns: the default widget
bool 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 button
bool getDestroyWithParent() nothrowReturns 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() nothrowRetrieves the current focused widget within the window.
bool getFocusVisible() nothrowGets 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() nothrowReturns the group for window.
bool getHandleMenubarAccel() nothrowReturns whether this window reacts to F10 key presses by activating a menubar it contains. Returns: true if the window handles F10
bool getHideOnClose() nothrowReturns whether the window will be hidden when the close button is clicked. Returns: true if the window will be hidden
string getIconName() nothrowReturns the name of the themed icon for the window. Returns: the icon name
bool 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 shown
bool getResizable() nothrowGets the value set by [gtk.window.Window.setResizable]. Returns: true if the user can resize the window
string getTitle() nothrowRetrieves the title of the window. Returns: the title of the window
gtk.widget.Widget getTitlebar() nothrowReturns the custom titlebar that has been set with [gtk.window.Window.setTitlebar]. Returns: the custom titlebar
gtk.window.Window getTransientFor() nothrowFetches the transient parent for this window. Returns: the transient parent for this window
bool hasGroup() nothrowReturns whether window has an explicit window group. Returns: true if window has an explicit window group.
bool isActive() nothrowReturns whether the window is part of the current active toplevel.
bool isFullscreen() nothrowRetrieves the current fullscreen state of window.
bool isMaximized() nothrowRetrieves the current maximized state of window.
bool isSuspended() nothrowRetrieves the current suspended state of window.
void maximize() nothrowAsks to maximize window, so that it fills the screen.
void minimize() nothrowAsks to minimize the specified window.
void present() nothrowPresents a window to the user.
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 setChild(gtk.widget.Widget child = null) nothrowSets the child widget of window.
void setDecorated(bool setting) nothrowSets whether the window should be decorated.
void setDefaultSize(int width, int height) nothrowSets the default size of a window.
void setDefaultWidget(gtk.widget.Widget defaultWidget = null) nothrowSets the default widget.
void setDeletable(bool setting) nothrowSets whether the window should be deletable.
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 setFocus(gtk.widget.Widget focus = null) nothrowSets the focus widget.
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 setIconName(string name = null) nothrowSets the icon for the window from a named themed icon.
void setMnemonicsVisible(bool setting) nothrowSets whether mnemonics are supposed to be visible.
void setModal(bool modal) nothrowSets a window modal or non-modal.
void setResizable(bool resizable) nothrowSets whether the user can resize a window.
void setStartupId(string startupId) nothrowSets the startup notification ID.
void setTitle(string title = null) nothrowSets the title of the [gtk.window.Window].
void setTitlebar(gtk.widget.Widget titlebar = null) nothrowSets a custom titlebar for window.
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.
void unmaximize() nothrowAsks to unmaximize window.
void unminimize() nothrowAsks 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) 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.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [gtk.window.Window].

Fluent builder implementation template for gtk.window.Window

Methods
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 chaining
T decorated(bool propval) nothrowSet `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) nothrowSet `defaultHeight` property. Params: propval = The default height of the window. Returns: Builder instance for fluent chaining
T defaultWidget(gtk.widget.Widget propval) nothrowSet `defaultWidget` property. Params: propval = The default widget. Returns: Builder instance for fluent chaining
T defaultWidth(int propval) nothrowSet `defaultWidth` property. Params: propval = The default width of the window. Returns: Builder instance for fluent chaining
T deletable(bool propval) nothrowSet `deletable` property. Params: propval = Whether the window frame should have a close button. Returns: Builder instance for fluent chaining
T destroyWithParent(bool propval) nothrowSet `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) nothrowSet `display` property. Params: propval = The display that will display this window. Returns: Builder instance for fluent chaining
T 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 chaining
T 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 chaining
T 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 chaining
T 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 chaining
T resizable(bool propval) nothrowSet `resizable` property. Params: propval = If true, users can resize the window. Returns: Builder instance for fluent chaining
T startupId(string propval) nothrowSet `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) nothrowSet `title` property. Params: propval = The title of the window. Returns: Builder instance for fluent chaining
T titlebar(gtk.widget.Widget propval) nothrowSet `titlebar` property. Params: propval = The titlebar widget. Returns: Builder instance for fluent chaining
T transientFor(gtk.window.Window propval) nothrowSet `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() nothrowCreate object from builder. Returns: New object