2024-10-30 09:06:10 +00:00
|
|
|
mod player;
|
|
|
|
pub use player::Player;
|
|
|
|
|
2024-11-01 11:11:49 +00:00
|
|
|
use adw::prelude::*;
|
|
|
|
use gtk::glib;
|
|
|
|
|
|
|
|
pub struct Mpris {
|
2024-11-01 11:57:20 +00:00
|
|
|
window: glib::SendWeakRef<crate::ui::Window>,
|
2024-11-01 11:11:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl Mpris {
|
2024-11-01 12:50:29 +00:00
|
|
|
pub async fn setup(
|
|
|
|
object_server: &zbus::ObjectServer,
|
|
|
|
window: &crate::ui::Window,
|
|
|
|
) -> Result<(), zbus::Error> {
|
|
|
|
let mpris = Self {
|
2024-11-01 11:57:20 +00:00
|
|
|
window: window.downgrade().into(),
|
2024-11-01 12:50:29 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
object_server.at("/org/mpris/MediaPlayer2", mpris).await?;
|
|
|
|
|
|
|
|
//let _mpris = object_server.interface::<_, Self>("/org/mpris/MediaPlayer2").await?;
|
|
|
|
|
|
|
|
Ok(())
|
2024-10-30 09:06:10 +00:00
|
|
|
}
|
2024-11-01 11:11:49 +00:00
|
|
|
}
|
2024-10-30 09:06:10 +00:00
|
|
|
|
2024-11-01 11:11:49 +00:00
|
|
|
#[zbus::interface(name = "org.mpris.MediaPlayer2")]
|
|
|
|
impl Mpris {
|
2024-11-01 12:02:27 +00:00
|
|
|
fn raise(&self) {
|
2024-11-01 12:50:29 +00:00
|
|
|
self.window
|
|
|
|
.upgrade()
|
|
|
|
.expect("main window was finalized")
|
|
|
|
.present();
|
2024-10-30 09:06:10 +00:00
|
|
|
}
|
|
|
|
|
2024-11-01 12:02:27 +00:00
|
|
|
fn quit(&self) {
|
|
|
|
match self.window.upgrade() {
|
2024-11-01 12:50:29 +00:00
|
|
|
None => {} // guess there's nothing to do
|
2024-11-01 12:02:27 +00:00
|
|
|
Some(window) => window.close(),
|
|
|
|
}
|
2024-10-30 09:06:10 +00:00
|
|
|
}
|
|
|
|
|
2024-11-01 11:11:49 +00:00
|
|
|
#[zbus(property)]
|
|
|
|
fn can_quit(&self) -> bool {
|
|
|
|
true
|
|
|
|
}
|
2024-10-30 09:06:10 +00:00
|
|
|
|
2024-11-01 11:11:49 +00:00
|
|
|
#[zbus(property)]
|
|
|
|
fn fullscreen(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
#[zbus(property)]
|
|
|
|
// TODO: report that if the argument is just _ the attribute panics
|
2024-11-01 12:02:27 +00:00
|
|
|
// TODO: why can't this return zbus::fdo::Result??
|
|
|
|
fn set_fullscreen(&self, _fullscreen: bool) -> zbus::Result<()> {
|
2024-11-01 11:11:49 +00:00
|
|
|
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<String> {
|
|
|
|
vec![]
|
|
|
|
}
|
2024-10-30 09:06:10 +00:00
|
|
|
|
2024-11-01 11:11:49 +00:00
|
|
|
#[zbus(property)]
|
|
|
|
fn supported_mime_types(&self) -> Vec<String> {
|
|
|
|
vec![]
|
2024-10-30 09:06:10 +00:00
|
|
|
}
|
|
|
|
}
|
2024-11-02 20:15:55 +00:00
|
|
|
|
|
|
|
impl Drop for Mpris {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
println!("dropping Mpris");
|
|
|
|
}
|
|
|
|
}
|