Package ch.bailu.gtk.adw
Klasse ToggleGroup
- Alle implementierten Schnittstellen:
PointerInterface
A group of exclusive toggles.
<picture>
<source srcset="toggle-group-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group.png" alt="toggle-group">
</picture>
`AdwToggleGroup` presents a set of exclusive toggles, represented as
[class@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 [property@ToggleGroup:active] to get that position.
Toggles can also have optional names, set via the [property@Toggle:name]
property. The name of the active toggle can be accessed via the
[property@ToggleGroup:active-name] property.
`AdwToggle` objects can be retrieved via their index or name, using
[method@ToggleGroup.get_toggle] or [method@ToggleGroup.get_toggle_by_name]
respectively. `AdwToggleGroup` also provides a [iface@Gtk.SelectionModel] of
its toggles via the [property@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 [property@ToggleGroup:homogeneous] property to make the toggles take
the same size, and the [property@ToggleGroup:can-shrink] to control whether
the toggles can ellipsize.
Example of an `AdwToggleGroup` UI definition:
```xml
<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: [class@InlineViewSwitcher].
## CSS nodes
`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.
## Style classes
`AdwToggleGroup` can use the [`.flat`](style-classes.html#flat_1) style class
to remove its background and make it look like a group of buttons.
<picture>
<source srcset="toggle-group-flat-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group-flat.png" alt="toggle-group-flat">
</picture>
It can also use the [`.round`](style-classes.html#round) style class to make
its toggles and the group itself rounded.
<picture>
<source srcset="toggle-group-round-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group-round.png" alt="toggle-group-round">
</picture>
They can also be combined with each other.
<picture>
<source srcset="toggle-group-flat-round-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group-flat-round.png" alt="toggle-group-flat-round">
</picture>
## Accessibility
`AdwToggleGroup` uses the `GTK_ACCESSIBLE_ROLE_RADIO_GROUP` role. Its toggles
use the `GTK_ACCESSIBLE_ROLE_RADIO` role.
<picture>
<source srcset="toggle-group-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group.png" alt="toggle-group">
</picture>
`AdwToggleGroup` presents a set of exclusive toggles, represented as
[class@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 [property@ToggleGroup:active] to get that position.
Toggles can also have optional names, set via the [property@Toggle:name]
property. The name of the active toggle can be accessed via the
[property@ToggleGroup:active-name] property.
`AdwToggle` objects can be retrieved via their index or name, using
[method@ToggleGroup.get_toggle] or [method@ToggleGroup.get_toggle_by_name]
respectively. `AdwToggleGroup` also provides a [iface@Gtk.SelectionModel] of
its toggles via the [property@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 [property@ToggleGroup:homogeneous] property to make the toggles take
the same size, and the [property@ToggleGroup:can-shrink] to control whether
the toggles can ellipsize.
Example of an `AdwToggleGroup` UI definition:
```xml
<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: [class@InlineViewSwitcher].
## CSS nodes
`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.
## Style classes
`AdwToggleGroup` can use the [`.flat`](style-classes.html#flat_1) style class
to remove its background and make it look like a group of buttons.
<picture>
<source srcset="toggle-group-flat-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group-flat.png" alt="toggle-group-flat">
</picture>
It can also use the [`.round`](style-classes.html#round) style class to make
its toggles and the group itself rounded.
<picture>
<source srcset="toggle-group-round-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group-round.png" alt="toggle-group-round">
</picture>
They can also be combined with each other.
<picture>
<source srcset="toggle-group-flat-round-dark.png" media="(prefers-color-scheme: dark)">
<img src="toggle-group-flat-round.png" alt="toggle-group-flat-round">
</picture>
## Accessibility
`AdwToggleGroup` uses the `GTK_ACCESSIBLE_ROLE_RADIO_GROUP` role. Its toggles
use the `GTK_ACCESSIBLE_ROLE_RADIO` role.
https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.ToggleGroup.html
-
Verschachtelte Klassen - Übersicht
Von Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gtk.Widget
Widget.OnDestroy, Widget.OnDestroyNotify, Widget.OnDirectionChanged, Widget.OnHide, Widget.OnKeynavFailed, Widget.OnMap, Widget.OnMnemonicActivate, Widget.OnMoveFocus, Widget.OnQueryTooltip, Widget.OnRealize, Widget.OnShow, Widget.OnStateFlagsChanged, Widget.OnTickCallback, Widget.OnUnmap, Widget.OnUnrealizeVon Klasse geerbte verschachtelte Klassen/Schnittstellen ch.bailu.gtk.gobject.Object
Object.OnBindingTransformFunc, Object.OnDuplicateFunc, Object.OnNotify, Object.OnToggleNotify, Object.OnWeakNotify -
Feldübersicht
Von Klasse geerbte Felder ch.bailu.gtk.gtk.Widget
SIGNAL_ON_DESTROY, SIGNAL_ON_DIRECTION_CHANGED, SIGNAL_ON_HIDE, SIGNAL_ON_KEYNAV_FAILED, SIGNAL_ON_MAP, SIGNAL_ON_MNEMONIC_ACTIVATE, SIGNAL_ON_MOVE_FOCUS, SIGNAL_ON_QUERY_TOOLTIP, SIGNAL_ON_REALIZE, SIGNAL_ON_SHOW, SIGNAL_ON_STATE_FLAGS_CHANGED, SIGNAL_ON_UNMAP, SIGNAL_ON_UNREALIZEVon Klasse geerbte Felder ch.bailu.gtk.gobject.Object
SIGNAL_ON_NOTIFY -
Konstruktorübersicht
Konstruktoren -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidAdds a toggle to @self.Implements interfaceAccessible.Implements interfaceBuildable.Implements interfaceConstraintTarget.Implements interfaceOrientable.intGets the index of the active toggle in @self.Gets the name of the active toggle in @self.booleanGets whether the toggles can be smaller than the natural size of their
contents.static ClassHandlerbooleanGets whether all toggles take the same size.static intintGets the number of toggles within @self.static longstatic TypeSystem.TypeSizegetToggle(int index) Gets the toggle with @index from @self.getToggleByName(Str name) Gets the toggle with the name @name from @self.getToggleByName(String name) Gets the toggle with the name @name from @self.Returns a [iface@Gio.ListModel] that contains the toggles of the group.static longstatic TypeSystem.TypeSizevoidRemoves @toggle from @self.voidRemoves all toggles from @self.voidsetActive(int active) Sets the active toggle for @self.voidsetActiveName(Str name) Sets the active toggle for @self.voidsetActiveName(String name) Sets the active toggle for @self.voidsetCanShrink(boolean can_shrink) Sets whether the toggles can be smaller than the natural size of their
contents.voidsetHomogeneous(boolean homogeneous) Sets whether all toggles take the same size.Von Klasse geerbte Methoden ch.bailu.gtk.gtk.Widget
actionSetEnabled, actionSetEnabled, activate, activateAction, activateAction, activateActionVariant, activateActionVariant, activateDefault, addController, addCssClass, addCssClass, addMnemonicLabel, addTickCallback, allocate, childFocus, computeBounds, computeExpand, computePoint, computeTransform, contains, createPangoContext, createPangoLayout, createPangoLayout, disposeTemplate, dragCheckThreshold, errorBell, getAllocatedBaseline, getAllocatedHeight, getAllocatedWidth, getAllocation, getAncestor, getBaseline, getCanFocus, getCanTarget, getChildVisible, getClipboard, getColor, getCssClasses, getCssName, getCursor, getDefaultDirection, getDirection, getDisplay, getFirstChild, getFocusable, getFocusChild, getFocusOnClick, getFontMap, getFontOptions, getFrameClock, getHalign, getHasTooltip, getHeight, getHexpand, getHexpandSet, getLastChild, getLayoutManager, getLimitEvents, getMapped, getMarginBottom, getMarginEnd, getMarginStart, getMarginTop, getName, getNative, getNextSibling, getOpacity, getOverflow, getPangoContext, getParent, getPreferredSize, getPrevSibling, getPrimaryClipboard, getRealized, getReceivesDefault, getRequestMode, getRoot, getScaleFactor, getSensitive, getSettings, getSize, getSizeRequest, getStateFlags, getStyleContext, getTemplateChild, getTemplateChild, getTooltipMarkup, getTooltipText, getValign, getVexpand, getVexpandSet, getVisible, getWidth, grabFocus, hasCssClass, hasCssClass, hasDefault, hasFocus, hasVisibleFocus, hide, inDestruction, initTemplate, insertActionGroup, insertActionGroup, insertAfter, insertBefore, isAncestor, isDrawable, isFocus, isSensitive, isVisible, keynavFailed, listMnemonicLabels, map, measure, mnemonicActivate, observeChildren, observeControllers, onDestroy, onDirectionChanged, onHide, onKeynavFailed, onMap, onMnemonicActivate, onMoveFocus, onQueryTooltip, onRealize, onShow, onStateFlagsChanged, onUnmap, onUnrealize, pick, queueAllocate, queueDraw, queueResize, realize, removeController, removeCssClass, removeCssClass, removeMnemonicLabel, removeTickCallback, setCanFocus, setCanTarget, setChildVisible, setCssClasses, setCursor, setCursorFromName, setCursorFromName, setDefaultDirection, setDirection, setFocusable, setFocusChild, setFocusOnClick, setFontMap, setFontOptions, setHalign, setHasTooltip, setHexpand, setHexpandSet, setLayoutManager, setLimitEvents, setMarginBottom, setMarginEnd, setMarginStart, setMarginTop, setName, setName, setOpacity, setOverflow, setParent, setReceivesDefault, setSensitive, setSizeRequest, setStateFlags, setTooltipMarkup, setTooltipMarkup, setTooltipText, setTooltipText, setValign, setVexpand, setVexpandSet, setVisible, shouldLayout, show, sizeAllocate, snapshotChild, triggerTooltipQuery, unmap, unparent, unrealize, unsetStateFlagsVon Klasse geerbte Methoden ch.bailu.gtk.type.PropertyHolder
getBooleanProperty, getIntProperty, getObjectProperty, getStringProperty, getStrProperty, setBooleanProperty, setIntProperty, setObjectProperty, setStringProperty, setStrPropertyVon Klasse geerbte Methoden ch.bailu.gtk.gobject.Object
addToggleRef, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, disconnect, disconnect, dupData, dupData, dupQdata, forceFloating, freezeNotify, get, get, getData, getData, getProperty, getProperty, getQdata, interfaceFindProperty, interfaceInstallProperty, isFloating, notify, notify, notifyByPspec, onNotify, ref, refSink, removeToggleRef, replaceData, replaceData, replaceQdata, runDispose, set, set, setData, setData, setDataFull, setDataFull, setProperty, setProperty, setQdata, setQdataFull, stealData, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnrefVon Klasse geerbte Methoden ch.bailu.gtk.type.Pointer
asCPointer, cast, connectSignal, disconnectSignals, disconnectSignals, equals, hashCode, throwIfNull, throwNullPointerException, toString, unregisterCallbacks, unregisterCallbacksVon Klasse geerbte Methoden ch.bailu.gtk.type.Type
asCPointer, asCPointer, asCPointerNotNull, asJnaPointer, asJnaPointer, asPointer, asPointer, cast, cast, throwIfNullVon Klasse geerbte Methoden java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitVon Schnittstelle geerbte Methoden ch.bailu.gtk.type.PointerInterface
asCPointerNotNull, asJnaPointer, asPointer, isNotNull, isNull
-
Konstruktordetails
-
ToggleGroup
-
ToggleGroup
public ToggleGroup()Creates a new `AdwToggleGroup`.
-
-
Methodendetails
-
getClassHandler
-
add
Adds a toggle to @self.- Parameter:
toggle- the toggle to add
-
getActive
public int getActive()Gets the index of the active toggle in @self.
Returns `GTK_INVALID_LIST_POSITION` if no toggle is active.- Gibt zurück:
- the active toggle index
-
getActiveName
Gets the name of the active toggle in @self.
Can be `NULL` if the currently active toggle doesn't have a name.
See [property@Toggle:name].- Gibt zurück:
- the active toggle name
-
getCanShrink
public boolean getCanShrink()Gets whether the toggles can be smaller than the natural size of their
contents.- Gibt zurück:
- whether the toggles can shrink
-
getHomogeneous
public boolean getHomogeneous()Gets whether all toggles take the same size.- Gibt zurück:
- whether all toggles take the same size
-
getNToggles
public int getNToggles()Gets the number of toggles within @self.- Gibt zurück:
- the number of toggles
-
getToggle
Gets the toggle with @index from @self.- Parameter:
index- toggle's index- Gibt zurück:
- the toggle
-
getToggleByName
Gets the toggle with the name @name from @self.- Parameter:
name- toggle name- Gibt zurück:
- the toggle
-
getToggleByName
Gets the toggle with the name @name from @self.- Parameter:
name- toggle name- Gibt zurück:
- the toggle
-
getToggles
Returns a [iface@Gio.ListModel] that contains the toggles of the group.
This can be used to keep an up-to-date view. The model also implements
[iface@Gtk.SelectionModel] and can be used to track and change the active
toggle.- Gibt zurück:
- a `GtkSelectionModel` for the group's toggles
-
remove
Removes @toggle from @self.- Parameter:
toggle- a toggle to remove
-
removeAll
public void removeAll()Removes all toggles from @self. -
setActive
public void setActive(int active) Sets the active toggle for @self.
If the index is larger than the number of toggles in @self, unsets the
current active toggle.- Parameter:
active- toggle index
-
setActiveName
Sets the active toggle for @self.
The name can be set via [property@Toggle:name].
If @name is `NULL`, unset the current active toggle instead.- Parameter:
name- toggle name
-
setActiveName
Sets the active toggle for @self.
The name can be set via [property@Toggle:name].
If @name is `NULL`, unset the current active toggle instead.- Parameter:
name- toggle name
-
setCanShrink
public void setCanShrink(boolean can_shrink) 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 [property@Gtk.Button:can-shrink].- Parameter:
can_shrink- whether the toggles can shrink
-
setHomogeneous
public void setHomogeneous(boolean homogeneous) Sets whether all toggles take the same size.- Parameter:
homogeneous- whether all toggles should take the same size
-
asAccessible
Implements interfaceAccessible. Call this to get access to interface functions.- Setzt außer Kraft:
asAccessiblein KlasseWidget- Gibt zurück:
Accessible
-
asBuildable
Implements interfaceBuildable. Call this to get access to interface functions.- Setzt außer Kraft:
asBuildablein KlasseWidget- Gibt zurück:
Buildable
-
asConstraintTarget
Implements interfaceConstraintTarget. Call this to get access to interface functions.- Setzt außer Kraft:
asConstraintTargetin KlasseWidget- Gibt zurück:
ConstraintTarget
-
asOrientable
Implements interfaceOrientable. Call this to get access to interface functions.- Gibt zurück:
Orientable
-
getTypeID
public static long getTypeID() -
getParentTypeID
public static long getParentTypeID() -
getTypeSize
-
getParentTypeSize
-
getInstanceSize
public static int getInstanceSize()
-