♻️ refactor: extract `refresh_label` for GUI
parent
fb9b0c67f5
commit
365c878a90
|
@ -112,6 +112,8 @@ struct Gui {
|
||||||
input_relay_url: Input,
|
input_relay_url: Input,
|
||||||
input_file_server_root: Input,
|
input_file_server_root: Input,
|
||||||
input_api_key: SecretInput,
|
input_api_key: SecretInput,
|
||||||
|
|
||||||
|
server_is_running: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive (Default, serde::Deserialize)]
|
#[derive (Default, serde::Deserialize)]
|
||||||
|
@ -176,16 +178,15 @@ impl Gui {
|
||||||
input_relay_url,
|
input_relay_url,
|
||||||
input_file_server_root,
|
input_file_server_root,
|
||||||
input_api_key,
|
input_api_key,
|
||||||
|
|
||||||
|
server_is_running: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_server_running (&mut self, b: bool) {
|
fn set_server_running (&mut self, b: bool) {
|
||||||
self.frame.set_label (if b {
|
self.server_is_running = b;
|
||||||
"Running"
|
|
||||||
}
|
self.refresh_label ();
|
||||||
else {
|
|
||||||
"Stopped"
|
|
||||||
});
|
|
||||||
|
|
||||||
set_active (&mut self.but_run, ! b);
|
set_active (&mut self.but_run, ! b);
|
||||||
set_active (&mut self.but_stop, b);
|
set_active (&mut self.but_stop, b);
|
||||||
|
@ -197,6 +198,15 @@ impl Gui {
|
||||||
set_active (&mut self.input_file_server_root, ! b);
|
set_active (&mut self.input_file_server_root, ! b);
|
||||||
set_active (&mut self.input_api_key, ! b);
|
set_active (&mut self.input_api_key, ! b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn refresh_label (&mut self) {
|
||||||
|
self.frame.set_label (if self.server_is_running {
|
||||||
|
"Running"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
"Stopped"
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_active <W: WidgetExt> (w: &mut W, b: bool) {
|
fn set_active <W: WidgetExt> (w: &mut W, b: bool) {
|
||||||
|
|
Loading…
Reference in New Issue