Struct gtk4::SizeGroup [−][src]
pub struct SizeGroup(_);
Expand description
SizeGroup
groups widgets together so they all request the same size.
This is typically useful when you want a column of widgets to have the
same size, but you can’t use a Grid
.
In detail, the size requested for each widget in a SizeGroup
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 set_mode()
) 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 SizeGroup
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.
SizeGroup
objects are referenced by each widget in the size group,
so once you have added all widgets to a SizeGroup
, you can drop
the initial reference to the size group with g_object_unref()
. If the
widgets in the size group are subsequently destroyed, then they will
be removed from the size group and drop their references on the size
group; when all widgets have been removed, the size group will be
freed.
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 SizeGroupMode::Horizontal
or SizeGroupMode::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
SizeGroupMode::Vertical
or SizeGroupMode::Both
.
Note that only non-contextual sizes of every widget are ever consulted
by size groups (since size groups have no knowledge of what size a widget
will be allocated in one dimension, it cannot derive how much height
a widget will receive for a given width). When grouping widgets that
trade height for width in mode SizeGroupMode::Vertical
or SizeGroupMode::Both
:
the height for the minimum width will be the requested height for all
widgets in the group. The same is of course true when horizontally grouping
width for height widgets.
Widgets that trade height-for-width should set a reasonably large minimum
width by way of property::Label::width-chars
for instance. Widgets with
static sizes as well as widgets that grow (such as ellipsizing text) need no
such considerations.
GtkSizeGroup as GtkBuildable
Size groups can be specified in a UI definition by placing an <object>
element with class="GtkSizeGroup"
somewhere in the UI definition. The
widgets that belong to the size group are specified by a <widgets>
element
that may contain multiple <widget>
elements, one for each member of the
size group. The ”name” attribute gives the id of the widget.
An example of a UI definition fragment with SizeGroup
:
<object class="GtkSizeGroup">
<property name="mode">horizontal</property>
<widgets>
<widget name="radio1"/>
<widget name="radio2"/>
</widgets>
</object>
Implements
Implementations
Adds a widget to a SizeGroup
.
In the future, the requisition
of the widget will be determined as the maximum of its requisition
and the requisition of the other widgets in the size group.
Whether this applies horizontally, vertically, or in both directions
depends on the mode of the size group.
See set_mode()
.
When the widget is destroyed or no longer referenced elsewhere, it will be removed from the size group.
widget
the Widget
to add
Returns the list of widgets associated with self
.
Returns
a GSList
of
widgets. The list is owned by GTK and should not be modified.
Sets the SizeGroupMode
of the size group.
The mode of the size group determines whether the widgets in the
size group should all have the same horizontal requisition
(SizeGroupMode::Horizontal
) all have the same vertical requisition
(SizeGroupMode::Vertical
), or should all have the same requisition
in both directions (SizeGroupMode::Both
).
mode
the mode to set for the size group.
Trait Implementations
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Returns the type identifier of Self
.
Auto Trait Implementations
impl RefUnwindSafe for SizeGroup
impl UnwindSafe for SizeGroup
Blanket Implementations
Mutably borrows from an owned value. Read more
Upcasts an object to a superclass or interface T
. Read more
Upcasts an object to a reference of its superclass or interface T
. Read more
Tries to downcast to a subclass or interface implementor T
. Read more
Tries to downcast to a reference of its subclass or interface implementor T
. Read more
Tries to cast to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Tries to cast to reference to an object of type T
. This handles upcasting, downcasting
and casting between interface and interface implementors. All checks are performed at
runtime, while downcast
and upcast
will do many checks at compile-time already. Read more
Casts to T
unconditionally. Read more
Casts to &T
unconditionally. Read more
Returns true
if the object is an instance of (can be cast to) T
.
pub fn set_property<'a, N, V>(
&self,
property_name: N,
value: V
) -> Result<(), BoolError> where
N: Into<&'a str>,
V: ToValue,
pub fn set_property_from_value<'a, N>(
&self,
property_name: N,
value: &Value
) -> Result<(), BoolError> where
N: Into<&'a str>,
pub fn set_properties_from_value(
&self,
property_values: &[(&str, Value)]
) -> Result<(), BoolError>
pub fn has_property<'a, N>(&self, property_name: N, type_: Option<Type>) -> bool where
N: Into<&'a str>,
pub fn find_property<'a, N>(&self, property_name: N) -> Option<ParamSpec> where
N: Into<&'a str>,
Safety Read more
Safety Read more
Safety Read more
Safety Read more
pub fn connect<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value> + Send + Sync,
Same as connect
but takes a SignalId
instead of a signal name.
pub fn connect_local<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: 'static + Fn(&[Value]) -> Option<Value>,
Same as connect_local
but takes a SignalId
instead of a signal name.
pub unsafe fn connect_unsafe<'a, N, F>(
&self,
signal_name: N,
after: bool,
callback: F
) -> Result<SignalHandlerId, BoolError> where
N: Into<&'a str>,
F: Fn(&[Value]) -> Option<Value>,
Same as connect_unsafe
but takes a SignalId
instead of a signal name.
Emit signal by signal id.
Same as emit
but takes Value
for the arguments.
Emit signal by its name.
Same as emit_by_name
but takes Value
for the arguments.
Emit signal with details by signal id.
Same as emit_with_details
but takes Value
for the arguments.
pub fn connect_notify<F>(&self, name: Option<&str>, f: F) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec) + Send + Sync,
pub fn connect_notify_local<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: 'static + Fn(&T, &ParamSpec),
pub unsafe fn connect_notify_unsafe<F>(
&self,
name: Option<&str>,
f: F
) -> SignalHandlerId where
F: Fn(&T, &ParamSpec),
pub fn bind_property<'a, O, N, M>(
&'a self,
source_property: N,
target: &'a O,
target_property: M
) -> BindingBuilder<'a> where
O: ObjectType,
N: Into<&'a str>,
M: Into<&'a str>,
Returns a SendValue
clone of self
.