From c706077ca96cbabf43438a4dbdea09351e2a68ce Mon Sep 17 00:00:00 2001 From: tsukinaha Date: Sat, 16 Nov 2024 23:05:59 +0800 Subject: [PATCH] chore: use if let chain downcast eventcontroller flags Signed-off-by: tsukinaha --- src/ui/widgets/fix.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ui/widgets/fix.rs b/src/ui/widgets/fix.rs index 58e2ed59..cc9322e1 100644 --- a/src/ui/widgets/fix.rs +++ b/src/ui/widgets/fix.rs @@ -10,12 +10,12 @@ pub trait ScrolledWindowFixExt { /// fix scrolledwindow fucking up the vscroll event impl ScrolledWindowFixExt for ScrolledWindow { fn fix(&self) -> &Self { - let controller = self.observe_controllers(); - let count = controller.n_items(); - for i in 0..count { - let item = controller.item(i).unwrap(); - if item.is::() { - let controller = item.downcast::().unwrap(); + let controller_model = self.observe_controllers(); + for i in 0..controller_model.n_items() { + if let Some(controller) = controller_model + .item(i) + .and_downcast_ref::() + { controller.set_flags( gtk::EventControllerScrollFlags::HORIZONTAL | gtk::EventControllerScrollFlags::KINETIC,