Package: gtk
Class gtk:size-group
Superclassesgtk:buildable, gobject:object, common-lisp:standard-object, common-lisp:t Documented Subclasses
None
Direct SlotsDetails The gtk:size-group object provides a mechanism for grouping a number
of widgets together so they all request the same amount of space.
This is typically useful when you want a column of widgets to have the same size, but you cannot use a gtk:grid widget. In detail, the size requested for each widget in a size group is the maximum of the sizes that would have been requested for each widget in the size group if they were not in the size group. The mode of the size group, see the gtk:size-group-mode function, determines whether this applies to the horizontal size, the vertical size, or both sizes. Note that size groups only affect the amount of space requested, not the size that the widgets finally receive. If you want the widgets in a size group to actually be the same size, you need to pack them in such a way that they get the size they request and not more. In particular it does not make a lot of sense to set the expand flags on the widgets that are members of a size group. Widgets can be part of multiple size groups. GTK will compute the horizontal size of a widget from the horizontal requisition of all widgets that can be reached from the widget by a chain of size groups of type :horizontal or :both, and the vertical size from the vertical requisition of all widgets that can be reached from the widget by a chain of size groups of type :vertical or :both. Size groups and trading height-for-widthWarning: Generally, size groups do not interact well with widgets that trade height for width (or width for height), such as wrappable labels. Avoid using size groups with such widgets.A size group with :horizontal or :vertival mode only consults non-contextual sizes of widgets other than the one being measured, since it has no knowledge of what size a widget will get allocated in the other orientation. This can lead to widgets in a size group actually requesting different contextual sizes, contrary to the purpose of the gtk:size-group widget. In contrast, a size group with :both mode can properly propagate the available size in the opposite orientation when measuring widgets in the size group, which results in consistent and accurate measurements. In case some mechanism other than a size group is already used to ensure that widgets in a size group all get the same size in one orientation, for example, some common ancestor is known to allocate the same width to all its children, and the size group is only really needed to also make the widgets request the same size in the other orientation, it is beneficial to still set the mode of the size group to the :both value. This lets the size group assume and count on sizes of the widgets in the former orientation being the same, which enables it to propagate the available size as described above. Alternatives to size groupsSize groups have many limitations, such as only influencing size requests but not allocations, and poor height-for-width support. When possible, prefer using dedicated mechanisms that can properly ensure that the widgets get the same size.Various container widgets and layout managers support a homogeneous layout mode, where they will explicitly give the same size to their children, see the homogeneous property. Using homogeneous mode can also have large performance benefits compared to either the same container in non-homogeneous mode, or to size groups. The gtk:grid widget can be used to position widgets into rows and columns. Members of each column will have the same width among them. Likewise, members of each row will have the same height. On top of that, the heights can be made equal between all rows with the row-homogeneous property, and the widths can be made equal between all columns with the column-homogeneous property. GtkSizeGroup as GtkBuildableExamples<object class="GtkSizeGroup"> <property name="mode">GTK_SIZE_GROUP_HORIZONTAL</property> <widgets> <widget name="radio1"/> <widget name="radio2"/> </widgets> </object> | Returned bySlot Access FunctionsInherited Slot Access FunctionsSee also |
2025-2-23