SwitchRow

A gtk.list_box_row.ListBoxRow used to represent two states.

<picture> <source srcset="switch-row-dark.png" media="(prefers-color-scheme: dark)"> <img src="switch-row.png" alt="switch-row"> </picture>

The adw.switch_row.SwitchRow widget contains a gtk.switch_.Switch that allows the user to select between two states: "on" or "off". When activated, the row will invert its active state.

The user can control the switch by activating the row or by dragging on the switch handle.

See gtk.switch_.Switch for details.

Example of an adw.switch_row.SwitchRow UI definition:

<object class="AdwSwitchRow">
  <property name="title" translatable="yes">Switch Row</property>
  <signal name="notify::active" handler="switch_row_notify_active_cb"/>
</object>

The property@SwitchRow:active property should be connected to in order to monitor changes to the active state.

Accessibility

adw.switch_row.SwitchRow uses the gtk.types.AccessibleRole.Switch role.

Constructors

this
this()

Creates a new adw.switch_row.SwitchRow.

Members

Functions

getActive
bool getActive()

Gets whether self is in its "on" or "off" position.

setActive
void setActive(bool isActive)

Sets whether self is in its "on" or "off" position

Inherited Members

From ActionRow

activate
void activate()

Activates self.

addPrefix
void addPrefix(gtk.widget.Widget widget)

Adds a prefix widget to self.

addSuffix
void addSuffix(gtk.widget.Widget widget)

Adds a suffix widget to self.

getActivatableWidget
gtk.widget.Widget getActivatableWidget()

Gets the widget activated when self is activated.

getIconName
string getIconName()

Gets the icon name for self.

getSubtitle
string getSubtitle()

Gets the subtitle for self.

getSubtitleLines
int getSubtitleLines()

Gets the number of lines at the end of which the subtitle label will be ellipsized.

getSubtitleSelectable
bool getSubtitleSelectable()

Gets whether the user can copy the subtitle from the label

getTitleLines
int getTitleLines()

Gets the number of lines at the end of which the title label will be ellipsized.

remove
void remove(gtk.widget.Widget widget)

Removes a child from self.

setActivatableWidget
void setActivatableWidget(gtk.widget.Widget widget)

Sets the widget to activate when self is activated.

setIconName
void setIconName(string iconName)

Sets the icon name for self.

setSubtitle
void setSubtitle(string subtitle)

Sets the subtitle for self.

setSubtitleLines
void setSubtitleLines(int subtitleLines)

Sets the number of lines at the end of which the subtitle label will be ellipsized.

setSubtitleSelectable
void setSubtitleSelectable(bool subtitleSelectable)

Sets whether the user can copy the subtitle from the label

setTitleLines
void setTitleLines(int titleLines)

Sets the number of lines at the end of which the title label will be ellipsized.

connectActivated
ulong connectActivated(T callback, Flag!"After" after)

Connect to Activated signal.