Class Window
- All Implemented Interfaces:
Proxy
,Accessible
,Buildable
,ConstraintTarget
,Native
,Root
,ShortcutManager
- Direct Known Subclasses:
AboutDialog
,ApplicationWindow
,Assistant
,Dialog
,MessageDialog
,ShortcutsWindow
,Window
GtkWindow
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 GtkWindow
implementation of the 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:
F10
activates the menubar, if present.Alt
makes the mnemonics visible while pressed.
The following signals have default keybindings:
Gtk.Window::activate-default
Gtk.Window::activate-focus
Gtk.Window::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
Until GTK 4.10, GtkWindow
used the GTK_ACCESSIBLE_ROLE_WINDOW
role.
Since GTK 4.12, GtkWindow
uses the GTK_ACCESSIBLE_ROLE_APPLICATION
role.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic interface
Functional interface declaration of theActivateDefaultCallback
callback.static interface
Functional interface declaration of theActivateFocusCallback
callback.static class
Window.Builder<B extends Window.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theCloseRequestCallback
callback.static interface
Functional interface declaration of theEnableDebuggingCallback
callback.static interface
Deprecated.static class
Nested classes/interfaces inherited from class org.gnome.gtk.Widget
Widget.DestroyCallback, Widget.DirectionChangedCallback, Widget.HideCallback, Widget.KeynavFailedCallback, Widget.MapCallback, Widget.MnemonicActivateCallback, Widget.MoveFocusCallback, Widget.QueryTooltipCallback, Widget.RealizeCallback, Widget.ShowCallback, Widget.StateFlagsChangedCallback, Widget.UnmapCallback, Widget.UnrealizeCallback, Widget.WidgetClass, Widget.WidgetImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
Nested classes/interfaces inherited from interface org.gnome.gtk.Accessible
Accessible.AccessibleImpl, Accessible.AccessibleInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Buildable
Buildable.BuildableIface, Buildable.BuildableImpl
Nested classes/interfaces inherited from interface org.gnome.gtk.ConstraintTarget
ConstraintTarget.ConstraintTargetImpl, ConstraintTarget.ConstraintTargetInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Native
Native.NativeImpl, Native.NativeInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.Root
Root.RootImpl, Root.RootInterface
Nested classes/interfaces inherited from interface org.gnome.gtk.ShortcutManager
ShortcutManager.ShortcutManagerImpl, ShortcutManager.ShortcutManagerInterface
-
Constructor Summary
ConstructorDescriptionWindow()
Creates a newGtkWindow
.Window
(MemorySegment address) Create a Window proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Activates the default widget for the window.protected void
Activates the current focused widget within the window.protected Window
asParent()
Returns this instance as if it were its parent type.static Window.Builder
<? extends Window.Builder> builder()
AWindow.Builder
object constructs aWindow
with the specified properties.void
close()
Requests that the window is closed.protected boolean
Class handler for theGtkWindow::close-request
signal.void
destroy()
Drop the internal reference GTK holds on toplevel windows.void
Emits the "activate-default" signal.void
Emits the "activate-focus" signal.boolean
Emits the "close-request" signal.boolean
emitEnableDebugging
(boolean toggle) Emits the "enable-debugging" signal.void
Deprecated.protected boolean
enableDebugging
(boolean toggle) Class handler for theGtkWindow::enable-debugging
keybinding signal.void
Asks to place this Window in the fullscreen state.void
fullscreenOnMonitor
(Monitor monitor) Asks to place this Window in the fullscreen state on the givenmonitor
.Gets theGtkApplication
associated with the window.getChild()
Gets the child widget of this Window.boolean
Returns whether the window has been set to have decorations.static String
Returns the fallback icon name for windows.void
getDefaultSize
(@Nullable Out<Integer> width, @Nullable Out<Integer> height) Gets the default size of the window.Returns the default widget for this Window.boolean
Returns whether the window has been set to have a close button.boolean
Returns whether the window will be destroyed with its transient parent.getFocus()
Retrieves the current focused widget within the window.boolean
Gets whether “focus rectangles” are supposed to be visible.getGroup()
Returns the group for this Window.boolean
Returns whether this window reacts to F10 key presses by activating a menubar it contains.boolean
Returns whether the window will be hidden when the close button is clicked.Returns the name of the themed icon for the window.static MemoryLayout
The memory layout of the native struct.boolean
Gets whether mnemonics are supposed to be visible.boolean
getModal()
Returns whether the window is modal.boolean
Gets the value set by gtk_window_set_resizable().getTitle()
Retrieves the title of the window.Returns the custom titlebar that has been set with gtk_window_set_titlebar().static ListModel
Returns a list of all existing toplevel windows.Fetches the transient parent for this window.static Type
getType()
Get the GType of the Window classboolean
hasGroup()
Returns whether this Window has an explicit window group.boolean
isActive()
Returns whether the window is part of the current active toplevel.boolean
Retrieves the current fullscreen state of this Window.boolean
Retrieves the current maximized state of this Window.boolean
Retrieves the current suspended state of this Window.protected void
Signal gets emitted when the set of accelerators or mnemonics that are associated with window changes.Returns a list of all existing toplevel windows.void
maximize()
Asks to maximize this Window, so that it fills the screen.void
minimize()
Asks to minimize the specified this Window.Emitted when the user activates the default widget ofwindow
.Emitted when the user activates the currently focused widget ofwindow
.Emitted when the user clicks on the close button of the window.Emitted when the user enables or disables interactive debugging.onKeysChanged
(Window.KeysChangedCallback handler) Deprecated.void
present()
Presents a window to the user.void
presentWithTime
(int timestamp) Deprecated.Use gtk_window_present()void
setApplication
(@Nullable Application application) Sets or unsets theGtkApplication
associated with the window.static void
setAutoStartupNotification
(boolean setting) Sets whether the window should request startup notification.void
Sets the child widget of this Window.void
setDecorated
(boolean setting) Sets whether the window should be decorated.static void
setDefaultIconName
(String name) Sets an icon to be used as fallback.void
setDefaultSize
(int width, int height) Sets the default size of a window.void
setDefaultWidget
(@Nullable Widget defaultWidget) Sets the default widget.void
setDeletable
(boolean setting) Sets whether the window should be deletable.void
setDestroyWithParent
(boolean setting) Ifsetting
istrue
, then destroying the transient parent of this Window will also destroy this Window itself.void
setDisplay
(Display display) Sets theGdkDisplay
where the this Window is displayed.void
Sets the focus widget.void
setFocusVisible
(boolean setting) Sets whether “focus rectangles” are supposed to be visible.void
setHandleMenubarAccel
(boolean handleMenubarAccel) Sets whether this window should react to F10 key presses by activating a menubar it contains.void
setHideOnClose
(boolean setting) Ifsetting
istrue
, then clicking the close button on the window will not destroy it, but only hide it.void
setIconName
(@Nullable String name) Sets the icon for the window from a named themed icon.static void
setInteractiveDebugging
(boolean enable) Opens or closes the interactive debugger.void
setMnemonicsVisible
(boolean setting) Sets whether mnemonics are supposed to be visible.void
setModal
(boolean modal) Sets a window modal or non-modal.void
setResizable
(boolean resizable) Sets whether the user can resize a window.void
setStartupId
(String startupId) Sets the startup notification ID.void
Sets the title of theGtkWindow
.void
setTitlebar
(@Nullable Widget titlebar) Sets a custom titlebar for this Window.void
setTransientFor
(@Nullable Window parent) Dialog windows should be set transient for the main application window they were spawned from.void
Asks to remove the fullscreen state for this Window, and return to its previous state.void
Asks to unmaximize this Window.void
Asks to unminimize the specified this Window.Methods inherited from class org.gnome.gtk.Widget
actionSetEnabled, activateActionIfExists, activateWidget, addController, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, cssChanged, directionChanged, disposeTemplate, dragCheckThreshold, emitDestroy, emitDirectionChanged, emitHide, emitKeynavFailed, emitMap, emitMnemonicActivate, emitMoveFocus, emitQueryTooltip, emitRealize, emitShow, emitStateFlagsChanged, emitUnmap, emitUnrealize, errorBell, focus, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, moveFocus, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, pick, queryTooltip, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeMnemonicLabel, removeTickCallback, root, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setStateFlags, setTooltipMarkup, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, sizeAllocate, snapshot, snapshotChild, stateFlagsChanged, systemSettingChanged, translateCoordinates, triggerTooltipQuery, unmap, unparent, unrealize, unroot, unsetStateFlags, unsetStateFlags
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.gnome.gtk.Accessible
announce, getAccessibleParent, getAccessibleRole, getAtContext, getBounds, getFirstAccessibleChild, getNextAccessibleSibling, getPlatformState, resetProperty, resetRelation, resetState, setAccessibleParent, updateNextAccessibleSibling, updateProperty, updateRelation, updateState
Methods inherited from interface org.gnome.gtk.Buildable
getBuildableId
Methods inherited from interface org.gnome.gtk.Native
getRenderer, getSurface, getSurfaceTransform, realize, unrealize
Methods inherited from interface org.gnome.gtk.Root
getDisplay
-
Constructor Details
-
Window
Create a Window proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
Window
public Window()Creates a newGtkWindow
.To get an undecorated window (no window borders), use
setDecorated(boolean)
.All top-level windows created by gtk_window_new() are stored in an internal top-level window list. This list can be obtained from
listToplevels()
. Due to GTK keeping a reference to the window internally, gtk_window_new() does not return a reference to the caller.To delete a
GtkWindow
, calldestroy()
.
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getDefaultIconName
Returns the fallback icon name for windows.The returned string is owned by GTK and should not be modified. It is only valid until the next call to
setDefaultIconName(java.lang.String)
.- Returns:
- the fallback icon name for windows
-
getToplevels
Returns a list of all existing toplevel windows.If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets or add new ones, be aware that the list of toplevels will change and emit the "items-changed" signal.
- Returns:
- the list of toplevel widgets
-
listToplevels
Returns a list of all existing toplevel windows.The widgets in the list are not individually referenced. If you want to iterate through the list and perform actions involving callbacks that might destroy the widgets, you must call
g_list_foreach (result, (GFunc)g_object_ref, NULL)
first, and then unref all the widgets afterwards.- Returns:
- list of toplevel widgets
-
setAutoStartupNotification
public static void setAutoStartupNotification(boolean setting) Sets whether the window should request startup notification.By default, after showing the first
GtkWindow
, GTK callsToplevel.setStartupId(java.lang.String)
. Call this function to disable the automatic startup notification. You might do this if your first window is a splash screen, and you want to delay notification until after your real main window has been shown, for example.In that example, you would disable startup notification temporarily, show your splash screen, then re-enable it so that showing the main window would automatically result in notification.
- Parameters:
setting
-true
to automatically do startup notification
-
setDefaultIconName
Sets an icon to be used as fallback.The fallback icon is used for windows that haven't had
setIconName(java.lang.String)
called on them.- Parameters:
name
- the name of the themed icon
-
setInteractiveDebugging
public static void setInteractiveDebugging(boolean enable) Opens or closes the interactive debugger.The debugger offers access to the widget hierarchy of the application and to useful debugging tools.
This function allows applications that already use
Ctrl
+Shift
+I
(orCtrl
+Shift
+D
) for their own key shortcuts to add a different shortcut to open the Inspector.If you are not overriding the default key shortcuts for the Inspector, you should not use this function.
- Parameters:
enable
-true
to enable interactive debugging
-
close
public void close()Requests that the window is closed.This is similar to what happens when a window manager close button is clicked.
This function can be used with close buttons in custom titlebars.
-
destroy
public void destroy()Drop the internal reference GTK holds on toplevel windows. -
fullscreen
public void fullscreen()Asks to place this Window in the fullscreen state.Note that you shouldn’t assume the window is definitely fullscreen afterward, because other entities (e.g. the user or window manager) unfullscreen it again, and not all window managers honor requests to fullscreen windows.
You can track the result of this operation via the
Gdk.Toplevel:state
property, or by listening to notifications of theGtk.Window:fullscreened
property. -
fullscreenOnMonitor
Asks to place this Window in the fullscreen state on the givenmonitor
.Note that you shouldn't assume the window is definitely fullscreen afterward, or that the windowing system allows fullscreen windows on any given monitor.
You can track the result of this operation via the
Gdk.Toplevel:state
property, or by listening to notifications of theGtk.Window:fullscreened
property.- Parameters:
monitor
- which monitor to go fullscreen on
-
getApplication
Gets theGtkApplication
associated with the window.- Returns:
- a
GtkApplication
-
getChild
Gets the child widget of this Window.- Returns:
- the child widget of this Window
-
getDecorated
public boolean getDecorated()Returns whether the window has been set to have decorations.- Returns:
true
if the window has been set to have decorations
-
getDefaultSize
public void getDefaultSize(@Nullable @Nullable Out<Integer> width, @Nullable @Nullable Out<Integer> height) Gets the default size of the window.A value of 0 for the width or height indicates that a default size has not been explicitly set for that dimension, so the “natural” size of the window will be used.
This function is the recommended way for [saving window state across restarts of applications](https://developer.gnome.org/documentation/tutorials/save-state.html).
- Parameters:
width
- location to store the default widthheight
- location to store the default height
-
getDefaultWidget
Returns the default widget for this Window.- Returns:
- the default widget
-
getDeletable
public boolean 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
-
getDestroyWithParent
public boolean getDestroyWithParent()Returns whether the window will be destroyed with its transient parent.- Returns:
true
if the window will be destroyed with its transient parent.
-
getFocus
Retrieves the current focused widget within the window.Note that this is the widget that would have the focus if the toplevel window focused; if the toplevel window is not focused then
gtk_widget_has_focus (widget)
will not betrue
for the widget. -
getFocusVisible
public boolean getFocusVisible()Gets whether “focus rectangles” are supposed to be visible.- Returns:
true
if “focus rectangles” are supposed to be visible in this window.
-
getGroup
Returns the group for this Window.If the window has no group, then the default group is returned.
- Returns:
- the
GtkWindowGroup
for a window or the default group
-
getHandleMenubarAccel
public boolean getHandleMenubarAccel()Returns whether this window reacts to F10 key presses by activating a menubar it contains.- Returns:
true
if the window handles F10
-
getHideOnClose
public boolean getHideOnClose()Returns whether the window will be hidden when the close button is clicked.- Returns:
true
if the window will be hidden
-
getIconName
Returns the name of the themed icon for the window.- Returns:
- the icon name
-
getMnemonicsVisible
public boolean getMnemonicsVisible()Gets whether mnemonics are supposed to be visible.- Returns:
true
if mnemonics are supposed to be visible in this window.
-
getModal
public boolean getModal()Returns whether the window is modal.- Returns:
true
if the window is set to be modal and establishes a grab when shown
-
getResizable
public boolean getResizable()Gets the value set by gtk_window_set_resizable().- Returns:
true
if the user can resize the window
-
getTitle
-
getTitlebar
Returns the custom titlebar that has been set with gtk_window_set_titlebar().- Returns:
- the custom titlebar
-
getTransientFor
Fetches the transient parent for this window.- Returns:
- the transient parent for this window
-
hasGroup
public boolean hasGroup()Returns whether this Window has an explicit window group.- Returns:
true
if this Window has an explicit window group.
-
isActive
public boolean isActive()Returns whether the window is part of the current active toplevel.The active toplevel is the window receiving keystrokes.
The return value is
true
if the window is active toplevel itself. You might use this function if you wanted to draw a widget differently in an active window from a widget in an inactive window.- Returns:
true
if the window part of the current active window.
-
isFullscreen
public boolean isFullscreen()Retrieves the current fullscreen state of this Window.Note that since fullscreening is ultimately handled by the window manager and happens asynchronously to an application request, you shouldn’t assume the return value of this function changing immediately (or at all), as an effect of calling
fullscreen()
orunfullscreen()
.If the window isn't yet mapped, the value returned will whether the initial requested state is fullscreen.
- Returns:
- whether the window has a fullscreen state.
-
isMaximized
public boolean isMaximized()Retrieves the current maximized state of this Window.Note that since maximization is ultimately handled by the window manager and happens asynchronously to an application request, you shouldn’t assume the return value of this function changing immediately (or at all), as an effect of calling
maximize()
orunmaximize()
.If the window isn't yet mapped, the value returned will whether the initial requested state is maximized.
- Returns:
- whether the window has a maximized state.
-
isSuspended
public boolean isSuspended()Retrieves the current suspended state of this Window.A window being suspended means it's currently not visible to the user, for example by being on a inactive workspace, minimized, obstructed.
- Returns:
- whether the window is suspended.
-
maximize
public void maximize()Asks to maximize this Window, so that it fills the screen.Note that you shouldn’t assume the window is definitely maximized afterward, because other entities (e.g. the user or window manager) could unmaximize it again, and not all window managers support maximization.
It’s permitted to call this function before showing a window, in which case the window will be maximized when it appears onscreen initially.
You can track the result of this operation via the
Gdk.Toplevel:state
property, or by listening to notifications on theGtk.Window:maximized
property. -
minimize
public void minimize()Asks to minimize the specified this Window.Note that you shouldn’t assume the window is definitely minimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager) could unminimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.
It’s permitted to call this function before showing a window, in which case the window will be minimized before it ever appears onscreen.
You can track result of this operation via the
Gdk.Toplevel:state
property. -
present
public void present()Presents a window to the user.This may mean raising the window in the stacking order, unminimizing it, moving it to the current desktop and/or giving it the keyboard focus (possibly dependent on the user’s platform, window manager and preferences).
If this Window is hidden, this function also makes it visible.
-
presentWithTime
Deprecated.Use gtk_window_present()Presents a window to the user in response to an user interaction.See
present()
for more details.The timestamp should be gathered when the window was requested to be shown (when clicking a link for example), rather than once the window is ready to be shown.
- Parameters:
timestamp
- the timestamp of the user interaction (typically a button or key press event) which triggered this call
-
setApplication
Sets or unsets theGtkApplication
associated with the window.The application will be kept alive for at least as long as it has any windows associated with it (see g_application_hold() for a way to keep it alive without windows).
Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it by setting the
application
tonull
.This is equivalent to calling
Application.removeWindow(org.gnome.gtk.Window)
and/orApplication.addWindow(org.gnome.gtk.Window)
on the old/new applications as relevant.- Parameters:
application
- aGtkApplication
, ornull
to unset
-
setChild
Sets the child widget of this Window.- Parameters:
child
- the child widget
-
setDecorated
public void setDecorated(boolean setting) Sets whether the window should be decorated.By default, windows are decorated with a title bar, resize controls, etc. Some window managers allow GTK to disable these decorations, creating a borderless window. If you set the decorated property to
false
using this function, GTK will do its best to convince the window manager not to decorate the window. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before callingWidget.show()
.On Windows, this function always works, since there’s no window manager policy involved.
- Parameters:
setting
-true
to decorate the window
-
setDefaultSize
public void setDefaultSize(int width, int height) Sets the default size of a window.The default size of a window is the size that will be used if no other constraints apply.
The default size will be updated whenever the window is resized to reflect the new size, unless the window is forced to a size, like when it is maximized or fullscreened.
If the window’s minimum size request is larger than the default, the default will be ignored.
Setting the default size to a value <= 0 will cause it to be ignored and the natural size request will be used instead. It is possible to do this while the window is showing to "reset" it to its initial size.
Unlike
Widget.setSizeRequest(int, int)
, which sets a size request for a widget and thus would keep users from shrinking the window, this function only sets the initial size, just as if the user had resized the window themselves. Users can still shrink the window again as they normally would. Setting a default size of -1 means to use the “natural” default size (the size request of the window).If you use this function to reestablish a previously saved window size, note that the appropriate size to save is the one returned by
getDefaultSize(io.github.jwharm.javagi.base.Out<java.lang.Integer>, io.github.jwharm.javagi.base.Out<java.lang.Integer>)
. Using the window allocation directly will not work in all circumstances and can lead to growing or shrinking windows.- Parameters:
width
- width in pixels, or -1 to unset the default widthheight
- height in pixels, or -1 to unset the default height
-
setDefaultWidget
Sets the default widget.The default widget is the widget that is activated when the user presses Enter in a dialog (for example).
- Parameters:
defaultWidget
- widget to be the default to unset the default widget for the toplevel
-
setDeletable
public void setDeletable(boolean setting) Sets whether the window should be deletable.By default, windows have a close button in the window frame. Some window managers allow GTK to disable this button. If you set the deletable property to
false
using this function, GTK will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before callingWidget.show()
.On Windows, this function always works, since there’s no window manager policy involved.
- Parameters:
setting
-true
to decorate the window as deletable
-
setDestroyWithParent
public void setDestroyWithParent(boolean setting) Ifsetting
istrue
, then destroying the transient parent of this Window will also destroy this Window itself.This is useful for dialogs that shouldn’t persist beyond the lifetime of the main window they are associated with, for example.
- Parameters:
setting
- whether to destroy this Window with its transient parent
-
setDisplay
Sets theGdkDisplay
where the this Window is displayed.If the window is already mapped, it will be unmapped, and then remapped on the new display.
- Parameters:
display
- aGdkDisplay
-
setFocus
Sets the focus widget.If
focus
is not the current focus widget, and is focusable, sets it as the focus widget for the window. Iffocus
isnull
, unsets the focus widget for this window. To set the focus to a particular widget in the toplevel, it is usually more convenient to useWidget.grabFocus()
instead of this function. -
setFocusVisible
public void setFocusVisible(boolean setting) Sets whether “focus rectangles” are supposed to be visible.This property is maintained by GTK based on user input, and should not be set by applications.
- Parameters:
setting
- the new value
-
setHandleMenubarAccel
public void setHandleMenubarAccel(boolean handleMenubarAccel) Sets whether this window should react to F10 key presses by activating a menubar it contains.- Parameters:
handleMenubarAccel
-true
to make this Window handle F10
-
setHideOnClose
public void setHideOnClose(boolean setting) Ifsetting
istrue
, then clicking the close button on the window will not destroy it, but only hide it.- Parameters:
setting
- whether to hide the window when it is closed
-
setIconName
Sets the icon for the window from a named themed icon.See the docs for
IconTheme
for more details. On some platforms, the window icon is not used at all.Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.
- Parameters:
name
- the name of the themed icon
-
setMnemonicsVisible
public void setMnemonicsVisible(boolean setting) Sets whether mnemonics are supposed to be visible.This property is maintained by GTK based on user input, and should not be set by applications.
- Parameters:
setting
- the new value
-
setModal
public void setModal(boolean modal) Sets a window modal or non-modal.Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use
setTransientFor(org.gnome.gtk.Window)
to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.- Parameters:
modal
- whether the window is modal
-
setResizable
public void setResizable(boolean resizable) Sets whether the user can resize a window.Windows are user resizable by default.
- Parameters:
resizable
-true
if the user can resize this window
-
setStartupId
Sets the startup notification ID.Startup notification identifiers are used by desktop environment to track application startup, to provide user feedback and other features. This function changes the corresponding property on the underlying
GdkSurface
.Normally, startup identifier is managed automatically and you should only use this function in special cases like transferring focus from other processes. You should use this function before calling
present()
or any equivalent function generating a window map event.This function is only useful on X11, not with other GTK targets.
- Parameters:
startupId
- a string with startup-notification identifier
-
setTitle
Sets the title of theGtkWindow
.The title of a window will be displayed in its title bar; on the X Window System, the title bar is rendered by the window manager so exactly how the title appears to users may vary according to a user’s exact configuration. The title should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document filename, for example.
Passing
null
does the same as setting the title to an empty string.- Parameters:
title
- title of the window
-
setTitlebar
Sets a custom titlebar for this Window.A typical widget used here is
HeaderBar
, as it provides various features expected of a titlebar while allowing the addition of child widgets to it.If you set a custom titlebar, GTK will do its best to convince the window manager not to put its own titlebar on the window. Depending on the system, this function may not work for a window that is already visible, so you set the titlebar before calling
Widget.show()
.- Parameters:
titlebar
- the widget to use as titlebar
-
setTransientFor
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 over the main window.Dialog.withButtons(java.lang.String, org.gnome.gtk.Window, java.util.Set<org.gnome.gtk.DialogFlags>, java.lang.String, java.lang.Object...)
and other convenience functions in GTK will sometimes call gtk_window_set_transient_for() on your behalf.Passing
null
forparent
unsets the current transient window.On Windows, this function puts the child window on top of the parent, much as the window manager would have done on X.
- Parameters:
parent
- parent window
-
unfullscreen
public void unfullscreen()Asks to remove the fullscreen state for this Window, and return to its previous state.Note that you shouldn’t assume the window is definitely not fullscreen afterward, because other entities (e.g. the user or window manager) could fullscreen it again, and not all window managers honor requests to unfullscreen windows; normally the window will end up restored to its normal state. Just don’t write code that crashes if not.
You can track the result of this operation via the
Gdk.Toplevel:state
property, or by listening to notifications of theGtk.Window:fullscreened
property. -
unmaximize
public void unmaximize()Asks to unmaximize this Window.Note that you shouldn’t assume the window is definitely unmaximized afterward, because other entities (e.g. the user or window manager) maximize it again, and not all window managers honor requests to unmaximize.
You can track the result of this operation via the
Gdk.Toplevel:state
property, or by listening to notifications on theGtk.Window:maximized
property. -
unminimize
public void unminimize()Asks to unminimize the specified this Window.Note that you shouldn’t assume the window is definitely unminimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager) could minimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.
You can track result of this operation via the
Gdk.Toplevel:state
property. -
activateDefault
public void activateDefault()Activates the default widget for the window.- Overrides:
activateDefault
in classWidget
-
activateFocus
protected void activateFocus()Activates the current focused widget within the window. -
closeRequest
protected boolean closeRequest()Class handler for theGtkWindow::close-request
signal. -
enableDebugging
protected boolean enableDebugging(boolean toggle) Class handler for theGtkWindow::enable-debugging
keybinding signal. -
keysChanged
protected void keysChanged()Signal gets emitted when the set of accelerators or mnemonics that are associated with window changes. -
onActivateDefault
public SignalConnection<Window.ActivateDefaultCallback> onActivateDefault(Window.ActivateDefaultCallback handler) Emitted when the user activates the default widget ofwindow
.This is a keybinding signal.
The keybindings for this signal are all forms of the
Enter
key.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitActivateDefault
public void emitActivateDefault()Emits the "activate-default" signal. SeeonActivateDefault(org.gnome.gtk.Window.ActivateDefaultCallback)
. -
onActivateFocus
public SignalConnection<Window.ActivateFocusCallback> onActivateFocus(Window.ActivateFocusCallback handler) Emitted when the user activates the currently focused widget ofwindow
.This is a keybinding signal.
The default binding for this signal is
␣
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitActivateFocus
public void emitActivateFocus()Emits the "activate-focus" signal. SeeonActivateFocus(org.gnome.gtk.Window.ActivateFocusCallback)
. -
onCloseRequest
public SignalConnection<Window.CloseRequestCallback> onCloseRequest(Window.CloseRequestCallback handler) Emitted when the user clicks on the close button of the window.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitCloseRequest
public boolean emitCloseRequest()Emits the "close-request" signal. SeeonCloseRequest(org.gnome.gtk.Window.CloseRequestCallback)
. -
onEnableDebugging
public SignalConnection<Window.EnableDebuggingCallback> onEnableDebugging(Window.EnableDebuggingCallback handler) Emitted when the user enables or disables interactive debugging.When
toggle
istrue
, interactive debugging is toggled on or off, when it isfalse
, the debugger will be pointed at the widget under the pointer.This is a keybinding signal.
The default bindings for this signal are
Ctrl
+Shift
+I
andCtrl
+Shift
+D
.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitEnableDebugging
public boolean emitEnableDebugging(boolean toggle) Emits the "enable-debugging" signal. SeeonEnableDebugging(org.gnome.gtk.Window.EnableDebuggingCallback)
. -
onKeysChanged
@Deprecated public SignalConnection<Window.KeysChangedCallback> onKeysChanged(Window.KeysChangedCallback handler) Deprecated.UseShortcut
andEventController
to implement keyboard shortcutsemitted when the set of accelerators or mnemonics that are associated withwindow
changes.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitKeysChanged
Deprecated.Emits the "keys-changed" signal. SeeonKeysChanged(org.gnome.gtk.Window.KeysChangedCallback)
. -
builder
AWindow.Builder
object constructs aWindow
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withWindow.Builder.build()
.
-
Shortcut
andEventController
to implement keyboard shortcuts