ButtonContent

class ButtonContent(pointer: <Error class: unknown class><<Error class: unknown class>>)

A helper widget for creating buttons.

button-content

AdwButtonContent is a box-like widget with an icon and a label.

It's intended to be used as a direct child of class@Gtk.Button, class@Gtk.MenuButton or class@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

Link copied to clipboard
constructor()

Creates a new AdwButtonContent.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
val adwButtonContentPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

Whether the button can be smaller than the natural size of its contents.

Link copied to clipboard
open val gtkAccessiblePointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val gtkBuildablePointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open val gtkConstraintTargetPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard

The name of the displayed icon.

Link copied to clipboard

The displayed label.

Link copied to clipboard

Whether an underline in the text indicates a mnemonic.

Functions

Link copied to clipboard

gets whether the button can be smaller than the natural size of its contents.

Link copied to clipboard

Gets the name of the displayed icon.

Link copied to clipboard

Gets the displayed label.

Link copied to clipboard

Gets whether an underline in the text indicates a mnemonic.

Link copied to clipboard
fun setCanShrink(canShrink: Boolean)

Sets whether the button can be smaller than the natural size of its contents.

Link copied to clipboard
fun setIconName(iconName: String)

Sets the name of the displayed icon.

Link copied to clipboard
fun setLabel(label: String)

Sets the displayed label.

Link copied to clipboard
fun setUseUnderline(useUnderline: Boolean)

Sets whether an underline in the text indicates a mnemonic.