notification: Use the same Source for showing system notifications

This drops all subclasses of `MessageTray.Source` that were used to
display system notifications. Now the `Source` returned from
`MessageTray.getSystemSource()` is used.
Ensure also that properties and methods that where set on the `Source`
are moved to the `Notification` object itself.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3156>
This commit is contained in:
Julian Sparber
2024-02-02 15:42:31 +01:00
committed by Marge Bot
parent 3faf1caead
commit c1ff00c01b
9 changed files with 65 additions and 178 deletions

View File

@ -236,7 +236,6 @@ class Indicator extends SystemIndicator {
Main.sessionMode.connect('updated', this._sync.bind(this));
this._sync();
this._source = null;
this._perm = null;
this._createPermission();
}
@ -254,27 +253,13 @@ class Indicator extends SystemIndicator {
this._client.close();
}
_ensureSource() {
if (!this._source) {
this._source = new MessageTray.Source({
title: _('Thunderbolt'),
iconName: 'thunderbolt-symbolic',
});
this._source.connect('destroy', () => (this._source = null));
Main.messageTray.add(this._source);
}
return this._source;
}
_notify(title, body) {
if (this._notification)
this._notification.destroy();
let source = this._ensureSource();
const source = MessageTray.getSystemSource();
this._notification = new MessageTray.Notification(source, title, body);
this._notification.iconName = 'thunderbolt-symbolic';
this._notification.setUrgency(MessageTray.Urgency.HIGH);
this._notification.connect('destroy', () => {
this._notification = null;