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:

committed by
Florian Müllner

parent
7059dcced3
commit
b5676a2a5c
@ -1,7 +1,7 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
/* exported Component */
|
||||
|
||||
const { Gio, St } = imports.gi;
|
||||
const { Gio, GObject, St } = imports.gi;
|
||||
|
||||
const GnomeSession = imports.misc.gnomeSession;
|
||||
const Main = imports.ui.main;
|
||||
@ -272,9 +272,10 @@ var AutorunDispatcher = class {
|
||||
}
|
||||
};
|
||||
|
||||
var AutorunSource = class extends MessageTray.Source {
|
||||
constructor(manager, mount, apps) {
|
||||
super(mount.get_name());
|
||||
var AutorunSource = GObject.registerClass(
|
||||
class AutorunSource extends MessageTray.Source {
|
||||
_init(manager, mount, apps) {
|
||||
super._init(mount.get_name());
|
||||
|
||||
this._manager = manager;
|
||||
this.mount = mount;
|
||||
@ -284,7 +285,7 @@ var AutorunSource = class extends MessageTray.Source {
|
||||
|
||||
// add ourselves as a source, and popup the notification
|
||||
Main.messageTray.add(this);
|
||||
this.notify(this._notification);
|
||||
this.showNotification(this._notification);
|
||||
}
|
||||
|
||||
getIcon() {
|
||||
@ -294,11 +295,12 @@ var AutorunSource = class extends MessageTray.Source {
|
||||
_createPolicy() {
|
||||
return new MessageTray.NotificationApplicationPolicy('org.gnome.Nautilus');
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var AutorunNotification = class extends MessageTray.Notification {
|
||||
constructor(manager, source) {
|
||||
super(source, source.title);
|
||||
var AutorunNotification = GObject.registerClass(
|
||||
class AutorunNotification extends MessageTray.Notification {
|
||||
_init(manager, source) {
|
||||
super._init(source, source.title);
|
||||
|
||||
this._manager = manager;
|
||||
this._mount = source.mount;
|
||||
@ -350,6 +352,6 @@ var AutorunNotification = class extends MessageTray.Notification {
|
||||
let app = Gio.app_info_get_default_for_type('inode/directory', false);
|
||||
startAppForMount(app, this._mount);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var Component = AutorunManager;
|
||||
|
@ -734,7 +734,7 @@ var NetworkAgent = class {
|
||||
});
|
||||
|
||||
Main.messageTray.add(source);
|
||||
source.notify(notification);
|
||||
source.showNotification(notification);
|
||||
}
|
||||
|
||||
_newRequest(agent, requestId, connection, settingName, hints, flags) {
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user