notification: Use full potential of MessageTray.Notification properties
Since MessageTray.Notification now uses GObject properties we can use property bindings and specific notify signals. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3173>
This commit is contained in:
parent
f0e863f529
commit
b746ab05b3
@ -778,17 +778,29 @@ class NotificationMessage extends MessageList.Message {
|
||||
this.notification.destroy(MessageTray.NotificationDestroyedReason.DISMISSED);
|
||||
});
|
||||
notification.connectObject(
|
||||
'updated', this._onUpdated.bind(this),
|
||||
'action-added', (_, action) => this._addAction(action),
|
||||
'action-removed', (_, action) => this._removeAction(action),
|
||||
|
||||
'destroy', () => {
|
||||
this.notification = null;
|
||||
if (!this._closed)
|
||||
this.close();
|
||||
}, this);
|
||||
|
||||
this._onUpdated(notification);
|
||||
notification.bind_property('title',
|
||||
this, 'title',
|
||||
GObject.BindingFlags.SYNC_CREATE);
|
||||
notification.bind_property('body',
|
||||
this, 'body',
|
||||
GObject.BindingFlags.SYNC_CREATE);
|
||||
notification.bind_property('use-body-markup',
|
||||
this, 'use-body-markup',
|
||||
GObject.BindingFlags.SYNC_CREATE);
|
||||
notification.bind_property('datetime',
|
||||
this, 'datetime',
|
||||
GObject.BindingFlags.SYNC_CREATE);
|
||||
notification.bind_property('gicon',
|
||||
this, 'icon',
|
||||
GObject.BindingFlags.SYNC_CREATE);
|
||||
|
||||
this._actions = new Map();
|
||||
this.notification.actions.forEach(action => {
|
||||
@ -796,14 +808,6 @@ class NotificationMessage extends MessageList.Message {
|
||||
});
|
||||
}
|
||||
|
||||
_onUpdated(n, _clear) {
|
||||
this.datetime = n.datetime;
|
||||
this.icon = n.gicon;
|
||||
this.title = n.title;
|
||||
this.body = n.body;
|
||||
this.useBodyMarkup = n.useBodyMarkup;
|
||||
}
|
||||
|
||||
vfunc_clicked() {
|
||||
this.notification.activate();
|
||||
}
|
||||
@ -876,7 +880,8 @@ class NotificationSection extends MessageList.MessageListSection {
|
||||
if (isUrgent)
|
||||
this._nUrgent--;
|
||||
},
|
||||
'updated', () => {
|
||||
'notify::datetime', () => {
|
||||
// The datetime property changes whenever the notification is updated
|
||||
this.moveMessage(message, isUrgent ? 0 : this._nUrgent, this.mapped);
|
||||
}, this);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user