Selecting an item from GTK ListView widget.
Related issue https://discourse.gnome.org/t/gtk4-listview-why-does-the-single-click-activate-also-trigger-the-selected-event/7947
// let list_view: gtk::ListView;
if let Some(model) = list_view.model() {
model.connect_selection_changed(move |selection_model, _, _| { // listen for selection change
let single_selection_model =
match selection_model.downcast_ref::<gtk::SingleSelection>() { // down cast to your model of choice(eg: single selection model)
Some(ss) => ss,
None => return,
};
let list_item = single_selection_model.selected_item();
let pos = single_selection_model.selected();
});
}