Clean up code a bit; remove unused dependencies
This commit is contained in:
parent
57c185acb1
commit
efba49688f
4 changed files with 19 additions and 26 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -241,10 +241,8 @@ dependencies = [
|
||||||
"gtk4",
|
"gtk4",
|
||||||
"libcosmic-widgets",
|
"libcosmic-widgets",
|
||||||
"libpulse-binding",
|
"libpulse-binding",
|
||||||
"once_cell",
|
|
||||||
"pulsectl-rs",
|
"pulsectl-rs",
|
||||||
"relm4",
|
"relm4",
|
||||||
"tokio",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,5 @@ futures-util = "0.3.21"
|
||||||
gtk4 = "0.4.6"
|
gtk4 = "0.4.6"
|
||||||
libcosmic-widgets = { git = "https://github.com/pop-os/libcosmic", branch = "lucy/widgets" }
|
libcosmic-widgets = { git = "https://github.com/pop-os/libcosmic", branch = "lucy/widgets" }
|
||||||
libpulse-binding = "2.26.0"
|
libpulse-binding = "2.26.0"
|
||||||
once_cell = "1.10.0"
|
|
||||||
pulsectl-rs = "0.3.2"
|
pulsectl-rs = "0.3.2"
|
||||||
relm4 = { git = "https://github.com/AaronErhardt/relm4", branch = "new-approach", features = ["macros"] }
|
relm4 = { git = "https://github.com/AaronErhardt/relm4", branch = "new-approach", features = ["macros"] }
|
||||||
tokio = { version = "1.17.0", features = ["full"] }
|
|
||||||
|
|
|
||||||
|
|
@ -71,22 +71,22 @@ impl App {
|
||||||
}
|
}
|
||||||
for input in inputs {
|
for input in inputs {
|
||||||
let input = Rc::new(input);
|
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! {
|
view! {
|
||||||
item = LabeledItem {
|
item = LabeledItem {
|
||||||
set_title: input.description
|
set_title: input.description
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.or_else(|| input.name.as_ref())
|
.unwrap_or(&name),
|
||||||
.cloned()
|
|
||||||
.unwrap_or_else(|| "Unknown".to_string()),
|
|
||||||
set_child: set_current_input_device = &Button {
|
set_child: set_current_input_device = &Button {
|
||||||
set_label: "Switch",
|
set_label: "Switch",
|
||||||
connect_clicked: clone!(@strong input, => move |_| {
|
connect_clicked: clone!(@strong input, => move |_| {
|
||||||
if let Some(name) = &input.name {
|
SourceController::create()
|
||||||
SourceController::create()
|
.expect("failed to create input controller")
|
||||||
.expect("failed to create input controller")
|
.set_default_device(&name)
|
||||||
.set_default_device(name)
|
.expect("failed to set default device");
|
||||||
.expect("failed to set default device");
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -104,22 +104,23 @@ impl App {
|
||||||
}
|
}
|
||||||
for output in outputs {
|
for output in outputs {
|
||||||
let output = Rc::new(output);
|
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! {
|
view! {
|
||||||
item = LabeledItem {
|
item = LabeledItem {
|
||||||
set_title: output.description
|
set_title: output.description
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.or_else(|| output.name.as_ref())
|
.unwrap_or(&name),
|
||||||
.cloned()
|
|
||||||
.unwrap_or_else(|| "Unknown".to_string()),
|
|
||||||
set_child: set_current_output_device = &Button {
|
set_child: set_current_output_device = &Button {
|
||||||
set_label: "Switch",
|
set_label: "Switch",
|
||||||
connect_clicked: clone!(@strong output, => move |_| {
|
connect_clicked: clone!(@strong output, => move |_| {
|
||||||
if let Some(name) = &output.name {
|
SinkController::create()
|
||||||
SinkController::create()
|
.expect("failed to create output controller")
|
||||||
.expect("failed to create output controller")
|
.set_default_device(&name)
|
||||||
.set_default_device(name)
|
.expect("failed to set default device");
|
||||||
.expect("failed to set default device");
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,7 @@ extern crate relm4;
|
||||||
|
|
||||||
mod app;
|
mod app;
|
||||||
|
|
||||||
use once_cell::sync::Lazy;
|
|
||||||
use relm4::RelmApp;
|
use relm4::RelmApp;
|
||||||
use tokio::runtime::Runtime;
|
|
||||||
|
|
||||||
static RT: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime"));
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
RelmApp::<app::App>::new("com.system76.cosmic.applets.audio").run(());
|
RelmApp::<app::App>::new("com.system76.cosmic.applets.audio").run(());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue