Start using MessageTray.Source directly instead of having to subclass it
For most subclasses, this is a direct swap -- a lot of the time, the constructor was a blank class that override createNotificationIcon, and called _setSummaryIcon in _init. https://bugzilla.gnome.org/show_bug.cgi?id=661236
This commit is contained in:
parent
c6fabe504a
commit
9e1a2cfeac
@ -262,12 +262,11 @@ const AutorunResidentSource = new Lang.Class({
|
|||||||
Extends: MessageTray.Source,
|
Extends: MessageTray.Source,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(_("Removable Devices"));
|
this.parent(_("Removable Devices"), 'media-removable', St.IconType.FULLCOLOR);
|
||||||
|
|
||||||
this._mounts = [];
|
this._mounts = [];
|
||||||
|
|
||||||
this._notification = new AutorunResidentNotification(this);
|
this._notification = new AutorunResidentNotification(this);
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
addMount: function(mount, apps) {
|
addMount: function(mount, apps) {
|
||||||
@ -310,12 +309,6 @@ const AutorunResidentSource = new Lang.Class({
|
|||||||
Main.messageTray.add(this);
|
Main.messageTray.add(this);
|
||||||
this.pushNotification(this._notification);
|
this.pushNotification(this._notification);
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
createNotificationIcon: function() {
|
|
||||||
return new St.Icon ({ icon_name: 'media-removable',
|
|
||||||
icon_type: St.IconType.FULLCOLOR,
|
|
||||||
icon_size: this.ICON_SIZE });
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -500,11 +493,11 @@ const AutorunTransientSource = new Lang.Class({
|
|||||||
Extends: MessageTray.Source,
|
Extends: MessageTray.Source,
|
||||||
|
|
||||||
_init: function(mount, apps) {
|
_init: function(mount, apps) {
|
||||||
this.parent(mount.get_name());
|
|
||||||
|
|
||||||
this.mount = mount;
|
this.mount = mount;
|
||||||
this.apps = apps;
|
this.apps = apps;
|
||||||
|
|
||||||
|
this.parent(mount.get_name());
|
||||||
|
|
||||||
this._notification = new AutorunTransientNotification(this);
|
this._notification = new AutorunTransientNotification(this);
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
this._setSummaryIcon(this.createNotificationIcon());
|
||||||
|
|
||||||
|
@ -541,16 +541,8 @@ const KeyboardSource = new Lang.Class({
|
|||||||
Extends: MessageTray.Source,
|
Extends: MessageTray.Source,
|
||||||
|
|
||||||
_init: function(keyboard) {
|
_init: function(keyboard) {
|
||||||
this.parent(_("Keyboard"));
|
|
||||||
this._keyboard = keyboard;
|
this._keyboard = keyboard;
|
||||||
|
this.parent(_("Keyboard"), 'input-keyboard', St.IconType.SYMBOLIC);
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
},
|
|
||||||
|
|
||||||
createNotificationIcon: function() {
|
|
||||||
return new St.Icon({ icon_name: 'input-keyboard',
|
|
||||||
icon_type: St.IconType.SYMBOLIC,
|
|
||||||
icon_size: this.ICON_SIZE });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
handleSummaryClick: function() {
|
handleSummaryClick: function() {
|
||||||
|
@ -2493,15 +2493,7 @@ const SystemNotificationSource = new Lang.Class({
|
|||||||
Extends: Source,
|
Extends: Source,
|
||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(_("System Information"));
|
this.parent(_("System Information"), 'dialog-information', St.IconType.SYMBOLIC);
|
||||||
|
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
},
|
|
||||||
|
|
||||||
createNotificationIcon: function() {
|
|
||||||
return new St.Icon({ icon_name: 'dialog-information',
|
|
||||||
icon_type: St.IconType.SYMBOLIC,
|
|
||||||
icon_size: this.ICON_SIZE });
|
|
||||||
},
|
},
|
||||||
|
|
||||||
open: function() {
|
open: function() {
|
||||||
|
@ -638,5 +638,10 @@ const Source = new Lang.Class({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.parent();
|
this.parent();
|
||||||
|
},
|
||||||
|
|
||||||
|
createNotificationIcon: function() {
|
||||||
|
// We set the summary icon ourselves.
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -243,6 +243,7 @@ const ShellMountPasswordSource = new Lang.Class({
|
|||||||
this.parent(strings[0]);
|
this.parent(strings[0]);
|
||||||
|
|
||||||
this._notification = new ShellMountPasswordNotification(this, strings, icon, reaskPassword);
|
this._notification = new ShellMountPasswordNotification(this, strings, icon, reaskPassword);
|
||||||
|
this._setSummaryIcon(icon);
|
||||||
|
|
||||||
// add ourselves as a source, and popup the notification
|
// add ourselves as a source, and popup the notification
|
||||||
Main.messageTray.add(this);
|
Main.messageTray.add(this);
|
||||||
|
@ -305,7 +305,7 @@ const Indicator = new Lang.Class({
|
|||||||
|
|
||||||
_ensureSource: function() {
|
_ensureSource: function() {
|
||||||
if (!this._source) {
|
if (!this._source) {
|
||||||
this._source = new Source();
|
this._source = new MessageTray.Source(_("Bluetooth"), 'bluetooth-active', St.IconType.SYMBOLIC);
|
||||||
Main.messageTray.add(this._source);
|
Main.messageTray.add(this._source);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -330,35 +330,6 @@ const Indicator = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const Source = new Lang.Class({
|
|
||||||
Name: 'BluetoothSource',
|
|
||||||
Extends: MessageTray.Source,
|
|
||||||
|
|
||||||
_init: function() {
|
|
||||||
this.parent(_("Bluetooth"));
|
|
||||||
|
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
},
|
|
||||||
|
|
||||||
notify: function(notification) {
|
|
||||||
this._private_destroyId = notification.connect('destroy', Lang.bind(this, function(notification) {
|
|
||||||
if (this.notification == notification) {
|
|
||||||
// the destroyed notification is the last for this source
|
|
||||||
this.notification.disconnect(this._private_destroyId);
|
|
||||||
this.destroy();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
this.parent(notification);
|
|
||||||
},
|
|
||||||
|
|
||||||
createNotificationIcon: function() {
|
|
||||||
return new St.Icon({ icon_name: 'bluetooth-active',
|
|
||||||
icon_type: St.IconType.SYMBOLIC,
|
|
||||||
icon_size: this.ICON_SIZE });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const AuthNotification = new Lang.Class({
|
const AuthNotification = new Lang.Class({
|
||||||
Name: 'AuthNotification',
|
Name: 'AuthNotification',
|
||||||
Extends: MessageTray.Notification,
|
Extends: MessageTray.Notification,
|
||||||
|
@ -1644,7 +1644,10 @@ const NMApplet = new Lang.Class({
|
|||||||
|
|
||||||
_ensureSource: function() {
|
_ensureSource: function() {
|
||||||
if (!this._source) {
|
if (!this._source) {
|
||||||
this._source = new NMMessageTraySource();
|
this._source = new MessageTray.Source(_("Network Manager"),
|
||||||
|
'network-transmit-receive',
|
||||||
|
St.IconType.SYMBOLIC);
|
||||||
|
|
||||||
this._source.connect('destroy', Lang.bind(this, function() {
|
this._source.connect('destroy', Lang.bind(this, function() {
|
||||||
this._source = null;
|
this._source = null;
|
||||||
}));
|
}));
|
||||||
@ -2100,18 +2103,3 @@ const NMApplet = new Lang.Class({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const NMMessageTraySource = new Lang.Class({
|
|
||||||
Name: 'NMMessageTraySource',
|
|
||||||
Extends: MessageTray.Source,
|
|
||||||
|
|
||||||
_init: function() {
|
|
||||||
this.parent(_("Network Manager"));
|
|
||||||
|
|
||||||
let icon = new St.Icon({ icon_name: 'network-transmit-receive',
|
|
||||||
icon_type: St.IconType.SYMBOLIC,
|
|
||||||
icon_size: this.ICON_SIZE
|
|
||||||
});
|
|
||||||
this._setSummaryIcon(icon);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
@ -365,8 +365,9 @@ const Client = new Lang.Class({
|
|||||||
|
|
||||||
_ensureSubscriptionSource: function() {
|
_ensureSubscriptionSource: function() {
|
||||||
if (this._subscriptionSource == null) {
|
if (this._subscriptionSource == null) {
|
||||||
this._subscriptionSource = new MultiNotificationSource(
|
this._subscriptionSource = new MessageTray.Source(_("Subscription request"),
|
||||||
_("Subscription request"), 'gtk-dialog-question');
|
'gtk-dialog-question',
|
||||||
|
St.IconType.FULLCOLOR);
|
||||||
Main.messageTray.add(this._subscriptionSource);
|
Main.messageTray.add(this._subscriptionSource);
|
||||||
this._subscriptionSource.connect('destroy', Lang.bind(this, function () {
|
this._subscriptionSource.connect('destroy', Lang.bind(this, function () {
|
||||||
this._subscriptionSource = null;
|
this._subscriptionSource = null;
|
||||||
@ -401,8 +402,9 @@ const Client = new Lang.Class({
|
|||||||
|
|
||||||
_ensureAccountSource: function() {
|
_ensureAccountSource: function() {
|
||||||
if (this._accountSource == null) {
|
if (this._accountSource == null) {
|
||||||
this._accountSource = new MultiNotificationSource(
|
this._accountSource = new MessageTray.Source(_("Connection error"),
|
||||||
_("Connection error"), 'gtk-dialog-error');
|
'gtk-dialog-error',
|
||||||
|
St.IconType.FULLCOLOR);
|
||||||
Main.messageTray.add(this._accountSource);
|
Main.messageTray.add(this._accountSource);
|
||||||
this._accountSource.connect('destroy', Lang.bind(this, function () {
|
this._accountSource.connect('destroy', Lang.bind(this, function () {
|
||||||
this._accountSource = null;
|
this._accountSource = null;
|
||||||
@ -418,14 +420,14 @@ const ChatSource = new Lang.Class({
|
|||||||
Extends: MessageTray.Source,
|
Extends: MessageTray.Source,
|
||||||
|
|
||||||
_init: function(account, conn, channel, contact, client) {
|
_init: function(account, conn, channel, contact, client) {
|
||||||
this.parent(contact.get_alias());
|
|
||||||
|
|
||||||
this.isChat = true;
|
this.isChat = true;
|
||||||
|
|
||||||
this._account = account;
|
this._account = account;
|
||||||
this._contact = contact;
|
this._contact = contact;
|
||||||
this._client = client;
|
this._client = client;
|
||||||
|
|
||||||
|
this.parent(contact.get_alias());
|
||||||
|
|
||||||
this._pendingMessages = [];
|
this._pendingMessages = [];
|
||||||
|
|
||||||
this._conn = conn;
|
this._conn = conn;
|
||||||
@ -446,8 +448,6 @@ const ChatSource = new Lang.Class({
|
|||||||
this._receivedId = this._channel.connect('message-received', Lang.bind(this, this._messageReceived));
|
this._receivedId = this._channel.connect('message-received', Lang.bind(this, this._messageReceived));
|
||||||
this._pendingId = this._channel.connect('pending-message-removed', Lang.bind(this, this._pendingRemoved));
|
this._pendingId = this._channel.connect('pending-message-removed', Lang.bind(this, this._pendingRemoved));
|
||||||
|
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
|
|
||||||
this._notifyAliasId = this._contact.connect('notify::alias', Lang.bind(this, this._updateAlias));
|
this._notifyAliasId = this._contact.connect('notify::alias', Lang.bind(this, this._updateAlias));
|
||||||
this._notifyAvatarId = this._contact.connect('notify::avatar-file', Lang.bind(this, this._updateAvatarIcon));
|
this._notifyAvatarId = this._contact.connect('notify::avatar-file', Lang.bind(this, this._updateAvatarIcon));
|
||||||
this._presenceChangedId = this._contact.connect('presence-changed', Lang.bind(this, this._presenceChanged));
|
this._presenceChangedId = this._contact.connect('presence-changed', Lang.bind(this, this._presenceChanged));
|
||||||
@ -1002,10 +1002,9 @@ const ApproverSource = new Lang.Class({
|
|||||||
Extends: MessageTray.Source,
|
Extends: MessageTray.Source,
|
||||||
|
|
||||||
_init: function(dispatchOp, text, gicon) {
|
_init: function(dispatchOp, text, gicon) {
|
||||||
this.parent(text);
|
|
||||||
|
|
||||||
this._gicon = gicon;
|
this._gicon = gicon;
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
|
this.parent(text);
|
||||||
|
|
||||||
this._dispatchOp = dispatchOp;
|
this._dispatchOp = dispatchOp;
|
||||||
|
|
||||||
@ -1028,7 +1027,6 @@ const ApproverSource = new Lang.Class({
|
|||||||
|
|
||||||
createNotificationIcon: function() {
|
createNotificationIcon: function() {
|
||||||
return new St.Icon({ gicon: this._gicon,
|
return new St.Icon({ gicon: this._gicon,
|
||||||
icon_type: St.IconType.FULLCOLOR,
|
|
||||||
icon_size: this.ICON_SIZE });
|
icon_size: this.ICON_SIZE });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -1151,40 +1149,6 @@ const FileTransferNotification = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// A notification source that can embed multiple notifications
|
|
||||||
const MultiNotificationSource = new Lang.Class({
|
|
||||||
Name: 'MultiNotificationSource',
|
|
||||||
Extends: MessageTray.Source,
|
|
||||||
|
|
||||||
_init: function(title, icon) {
|
|
||||||
this.parent(title);
|
|
||||||
|
|
||||||
this._icon = icon;
|
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
this._nbNotifications = 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
notify: function(notification) {
|
|
||||||
this.parent(notification);
|
|
||||||
|
|
||||||
this._nbNotifications += 1;
|
|
||||||
|
|
||||||
// Display the source while there is at least one notification
|
|
||||||
notification.connect('destroy', Lang.bind(this, function () {
|
|
||||||
this._nbNotifications -= 1;
|
|
||||||
|
|
||||||
if (this._nbNotifications == 0)
|
|
||||||
this.destroy();
|
|
||||||
}));
|
|
||||||
},
|
|
||||||
|
|
||||||
createNotificationIcon: function() {
|
|
||||||
return new St.Icon({ gicon: Gio.icon_new_for_string(this._icon),
|
|
||||||
icon_type: St.IconType.FULLCOLOR,
|
|
||||||
icon_size: this.ICON_SIZE });
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Subscription request
|
// Subscription request
|
||||||
const SubscriptionRequestNotification = new Lang.Class({
|
const SubscriptionRequestNotification = new Lang.Class({
|
||||||
Name: 'SubscriptionRequestNotification',
|
Name: 'SubscriptionRequestNotification',
|
||||||
|
@ -53,10 +53,10 @@ const Source = new Lang.Class({
|
|||||||
Extends: MessageTray.Source,
|
Extends: MessageTray.Source,
|
||||||
|
|
||||||
_init: function(app, window) {
|
_init: function(app, window) {
|
||||||
this.parent(app.get_name());
|
|
||||||
this._window = window;
|
this._window = window;
|
||||||
this._app = app;
|
this._app = app;
|
||||||
this._setSummaryIcon(this.createNotificationIcon());
|
|
||||||
|
this.parent(app.get_name());
|
||||||
|
|
||||||
this.signalIDs = [];
|
this.signalIDs = [];
|
||||||
this.signalIDs.push(this._window.connect('notify::demands-attention', Lang.bind(this, function() { this.destroy(); })));
|
this.signalIDs.push(this._window.connect('notify::demands-attention', Lang.bind(this, function() { this.destroy(); })));
|
||||||
|
Loading…
Reference in New Issue
Block a user