Gtk.SingleSelection¶
- Subclasses:
None
Methods¶
- Inherited:
GObject.Object (37), Gio.ListModel (4), Gtk.SectionModel (2), Gtk.SelectionModel (11)
- Structs:
class |
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/en |
|||
r/w/en |
|||
r |
|||
r/w/en |
|||
r |
|||
r/w/en |
|||
r |
Signals¶
Fields¶
Class Details¶
- class Gtk.SingleSelection(**kwargs)¶
- Bases:
GObject.Object
,Gio.ListModel
,Gtk.SectionModel
,Gtk.SelectionModel
- Abstract:
No
- Structure:
GtkSingleSelection
is aGtkSelectionModel
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.
- classmethod new(model)[source]¶
- Parameters:
model (
Gio.ListModel
orNone
) – theGListModel
to manage- Returns:
a new
GtkSingleSelection
- Return type:
Creates a new selection to handle model.
- get_autoselect()[source]¶
-
Checks if autoselect has been enabled or disabled via
Gtk.SingleSelection.set_autoselect
().
- get_can_unselect()[source]¶
-
If
True
,Gtk.SelectionModel.unselect_item
() is supported and allows unselecting the selected item.
- get_model()[source]¶
- Returns:
The model being wrapped
- Return type:
Gets the model that self is wrapping.
- get_selected()[source]¶
- Returns:
The position of the selected item
- Return type:
Gets the position of the selected item.
If no item is selected,
Gtk.INVALID_LIST_POSITION
is returned.
- get_selected_item()[source]¶
- Returns:
The selected item
- Return type:
Gets the selected item.
If no item is selected,
None
is returned.
- set_autoselect(autoselect)[source]¶
-
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.
- set_can_unselect(can_unselect)[source]¶
-
If
True
, unselecting the current item viaGtk.SelectionModel.unselect_item
() is supported.Note that setting [property`Gtk`.SingleSelection:autoselect] will cause unselecting to not work, so it practically makes no sense to set both at the same time the same time.
- set_model(model)[source]¶
- Parameters:
model (
Gio.ListModel
orNone
) – AGListModel
to wrap
Sets the model that self should wrap.
If model is
None
, self will be empty.
- set_selected(position)[source]¶
- Parameters:
position (
int
) – the item to select orGtk.INVALID_LIST_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 [property`Gtk`.SingleSelection: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.
Property Details¶
- Gtk.SingleSelection.props.autoselect¶
- Name:
autoselect
- Type:
- Default Value:
- Flags:
If the selection will always select an item.
- Gtk.SingleSelection.props.can_unselect¶
- Name:
can-unselect
- Type:
- Default Value:
- Flags:
If unselecting the selected item is allowed.
- Gtk.SingleSelection.props.item_type¶
- Name:
item-type
- Type:
- Default Value:
<GType GObject>
- Flags:
The type of items. See [method`Gio`.ListModel.get_item_type].
New in version 4.8.
- Gtk.SingleSelection.props.model¶
- Name:
model
- Type:
- Default Value:
- Flags:
The model being managed.
- Gtk.SingleSelection.props.n_items¶
-
The number of items. See [method`Gio`.ListModel.get_n_items].
New in version 4.8.
- Gtk.SingleSelection.props.selected¶
- Name:
selected
- Type:
- Default Value:
4294967295
- Flags:
Position of the selected item.
- Gtk.SingleSelection.props.selected_item¶
- Name:
selected-item
- Type:
- Default Value:
- Flags:
The selected item.