1.14 <AdwButtonContent>

Class: <AdwButtonContent>

It derives from <GtkWidget>.

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 <GtkButton>, <GtkMenuButton> 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.AccessibleRole.group role.

Properties

Property: button-content:can-shrink self

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

If set to TRUE, the label will ellipsize.

See button:can-shrink.

Its value is a boolean.

Set it with (set! (button-content:can-shrink self) value).

Property: button-content:icon-name self

The name of the displayed icon.

If empty, the icon is not shown.

Its value is a string, or #f.

Set it with (set! (button-content:icon-name self) value).

Property: button-content:label self

The displayed label.

Its value is a string, or #f.

Set it with (set! (button-content:label self) value).

Property: button-content:use-underline self

Whether an underline in the text indicates a mnemonic.

The mnemonic can be used to activate the parent button.

See ButtonContent:label.

Its value is a boolean.

Set it with (set! (button-content:use-underline self) value).

Procedures

Method: button-content:get-can-shrink? self ⇒ %return
Method: get-can-shrink? self ⇒ %return

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

self

Passed: a <AdwButtonContent>.

a button content

%return

Returned: a boolean.

whether the button can shrink

Method: button-content:get-icon-name self ⇒ %return
Method: get-icon-name self ⇒ %return

Gets the name of the displayed icon.

self

Passed: a <AdwButtonContent>.

a button content

%return

Returned: a string.

the icon name

Method: button-content:get-label self ⇒ %return
Method: get-label self ⇒ %return

Gets the displayed label.

self

Passed: a <AdwButtonContent>.

a button content

%return

Returned: a string.

the label

Method: button-content:get-use-underline? self ⇒ %return
Method: get-use-underline? self ⇒ %return

Gets whether an underline in the text indicates a mnemonic.

self

Passed: a <AdwButtonContent>.

a button content

%return

Returned: a boolean.

whether an underline in the text indicates a mnemonic

Procedure: button-content:new ⇒ %return

Creates a new <AdwButtonContent>.

%return

Returned: a <GtkWidget>.

the new created <AdwButtonContent>

Method: button-content:set-can-shrink self can-shrink
Method: set-can-shrink self can-shrink

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

If set to TRUE, the label will ellipsize.

See button:set-can-shrink.

self

Passed: a <AdwButtonContent>.

a button content

can-shrink

Passed: a boolean.

whether the button can shrink

Method: button-content:set-icon-name self icon-name
Method: set-icon-name self icon-name

Sets the name of the displayed icon.

If empty, the icon is not shown.

self

Passed: a <AdwButtonContent>.

a button content

icon-name

Passed: a string.

the new icon name

Method: button-content:set-label self label
Method: set-label self label

Sets the displayed label.

self

Passed: a <AdwButtonContent>.

a button content

label

Passed: a string.

the new label

Method: button-content:set-use-underline self use-underline
Method: set-use-underline self use-underline

Sets whether an underline in the text indicates a mnemonic.

The mnemonic can be used to activate the parent button.

See ButtonContent:label.

self

Passed: a <AdwButtonContent>.

a button content

use-underline

Passed: a boolean.

whether an underline in the text indicates a mnemonic