mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
Disable list selection except for sidebar
This commit is contained in:
parent
1f90f6108e
commit
2d846a7b1a
2 changed files with 7 additions and 0 deletions
|
|
@ -28,6 +28,7 @@ impl List {
|
||||||
// let widget = gtk::ListView::new(Some(&selection), Some(&factory));
|
// let widget = gtk::ListView::new(Some(&selection), Some(&factory));
|
||||||
|
|
||||||
let widget = gtk::ListBox::new();
|
let widget = gtk::ListBox::new();
|
||||||
|
widget.set_selection_mode(gtk::SelectionMode::None);
|
||||||
|
|
||||||
let this = Rc::new(Self {
|
let this = Rc::new(Self {
|
||||||
widget,
|
widget,
|
||||||
|
|
@ -113,6 +114,11 @@ impl List {
|
||||||
self.move_cb.replace(Some(Box::new(cb)));
|
self.move_cb.replace(Some(Box::new(cb)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Set the lists selection mode to single.
|
||||||
|
pub fn enable_selection(&self) {
|
||||||
|
self.widget.set_selection_mode(gtk::SelectionMode::Single);
|
||||||
|
}
|
||||||
|
|
||||||
/// Select an item by its index. If the index is out of range, nothing will happen.
|
/// Select an item by its index. If the index is out of range, nothing will happen.
|
||||||
pub fn select(&self, index: usize) {
|
pub fn select(&self, index: usize) {
|
||||||
let row = self.widget.get_row_at_index(index as i32);
|
let row = self.widget.get_row_at_index(index as i32);
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ impl PoeList {
|
||||||
|
|
||||||
let list = List::new();
|
let list = List::new();
|
||||||
list.widget.add_css_class("navigation-sidebar");
|
list.widget.add_css_class("navigation-sidebar");
|
||||||
|
list.enable_selection();
|
||||||
|
|
||||||
scrolled_window.set_child(Some(&list.widget));
|
scrolled_window.set_child(Some(&list.widget));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue