Gnome::Gtk4::SingleSelection
#------------------------------------------------------------------------------- #--[Class Description]---------------------------------------------------------- #-------------------------------------------------------------------------------
Description
Gnome::Gtk4::SingleSelection is a Gnome::Gtk4::R-SelectionModel that allows selecting a single item.
Note that the selection is *persistent* -- if the selected item is removed
and re-added in the same [signal $Gio.ListModel::items-changed] emission, it
stays selected. In particular, this means that changing the sort order of an
underlying sort model will preserve the selection.
Uml Diagram =for image :src<asset_files/images/plantuml/SingleSelection.png> :width<70%> :class<inline>
#------------------------------------------------------------------------------- #--[Class Initialization]------------------------------------------------------- #-------------------------------------------------------------------------------
Class initialization
new
:native-object
Create an object using a native object from an object of the same type found elsewhere. See also Gnome::N::TopLevelSupportClass.
multi method new ( N-Object() :$native-object! )
#-------------------------------------------------------------------------------
new-singleselection
Creates a new selection to handle $model.
method new-singleselection ( N-List() $model --> Gnome::Gtk4::SingleSelection )
$model; (transfer ownership: full) the Gnome::Gio::R-ListModel to manage.
#------------------------------------------------------------------------------- #--[Methods]-------------------------------------------------------------------- #-------------------------------------------------------------------------------
Methods
#-------------------------------------------------------------------------------
get-autoselect
Checks if autoselect has been enabled or disabled via
.set-autoselect().
method get-autoselect (--> Bool )
Return value; True if autoselect is enabled.
#-------------------------------------------------------------------------------
get-can-unselect
If True, gtk_selection_model_unselect_item() is supported and allows
unselecting the selected item.
method get-can-unselect (--> Bool )
Return value; True to support unselecting.
#-------------------------------------------------------------------------------
get-model
Gets the model that $self is wrapping.
method get-model (--> N-List )
Return value; The model being wrapped.
#-------------------------------------------------------------------------------
get-selected
Gets the position of the selected item.
If no item is selected, GTK_INVALID_LIST_POSITION is returned.
method get-selected (--> UInt )
Return value; The position of the selected item.
#-------------------------------------------------------------------------------
get-selected-item
Gets the selected item.
If no item is selected, undefined is returned.
method get-selected-item (--> gpointer )
Return value; The selected item.
#-------------------------------------------------------------------------------
set-autoselect
Enables or disables autoselect.
If $autoselect is True, $self will enforce that an item is always
selected. It will select a new item when the currently selected
item is deleted and it will disallow unselecting the current item.
method set-autoselect ( Bool() $autoselect )
$autoselect;
Trueto always select an item.
#-------------------------------------------------------------------------------
set-can-unselect
If True, unselecting the current item via
gtk_selection_model_unselect_item() is supported.
Note that setting autoselect will cause unselecting to not work, so it practically makes no sense to set both at the same time the same time.
method set-can-unselect ( Bool() $can-unselect )
$can-unselect;
Trueto allow unselecting.
#-------------------------------------------------------------------------------
set-model
Sets the model that $self should wrap.
If $model is undefined, $self will be empty.
method set-model ( N-List() $model )
$model; A Gnome::Gio::R-ListModel to wrap.
#-------------------------------------------------------------------------------
set-selected
Selects the item at the given position.
If the list does not have an item at $position or
GTK_INVALID_LIST_POSITION is given, the behavior depends on the
value of the autoselect property:
If it is set, no change will occur and the old item will stay
selected. If it is unset, the selection will be unset and no item
will be selected.
method set-selected ( UInt() $position )
$position; the item to select or
GTK_INVALID_LIST_POSITION.