Top |
Functions
GtkSingleSelection * | gtk_single_selection_new () |
GListModel * | gtk_single_selection_get_model () |
void | gtk_single_selection_set_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 () |
Properties
gboolean | autoselect | Read / Write |
gboolean | can-unselect | Read / Write |
GListModel * | model | Read / Write |
guint | selected | Read / Write |
GObject * | selected-item | Read |
Description
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.
Note that the selection is *persistent* -- if the selected item is removed and re-added in the same “items-changed” emission, it stays selected. In particular, this means that changing the sort order of an underlying sort model will preserve the selection.
Functions
gtk_single_selection_new ()
GtkSingleSelection *
gtk_single_selection_new (GListModel *model
);
Creates a new selection to handle model
.
gtk_single_selection_get_model ()
GListModel *
gtk_single_selection_get_model (GtkSingleSelection *self
);
Gets the model that self
is wrapping.
gtk_single_selection_set_model ()
void gtk_single_selection_set_model (GtkSingleSelection *self
,GListModel *model
);
Sets the model that self
should wrap. If model
is NULL
, self
will be empty.
gtk_single_selection_get_selected ()
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.
gtk_single_selection_set_selected ()
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 “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.
gtk_single_selection_get_selected_item ()
gpointer
gtk_single_selection_get_selected_item
(GtkSingleSelection *self
);
Gets the selected item.
If no item is selected, NULL
is returned.
gtk_single_selection_get_autoselect ()
gboolean
gtk_single_selection_get_autoselect (GtkSingleSelection *self
);
Checks if autoselect has been enabled or disabled via
gtk_single_selection_set_autoselect()
.
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.
gtk_single_selection_get_can_unselect ()
gboolean
gtk_single_selection_get_can_unselect (GtkSingleSelection *self
);
If TRUE
, gtk_selection_model_unselect_item()
is supported and allows
unselecting the selected item.
gtk_single_selection_set_can_unselect ()
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 “autoselect” will cause the unselecting to not work, so it practically makes no sense to set both at the same time the same time.
Types and Values
GTK_INVALID_LIST_POSITION
#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 interpretation may differ for different functions.
Refer to each function's documentation for if this value is allowed and what it does.
Property Details
The “autoselect”
property
“autoselect” gboolean
If the selection will always select an item
Owner: GtkSingleSelection
Flags: Read / Write
Default value: TRUE
The “can-unselect”
property
“can-unselect” gboolean
If unselecting the selected item is allowed
Owner: GtkSingleSelection
Flags: Read / Write
Default value: FALSE
The “model”
property
“model” GListModel *
The model being managed
Owner: GtkSingleSelection
Flags: Read / Write
The “selected”
property
“selected” guint
Position of the selected item
Owner: GtkSingleSelection
Flags: Read / Write
Default value: 4294967295