From c227e8caeaa4f89509a274d36e20ff87ceefbc48 Mon Sep 17 00:00:00 2001 From: Erica Z Date: Sat, 2 Nov 2024 08:28:31 +0100 Subject: [PATCH] directly provide playqueue list model --- src/playbin.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/playbin.rs b/src/playbin.rs index f9bfdb4..75891ad 100644 --- a/src/playbin.rs +++ b/src/playbin.rs @@ -5,7 +5,7 @@ mod state; pub use state::State; pub mod ffi { - use gtk::glib; + use gtk::{gio, glib}; #[repr(C)] pub struct AudreyPlaybin { @@ -43,13 +43,14 @@ pub mod ffi { ); pub fn audrey_playbin_remove_track(self_: *mut AudreyPlaybin, position: std::ffi::c_uint); pub fn audrey_playbin_select_track(self_: *mut AudreyPlaybin, position: std::ffi::c_uint); + pub fn audrey_playbin_get_play_queue( + self_: *mut AudreyPlaybin, + ) -> *mut gio::ffi::GListModel; } } -use glib::translate::from_glib; -use glib::translate::IntoGlib; -use glib::translate::ToGlibPtr; -use gtk::glib; +use glib::translate::{from_glib, from_glib_none, IntoGlib, ToGlibPtr}; +use gtk::{gio, glib}; glib::wrapper! { pub struct Playbin(Object); @@ -131,4 +132,8 @@ impl Playbin { pub fn stop(&self) { unsafe { ffi::audrey_playbin_stop(self.to_glib_none().0) } } + + pub fn play_queue(&self) -> gio::ListModel { + unsafe { from_glib_none(ffi::audrey_playbin_get_play_queue(self.to_glib_none().0)) } + } }