diff options
author | Florian Müllner <fmuellner@gnome.org> | 2023-04-19 12:51:14 +0200 |
---|---|---|
committer | Marge Bot <marge-bot@gnome.org> | 2023-05-15 16:05:31 +0000 |
commit | 35315a605b33f7e2d69350b3fa2235518c63f580 (patch) | |
tree | 6e5a4573934ccee1e7384e0662d2c1fdde8e0b31 | |
parent | 402067137221639847b4265f1912d417b15e8fc1 (diff) | |
download | gnome-shell-35315a605b33f7e2d69350b3fa2235518c63f580.tar.gz |
mpris: Expose player app
This will allow accessing it from the notification.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2755>
-rw-r--r-- | js/ui/mpris.js | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/js/ui/mpris.js b/js/ui/mpris.js index f44f87e92..93d1ec68b 100644 --- a/js/ui/mpris.js +++ b/js/ui/mpris.js @@ -120,6 +120,10 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter { return this._trackCoverUrl; } + get app() { + return this._app; + } + playPause() { this._playerProxy.PlayPauseAsync().catch(logError); } @@ -143,14 +147,8 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter { raise() { // The remote Raise() method may run into focus stealing prevention, // so prefer activating the app via .desktop file if possible - let app = null; - if (this._mprisProxy.DesktopEntry) { - let desktopId = `${this._mprisProxy.DesktopEntry}.desktop`; - app = Shell.AppSystem.get_default().lookup_app(desktopId); - } - - if (app) - app.activate(); + if (this._app) + this._app.activate(); else if (this._mprisProxy.CanRaise) this._mprisProxy.RaiseAsync().catch(logError); } @@ -222,6 +220,13 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter { this._trackCoverUrl = ''; } + if (this._mprisProxy.DesktopEntry) { + const desktopId = `${this._mprisProxy.DesktopEntry}.desktop`; + this._app = Shell.AppSystem.get_default().lookup_app(desktopId); + } else { + this._app = null; + } + this.emit('changed'); let visible = this._playerProxy.CanPlay; |