mpris: Expose player app

This will allow accessing it from the notification.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2755>
This commit is contained in:
Florian Müllner 2023-04-19 12:51:14 +02:00 committed by Marge Bot
parent 4020671372
commit 35315a605b

View File

@ -120,6 +120,10 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
return this._trackCoverUrl; return this._trackCoverUrl;
} }
get app() {
return this._app;
}
playPause() { playPause() {
this._playerProxy.PlayPauseAsync().catch(logError); this._playerProxy.PlayPauseAsync().catch(logError);
} }
@ -143,14 +147,8 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
raise() { raise() {
// The remote Raise() method may run into focus stealing prevention, // The remote Raise() method may run into focus stealing prevention,
// so prefer activating the app via .desktop file if possible // so prefer activating the app via .desktop file if possible
let app = null; if (this._app)
if (this._mprisProxy.DesktopEntry) { this._app.activate();
let desktopId = `${this._mprisProxy.DesktopEntry}.desktop`;
app = Shell.AppSystem.get_default().lookup_app(desktopId);
}
if (app)
app.activate();
else if (this._mprisProxy.CanRaise) else if (this._mprisProxy.CanRaise)
this._mprisProxy.RaiseAsync().catch(logError); this._mprisProxy.RaiseAsync().catch(logError);
} }
@ -222,6 +220,13 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
this._trackCoverUrl = ''; 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'); this.emit('changed');
let visible = this._playerProxy.CanPlay; let visible = this._playerProxy.CanPlay;