From 2d846a7b1a94ed0a805fe313f46dfd0ff0b3ed7c Mon Sep 17 00:00:00 2001 From: Elias Projahn Date: Sun, 31 Jan 2021 19:36:31 +0100 Subject: [PATCH] Disable list selection except for sidebar --- src/widgets/list.rs | 6 ++++++ src/widgets/poe_list.rs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/widgets/list.rs b/src/widgets/list.rs index f95ac5c..b757f3a 100644 --- a/src/widgets/list.rs +++ b/src/widgets/list.rs @@ -28,6 +28,7 @@ impl List { // let widget = gtk::ListView::new(Some(&selection), Some(&factory)); let widget = gtk::ListBox::new(); + widget.set_selection_mode(gtk::SelectionMode::None); let this = Rc::new(Self { widget, @@ -113,6 +114,11 @@ impl List { 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. pub fn select(&self, index: usize) { let row = self.widget.get_row_at_index(index as i32); diff --git a/src/widgets/poe_list.rs b/src/widgets/poe_list.rs index d1fe7c6..15a7ba8 100644 --- a/src/widgets/poe_list.rs +++ b/src/widgets/poe_list.rs @@ -44,6 +44,7 @@ impl PoeList { let list = List::new(); list.widget.add_css_class("navigation-sidebar"); + list.enable_selection(); scrolled_window.set_child(Some(&list.widget));