This commit is contained in:
Erica Z 2024-11-19 21:52:44 +01:00
parent 162a151595
commit 5cd88a0711
2 changed files with 25 additions and 3 deletions

View file

@ -222,6 +222,16 @@ impl Player {
*/ */
} }
pub async fn on_playlist_count_changed(
&self,
emitter: &SignalEmitter<'_>,
) -> Result<(), zbus::fdo::Error> {
self.can_go_next_changed(emitter).await?;
self.can_go_previous_changed(emitter).await?;
self.can_play_changed(emitter).await?;
Ok(())
}
fn window(&self) -> Window { fn window(&self) -> Window {
self.window.upgrade().unwrap() self.window.upgrade().unwrap()
} }
@ -370,17 +380,17 @@ impl Player {
#[zbus(property)] #[zbus(property)]
fn can_go_next(&self) -> bool { fn can_go_next(&self) -> bool {
true // TODO self.window().playlist_count() > 0
} }
#[zbus(property)] #[zbus(property)]
fn can_go_previous(&self) -> bool { fn can_go_previous(&self) -> bool {
true // TODO self.window().playlist_count() > 0
} }
#[zbus(property)] #[zbus(property)]
fn can_play(&self) -> bool { fn can_play(&self) -> bool {
true // TODO self.window().playlist_count() > 0
} }
#[zbus(property)] #[zbus(property)]

View file

@ -597,6 +597,18 @@ mod imp {
6 => { 6 => {
assert_eq!(event.name, "playlist-count"); assert_eq!(event.name, "playlist-count");
self.obj().notify("playlist-count"); self.obj().notify("playlist-count");
// mpris can-go-next depends on this
if let Some(iface_ref) = self.mpris_player() {
glib::spawn_future_local(async move {
iface_ref
.get()
.await
.on_playlist_count_changed(iface_ref.signal_emitter())
.await
.unwrap();
});
}
} }
7 => { 7 => {