Top | ![]() |
![]() |
![]() |
![]() |
GtkSingleSelection * | gtk_single_selection_new () |
GListModel * | gtk_single_selection_get_model () |
guint | gtk_single_selection_get_selected () |
void | gtk_single_selection_set_selected () |
gpointer | gtk_single_selection_get_selected_item () |
gboolean | gtk_single_selection_get_autoselect () |
void | gtk_single_selection_set_autoselect () |
gboolean | gtk_single_selection_get_can_unselect () |
void | gtk_single_selection_set_can_unselect () |
gboolean | autoselect | Read / Write |
gboolean | can-unselect | Read / Write |
GListModel * | model | Read / Write / Construct Only |
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
.
GListModel *
gtk_single_selection_get_model (GtkSingleSelection *self
);
Gets the model that self
is wrapping.
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..
“autoselect”
property “autoselect” gboolean
If the selection will always select an item
Owner: GtkSingleSelection
Flags: Read / Write
Default value: TRUE
“can-unselect”
property “can-unselect” gboolean
If unselecting the selected item is allowed
Owner: GtkSingleSelection
Flags: Read / Write
Default value: FALSE
“model”
property “model” GListModel *
The model being managed
Owner: GtkSingleSelection
Flags: Read / Write / Construct Only
“selected”
property “selected” guint
Position of the selected item
Owner: GtkSingleSelection
Flags: Read / Write
Default value: 4294967295