mirror of
https://github.com/YGGverse/Yoda.git
synced 2025-01-15 17:20:08 +00:00
implement status actions
This commit is contained in:
parent
7bdf38d327
commit
556a85b7e5
@ -50,8 +50,7 @@ pub fn new(
|
||||
progress.disable();
|
||||
|
||||
// update `status`
|
||||
status.label.set_css_classes(&["warning"]);
|
||||
status.label.set_label("Operation cancelled");
|
||||
status.set_warning("Operation cancelled");
|
||||
|
||||
// hide self
|
||||
button.set_visible(false);
|
||||
@ -86,8 +85,7 @@ pub fn new(
|
||||
file_launcher.set_file(Some(&file));
|
||||
|
||||
// update `status`
|
||||
status.label.set_css_classes(&[]);
|
||||
status.label.set_label("Loading...");
|
||||
status.set_default("Loading...");
|
||||
|
||||
// show `cancel` button
|
||||
cancel.button.set_visible(true);
|
||||
@ -109,8 +107,7 @@ pub fn new(
|
||||
progress.disable();
|
||||
|
||||
// update `status`
|
||||
status.label.set_css_classes(&["warning"]);
|
||||
status.label.set_label(e.message())
|
||||
status.set_warning(e.message());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -129,8 +126,7 @@ pub fn new(
|
||||
let button = button.clone();
|
||||
move |result| {
|
||||
if let Err(ref e) = result {
|
||||
status.label.set_css_classes(&["error"]);
|
||||
status.label.set_label(e.message())
|
||||
status.set_error(e.message())
|
||||
}
|
||||
button.set_sensitive(true); // unlock
|
||||
}
|
||||
|
@ -1,7 +1,11 @@
|
||||
use gtk::Label;
|
||||
use gtk::{prelude::WidgetExt, Label};
|
||||
|
||||
// Defaults
|
||||
|
||||
const CSS_CLASSES_DEFAULT: &[&str; 0] = &[];
|
||||
const CSS_CLASSES_ERROR: &[&str; 1] = &["error"];
|
||||
const CSS_CLASSES_SUCCESS: &[&str; 1] = &["success"];
|
||||
const CSS_CLASSES_WARNING: &[&str; 1] = &["warning"];
|
||||
const LABEL: &str = "Choose location to download";
|
||||
const MARGIN: i32 = 16;
|
||||
|
||||
@ -20,4 +24,26 @@ impl Status {
|
||||
label: Label::builder().label(LABEL).margin_top(MARGIN).build(),
|
||||
}
|
||||
}
|
||||
|
||||
// Actions
|
||||
|
||||
pub fn set_default(&self, label: &str) {
|
||||
self.label.set_css_classes(CSS_CLASSES_DEFAULT);
|
||||
self.label.set_label(label)
|
||||
}
|
||||
|
||||
pub fn set_error(&self, label: &str) {
|
||||
self.label.set_css_classes(CSS_CLASSES_ERROR);
|
||||
self.label.set_label(label)
|
||||
}
|
||||
|
||||
pub fn set_success(&self, label: &str) {
|
||||
self.label.set_css_classes(CSS_CLASSES_SUCCESS);
|
||||
self.label.set_label(label)
|
||||
}
|
||||
|
||||
pub fn set_warning(&self, label: &str) {
|
||||
self.label.set_css_classes(CSS_CLASSES_WARNING);
|
||||
self.label.set_label(label)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user