About my projects, examples and tutorials
Gnome::Gtk4::SingleSelection

Gnome::Gtk4::SingleSelection

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§

UNKNOWN image§

=for image :class<inline> :src<asset_files/images/plantuml/SingleSelection.png> :width<70\%>

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! )
Code

new-singleselection§

Creates a new selection to handle $model.

method new-singleselection ( N-List() $model --> Gnome::Gtk4::SingleSelection )
Code

Methods§

get-autoselect§

Checks if autoselect has been enabled or disabled via .set-autoselect().

method get-autoselect (--> Bool )
Code

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 )
Code

Return value; True to support unselecting.

get-model§

Gets the model that $self is wrapping.

method get-model (--> N-List )
Code

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 )
Code

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 )
Code

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 )
Code
  • $autoselect; True to 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 )
Code
  • $can-unselect; True to 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 )
Code

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 )
Code
  • $position; the item to select or GTK_INVALID_LIST_POSITION.