implement progress spinner actions

This commit is contained in:
yggverse 2024-12-10 20:52:40 +02:00
parent df99760d0f
commit 7bdf38d327
2 changed files with 17 additions and 8 deletions

View File

@ -43,12 +43,11 @@ pub fn new(
let progress = progress.clone(); let progress = progress.clone();
let status = status.clone(); let status = status.clone();
move |_, button| { move |_, button| {
// apply cancellable // cancel all operations
cancellable.cancel(); cancellable.cancel();
// deactivate `spinner` // deactivate `spinner`
progress.spinner.set_visible(false); progress.disable();
progress.spinner.stop();
// update `status` // update `status`
status.label.set_css_classes(&["warning"]); status.label.set_css_classes(&["warning"]);
@ -94,8 +93,7 @@ pub fn new(
cancel.button.set_visible(true); cancel.button.set_visible(true);
// show `spinner` // show `spinner`
progress.spinner.set_visible(true); progress.enable();
progress.spinner.start();
// hide self // hide self
button.set_visible(false); button.set_visible(false);
@ -108,8 +106,7 @@ pub fn new(
file_launcher.set_file(File::NONE); file_launcher.set_file(File::NONE);
// update `spinner` // update `spinner`
progress.spinner.set_visible(false); progress.disable();
progress.spinner.stop();
// update `status` // update `status`
status.label.set_css_classes(&["warning"]); status.label.set_css_classes(&["warning"]);

View File

@ -1,4 +1,4 @@
use gtk::Spinner; // use adw::Spinner; @TODO adw 1.6 / ubuntu 24.10+ use gtk::{prelude::WidgetExt, Spinner}; // use adw::Spinner; @TODO adw 1.6 / ubuntu 24.10+
// Defaults // Defaults
@ -22,4 +22,16 @@ impl Progress {
.build(), .build(),
} }
} }
// Actions
pub fn enable(&self) {
self.spinner.set_visible(true);
self.spinner.start();
}
pub fn disable(&self) {
self.spinner.set_visible(false);
self.spinner.stop();
}
} }