directly provide playqueue list model

This commit is contained in:
Erica Z 2024-11-02 08:28:31 +01:00
parent 35aa3e3101
commit c227e8caea

View file

@ -5,7 +5,7 @@ mod state;
pub use state::State; pub use state::State;
pub mod ffi { pub mod ffi {
use gtk::glib; use gtk::{gio, glib};
#[repr(C)] #[repr(C)]
pub struct AudreyPlaybin { 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_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_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::{from_glib, from_glib_none, IntoGlib, ToGlibPtr};
use glib::translate::IntoGlib; use gtk::{gio, glib};
use glib::translate::ToGlibPtr;
use gtk::glib;
glib::wrapper! { glib::wrapper! {
pub struct Playbin(Object<ffi::AudreyPlaybin, ffi::AudreyPlaybinClass>); pub struct Playbin(Object<ffi::AudreyPlaybin, ffi::AudreyPlaybinClass>);
@ -131,4 +132,8 @@ impl Playbin {
pub fn stop(&self) { pub fn stop(&self) {
unsafe { ffi::audrey_playbin_stop(self.to_glib_none().0) } 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)) }
}
} }