Better enum names

This commit is contained in:
Lucy 2022-03-18 12:11:05 -04:00
parent 3b8996a24c
commit 84364936b7
No known key found for this signature in database
GPG key ID: EBC517FAD666BBF1

View file

@ -14,11 +14,11 @@ use pulsectl::{
use relm4::{component, view, ComponentParts, RelmContainerExt, Sender, SimpleComponent}; use relm4::{component, view, ComponentParts, RelmContainerExt, Sender, SimpleComponent};
use std::rc::Rc; use std::rc::Rc;
pub enum Input { pub enum AppInput {
UpdateInputs, Inputs,
UpdateOutputs, Outputs,
UpdateInputVolume, InputVolume,
UpdateOutputVolume, OutputVolume,
} }
pub struct App { pub struct App {
@ -96,7 +96,7 @@ impl App {
}; };
} }
fn subscribe_for_updates(&self, input: &Sender<Input>) { fn subscribe_for_updates(&self, input: &Sender<AppInput>) {
let mut context = self.handler.context.borrow_mut(); let mut context = self.handler.context.borrow_mut();
let input = input.clone(); let input = input.clone();
context.set_subscribe_callback(Some(Box::new(move |facility, operation, _idx| { context.set_subscribe_callback(Some(Box::new(move |facility, operation, _idx| {
@ -106,10 +106,10 @@ impl App {
} }
match dbg!(facility) { match dbg!(facility) {
Some(Facility::Sink | Facility::SinkInput) => { Some(Facility::Sink | Facility::SinkInput) => {
send!(input, Input::UpdateOutputVolume); send!(input, AppInput::OutputVolume);
} }
Some(Facility::Source | Facility::SourceOutput) => { Some(Facility::Source | Facility::SourceOutput) => {
send!(input, Input::UpdateInputVolume); send!(input, AppInput::InputVolume);
} }
_ => {} _ => {}
} }
@ -191,7 +191,7 @@ impl App {
impl SimpleComponent for App { impl SimpleComponent for App {
type Widgets = AppWidgets; type Widgets = AppWidgets;
type InitParams = (); type InitParams = ();
type Input = Input; type Input = AppInput;
type Output = (); type Output = ();
view! { view! {
@ -246,7 +246,7 @@ impl SimpleComponent for App {
set_text: watch! { model.get_default_output_name() } set_text: watch! { model.get_default_output_name() }
}, },
connect_clicked(input, outputs_revealer) => move |_| { connect_clicked(input, outputs_revealer) => move |_| {
send!(input, Input::UpdateOutputs); send!(input, AppInput::Outputs);
outputs_revealer.set_reveal_child(!outputs_revealer.reveals_child()); outputs_revealer.set_reveal_child(!outputs_revealer.reveals_child());
} }
}, },
@ -268,7 +268,7 @@ impl SimpleComponent for App {
set_text: watch! { model.get_default_input_name() } set_text: watch! { model.get_default_input_name() }
}, },
connect_clicked(input, inputs_revealer) => move |_| { connect_clicked(input, inputs_revealer) => move |_| {
send!(input, Input::UpdateInputs); send!(input, AppInput::Inputs);
inputs_revealer.set_reveal_child(!inputs_revealer.reveals_child()); inputs_revealer.set_reveal_child(!inputs_revealer.reveals_child());
} }
}, },
@ -304,16 +304,16 @@ impl SimpleComponent for App {
_ouput: &Sender<Self::Output>, _ouput: &Sender<Self::Output>,
) { ) {
match msg { match msg {
Input::UpdateOutputs => { AppInput::Outputs => {
self.outputs.clear(); self.outputs.clear();
} }
Input::UpdateInputs => { AppInput::Inputs => {
self.inputs.clear(); self.inputs.clear();
} }
Input::UpdateInputVolume => { AppInput::InputVolume => {
self.update_default_input(); self.update_default_input();
} }
Input::UpdateOutputVolume => { AppInput::OutputVolume => {
self.update_default_output(); self.update_default_output();
} }
} }