From 6ed96cddb451bbddd8c9f3decb7f6d1cd83bcf20 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Tue, 5 Nov 2024 09:36:24 +0100 Subject: [PATCH] just use the notify mechanism for time-pos --- src/ui/window.rs | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/ui/window.rs b/src/ui/window.rs index a63e478..e89e8f7 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -64,6 +64,7 @@ mod imp { mpv.observe_property(2, "pause").unwrap(); mpv.observe_property(3, "playlist-pos").unwrap(); mpv.observe_property(4, "idle-active").unwrap(); + mpv.observe_property(5, "time-pos").unwrap(); // "Useful to drain property changes before a new file is loaded." mpv.add_hook(0, "on_before_start_file", 0).unwrap(); @@ -147,6 +148,11 @@ mod imp { window.notify("idle-active"); } + 5 => { + assert_eq!(event.name, "time-pos"); + window.notify("time-pos"); + } + _ => unreachable!(), }, @@ -245,19 +251,6 @@ mod imp { .await .expect("could not register name in session bus"); }); - - // notify of new time-pos every 100 ms - glib::source::timeout_add_local(std::time::Duration::from_millis(100), { - let window = self.obj().downgrade(); - move || { - let window = match window.upgrade() { - None => return glib::ControlFlow::Break, - Some(window) => window, - }; - window.notify("time-pos"); - glib::ControlFlow::Continue - } - }); } }