adw.button_content

Module for [ButtonContent] class

Types 3

A helper widget for creating buttons.

button-content

adw.button_content.ButtonContent is a box-like widget with an icon and a label.

It's intended to be used as a direct child of gtk.button.Button, gtk.menu_button.MenuButton or adw.split_button.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>

adw.button_content.ButtonContent handles style classes and connecting the mnemonic to the button automatically.

CSS nodes

buttoncontent
╰── box
    ├── image
    ╰── label

adw.button_content.ButtonContent'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 gtk.button.Button or adw.split_button.SplitButton, the button will receive the .image-text-button style class. When inside a gtk.menu_button.MenuButton, the internal gtk.button.Button will receive it instead.

Accessibility

adw.button_content.ButtonContent uses the gtk.types.AccessibleRole.Group role.

Methods
GType _getGType() static nothrow
GType _gType() @property nothrow
ButtonContent self() nothrowReturns `this`, for use in `with` statements.
ButtonContentGidBuilder builder() static nothrowGet builder for [adw.button_content.ButtonContent] Returns: New builder object
bool canShrink() @property nothrowGet `canShrink` property. Returns: Whether the button can be smaller than the natural size of its contents.
void canShrink(bool propval) @property nothrowSet `canShrink` property. Params: propval = Whether the button can be smaller than the natural size of its contents.
string iconName() @property nothrowGet `iconName` property. Returns: The name of the displayed icon.
void iconName(string propval) @property nothrowSet `iconName` property. Params: propval = The name of the displayed icon.
string label() @property nothrowGet `label` property. Returns: The displayed label.
void label(string propval) @property nothrowSet `label` property. Params: propval = The displayed label.
bool useUnderline() @property nothrowGet `useUnderline` property. Returns: Whether an underline in the text indicates a mnemonic.
void useUnderline(bool propval) @property nothrowSet `useUnderline` property. Params: propval = Whether an underline in the text indicates a mnemonic.
bool getCanShrink() nothrowgets whether the button can be smaller than the natural size of its contents. Returns: whether the button can shrink
string getIconName() nothrowGets the name of the displayed icon. Returns: the icon name
string getLabel() nothrowGets the displayed label. Returns: the label
bool getUseUnderline() nothrowGets whether an underline in the text indicates a mnemonic. Returns: whether an underline in the text indicates a mnemonic
void setCanShrink(bool canShrink) nothrowSets whether the button can be smaller than the natural size of its contents.
void setIconName(string iconName) nothrowSets the name of the displayed icon.
void setLabel(string label) nothrowSets the displayed label.
void setUseUnderline(bool useUnderline) nothrowSets whether an underline in the text indicates a mnemonic.
Constructors
this(void * ptr, Flag!"Take" take)
this()Creates a new [adw.button_content.ButtonContent]. Returns: the new created [adw.button_content.ButtonContent]

Fluent builder implementation template for adw.button_content.ButtonContent

Methods
T canShrink(bool propval) nothrowSet `canShrink` property. Params: propval = Whether the button can be smaller than the natural size of its contents.
T iconName(string propval) nothrowSet `iconName` property. Params: propval = The name of the displayed icon.
T label(string propval) nothrowSet `label` property. Params: propval = The displayed label. Returns: Builder instance for fluent chaining
T useUnderline(bool propval) nothrowSet `useUnderline` property. Params: propval = Whether an underline in the text indicates a mnemonic.
Methods
ButtonContent build() nothrowCreate object from builder. Returns: New object