network: Use one notification globally for connection status

Rather than one per device.

https://bugzilla.gnome.org/show_bug.cgi?id=706098
This commit is contained in:
Jasper St. Pierre 2013-08-27 14:58:50 -04:00
parent e1c4cfd7eb
commit 3f15a41006

View File

@ -1250,6 +1250,8 @@ const NMApplet = new Lang.Class({
this._mainConnection = null; this._mainConnection = null;
this._mainConnectionIconChangedId = 0; this._mainConnectionIconChangedId = 0;
this._notification = null;
this._nmDevices = []; this._nmDevices = [];
this._devices = { }; this._devices = { };
@ -1313,29 +1315,26 @@ const NMApplet = new Lang.Class({
this._syncDeviceNames(); this._syncDeviceNames();
}, },
_notifyForDevice: function(device, iconName, title, text, urgency) { _notify: function(iconName, title, text, urgency) {
if (device._notification) if (this._notification)
device._notification.destroy(); this._notification.destroy();
/* must call after destroying previous notification,
or this._source will be cleared */
this._ensureSource(); this._ensureSource();
let gicon = new Gio.ThemedIcon({ name: iconName }); let gicon = new Gio.ThemedIcon({ name: iconName });
device._notification = new MessageTray.Notification(this._source, title, text, this._notification = new MessageTray.Notification(this._source, title, text, { gicon: gicon });
{ gicon: gicon }); this._notification.setUrgency(urgency);
device._notification.setUrgency(urgency); this._notification.setTransient(true);
device._notification.setTransient(true); this._notification.connect('destroy', function() {
device._notification.connect('destroy', function() { this._notification = null;
device._notification = null;
}); });
this._source.notify(device._notification); this._source.notify(this._notification);
}, },
_onActivationFailed: function(device, reason) { _onActivationFailed: function(device, reason) {
// XXX: nm-applet has no special text depending on reason // XXX: nm-applet has no special text depending on reason
// but I'm not sure of this generic message // but I'm not sure of this generic message
this._notifyForDevice(device, 'network-error-symbolic', this._notify('network-error-symbolic',
_("Connection failed"), _("Connection failed"),
_("Activation of network connection failed"), _("Activation of network connection failed"),
MessageTray.Urgency.HIGH); MessageTray.Urgency.HIGH);
@ -1476,12 +1475,8 @@ const NMApplet = new Lang.Class({
}, },
_mainConnectionStateChanged: function() { _mainConnectionStateChanged: function() {
let a = this._mainConnection; if (this._mainConnection.state == NetworkManager.ActiveConnectionState.ACTIVATED && this._notification)
let dev = a._primaryDevice; this._notification.destroy();
if (a.state == NetworkManager.ActiveConnectionState.ACTIVATED && dev && dev._notification) {
dev._notification.destroy();
dev._notification = null;
}
}, },
_ignoreConnection: function(connection) { _ignoreConnection: function(connection) {