diff --git a/js/ui/messageList.js b/js/ui/messageList.js index 169168c3aef64a8513c6f32efbc2ec05e96ccd36..1d2453b0a01c2abbe44fe8f165fc78104dad2791 100644 --- a/js/ui/messageList.js +++ b/js/ui/messageList.js @@ -770,7 +770,7 @@ class NotificationMessage extends Message { } }); -const MediaMessage = GObject.registerClass( +export const MediaMessage = GObject.registerClass( class MediaMessage extends Message { constructor(player) { super(player.source); @@ -798,6 +798,9 @@ class MediaMessage extends Message { } vfunc_clicked() { + if (Main.sessionMode.isLocked) + return; + this._player.raise(); Main.panel.closeCalendar(); } diff --git a/js/ui/unlockDialog.js b/js/ui/unlockDialog.js index 77e80571ee5a68965dbcf233b85138c2453d4432..fae4d0787dc65baa0678a426298e4ffd3763b21e 100644 --- a/js/ui/unlockDialog.js +++ b/js/ui/unlockDialog.js @@ -16,6 +16,8 @@ import * as MessageTray from './messageTray.js'; import * as SwipeTracker from './swipeTracker.js'; import {formatDateWithCFormatString} from '../misc/dateUtils.js'; import * as AuthPrompt from '../gdm/authPrompt.js'; +import {MprisSource} from './mpris.js'; +import {MediaMessage} from './messageList.js'; // The timeout before going back automatically to the lock screen (in seconds) const IDLE_TIMEOUT = 2 * 60; @@ -49,6 +51,16 @@ const NotificationsBox = GObject.registerClass({ }); this.add_child(this._scrollView); + this._players = new Map(); + this._mediaSource = new MprisSource(); + this._mediaSource.connectObject( + 'player-added', (o, player) => this._addPlayer(player), + 'player-removed', (o, player) => this._removePlayer(player), + this); + this._mediaSource.players.forEach(player => { + this._addPlayer(player); + }); + this._settings = new Gio.Settings({ schema_id: 'org.gnome.desktop.notifications', }); @@ -69,6 +81,9 @@ const NotificationsBox = GObject.registerClass({ let items = this._sources.entries(); for (let [source, obj] of items) this._removeSource(source, obj); + + for (const player of this._players.keys()) + this._removePlayer(player); } _updateVisibility() { @@ -202,6 +217,20 @@ const NotificationsBox = GObject.registerClass({ this.emit('wake-up-screen'); } + _addPlayer(player) { + const message = new MediaMessage(player); + this._players.set(player, message); + this._notificationBox.insert_child_at_index(message, 0); + this._updateVisibility(); + } + + _removePlayer(player) { + const message = this._players.get(player); + this._players.delete(player); + message.destroy(); + this._updateVisibility(); + } + _sourceAdded(tray, source, initial) { let obj = { visible: source.policy.showInLockScreen, @@ -217,7 +246,7 @@ const NotificationsBox = GObject.registerClass({ x_expand: true, }); this._showSource(source, obj, obj.sourceBox); - this._notificationBox.add_child(obj.sourceBox); + this._notificationBox.insert_child_at_index(obj.sourceBox, this._players.size); source.connectObject( 'notify::count', () => this._countChanged(source, obj),