From 4060213e80733492e5982be0b557c00efedb54d6 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sun, 10 Nov 2024 17:40:41 +0100 Subject: [PATCH] time-pos notification --- src/ui/window.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/ui/window.rs b/src/ui/window.rs index 1dac4f2..42c8abb 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -175,8 +175,10 @@ mod imp { move || match window.upgrade() { None => glib::ControlFlow::Break, Some(window) => { - if !window.idle_active() && !window.pause() { - window.notify("time-pos"); + match window.imp().state.get() { + State::Idle | State::FileLoading | State::Seeking => {}, + State::Active => window.notify("time-pos"), + other => unreachable!("{other:?}"), } glib::ControlFlow::Continue } @@ -506,6 +508,9 @@ mod imp { } self.state.set(State::FileLoading); + // make sure this is reported as 0 + self.obj().notify("time-pos"); + event!(Level::INFO, "StartFile"); self.obj().notify("song"); self.buffering_start(); @@ -538,9 +543,6 @@ mod imp { { handle.abort(); } - - // make sure this is reported as 0 - self.obj().notify("time-pos"); } fn on_file_loaded(&self) { @@ -596,7 +598,6 @@ mod imp { event!(Level::INFO, "PlaybackRestart"); self.buffering_end(); - self.obj().notify("time-pos"); if let Some(queued_seek) = self.queued_seek.take() { // a seek was tried before and failed, try again now @@ -617,6 +618,9 @@ mod imp { } self.state.set(State::FileEnded); + // make sure the seekbar looks full + self.obj().notify("time-pos"); + self.obj().notify("song"); self.buffering_end(); @@ -628,9 +632,6 @@ mod imp { self.queued_seek.set(None); self.obj().set_playing_cover_art(None::); - - // make sure the seekbar looks full - self.obj().notify("time-pos"); } #[template_callback]