Top | ![]() |
![]() |
![]() |
![]() |
gboolean | autoselect | Read / Write |
gboolean | can-unselect | Read / Write |
GListModel * | model | Read / Write |
guint | selected | Read / Write |
GObject * | selected-item | Read |
GtkSingleSelection is an implementation of the GtkSelectionModel interface that allows selecting a single element. It is the default selection method used by list widgets in GTK.
GtkSingleSelection *
gtk_single_selection_new (GListModel *model
);
Creates a new selection to handle model
.
guint
gtk_single_selection_get_selected (GtkSingleSelection *self
);
Gets the position of the selected item. If no item is selected, GTK_INVALID_LIST_POSITION is returned.
void gtk_single_selection_set_selected (GtkSingleSelection *self
,guint 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 GtkSingleSelection: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.
gpointer
gtk_single_selection_get_selected_item
(GtkSingleSelection *self
);
Gets the selected item. If no item is selected, NULL
is returned.
gboolean
gtk_single_selection_get_autoselect (GtkSingleSelection *self
);
Checks if autoselect has been enabled or disabled via
gtk_single_selection_set_autoselect()
.
void gtk_single_selection_set_autoselect (GtkSingleSelection *self
,gboolean 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.
gboolean
gtk_single_selection_get_can_unselect (GtkSingleSelection *self
);
If TRUE
, gtk_selection_model_unselect_item()
is supported and allows
unselecting the selected item.
void gtk_single_selection_set_can_unselect (GtkSingleSelection *self
,gboolean can_unselect
);
If TRUE
, unselecting the current item via
gtk_selection_model_unselect_item()
is supported.
Note that setting GtkSingleSelection:autoselect will cause the unselecting to not work, so it practically makes no sense to set both at the same time the same time..
#define GTK_INVALID_LIST_POSITION (G_MAXUINT)
The value used to refer to a guaranteed invalid position in a GListModel. This value may be returned from some functions, others may accept it as input. Its interpretion may differ for different functions.
Refer to each function's documentation for if this value is allowed and what it does.
“autoselect”
property“autoselect” gboolean
If the selection will always select an item
Flags: Read / Write
Default value: TRUE
“can-unselect”
property“can-unselect” gboolean
If unselecting the selected item is allowed
Flags: Read / Write
Default value: FALSE
“selected”
property“selected” guint
Position of the selected item
Flags: Read / Write
Default value: 4294967295