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.

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.

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.

If you use this function to reestablish a previously saved window size, note that the appropriate size to save is the one returned by the gtk:window-default-size function. Using the window allocation directly will not work in all circumstances and can lead to growing or shrinking windows.

Examples

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

See also

2024-10-2