mod player; pub use player::Player; use adw::prelude::*; use gtk::glib; pub struct Mpris { window: glib::SendWeakRef, } impl Mpris { pub fn new(window: &crate::ui::Window) -> Self { Self { window: window.downgrade().into(), } } } #[zbus::interface(name = "org.mpris.MediaPlayer2")] impl Mpris { async fn raise(&self) { // TODO: don't unwrap self.window.upgrade().unwrap().present(); } async fn quit(&self) { // TODO: don't unwrap self.window.upgrade().unwrap().close(); } #[zbus(property)] fn can_quit(&self) -> bool { true } #[zbus(property)] fn fullscreen(&self) -> bool { false } #[zbus(property)] // TODO: report that if the argument is just _ the attribute panics async fn set_fullscreen(&self, _fullscreen: bool) -> zbus::Result<()> { Err(zbus::Error::Unsupported) } #[zbus(property)] fn can_set_fullscreen(&self) -> bool { false } #[zbus(property)] fn can_raise(&self) -> bool { true } #[zbus(property)] fn has_track_list(&self) -> bool { false // TODO? } #[zbus(property)] fn identity(&self) -> String { "audrey".to_string() } #[zbus(property)] fn desktop_entry(&self) -> String { crate::APP_ID.to_string() } #[zbus(property)] fn supported_uri_schemes(&self) -> Vec { vec![] } #[zbus(property)] fn supported_mime_types(&self) -> Vec { vec![] } }