network: Remove the global wireless killswitch
"Airplane Mode" is able to be turned on in gnome-control-center, and it will replace the killswitch UI we have in the menu right now. https://bugzilla.gnome.org/show_bug.cgi?id=704670
This commit is contained in:
parent
6295d0fc6c
commit
bda3e53511
@ -117,53 +117,6 @@ const NMNetworkMenuItem = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const NMWirelessSectionTitleMenuItem = new Lang.Class({
|
|
||||||
Name: 'NMWirelessSectionTitleMenuItem',
|
|
||||||
Extends: PopupMenu.PopupSwitchMenuItem,
|
|
||||||
|
|
||||||
_init: function(client) {
|
|
||||||
this.parent(_("Wi-Fi"), false, { style_class: 'popup-subtitle-menu-item' });
|
|
||||||
|
|
||||||
this._client = client;
|
|
||||||
this._client.connect('notify::wireless-enabled', Lang.bind(this, this._propertyChanged));
|
|
||||||
this._client.connect('notify::wireless-hardware-enabled', Lang.bind(this, this._propertyChanged));
|
|
||||||
|
|
||||||
this._propertyChanged();
|
|
||||||
},
|
|
||||||
|
|
||||||
updateForDevice: function(device) {
|
|
||||||
// we show the switch
|
|
||||||
// - if there not just one device
|
|
||||||
// - if the switch is off (but it can be turned on)
|
|
||||||
// - if the device is activated or disconnected
|
|
||||||
if (!this._hardwareEnabled) {
|
|
||||||
this.setStatus(_("hardware disabled"));
|
|
||||||
} else if (device && this._softwareEnabled) {
|
|
||||||
let text = device.getStatusLabel();
|
|
||||||
this.setStatus(text);
|
|
||||||
} else
|
|
||||||
this.setStatus(null);
|
|
||||||
},
|
|
||||||
|
|
||||||
activate: function(event) {
|
|
||||||
this.parent(event);
|
|
||||||
|
|
||||||
this._client.wireless_set_enabled(this._switch.state);
|
|
||||||
},
|
|
||||||
|
|
||||||
_propertyChanged: function() {
|
|
||||||
this._softwareEnabled = this._client.wireless_enabled;
|
|
||||||
this._hardwareEnabled = this._client.wireless_hardware_enabled;
|
|
||||||
|
|
||||||
let enabled = this._softwareEnabled && this._hardwareEnabled;
|
|
||||||
this.setToggleState(enabled);
|
|
||||||
if (!this._hardwareEnabled)
|
|
||||||
/* Translators: this indicates that wireless or wwan is disabled by hardware killswitch */
|
|
||||||
this.setStatus(_("disabled"));
|
|
||||||
|
|
||||||
this.emit('enabled-changed', enabled);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const NMDevice = new Lang.Class({
|
const NMDevice = new Lang.Class({
|
||||||
Name: 'NMDevice',
|
Name: 'NMDevice',
|
||||||
@ -366,11 +319,6 @@ const NMDevice = new Lang.Class({
|
|||||||
return this._device.connection_valid(connection);
|
return this._device.connection_valid(connection);
|
||||||
},
|
},
|
||||||
|
|
||||||
setEnabled: function(enabled) {
|
|
||||||
// do nothing by default, we want to keep the conneciton list visible
|
|
||||||
// in the majority of cases (wired, wwan)
|
|
||||||
},
|
|
||||||
|
|
||||||
getStatusLabel: function() {
|
getStatusLabel: function() {
|
||||||
if (!this._device)
|
if (!this._device)
|
||||||
return null;
|
return null;
|
||||||
@ -511,7 +459,6 @@ const NMDevice = new Lang.Class({
|
|||||||
this._updateStatusItem();
|
this._updateStatusItem();
|
||||||
|
|
||||||
this._queueCreateSection();
|
this._queueCreateSection();
|
||||||
this.emit('state-changed');
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateStatusItem: function() {
|
_updateStatusItem: function() {
|
||||||
@ -521,8 +468,6 @@ const NMDevice = new Lang.Class({
|
|||||||
|
|
||||||
_substateChanged: function() {
|
_substateChanged: function() {
|
||||||
this.statusItem.setStatus(this.getStatusLabel());
|
this.statusItem.setStatus(this.getStatusLabel());
|
||||||
|
|
||||||
this.emit('state-changed');
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Signals.addSignalMethods(NMDevice.prototype);
|
Signals.addSignalMethods(NMDevice.prototype);
|
||||||
@ -575,7 +520,6 @@ const NMDeviceModem = new Lang.Class({
|
|||||||
|
|
||||||
_init: function(client, device, connections) {
|
_init: function(client, device, connections) {
|
||||||
device._description = _("Mobile broadband");
|
device._description = _("Mobile broadband");
|
||||||
this._enabled = true;
|
|
||||||
this.mobileDevice = null;
|
this.mobileDevice = null;
|
||||||
|
|
||||||
this._capabilities = device.current_capabilities;
|
this._capabilities = device.current_capabilities;
|
||||||
@ -612,23 +556,6 @@ const NMDeviceModem = new Lang.Class({
|
|||||||
this.parent(client, device, connections);
|
this.parent(client, device, connections);
|
||||||
},
|
},
|
||||||
|
|
||||||
setEnabled: function(enabled) {
|
|
||||||
this._enabled = enabled;
|
|
||||||
if (this.category == NMConnectionCategory.WWAN) {
|
|
||||||
if (enabled) {
|
|
||||||
// prevent "network unavailable" statuses
|
|
||||||
this.statusItem.setStatus(null);
|
|
||||||
} else
|
|
||||||
this.statusItem.setStatus(this.getStatusLabel());
|
|
||||||
}
|
|
||||||
|
|
||||||
this.parent(enabled);
|
|
||||||
},
|
|
||||||
|
|
||||||
get connected() {
|
|
||||||
return this._enabled && this._device.state == NetworkManager.DeviceState.ACTIVATED;
|
|
||||||
},
|
|
||||||
|
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
if (this._operatorNameId) {
|
if (this._operatorNameId) {
|
||||||
this.mobileDevice.disconnect(this._operatorNameId);
|
this.mobileDevice.disconnect(this._operatorNameId);
|
||||||
@ -770,11 +697,6 @@ const NMDeviceWireless = new Lang.Class({
|
|||||||
this.parent();
|
this.parent();
|
||||||
},
|
},
|
||||||
|
|
||||||
setEnabled: function(enabled) {
|
|
||||||
this.statusItem.actor.visible = enabled;
|
|
||||||
this.section.actor.visible = enabled;
|
|
||||||
},
|
|
||||||
|
|
||||||
activate: function() {
|
activate: function() {
|
||||||
if (this._activeConnection)
|
if (this._activeConnection)
|
||||||
// nothing to do
|
// nothing to do
|
||||||
@ -1473,9 +1395,7 @@ const NMApplet = new Lang.Class({
|
|||||||
this._devices.wireless = {
|
this._devices.wireless = {
|
||||||
section: new PopupMenu.PopupMenuSection(),
|
section: new PopupMenu.PopupMenuSection(),
|
||||||
devices: [ ],
|
devices: [ ],
|
||||||
item: this._makeWirelessToggle()
|
|
||||||
};
|
};
|
||||||
this._devices.wireless.section.addMenuItem(this._devices.wireless.item);
|
|
||||||
this.menu.addMenuItem(this._devices.wireless.section);
|
this.menu.addMenuItem(this._devices.wireless.section);
|
||||||
|
|
||||||
this._devices.wwan = {
|
this._devices.wwan = {
|
||||||
@ -1515,41 +1435,6 @@ const NMApplet = new Lang.Class({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_makeWirelessToggle: function() {
|
|
||||||
let item = new NMWirelessSectionTitleMenuItem(this._client);
|
|
||||||
item.connect('enabled-changed', Lang.bind(this, function(item, enabled) {
|
|
||||||
let devices = this._devices.wireless.devices;
|
|
||||||
devices.forEach(function(dev) {
|
|
||||||
dev.setEnabled(enabled);
|
|
||||||
});
|
|
||||||
this._syncSectionTitle('wireless');
|
|
||||||
}));
|
|
||||||
return item;
|
|
||||||
},
|
|
||||||
|
|
||||||
_syncSectionTitle: function(category) {
|
|
||||||
let devices = this._devices[category].devices;
|
|
||||||
let item = this._devices[category].item;
|
|
||||||
|
|
||||||
// Sync the relation between the section title
|
|
||||||
// item (the one with the airplane mode switch)
|
|
||||||
// and the individual device switches
|
|
||||||
if (item) {
|
|
||||||
if (devices.length == 1) {
|
|
||||||
let dev = devices[0];
|
|
||||||
dev.statusItem.actor.hide();
|
|
||||||
item.updateForDevice(dev);
|
|
||||||
} else {
|
|
||||||
devices.forEach(function(dev) {
|
|
||||||
dev.statusItem.actor.show();
|
|
||||||
});
|
|
||||||
|
|
||||||
// remove status text from the section title item
|
|
||||||
item.updateForDevice(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
_readDevices: function() {
|
_readDevices: function() {
|
||||||
let devices = this._client.get_devices() || [ ];
|
let devices = this._client.get_devices() || [ ];
|
||||||
for (let i = 0; i < devices.length; ++i) {
|
for (let i = 0; i < devices.length; ++i) {
|
||||||
@ -1616,9 +1501,6 @@ const NMApplet = new Lang.Class({
|
|||||||
_addDeviceWrapper: function(wrapper) {
|
_addDeviceWrapper: function(wrapper) {
|
||||||
wrapper._activationFailedId = wrapper.connect('activation-failed',
|
wrapper._activationFailedId = wrapper.connect('activation-failed',
|
||||||
Lang.bind(this, this._onActivationFailed));
|
Lang.bind(this, this._onActivationFailed));
|
||||||
wrapper._deviceStateChangedId = wrapper.connect('state-changed', Lang.bind(this, function(dev) {
|
|
||||||
this._syncSectionTitle(dev.category);
|
|
||||||
}));
|
|
||||||
|
|
||||||
let section = this._devices[wrapper.category].section;
|
let section = this._devices[wrapper.category].section;
|
||||||
section.addMenuItem(wrapper.statusItem);
|
section.addMenuItem(wrapper.statusItem);
|
||||||
@ -1626,8 +1508,6 @@ const NMApplet = new Lang.Class({
|
|||||||
|
|
||||||
let devices = this._devices[wrapper.category].devices;
|
let devices = this._devices[wrapper.category].devices;
|
||||||
devices.push(wrapper);
|
devices.push(wrapper);
|
||||||
|
|
||||||
this._syncSectionTitle(wrapper.category);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_deviceRemoved: function(client, device) {
|
_deviceRemoved: function(client, device) {
|
||||||
@ -1648,14 +1528,11 @@ const NMApplet = new Lang.Class({
|
|||||||
|
|
||||||
_removeDeviceWrapper: function(wrapper) {
|
_removeDeviceWrapper: function(wrapper) {
|
||||||
wrapper.disconnect(wrapper._activationFailedId);
|
wrapper.disconnect(wrapper._activationFailedId);
|
||||||
wrapper.disconnect(wrapper._deviceStateChangedId);
|
|
||||||
wrapper.destroy();
|
wrapper.destroy();
|
||||||
|
|
||||||
let devices = this._devices[wrapper.category].devices;
|
let devices = this._devices[wrapper.category].devices;
|
||||||
let pos = devices.indexOf(wrapper);
|
let pos = devices.indexOf(wrapper);
|
||||||
devices.splice(pos, 1);
|
devices.splice(pos, 1);
|
||||||
|
|
||||||
this._syncSectionTitle(wrapper.category)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_getSupportedActiveConnections: function() {
|
_getSupportedActiveConnections: function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user