Top | ![]() |
![]() |
![]() |
![]() |
GtkSelectionModelGtkSelectionModel — An extension of the list model interface that handles selections |
gboolean | gtk_selection_model_is_selected () |
gboolean | gtk_selection_model_select_item () |
gboolean | gtk_selection_model_unselect_item () |
gboolean | gtk_selection_model_select_range () |
gboolean | gtk_selection_model_unselect_range () |
gboolean | gtk_selection_model_select_all () |
gboolean | gtk_selection_model_unselect_all () |
void | gtk_selection_model_selection_changed () |
GtkSelectionModel is an interface that extends the GListModel interface by adding support for selections. This support is then used by widgets using list models to add the ability to select and unselect various items.
GTK provides default implementations of the mode common selection modes such as GtkSingleSelection, so you will only need to implement this interface if you want detailed control about how selections should be handled.
A GtkSelectionModel supports a single boolean per row indicating if a row is selected
or not. This can be queried via gtk_selection_model_is_selected()
. When the selected
state of one or more rows changes, the model will emit the
GtkSelectionModel::selection-changed signal by calling the
gtk_selection_model_selection_changed()
function. The positions given in that signal
may have their selection state changed, though that is not a requirement.
If new items added to the model via the “items-changed” signal are selected
or not is up to the implementation.
Additionally, the interface can expose functionality to select and unselect items. If these functions are implemented, GTK's list widgets will allow users to select and unselect items. However, GtkSelectionModels are free to only implement them partially or not at all. In that case the widgets will not support the unimplemented operations.
When selecting or unselecting is supported by a model, the return values of the selection functions do NOT indicate if selection or unselection happened. They are only meant to indicate complete failure, like when this mode of selecting is not supported by the model. Selections may happen asynchronously, so the only reliable way to find out when an item was selected is to listen to the signals that indicate selection.
gboolean gtk_selection_model_is_selected (GtkSelectionModel *model
,guint position
);
Checks if the given item is selected.
gboolean gtk_selection_model_select_item (GtkSelectionModel *model
,guint position
,gboolean exclusive
);
gboolean gtk_selection_model_unselect_item (GtkSelectionModel *model
,guint position
);
gboolean gtk_selection_model_select_range (GtkSelectionModel *model
,guint position
,guint n_items
,gboolean exclusive
);
gboolean gtk_selection_model_unselect_range (GtkSelectionModel *model
,guint position
,guint n_items
);
gboolean
gtk_selection_model_select_all (GtkSelectionModel *model
);
gboolean
gtk_selection_model_unselect_all (GtkSelectionModel *model
);
void gtk_selection_model_selection_changed (GtkSelectionModel *model
,guint position
,guint n_items
);
“selection-changed”
signalvoid user_function (GtkSelectionModel *model, guint position, guint n_items, gpointer user_data)
Emitted when the selection state of some of the items in model
changes.
Note that this signal does not specify the new selection state of the items, they need to be queried manually. It is also not necessary for a model to change the selection state of any of the items in the selection model, though it would be rather useless to emit such a signal.
model |
||
position |
The first item that may have changed |
|
n_items |
number of items with changes |
|
user_data |
user data set when the signal handler was connected. |
Flags: Run Last