Package ch.bailu.gtk.gtk
Class Window
- All Implemented Interfaces:
PointerInterface
- Direct Known Subclasses:
AboutDialog
,ApplicationWindow
,Assistant
,Dialog
,MessageDialog
,ShortcutsWindow
,Window
A `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 [iface@Gtk.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]
```
`GtkWindow` has a main CSS node with name window and style class .background.
Style classes that are typically used with the main CSS node are .csd (when
client-side decorations are in use), .solid-csd (for client-side decorations
without invisible borders), .ssd (used by mutter when rendering server-side
decorations). GtkWindow also represents window states with the following
style classes on the main node: .maximized, .fullscreen, .tiled (when supported,
also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom).
`GtkWindow` subclasses often add their own discriminating style classes,
such as .dialog, .popup or .tooltip.
Generally, some CSS properties don't make sense on the toplevel window node,
such as margins or padding. When client-side decorations without invisible
borders are in use (i.e. the .solid-csd style class is added to the
main window node), the CSS border of the toplevel window is used for
resize drags. In the .csd case, the shadow area outside of the window
can be used to resize it.
`GtkWindow` adds the .titlebar and .default-decoration style classes to the
widget that is added as a titlebar child.
# Accessibility
`GtkWindow` uses the %GTK_ACCESSIBLE_ROLE_WINDOW role.
# Actions
`GtkWindow` 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.

