diff --git a/src/ui/play_queue/song.rs b/src/ui/play_queue/song.rs index d350fb2..1a2ee7c 100644 --- a/src/ui/play_queue/song.rs +++ b/src/ui/play_queue/song.rs @@ -8,7 +8,7 @@ mod imp { #[template(resource = "/eu/callcc/audrey/play_queue_song.ui")] #[properties(wrapper_type = super::Song)] pub struct Song { - #[property(type = i32, set = Self::set_playlist_pos)] + #[property(type = i64, set = Self::set_playlist_pos)] _playlist_pos: (), #[property(set, get)] @@ -167,9 +167,9 @@ mod imp { true } - fn set_playlist_pos(&self, playlist_pos: i32) { + fn set_playlist_pos(&self, playlist_pos: i64) { self.obj() - .set_current(playlist_pos == self.position.get() as i32); + .set_current(playlist_pos == self.position.get() as i64); } } } diff --git a/src/ui/playbar.rs b/src/ui/playbar.rs index 95ed5ea..f22afdc 100644 --- a/src/ui/playbar.rs +++ b/src/ui/playbar.rs @@ -95,7 +95,7 @@ mod imp { #[template_callback] fn on_skip_forward_clicked(&self) { - if self.window().playlist_pos() + 1 < self.window().playlist_count() as i32 { + if self.window().playlist_pos() + 1 < self.window().playlist_count() { self.window().playlist_next(); } else { self.window().playlist_play_index(None); diff --git a/src/ui/window.rs b/src/ui/window.rs index 0b93b3b..85d8355 100644 --- a/src/ui/window.rs +++ b/src/ui/window.rs @@ -38,13 +38,13 @@ mod imp { #[property(get)] playlist_model: gio::ListStore, - #[property(type = u32, get = Self::volume, set = Self::set_volume)] + #[property(type = i64, get = Self::volume, set = Self::set_volume, minimum = 0, maximum = 100)] _volume: (), #[property(type = bool, get = Self::mute, set = Self::set_mute)] _mute: (), #[property(type = bool, get = Self::pause, set = Self::set_pause)] _pause: (), - #[property(type = i32, get = Self::playlist_pos)] + #[property(type = i64, get = Self::playlist_pos)] _playlist_pos: (), #[property(type = f64, get = Self::time_pos)] _time_pos: (), @@ -52,7 +52,7 @@ mod imp { _duration: (), // as reported by mpv, compare with song.duration #[property(type = bool, get = Self::idle_active)] _idle_active: (), - #[property(type = u32, get = Self::playlist_count)] + #[property(type = i64, get = Self::playlist_count)] _playlist_count: (), pub(super) queued_seek: Cell>, @@ -290,7 +290,7 @@ mod imp { self.setup.present(Some(self.obj().as_ref())); } - fn volume(&self) -> u32 { + fn volume(&self) -> i64 { self.mpv .get_property::("volume") .unwrap() @@ -298,7 +298,7 @@ mod imp { .unwrap() } - fn set_volume(&self, volume: u32) { + fn set_volume(&self, volume: i64) { self.mpv.set_property("volume", volume as i64).unwrap(); } @@ -318,11 +318,9 @@ mod imp { self.mpv.set_property("pause", pause).unwrap(); } - fn playlist_pos(&self) -> i32 { + fn playlist_pos(&self) -> i64 { self.mpv - .get_property::("playlist-pos") - .unwrap() - .try_into() + .get_property("playlist-pos") .unwrap() } @@ -368,7 +366,7 @@ mod imp { self.mpv.get_property("idle-active").unwrap() } - fn playlist_count(&self) -> u32 { + fn playlist_count(&self) -> i64 { self.mpv .get_property::("playlist-count") .unwrap() @@ -377,16 +375,16 @@ mod imp { } fn song(&self) -> Option { - match self.obj().playlist_pos() { - playlist_pos if playlist_pos < 0 => None, - playlist_pos => Some( + match self.obj().playlist_pos().try_into() { + Ok(playlist_pos) => Some( self.obj() .playlist_model() - .item(playlist_pos as u32) + .item(playlist_pos) .unwrap() .dynamic_cast() .unwrap(), ), + Err(_) => None, } }