Adw.SplitButton

g Adw.SplitButton Adw.SplitButton GObject.GInterface GObject.GInterface Gtk.Accessible Gtk.Accessible GObject.GInterface->Gtk.Accessible Gtk.Actionable Gtk.Actionable GObject.GInterface->Gtk.Actionable Gtk.Buildable Gtk.Buildable GObject.GInterface->Gtk.Buildable Gtk.ConstraintTarget Gtk.ConstraintTarget GObject.GInterface->Gtk.ConstraintTarget GObject.InitiallyUnowned GObject.InitiallyUnowned Gtk.Widget Gtk.Widget GObject.InitiallyUnowned->Gtk.Widget GObject.Object GObject.Object GObject.Object->GObject.InitiallyUnowned Gtk.Accessible->Gtk.Widget Gtk.Actionable->Adw.SplitButton Gtk.Buildable->Gtk.Widget Gtk.ConstraintTarget->Gtk.Widget Gtk.Widget->Adw.SplitButton

Subclasses:

None

Methods

Inherited:

Gtk.Widget (181), GObject.Object (37), Gtk.Accessible (15), Gtk.Buildable (1), Gtk.Actionable (5)

Structs:

Gtk.WidgetClass (18), GObject.ObjectClass (5)

class

new ()

get_can_shrink ()

get_child ()

get_direction ()

get_dropdown_tooltip ()

get_icon_name ()

get_label ()

get_menu_model ()

get_popover ()

get_use_underline ()

popdown ()

popup ()

set_can_shrink (can_shrink)

set_child (child)

set_direction (direction)

set_dropdown_tooltip (tooltip)

set_icon_name (icon_name)

set_label (label)

set_menu_model (menu_model)

set_popover (popover)

set_use_underline (use_underline)

Virtual Methods

Inherited:

Gtk.Widget (25), GObject.Object (7), Gtk.Accessible (6), Gtk.Buildable (9), Gtk.Actionable (4)

Properties

Inherited:

Gtk.Widget (34), Gtk.Accessible (1), Gtk.Actionable (2)

Name

Type

Flags

Short Description

can-shrink

bool

r/w/en

child

Gtk.Widget

r/w/en

direction

Gtk.ArrowType

r/w/en

dropdown-tooltip

str

r/w/en

icon-name

str

r/w/en

label

str

r/w/en

menu-model

Gio.MenuModel

r/w/en

popover

Gtk.Popover

r/w/en

use-underline

bool

r/w/en

Signals

Inherited:

Gtk.Widget (13), GObject.Object (1)

Name

Short Description

activate

Emitted to animate press then release.

clicked

Emitted when the button has been activated (pressed and released).

Fields

Inherited:

Gtk.Widget (13), GObject.Object (1)

Class Details

class Adw.SplitButton(**kwargs)
Bases:

Gtk.Widget, Gtk.Actionable

Abstract:

No

Structure:

Adw.SplitButtonClass

A combined button and dropdown widget.

<picture> <source srcset=”split-button-dark.png” media=”(prefers-color-scheme: dark)”> <img src=”split-button.png” alt=”split-button”> </picture>

AdwSplitButton is typically used to present a set of actions in a menu, but allow access to one of them with a single click.

The API is very similar to [class`Gtk`.Button] and [class`Gtk`.MenuButton], see their documentation for details.

CSS nodes

`` splitbutton[.image-button][.text-button] ├── button │ ╰── <content> ├── separator ╰── menubutton

╰── button.toggle

╰── arrow

``

AdwSplitButton’s CSS node is called splitbutton. It contains the css nodes: button, separator, menubutton. See [class`Gtk`.MenuButton] documentation for the menubutton contents.

The main CSS node will contain the .image-button or .text-button style classes matching the button contents. The nested button nodes will never contain them.

Accessibility

AdwSplitButton uses the GTK_ACCESSIBLE_ROLE_GROUP role.

