imagePage: Show spinner with small delay

That way, when quickly scrolling through images (holding down arrow
keys) no restarting spinner animations are shown in between.
This commit is contained in:
Sophie Herold 2024-07-29 15:16:06 +02:00
parent 05319522a0
commit f2bc4a66b5
3 changed files with 20 additions and 1 deletions

View file

@ -33,6 +33,8 @@ use crate::util::gettext::*;
use crate::widgets::LpImage;
mod imp {
use std::time::Duration;
use super::*;
#[derive(Debug, Default, CompositeTemplate, Properties)]
@ -43,6 +45,8 @@ mod imp {
pub(super) stack: TemplateChild<gtk::Stack>,
#[template_child]
pub(super) spinner_page: TemplateChild<gtk::Widget>,
#[template_child]
pub(super) spinner_revealer: TemplateChild<gtk::Revealer>,
#[template_child]
pub(super) error_page: TemplateChild<adw::StatusPage>,
@ -146,6 +150,13 @@ mod imp {
glib::spawn_future_local(async move { obj.show_error().await });
}
));
self.spinner_revealer.connect_map(|revealer| {
let revealer = revealer.clone();
glib::timeout_add_local_once(Duration::from_millis(200), move || {
revealer.set_reveal_child(true);
});
});
}
}