messageTray: Inherit Notification, Source and NotificationPolicy from GObject

Register notifications, sources and policies as GObject gtypes so that they can
be passed in signals and use native properties and signals.

Reimplement all the extending classes.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/559
This commit is contained in:
Marco Trevisan (Treviño)
2019-05-13 23:32:31 +02:00
committed by Florian Müllner
parent 7059dcced3
commit b5676a2a5c
13 changed files with 211 additions and 131 deletions

View File

@ -215,7 +215,7 @@ class TelepathyClient extends Tp.BaseClient {
// We are already handling the channel, display the source
let source = this._chatSources[channel.get_object_path()];
if (source)
source.notify();
source.showNotification();
}
}
}
@ -266,9 +266,10 @@ class TelepathyClient extends Tp.BaseClient {
}
}) : null;
var ChatSource = class extends MessageTray.Source {
constructor(account, conn, channel, contact, client) {
super(contact.get_alias());
var ChatSource = HAVE_TP ? GObject.registerClass(
class ChatSource extends MessageTray.Source {
_init(account, conn, channel, contact, client) {
super._init(contact.get_alias());
this._account = account;
this._contact = contact;
@ -476,7 +477,7 @@ var ChatSource = class extends MessageTray.Source {
this._notification.appendMessage(pendingMessages[i], true);
if (pendingMessages.length > 0)
this.notify();
this.showNotification();
}
destroy(reason) {
@ -553,7 +554,7 @@ var ChatSource = class extends MessageTray.Source {
_notifyTimeout() {
if (this._pendingMessages.length != 0)
this.notify();
this.showNotification();
this._notifyTimeoutId = 0;
@ -568,8 +569,8 @@ var ChatSource = class extends MessageTray.Source {
this._notification.appendMessage(message);
}
notify() {
super.notify(this._notification);
showNotification() {
super.showNotification(this._notification);
}
respond(text) {
@ -625,12 +626,18 @@ var ChatSource = class extends MessageTray.Source {
// 'pending-message-removed' for each one.
this._channel.ack_all_pending_messages_async(null);
}
};
}) : null;
var ChatNotification = class extends MessageTray.Notification {
constructor(source) {
super(source, source.title, null,
{ secondaryGIcon: source.getSecondaryIcon() });
var ChatNotification = HAVE_TP ? GObject.registerClass({
Signals: {
'message-removed': { param_types: [Tp.Message.$gtype] },
'message-added': { param_types: [Tp.Message.$gtype] },
'timestamp-changed': { param_types: [Tp.Message.$gtype] },
}
}, class ChatNotification extends MessageTray.Notification {
_init(source) {
super._init(source, source.title, null,
{ secondaryGIcon: source.getSecondaryIcon() });
this.setUrgency(MessageTray.Urgency.HIGH);
this.setResident(true);
@ -782,7 +789,7 @@ var ChatNotification = class extends MessageTray.Notification {
this._filterMessages();
}
};
}) : null;
var ChatLineBox = GObject.registerClass(
class ChatLineBox extends St.BoxLayout {