classmethod new()
Returns:

the newly created AdwSplitButton

Return type:

Gtk.Widget

Creates a new AdwSplitButton.

get_can_shrink()
Returns:

whether the button can shrink

Return type:

bool

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

New in version 1.4.

get_child()
Returns:

the child widget

Return type:

Gtk.Widget or None

Gets the child widget.

get_direction()
Returns:

the direction

Return type:

Gtk.ArrowType

Gets the direction in which the popup will be popped up.

get_dropdown_tooltip()
Returns:

the dropdown tooltip of self

Return type:

str

Gets the tooltip of the dropdown button of self.

New in version 1.2.

get_icon_name()
Returns:

the icon name

Return type:

str or None

Gets the name of the icon used to automatically populate the button.

get_label()
Returns:

the label for self

Return type:

str or None

Gets the label for self.

get_menu_model()
Returns:

the menu model

Return type:

Gio.MenuModel or None

Gets the menu model from which the popup will be created.

get_popover()
Returns:

the popover

Return type:

Gtk.Popover or None

Gets the popover that will be popped up when the dropdown is clicked.

get_use_underline()
Returns:

whether an underline in the text indicates a mnemonic

Return type:

bool

Gets whether an underline in the text indicates a mnemonic.

popdown()

Dismisses the menu.

popup()

Pops up the menu.

set_can_shrink(can_shrink)
Parameters:

can_shrink (bool) – whether the button 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 [method`Gtk`.Button.set_can_shrink] and [method`Gtk`.MenuButton.set_can_shrink].

New in version 1.4.

set_child(child)
Parameters:

child (Gtk.Widget or None) – the new child widget

Sets the child widget.

Setting the child widget will set [property`SplitButton`:py:data::label<Adw.SplitButton.props.label>] and [property`SplitButton`:py:data::icon-name<Adw.SplitButton.props.icon_name>] to NULL.

set_direction(direction)
Parameters:

direction (Gtk.ArrowType) – the direction

Sets the direction in which the popup will be popped up.

The dropdown arrow icon will point at the same direction.

If the does not fit in the available space in the given direction, GTK will try its best to keep it inside the screen and fully visible.

If you pass GTK_ARROW_NONE, it’s equivalent to GTK_ARROW_DOWN.

set_dropdown_tooltip(tooltip)
Parameters:

tooltip (str) – the dropdown tooltip of self

Sets the tooltip of the dropdown button of self.

The tooltip can be marked up with the Pango text markup language.

New in version 1.2.

set_icon_name(icon_name)
Parameters:

icon_name (str) – the icon name to set

Sets the name of the icon used to automatically populate the button.

Setting the icon name will set [property`SplitButton`:py:data::label<Adw.SplitButton.props.label>] and [property`SplitButton`:py:data::child<Adw.SplitButton.props.child>] to NULL.

set_label(label)
Parameters:

label (str) – the label to set

Sets the label for self.

Setting the label will set [property`SplitButton`:py:data::icon-name<Adw.SplitButton.props.icon_name>] and [property`SplitButton`:py:data::child<Adw.SplitButton.props.child>] to NULL.

set_menu_model(menu_model)
Parameters:

menu_model (Gio.MenuModel or None) – the menu model

Sets the menu model from which the popup will be created.

If the menu model is NULL, the dropdown is disabled.

A [class`Gtk`.Popover] will be created from the menu model with [ctor`Gtk`.PopoverMenu.new_from_model]. Actions will be connected as documented for this function.

If [property`SplitButton`:py:data::popover<Adw.SplitButton.props.popover>] is already set, it will be dissociated from the button, and the property is set to NULL.

set_popover(popover)
Parameters:

popover (Gtk.Popover or None) – the popover

Sets the popover that will be popped up when the dropdown is clicked.

If the popover is NULL, the dropdown is disabled.

If [property`SplitButton`:py:data::menu-model<Adw.SplitButton.props.menu_model>] is set, the menu model is dissociated from the button, and the property is set to NULL.