Windows normally have decorations that are under the control
of the windowing system and allow the user to manipulate the window
(resize it, move it, close it,...).
# GtkWindow as GtkBuildable
The `GtkWindow` implementation of the [iface@Gtk.Buildable] interface supports
setting a child as the titlebar by specifying “titlebar” as the “type”
attribute of a <child> element.
# CSS nodes
```
window.background [.csd / .solid-csd / .ssd] [.maximized / .fullscreen / .tiled]
├── <child>
╰── <titlebar child>.titlebar [.default-decoration]
```
`GtkWindow` has a main CSS node with name window and style class .background.
Style classes that are typically used with the main CSS node are .csd (when
client-side decorations are in use), .solid-csd (for client-side decorations
without invisible borders), .ssd (used by mutter when rendering server-side
decorations). GtkWindow also represents window states with the following
style classes on the main node: .maximized, .fullscreen, .tiled (when supported,
also .tiled-top, .tiled-left, .tiled-right, .tiled-bottom).
`GtkWindow` subclasses often add their own discriminating style classes,
such as .dialog, .popup or .tooltip.
Generally, some CSS properties don't make sense on the toplevel window node,
such as margins or padding. When client-side decorations without invisible
borders are in use (i.e. the .solid-csd style class is added to the
main window node), the CSS border of the toplevel window is used for
resize drags. In the .csd case, the shadow area outside of the window
can be used to resize it.
`GtkWindow` adds the .titlebar and .default-decoration style classes to the
widget that is added as a titlebar child.
# Accessibility
`GtkWindow` uses the %GTK_ACCESSIBLE_ROLE_WINDOW role.
# Actions
`GtkWindow` 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static interface
static interface
static interface
static interface
Nested classes/interfaces inherited from class ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealize
Nested classes/interfaces inherited from class ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
Fields inherited from class ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZE
Fields inherited from class ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionImplements interfaceAccessible
.Implements interfaceBuildable
.Implements interfaceConstraintTarget
.asNative()
Implements interfaceNative
.asRoot()
Implements interfaceRoot
.Implements interfaceShortcutManager
.void
close()
Requests that the window is closed.void
destroy()
Drop the internal reference GTK holds on toplevel windows.void
Asks to place @window in the fullscreen state.void
fullscreenOnMonitor
(Monitor monitor) Asks to place @window in the fullscreen state on the given @monitor.Gets the `GtkApplication` associated with the window.getChild()
Gets the child widget of @window.static ClassHandler
boolean
Returns whether the window has been set to have decorations.static Str
Returns the fallback icon name for windows.void
getDefaultSize
(Int width, Int height) Gets the default size of the window.Returns the default widget for @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 @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 int
boolean
Gets whether mnemonics are supposed to be visible.boolean
getModal()
Returns whether the window is modal.static long
static TypeSystem.TypeSize
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 long
static TypeSystem.TypeSize
boolean
hasGroup()
Returns whether @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 @window.boolean
Retrieves the current maximized state of @window.static List
Returns a list of all existing toplevel windows.void
maximize()
Asks to maximize @window, so that it fills the screen.void
minimize()
Asks to minimize the specified @window.Connect to signal "activate-default".Connect to signal "activate-focus".onCloseRequest
(Window.OnCloseRequest signal) Connect to signal "close-request".Connect to signal "enable-debugging".onKeysChanged
(Window.OnKeysChanged signal) Connect to signal "keys-changed".void
present()
Presents a window to the user.void
presentWithTime
(int timestamp) Presents a window to the user.void
setApplication
(Application application) Sets or unsets the `GtkApplication` associated with the window.static void
setAutoStartupNotification
(boolean setting) Sets whether the window should request startup notification.void
Sets the child widget of @window.void
setDecorated
(boolean setting) Sets whether the window should be decorated.static void
setDefaultIconName
(Str name) Sets an icon to be used as fallback.void
setDefaultSize
(int width, int height) Sets the default size of a window.void
setDefaultWidget
(Widget default_widget) Sets the default widget.void
setDeletable
(boolean setting) Sets whether the window should be deletable.void
setDestroyWithParent
(boolean setting) If @setting is %TRUE, then destroying the transient parent of @window
will also destroy @window itself.void
setDisplay
(Display display) Sets the `GdkDisplay` where the @window is displayed.void
Sets the focus widget.void
setFocusVisible
(boolean setting) Sets whether “focus rectangles” are supposed to be visible.void
setHandleMenubarAccel
(boolean handle_menubar_accel) Sets whether this window should react to F10 key presses
by activating a menubar it contains.void
setHideOnClose
(boolean setting) If @setting is %TRUE, then clicking the close button on the window
will not destroy it, but only hide it.void
setIconName
(Str name) Sets the icon for the window from a named themed icon.void
setIconName
(String name) Sets the icon for the window from a named themed icon.static void
setInteractiveDebugging
(boolean enable) Opens or closes the [interactive debugger](running.html#interactive-debugging).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
(Str startup_id) Sets the startup notification ID.void
setStartupId
(String startup_id) Sets the startup notification ID.void
Sets the title of the `GtkWindow`.void
Sets the title of the `GtkWindow`.void
setTitlebar
(Widget titlebar) Sets a custom titlebar for @window.void
setTransientFor
(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 @window, and return to
its previous state.void
Asks to unmaximize @window.void
Asks to unminimize the specified @window.Methods inherited from class ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getCanFocus, getCanTarget, getChildVisible, getClipboard, 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, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlags
Methods inherited from class ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref
Methods inherited from class ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacks
Methods inherited from class ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNull
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Field Details
-
SIGNAL_ON_ACTIVATE_DEFAULT
- See Also:
-
SIGNAL_ON_ACTIVATE_FOCUS
- See Also:
-
SIGNAL_ON_CLOSE_REQUEST
- See Also:
-
SIGNAL_ON_ENABLE_DEBUGGING
- See Also:
-
SIGNAL_ON_KEYS_CHANGED
- See Also:
-
-
Constructor Details
-
Window
-
Window
public Window()Creates a new `GtkWindow`.
To get an undecorated window (no window borders), use
[method@Gtk.Window.set_decorated].
All top-level windows created by gtk_window_new() are stored
in an internal top-level window list. This list can be obtained
from [func@Gtk.Window.list_toplevels]. 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`, call [method@Gtk.Window.destroy].
-
-
Method Details
-
getClassHandler
-
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 @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
[property@Gdk.Toplevel:state] property, or by listening to
notifications of the [property@Gtk.Window:fullscreened] property. -
fullscreenOnMonitor
Asks to place @window in the fullscreen state on the given @monitor.
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
[property@Gdk.Toplevel:state] property, or by listening to
notifications of the [property@Gtk.Window:fullscreened] property.- Parameters:
monitor
- which monitor to go fullscreen on
-
getApplication
Gets the `GtkApplication` associated with the window.- Returns:
- a `GtkApplication`
-
getChild
Gets the child widget of @window.- Returns:
- the child widget of @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
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.- Parameters:
width
- location to store the default widthheight
- location to store the default height
-
getDefaultWidget
Returns the default widget for @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 be %TRUE for the widget.- Returns:
- the currently focused 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 @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
Retrieves the title of the window.- Returns:
- the title of the window
-
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 @window has an explicit window group.- Returns:
- %TRUE if @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 @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
[method@Gtk.Window.fullscreen] or [method@Gtk.Window.unfullscreen].
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 @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
[method@Gtk.Window.maximize] or [method@Gtk.Window.unmaximize].
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.
-
maximize
public void maximize()Asks to maximize @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
[property@Gdk.Toplevel:state] property, or by listening to
notifications on the [property@Gtk.Window:maximized]
property. -
minimize
public void minimize()Asks to minimize the specified @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
[property@Gdk.Toplevel:state] property. -
present
public void present()Presents a window to the user.
This function should not be used as when it is called,
it is too late to gather a valid timestamp to allow focus
stealing prevention to work correctly. -
presentWithTime
public void presentWithTime(int timestamp) 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 @window is hidden, this function calls [method@Gtk.Widget.show]
as well.
This function should be used when the user tries to open a window
that’s already open. Say for example the preferences dialog is
currently open, and the user chooses Preferences from the menu
a second time; use [method@Gtk.Window.present] to move the
already-open dialog where the user can see it.
Presents a window to the user in response to a user interaction.
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 the `GtkApplication` 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 to %NULL.
This is equivalent to calling [method@Gtk.Application.remove_window]
and/or [method@Gtk.Application.add_window] on the old/new applications
as relevant.- Parameters:
application
- a `GtkApplication`, or %NULL to unset
-
setChild
Sets the child widget of @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 calling
[method@Gtk.Widget.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.
If the window’s “natural” size (its size request) is larger than
the default, the default will be ignored.
Unlike [method@Gtk.Widget.set_size_request], 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).
The default size of a window only affects the first time a window is
shown; if a window is hidden and re-shown, it will remember the size
it had prior to hiding, rather than using the default size.
Windows can’t actually be 0x0 in size, they must be at least 1x1, but
passing 0 for @width and @height is OK, resulting in a 1x1 default size.
If you use this function to reestablish a previously saved window size,
note that the appropriate size to save is the one returned by
[method@Gtk.Window.get_default_size]. 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:
default_widget
- 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 calling [method@Gtk.Widget.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) If @setting is %TRUE, then destroying the transient parent of @window
will also destroy @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 @window with its transient parent
-
setDisplay
Sets the `GdkDisplay` where the @window is displayed.
If the window is already mapped, it will be unmapped,
and then remapped on the new display.- Parameters:
display
- a `GdkDisplay`
-
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. If @focus is %NULL,
unsets the focus widget for this window. To set the focus to a
particular widget in the toplevel, it is usually more convenient
to use [method@Gtk.Widget.grab_focus] instead of this function.- Parameters:
focus
- widget to be the new focus widget, or %NULL to unset any focus widget for the toplevel window.
-
setFocusVisible
public void setFocusVisible(boolean setting) Sets whether “focus rectangles” are supposed to be visible.- Parameters:
setting
- the new value
-
setHandleMenubarAccel
public void setHandleMenubarAccel(boolean handle_menubar_accel) Sets whether this window should react to F10 key presses
by activating a menubar it contains.- Parameters:
handle_menubar_accel
- %TRUE to make @window handle F10
-
setHideOnClose
public void setHideOnClose(boolean setting) If @setting is %TRUE, 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 [class@Gtk.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
-
setIconName
Sets the icon for the window from a named themed icon.
See the docs for [class@Gtk.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.- 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 [method@Gtk.Window.set_transient_for] 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
[method@Gtk.Window.present] or any equivalent function generating
a window map event.
This function is only useful on X11, not with other GTK targets.- Parameters:
startup_id
- a string with startup-notification identifier
-
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
[method@Gtk.Window.present] or any equivalent function generating
a window map event.
This function is only useful on X11, not with other GTK targets.- Parameters:
startup_id
- a string with startup-notification identifier
-
setTitle
Sets the title of the `GtkWindow`.
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
-
setTitle
Sets the title of the `GtkWindow`.
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 @window.
A typical widget used here is [class@Gtk.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
[method@Gtk.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. [ctor@Gtk.Dialog.new_with_buttons] and other
convenience functions in GTK will sometimes call
gtk_window_set_transient_for() on your behalf.
Passing %NULL for @parent 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 @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
[property@Gdk.Toplevel:state] property, or by listening to
notifications of the [property@Gtk.Window:fullscreened] property. -
unmaximize
public void unmaximize()Asks to unmaximize @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
[property@Gdk.Toplevel:state] property, or by listening to
notifications on the [property@Gtk.Window:maximized] property. -
unminimize
public void unminimize()Asks to unminimize the specified @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
[property@Gdk.Toplevel:state] property. -
onActivateDefault
Connect to signal "activate-default".
SeeWindow.OnActivateDefault.onActivateDefault()
for signal description.
FieldSIGNAL_ON_ACTIVATE_DEFAULT
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onActivateFocus
Connect to signal "activate-focus".
SeeWindow.OnActivateFocus.onActivateFocus()
for signal description.
FieldSIGNAL_ON_ACTIVATE_FOCUS
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onCloseRequest
Connect to signal "close-request".
SeeWindow.OnCloseRequest.onCloseRequest()
for signal description.
FieldSIGNAL_ON_CLOSE_REQUEST
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onEnableDebugging
Connect to signal "enable-debugging".
SeeWindow.OnEnableDebugging.onEnableDebugging(boolean)
for signal description.
FieldSIGNAL_ON_ENABLE_DEBUGGING
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
onKeysChanged
Connect to signal "keys-changed".
SeeWindow.OnKeysChanged.onKeysChanged()
for signal description.
FieldSIGNAL_ON_KEYS_CHANGED
contains original signal name and can be used as resource reference.- Parameters:
signal
- callback function (lambda).- Returns:
SignalHandler
. Can be used to disconnect signal and to release callback function.
-
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
[func@Gtk.Window.set_default_icon_name].- 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 calls
[method@Gdk.Display.notify_startup_complete]. 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 [method@Gtk.Window.set_icon_name]
called on them.- Parameters:
name
- the name of the themed icon
-
setInteractiveDebugging
public static void setInteractiveDebugging(boolean enable) Opens or closes the [interactive debugger](running.html#interactive-debugging).
The debugger offers access to the widget hierarchy of the application
and to useful debugging tools.- Parameters:
enable
- %TRUE to enable interactive debugging
-
asAccessible
Implements interfaceAccessible
. Call this to get access to interface functions.- Overrides:
asAccessible
in classWidget
- Returns:
Accessible
-
asBuildable
Implements interfaceBuildable
. Call this to get access to interface functions.- Overrides:
asBuildable
in classWidget
- Returns:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget
. Call this to get access to interface functions.- Overrides:
asConstraintTarget
in classWidget
- Returns:
ConstraintTarget
-
asNative
Implements interfaceNative
. Call this to get access to interface functions.- Returns:
Native
-
asRoot
Implements interfaceRoot
. Call this to get access to interface functions.- Returns:
Root
-
asShortcutManager
Implements interfaceShortcutManager
. Call this to get access to interface functions.- Returns:
ShortcutManager
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-