From 900cc26e2a43b2dd50809ce9511cf085e15af46c Mon Sep 17 00:00:00 2001 From: Nicolai Syvertsen Date: Sun, 28 Apr 2024 13:03:13 +0200 Subject: [PATCH] Add get device by id function to manager. --- src/backend/manager.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/backend/manager.rs b/src/backend/manager.rs index c72c698..335a0d6 100644 --- a/src/backend/manager.rs +++ b/src/backend/manager.rs @@ -290,6 +290,18 @@ impl PwvucontrolManager { glib::Object::builder() .build() } + + pub fn get_device_by_id(&self, id: u32) -> Option { + let devicemodel = self.imp().devicemodel.get().expect("devicemodel"); + for device in devicemodel.iter::() { + if let Ok(device) = device { + if device.wpdevice().bound_id() == id { + return Some(device); + } + } + } + None + } } impl Default for PwvucontrolManager {