Package: gtk

Function gtk-widget-size-request

Lambda List

gtk-widget-size-request (widget)

Syntax

(gtk-widget-size-request object) => width, height
(setf (gtk-widget-size-request object) (list width height))

Arguments

object -- a gtk-widget object
width -- an integer with the width
height -- an integer with the height

Details

Accessor of the size request of the widget.

A value of -1 returned in width or height indicates that that dimension has not been set explicitly and the natural requisition of the widget will be used instead. To get the size a widget will actually request, call the gtk-widget-preferred-size function instead of this function.

The (setf gtk-widget-size-request) function sets the minimum size of a widget. That is, the size request of the widget will be width by height. You can use this function to force a widget to be either larger or smaller than it normally would be.

In most cases, the gtk-window-default-size function is a better choice for toplevel windows than this function. Setting the default size will still allow users to shrink the window. Setting the size request will force them to leave the window at least as large as the size request. When dealing with window sizes, the gtk-window-set-geometry-hints function can be a useful function as well.

Note the inherent danger of setting any fixed size - themes, translations into other languages, different fonts, and user action can all change the appropriate size for a given widget. So, it is basically impossible to hardcode a size that will always be correct.

The size request of a widget is the smallest size a widget can accept while still functioning well and drawing itself correctly. However in some strange cases a widget may be allocated less than its requested size, and in many cases a widget may be allocated more space than it requested.

If the size request in a given direction is -1 (unset), then the "natural" size request of the widget will be used instead.

Widgets cannot actually be allocated a size less than 1 by 1, but you can pass 0 by 0 to this function to mean "as small as possible".

The size request set here does not include any margin from the margin-start, margin-end, margin-top, and margin-bottom properties, but it does include pretty much all other padding or border properties set by any subclass of the gtk-widget class.
 

See also

2021-9-16