Package: gtk

Function gtk-window-default-size

Lambda List

gtk-window-default-size (window)

Syntax

(gtk-window-default-size window) => width, height
(setf (gtk-window-default-size window) (list width height))

Arguments

window -- a gtk-window widget
width -- an integer with the default width of the window
height -- an integer with the default height of the window

Details

Accessor of the default size of a gtk-window widget.

The gtk-window-default-size function gets the default size of the window. The (setf gtk-window-default-size) function sets the default size. A value of -1 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.

If the "natural" size of the window, its size request, is larger than the default, the default will be ignored. More generally, if the default size does not obey the geometry hints for the window, the gtk-window-set-geometry-hints function can be used to set these explicitly, the default size will be clamped to the nearest permitted size.

Unlike the gtk-widget-size-request function, 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.

For more control over the initial size of the window and how resizing works, investigate the gtk-window-set-geometry-hints function.

For some uses, the gtk-window-resize function is a more appropriate function. The gtk-window-resize function changes the current size of the window, rather than the size to be used on initial display. The gtk-window-resize function always affects the window itself, not the geometry widget.

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 cannot actually be 0 x 0 in size, they must be at least 1 x 1, but passing 0 for width and height is fine, resulting in a 1 x 1 default size.

Example

(let ((window (make-instance 'gtk-window)))
  (setf (gtk-window-default-size window) '(300 200))
  (gtk-window-default-size window))
=> 300, 200    
 

See also

2021-9-12