ButtonContent#
Superclasses: Widget, InitiallyUnowned, Object
Implemented Interfaces: Accessible, Buildable, ConstraintTarget
A helper widget for creating buttons.
AdwButtonContent is a box-like widget with an icon and a label.
It’s intended to be used as a direct child of Button,
MenuButton or SplitButton, when they need to have both an
icon and a label, as follows:
<object class="GtkButton">
<property name="child">
<object class="AdwButtonContent">
<property name="icon-name">document-open-symbolic</property>
<property name="label" translatable="yes">_Open</property>
<property name="use-underline">True</property>
</object>
</property>
</object>
AdwButtonContent handles style classes and connecting the mnemonic to the
button automatically.
CSS nodes#
buttoncontent
╰── box
├── image
╰── label
AdwButtonContent's CSS node is called buttoncontent. It contains a box
subnode that serves as a container for the image and label nodes.
When inside a GtkButton or AdwSplitButton, the button will receive the
.image-text-button style class. When inside a GtkMenuButton, the
internal GtkButton will receive it instead.
Accessibility#
AdwButtonContent uses the GTK_ACCESSIBLE_ROLE_GROUP role.
Constructors#
Methods#
- class ButtonContent
- get_can_shrink() → bool#
gets whether the button can be smaller than the natural size of its contents.
Added in version 1.4.
- set_can_shrink(can_shrink: bool) → None#
Sets whether the button can be smaller than the natural size of its contents.
If set to
TRUE, the label will ellipsize.See
set_can_shrink.Added in version 1.4.
- Parameters:
can_shrink – whether the button can shrink