50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
# Copyright 2022 (c) Anna Schumaker.
|
|
"""Our Mpris2 Application dbus Object."""
|
|
import pathlib
|
|
from gi.repository import GObject
|
|
from gi.repository import GLib
|
|
from . import dbus
|
|
|
|
MPRIS2_XML = pathlib.Path(__file__).parent / "MediaPlayer2.xml"
|
|
|
|
|
|
class Application(dbus.Object):
|
|
"""The mpris2 Application dbus object."""
|
|
|
|
CanQuit = GObject.Property(type=bool, default=True)
|
|
Fullscreen = GObject.Property(type=bool, default=False)
|
|
CanSetFullscreen = GObject.Property(type=bool, default=True)
|
|
CanRaise = GObject.Property(type=bool, default=True)
|
|
HasTrackList = GObject.Property(type=bool, default=False)
|
|
Identity = GObject.Property(type=str, default="Emmental Music Player")
|
|
DesktopEntry = GObject.Property(type=str, default="emmental")
|
|
|
|
def __init__(self):
|
|
"""Initialize the mpris2 application object."""
|
|
super().__init__(xml=MPRIS2_XML)
|
|
|
|
def do_notify(self, property: str) -> None:
|
|
"""Notify DBus when the Fullscreen property changes."""
|
|
match property:
|
|
case "Fullscreen":
|
|
value = GLib.Variant("b", self.Fullscreen)
|
|
self.properties_changed({property: value})
|
|
|
|
@GObject.Property
|
|
def SupportedUriSchemes(self) -> list[str]:
|
|
"""URI schemes supported by Emmental."""
|
|
return ["file"]
|
|
|
|
@GObject.Property
|
|
def SupportedMimeTypes(self) -> list[str]:
|
|
"""Mime Types supported by Emmental."""
|
|
return ["audio"]
|
|
|
|
@GObject.Signal
|
|
def Raise(self) -> None:
|
|
"""Raise the window."""
|
|
|
|
@GObject.Signal
|
|
def Quit(self) -> None:
|
|
"""Quit Emmental."""
|