Clean up code a bit; remove unused dependencies

This commit is contained in:
Lucy 2022-03-16 16:02:22 -04:00
parent 57c185acb1
commit efba49688f
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1
4 changed files with 19 additions and 26 deletions

2
Cargo.lock generated
View file

@ -241,10 +241,8 @@ dependencies = [
"gtk4",
"libcosmic-widgets",
"libpulse-binding",
"once_cell",
"pulsectl-rs",
"relm4",
"tokio",
]
[[package]]

View file

@ -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"] }

View file

@ -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");
})
}
}

View file

@ -5,11 +5,7 @@ extern crate relm4;
mod app;
use once_cell::sync::Lazy;
use relm4::RelmApp;
use tokio::runtime::Runtime;
static RT: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime"));
fn main() {
RelmApp::<app::App>::new("com.system76.cosmic.applets.audio").run(());