network: Remove some genericism in the wireless code

This was presumably originally used in multiple places, but it's
not anymore, so un-generify the code here.

https://bugzilla.gnome.org/show_bug.cgi?id=698918
This commit is contained in:
Jasper St. Pierre 2013-04-25 17:20:57 -04:00
parent bfdf069d2d
commit 7a8b392607

View File

@ -130,18 +130,12 @@ const NMWirelessSectionTitleMenuItem = new Lang.Class({
Name: 'NMWirelessSectionTitleMenuItem', Name: 'NMWirelessSectionTitleMenuItem',
Extends: PopupMenu.PopupSwitchMenuItem, Extends: PopupMenu.PopupSwitchMenuItem,
_init: function(client, property, title, params) { _init: function(client) {
params = params || { }; this.parent(_("Wi-Fi"), false, { style_class: 'popup-subtitle-menu-item' });
params.style_class = 'popup-subtitle-menu-item';
this.parent(title, false, params);
this._client = client; this._client = client;
this._property = property + '_enabled'; this._client.connect('notify::wireless-enabled', Lang.bind(this, this._propertyChanged));
this._propertyHardware = property + '_hardware_enabled'; this._client.connect('notify::wireless-hardware-enabled', Lang.bind(this, this._propertyChanged));
this._setEnabledFunc = property + '_set_enabled';
this._client.connect('notify::' + property + '-enabled', Lang.bind(this, this._propertyChanged));
this._client.connect('notify::' + property + '-hardware-enabled', Lang.bind(this, this._propertyChanged));
this._propertyChanged(); this._propertyChanged();
}, },
@ -163,12 +157,12 @@ const NMWirelessSectionTitleMenuItem = new Lang.Class({
activate: function(event) { activate: function(event) {
this.parent(event); this.parent(event);
this._client[this._setEnabledFunc](this._switch.state); this._client.wireless_set_enabled(this._switch.state);
}, },
_propertyChanged: function() { _propertyChanged: function() {
this._softwareEnabled = this._client[this._property]; this._softwareEnabled = this._client.wireless_enabled;
this._hardwareEnabled = this._client[this._propertyHardware]; this._hardwareEnabled = this._client.wireless_hardware_enabled;
let enabled = this._softwareEnabled && this._hardwareEnabled; let enabled = this._softwareEnabled && this._hardwareEnabled;
this.setToggleState(enabled); this.setToggleState(enabled);
@ -1641,7 +1635,7 @@ const NMApplet = new Lang.Class({
this._devices.wireless = { this._devices.wireless = {
section: new PopupMenu.PopupMenuSection(), section: new PopupMenu.PopupMenuSection(),
devices: [ ], devices: [ ],
item: this._makeToggleItem('wireless', _("Wi-Fi")) item: this._makeWirelessToggle()
}; };
this._devices.wireless.section.addMenuItem(this._devices.wireless.item); this._devices.wireless.section.addMenuItem(this._devices.wireless.item);
this._devices.wireless.section.actor.hide(); this._devices.wireless.section.actor.hide();
@ -1688,14 +1682,14 @@ const NMApplet = new Lang.Class({
} }
}, },
_makeToggleItem: function(type, title) { _makeWirelessToggle: function() {
let item = new NMWirelessSectionTitleMenuItem(this._client, type, title); let item = new NMWirelessSectionTitleMenuItem(this._client);
item.connect('enabled-changed', Lang.bind(this, function(item, enabled) { item.connect('enabled-changed', Lang.bind(this, function(item, enabled) {
let devices = this._devices[type].devices; let devices = this._devices.wireless.devices;
devices.forEach(function(dev) { devices.forEach(function(dev) {
dev.setEnabled(enabled); dev.setEnabled(enabled);
}); });
this._syncSectionTitle(type); this._syncSectionTitle('wireless');
})); }));
return item; return item;
}, },