It derives from <GtkWidget>.
A group of exclusive toggles.
<AdwToggleGroup> presents a set of exclusive
toggles, represented as Toggle objects. Each toggle can display
an icon, a label, an icon and a label, or a custom child.
Toggles are indexed by their position, with the first toggle being
equivalent to 0, and so on. Use the ToggleGroup:active to get
that position.
Toggles can also have optional names, set via the Toggle:name
property. The name of the active toggle can be accessed via the
ToggleGroup:active-name property.
<AdwToggle> objects can be retrieved via their
index or name, using ToggleGroup.get_toggle or
ToggleGroup.get_toggle_by_name respectively.
<AdwToggleGroup> also provides a
<GtkSelectionModel> of its toggles via
the ToggleGroup:toggles property.
<AdwToggleGroup> is orientable, and the
toggles can be displayed horizontally or vertically. This is mostly
useful for icon-only toggles.
Use the ToggleGroup:homogeneous property to make the toggles take
the same size, and the ToggleGroup:can-shrink to control whether
the toggles can ellipsize.
Example of an <AdwToggleGroup> UI definition:
<object class="AdwToggleGroup">
<property name="active-name">picture</property>
<child>
<object class="AdwToggle">
<property name="icon-name">camera-photo-symbolic</property>
<property name="tooltip" translatable="yes">Picture Mode</property>
<property name="name">picture</property>
</object>
</child>
<child>
<object class="AdwToggle">
<property name="icon-name">camera-video-symbolic</property>
<property name="tooltip" translatable="yes">Recording Mode</property>
<property name="name">recording</property>
</object>
</child>
</object>
See also: InlineViewSwitcher.
<AdwToggleGroup> has a main CSS node with the
name toggle-group.
Its toggles have CSS nodes with the name toggle, and its
separators have nodes with the name separator.
Toggle nodes will have a different style classes depending on their
content: .text-button for labels, .image-button for icons,
.image-text-button for both or no style class for custom
children.
The hidden separators use the .hidden style class.
<AdwToggleGroup> can use the ‘.flat‘ style
class to remove its background and make it look like a group of buttons.
It can also use the ‘.round‘ style class to make its toggles and the group itself rounded.
They can also be combined with each other.
<AdwToggleGroup> uses the
Gtk.AccessibleRole.radio-group role. Its toggles use the
Gtk.AccessibleRole.radio role.
The index of the active toggle.
Setting the index to a larger value than the number of toggles in the group unsets the current active toggle.
If no toggle is active, the property will be set to
Gtk.INVALID_LIST_POSITION.
Its value is an unsigned 32-bit integer.
Set it with (set! (toggle-group:active self) value).
The name of the active toggle.
The name can be set via Toggle:name. If the currently active
toggle doesn’t have a name, the property will be set to NULL.
Set it to NULL to unset the current active toggle.
Its value is a string, or #f.
Set it with (set! (toggle-group:active-name self) value).
Whether the toggles can be smaller than the natural size of their contents.
If set to TRUE, the toggle labels will ellipsize.
See button:can-shrink.
Its value is a boolean.
Set it with (set! (toggle-group:can-shrink self) value).
Whether all toggles take the same size.
Its value is a boolean.
Set it with (set! (toggle-group:homogeneous self) value).
The number of toggles within the group.
Its value is an unsigned 32-bit integer.
It is read only.
A selection model with the groups’s toggles.
This can be used to keep an up-to-date view. The model also implements
<GtkSelectionModel> and can be used to
track and change the active toggle.
Its value is a <GtkSelectionModel>, or
#f.
It is read only.
Adds a toggle to self.
Passed: a <AdwToggleGroup>.
a toggle group
Passed: a <AdwToggle>.
the toggle to add
Gets the index of the active toggle in self.
Returns Gtk.INVALID_LIST_POSITION if no toggle is active.
Passed: a <AdwToggleGroup>.
a toggle group
Returned: an unsigned 32-bit integer.
the active toggle index
Gets the name of the active toggle in self.
Can be NULL if the currently active toggle doesn’t have a name.
See Toggle:name.
Passed: a <AdwToggleGroup>.
a toggle group
Returned: a string, or #f.
the active toggle name
Gets whether the toggles can be smaller than the natural size of their contents.
Passed: a <AdwToggleGroup>.
a toggle group
Returned: a boolean.
whether the toggles can shrink
Gets whether all toggles take the same size.
Passed: a <AdwToggleGroup>.
a toggle group
Returned: a boolean.
whether all toggles take the same size
Gets the number of toggles within self.
Passed: a <AdwToggleGroup>.
a toggle group
Returned: an unsigned 32-bit integer.
the number of toggles
Gets the toggle with index from self.
Passed: a <AdwToggleGroup>.
a toggle group
Passed: an unsigned 32-bit integer.
toggle’s index
Returned: a <AdwToggle>, or #f.
the toggle
Gets the toggle with the name name from self.
Passed: a <AdwToggleGroup>.
a toggle group
Passed: a string.
toggle name
Returned: a <AdwToggle>, or #f.
the toggle
Returns a <GListModel> that contains the
toggles of the group.
This can be used to keep an up-to-date view. The model also implements
<GtkSelectionModel> and can be used to
track and change the active toggle.
Passed: a <AdwToggleGroup>.
a toggle group
Returned: a <GtkSelectionModel>.
a <GtkSelectionModel> for the group’s
toggles
Creates a new <AdwToggleGroup>.
Returned: a <GtkWidget>.
the newly created <AdwToggleGroup>
Removes toggle from self.
Passed: a <AdwToggleGroup>.
a toggle group
Passed: a <AdwToggle>.
a toggle to remove
Removes all toggles from self.
Passed: a <AdwToggleGroup>.
a toggle group
Sets the active toggle for self.
If the index is larger than the number of toggles in self, unsets the current active toggle.
Passed: a <AdwToggleGroup>.
a toggle group
Passed: an unsigned 32-bit integer.
toggle index
Sets the active toggle for self.
The name can be set via Toggle:name.
If name is NULL, unset the current active toggle instead.
Passed: a <AdwToggleGroup>.
a toggle group
Passed, or left out: a string, or #f.
toggle name
Sets whether the toggles can be smaller than the natural size of their contents.
If can-shrink is TRUE, the toggle labels will ellipsize.
See button:can-shrink.
Passed: a <AdwToggleGroup>.
a toggle group
Passed: a boolean.
whether the toggles can shrink
Sets whether all toggles take the same size.
Passed: a <AdwToggleGroup>.
a toggle group
Passed: a boolean.
whether all toggles should take the same size