1.179 <GtkSingleSelection>

Class: <GtkSingleSelection>

It derives from <GObject>.

A selection model that allows selecting a single item.

Note that the selection is persistent – if the selected item is removed and re-added in the same list-model:items-changed emission, it stays selected. In particular, this means that changing the sort order of an underlying sort model will preserve the selection.

Properties

Property: single-selection:autoselect self

If the selection will always select an item.

Its value is a boolean.

Set it with (set! (single-selection:autoselect self) value).

Property: single-selection:can-unselect self

If unselecting the selected item is allowed.

Its value is a boolean.

Set it with (set! (single-selection:can-unselect self) value).

Property: single-selection:item-type self

The type of items. See list-model:get-item-type.

Its value is a class, or a GType number.

It is read only.

Property: single-selection:model self

The model being managed.

Its value is a <GListModel>, or #f.

Set it with (set! (single-selection:model self) value).

Property: single-selection:n-items self

The number of items. See list-model:get-n-items.

Its value is an unsigned 32-bit integer.

It is read only.

Property: single-selection:selected self

Position of the selected item.

Its value is an unsigned 32-bit integer.

Set it with (set! (single-selection:selected self) value).

Property: single-selection:selected-item self

The selected item.

Its value is a <GObject>, or #f.

It is read only.

Procedures

Method: single-selection:get-autoselect? self ⇒ %return
Method: get-autoselect? self ⇒ %return

Checks if autoselect has been enabled or disabled via single-selection:set-autoselect.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

%return

Returned: a boolean.

#t if autoselect is enabled

Method: single-selection:get-can-unselect? self ⇒ %return
Method: get-can-unselect? self ⇒ %return

If #t, selection-model:unselect-item? is supported and allows unselecting the selected item.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

%return

Returned: a boolean.

#t to support unselecting

Method: single-selection:get-model self ⇒ %return
Method: get-model self ⇒ %return

Gets the model that self is wrapping.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

%return

Returned: a <GListModel>, or #f.

The model being wrapped

Method: single-selection:get-selected self ⇒ %return
Method: get-selected self ⇒ %return

Gets the position of the selected item.

If no item is selected, GTK_INVALID_LIST_POSITION is returned.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

%return

Returned: an unsigned 32-bit integer.

The position of the selected item

Method: single-selection:get-selected-item self ⇒ %return
Method: get-selected-item self ⇒ %return

Gets the selected item.

If no item is selected, #f is returned.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

%return

Returned: a <GObject>, or #f.

The selected item

Procedure: single-selection:new [model] ⇒ %return

Creates a new selection to handle model.

model

Passed, or left out: a <GListModel>, or #f.

the <GListModel> to manage

%return

Returned: a <GtkSingleSelection>.

a new <GtkSingleSelection>

Method: single-selection:set-autoselect self autoselect
Method: set-autoselect self autoselect

Enables or disables autoselect.

If autoselect is #t, 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.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

autoselect

Passed: a boolean.

#t to always select an item

Method: single-selection:set-can-unselect self can-unselect
Method: set-can-unselect self can-unselect

If #t, unselecting the current item via selection-model:unselect-item? is supported.

Note that setting single-selection:autoselect will cause unselecting to not work, so it practically makes no sense to set both at the same time.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

can-unselect

Passed: a boolean.

#t to allow unselecting

Method: single-selection:set-model self [model]
Method: set-model self [model]

Sets the model that self should wrap.

If model is #f, self will be empty.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

model

Passed, or left out: a <GListModel>, or #f.

A <GListModel> to wrap

Method: single-selection:set-selected self position
Method: set-selected self position

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 single-selection: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. This also applies if single-selection:can-unselect is set to #f.

self

Passed: a <GtkSingleSelection>.

a <GtkSingleSelection>

position

Passed: an unsigned 32-bit integer.

the item to select or GTK_INVALID_LIST_POSITION