diff --git a/Cargo.lock b/Cargo.lock index 75007e49..c4655c1f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -241,10 +241,8 @@ dependencies = [ "gtk4", "libcosmic-widgets", "libpulse-binding", - "once_cell", "pulsectl-rs", "relm4", - "tokio", ] [[package]] diff --git a/applets/cosmic-applet-audio/Cargo.toml b/applets/cosmic-applet-audio/Cargo.toml index 7b2a6b1c..c5dc3700 100644 --- a/applets/cosmic-applet-audio/Cargo.toml +++ b/applets/cosmic-applet-audio/Cargo.toml @@ -9,7 +9,5 @@ futures-util = "0.3.21" gtk4 = "0.4.6" libcosmic-widgets = { git = "https://github.com/pop-os/libcosmic", branch = "lucy/widgets" } libpulse-binding = "2.26.0" -once_cell = "1.10.0" pulsectl-rs = "0.3.2" relm4 = { git = "https://github.com/AaronErhardt/relm4", branch = "new-approach", features = ["macros"] } -tokio = { version = "1.17.0", features = ["full"] } diff --git a/applets/cosmic-applet-audio/src/app.rs b/applets/cosmic-applet-audio/src/app.rs index ea08c9a0..0250cf20 100644 --- a/applets/cosmic-applet-audio/src/app.rs +++ b/applets/cosmic-applet-audio/src/app.rs @@ -71,22 +71,22 @@ impl App { } for input in inputs { let input = Rc::new(input); + let name = match &input.name { + Some(name) => name.to_owned(), + None => continue, // Why doesn't this have a name? Whatever, it's invalid. + }; view! { item = LabeledItem { set_title: input.description .as_ref() - .or_else(|| input.name.as_ref()) - .cloned() - .unwrap_or_else(|| "Unknown".to_string()), + .unwrap_or(&name), set_child: set_current_input_device = &Button { set_label: "Switch", connect_clicked: clone!(@strong input, => move |_| { - if let Some(name) = &input.name { - SourceController::create() - .expect("failed to create input controller") - .set_default_device(name) - .expect("failed to set default device"); - } + SourceController::create() + .expect("failed to create input controller") + .set_default_device(&name) + .expect("failed to set default device"); }) } } @@ -104,22 +104,23 @@ impl App { } for output in outputs { let output = Rc::new(output); + let name = match &output.name { + Some(name) => name.to_owned(), + None => continue, // Why doesn't this have a name? Whatever, it's invalid. + }; view! { item = LabeledItem { set_title: output.description .as_ref() - .or_else(|| output.name.as_ref()) - .cloned() - .unwrap_or_else(|| "Unknown".to_string()), + .unwrap_or(&name), set_child: set_current_output_device = &Button { set_label: "Switch", connect_clicked: clone!(@strong output, => move |_| { - if let Some(name) = &output.name { - SinkController::create() - .expect("failed to create output controller") - .set_default_device(name) - .expect("failed to set default device"); - } + SinkController::create() + .expect("failed to create output controller") + .set_default_device(&name) + .expect("failed to set default device"); + }) } } diff --git a/applets/cosmic-applet-audio/src/main.rs b/applets/cosmic-applet-audio/src/main.rs index 40e0f4db..6254c362 100644 --- a/applets/cosmic-applet-audio/src/main.rs +++ b/applets/cosmic-applet-audio/src/main.rs @@ -5,11 +5,7 @@ extern crate relm4; mod app; -use once_cell::sync::Lazy; use relm4::RelmApp; -use tokio::runtime::Runtime; - -static RT: Lazy = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime")); fn main() { RelmApp::::new("com.system76.cosmic.applets.audio").run(());