set_use_underline(use_underline)
Parameters:

use_underline (bool) – whether an underline in the text indicates a mnemonic

Sets whether an underline in the text indicates a mnemonic.

See [property`SplitButton`:py:data::label<Adw.SplitButton.props.label>].

Signal Details

Adw.SplitButton.signals.activate(split_button)
Signal Name:

activate

Flags:

RUN_FIRST, ACTION

Parameters:

split_button (Adw.SplitButton) – The object which received the signal

Emitted to animate press then release.

This is an action signal. Applications should never connect to this signal, but use the [signal`SplitButton`:py:func:::clicked<Adw.SplitButton.signals.clicked>] signal.

Adw.SplitButton.signals.clicked(split_button)
Signal Name:

clicked

Flags:

RUN_FIRST, ACTION

Parameters:

split_button (Adw.SplitButton) – The object which received the signal

Emitted when the button has been activated (pressed and released).

Property Details

Adw.SplitButton.props.can_shrink
Name:

can-shrink

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

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

If set to TRUE, the label will ellipsize.

See [property`Gtk`.Button:can-shrink] and [property`Gtk`.MenuButton:can-shrink].

New in version 1.4.

Adw.SplitButton.props.child
Name:

child

Type:

Gtk.Widget

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The child widget.

Setting the child widget will set [property`SplitButton`:py:data::label<Adw.SplitButton.props.label>] and [property`SplitButton`:py:data::icon-name<Adw.SplitButton.props.icon_name>] to NULL.

Adw.SplitButton.props.direction
Name:

direction

Type:

Gtk.ArrowType

Default Value:

Gtk.ArrowType.DOWN

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The direction in which the popup will be popped up.

The dropdown arrow icon will point at the same direction.

If the does not fit in the available space in the given direction, GTK will try its best to keep it inside the screen and fully visible.

If you pass GTK_ARROW_NONE, it’s equivalent to GTK_ARROW_DOWN.

Adw.SplitButton.props.dropdown_tooltip
Name:

dropdown-tooltip

Type:

str

Default Value:

''

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The tooltip of the dropdown button.

The tooltip can be marked up with the Pango text markup language.

New in version 1.2.

Adw.SplitButton.props.icon_name
Name:

icon-name

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The name of the icon used to automatically populate the button.

Setting the icon name will set [property`SplitButton`:py:data::label<Adw.SplitButton.props.label>] and [property`SplitButton`:py:data::child<Adw.SplitButton.props.child>] to NULL.

Adw.SplitButton.props.label
Name:

label

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The label for the button.

Setting the label will set [property`SplitButton`:py:data::icon-name<Adw.SplitButton.props.icon_name>] and [property`SplitButton`:py:data::child<Adw.SplitButton.props.child>] to NULL.

Adw.SplitButton.props.menu_model
Name:

menu-model

Type:

Gio.MenuModel

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The GMenuModel from which the popup will be created.

If the menu model is NULL, the dropdown is disabled.

A [class`Gtk`.Popover] will be created from the menu model with [ctor`Gtk`.PopoverMenu.new_from_model]. Actions will be connected as documented for this function.

If [property`SplitButton`:py:data::popover<Adw.SplitButton.props.popover>] is already set, it will be dissociated from the button, and the property is set to NULL.

Adw.SplitButton.props.popover
Name:

popover

Type:

Gtk.Popover

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The GtkPopover that will be popped up when the dropdown is clicked.

If the popover is NULL, the dropdown is disabled.

If [property`SplitButton`:py:data::menu-model<Adw.SplitButton.props.menu_model>] is set, the menu model is dissociated from the button, and the property is set to NULL.

Adw.SplitButton.props.use_underline
Name:

use-underline

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether an underline in the text indicates a mnemonic.

See [property`SplitButton`:py:data::label<Adw.SplitButton.props.label>].