sanity check

This commit is contained in:
Erica Z 2024-11-04 13:29:10 +01:00
parent b7f42bce44
commit 224a7ff3dc

View file

@ -25,8 +25,8 @@ mod imp {
#[property(get, set, nullable)]
playing_cover_art: RefCell<Option<gdk::Paintable>>,
#[property(get, set, nullable)]
song: RefCell<Option<PlaybinSong>>,
#[property(type = Option<PlaybinSong>, get = Self::song, nullable)]
_song: (),
pub(super) setup: crate::ui::Setup,
@ -70,7 +70,7 @@ mod imp {
play_queue: Default::default(),
can_click_shuffle_all: Cell::new(false),
playing_cover_art: Default::default(),
song: Default::default(),
_song: (),
setup: Default::default(),
api: Default::default(),
mpv,
@ -139,14 +139,14 @@ mod imp {
},
Event::StartFile(_) => {
let song: PlaybinSong = window
.playlist_model()
.item(window.playlist_pos() as u32)
.unwrap()
.dynamic_cast()
.unwrap();
window.set_song(Some(&song));
window.notify("song");
// TODO: load cover art
// sanity check
assert_eq!(
window.song().unwrap().stream_url(),
window.imp().mpv.get_property::<String>("path").unwrap()
);
}
Event::Hook(event) => match event.reply_userdata {
@ -298,6 +298,21 @@ mod imp {
}
.unwrap()
}
fn song(&self) -> Option<PlaybinSong> {
if self.obj().playlist_pos() < 0 {
None
} else {
Some(
self.obj()
.playlist_model()
.item(self.obj().playlist_pos() as u32)
.unwrap()
.dynamic_cast()
.unwrap(),
)
}
}
}
impl Drop for Window {