status/network: Add section classes for each device type
Those will eventually become quick toggles, and as there'll be small differences like menu headers or which settings panel to launch, it makes sense to give each its own class. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>
This commit is contained in:
parent
cad3ec1ecd
commit
c050002021
@ -1541,40 +1541,81 @@ var NMDeviceSection = class extends PopupMenu.PopupMenuSection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_getSummaryIcon() {
|
_getSummaryIcon() {
|
||||||
switch (this._deviceType) {
|
throw new GObject.NotImplementedError();
|
||||||
case NM.DeviceType.ETHERNET:
|
}
|
||||||
return 'network-wired-symbolic';
|
|
||||||
case NM.DeviceType.WIFI:
|
_getSummaryLabel() {
|
||||||
case NM.DeviceType.BT:
|
throw new GObject.NotImplementedError();
|
||||||
case NM.DeviceType.MODEM:
|
}
|
||||||
return 'network-wireless-symbolic';
|
};
|
||||||
}
|
|
||||||
return '';
|
class NMWirelessSection extends NMDeviceSection {
|
||||||
|
constructor() {
|
||||||
|
super(NM.DeviceType.WIFI);
|
||||||
|
}
|
||||||
|
|
||||||
|
_getSummaryIcon() {
|
||||||
|
return 'network-wireless-symbolic';
|
||||||
}
|
}
|
||||||
|
|
||||||
_getSummaryLabel(nDevices) {
|
_getSummaryLabel(nDevices) {
|
||||||
switch (this._deviceType) {
|
return ngettext(
|
||||||
case NM.DeviceType.ETHERNET:
|
'%s Wi-Fi Connection',
|
||||||
return ngettext("%s Wired Connection",
|
'%s Wi-Fi Connections',
|
||||||
"%s Wired Connections",
|
nDevices).format(nDevices);
|
||||||
nDevices).format(nDevices);
|
|
||||||
case NM.DeviceType.WIFI:
|
|
||||||
return ngettext("%s Wi-Fi Connection",
|
|
||||||
"%s Wi-Fi Connections",
|
|
||||||
nDevices).format(nDevices);
|
|
||||||
case NM.DeviceType.BT:
|
|
||||||
return ngettext(
|
|
||||||
'%s Bluetooth Connection',
|
|
||||||
'%s Bluetooth Connections',
|
|
||||||
nDevices).format(nDevices);
|
|
||||||
case NM.DeviceType.MODEM:
|
|
||||||
return ngettext("%s Modem Connection",
|
|
||||||
"%s Modem Connections",
|
|
||||||
nDevices).format(nDevices);
|
|
||||||
}
|
|
||||||
return '';
|
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
class NMWiredSection extends NMDeviceSection {
|
||||||
|
constructor() {
|
||||||
|
super(NM.DeviceType.ETHERNET);
|
||||||
|
}
|
||||||
|
|
||||||
|
_getSummaryIcon() {
|
||||||
|
return 'network-wired-symbolic';
|
||||||
|
}
|
||||||
|
|
||||||
|
_getSummaryLabel(nDevices) {
|
||||||
|
return ngettext(
|
||||||
|
'%s Wired Connection',
|
||||||
|
'%s Wired Connections',
|
||||||
|
nDevices).format(nDevices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NMBluetoothSection extends NMDeviceSection {
|
||||||
|
constructor() {
|
||||||
|
super(NM.DeviceType.BT);
|
||||||
|
}
|
||||||
|
|
||||||
|
_getSummaryIcon() {
|
||||||
|
return 'network-wireless-symbolic';
|
||||||
|
}
|
||||||
|
|
||||||
|
_getSummaryLabel(nDevices) {
|
||||||
|
return ngettext(
|
||||||
|
'%s Bluetooth Connection',
|
||||||
|
'%s Bluetooth Connections',
|
||||||
|
nDevices).format(nDevices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class NMModemSection extends NMDeviceSection {
|
||||||
|
constructor() {
|
||||||
|
super(NM.DeviceType.MODEM);
|
||||||
|
}
|
||||||
|
|
||||||
|
_getSummaryIcon() {
|
||||||
|
return 'network-wireless-symbolic';
|
||||||
|
}
|
||||||
|
|
||||||
|
_getSummaryLabel(nDevices) {
|
||||||
|
return ngettext(
|
||||||
|
'%s Modem Connection',
|
||||||
|
'%s Modem Connections',
|
||||||
|
nDevices).format(nDevices);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var NMApplet = GObject.registerClass(
|
var NMApplet = GObject.registerClass(
|
||||||
class Indicator extends PanelMenu.SystemIndicator {
|
class Indicator extends PanelMenu.SystemIndicator {
|
||||||
@ -1616,18 +1657,20 @@ class Indicator extends PanelMenu.SystemIndicator {
|
|||||||
this._notification = null;
|
this._notification = null;
|
||||||
|
|
||||||
this._nmDevices = [];
|
this._nmDevices = [];
|
||||||
this._deviceSections = new Map();
|
|
||||||
|
|
||||||
const sections = [
|
this._wiredSection = new NMWiredSection();
|
||||||
[NMConnectionCategory.WIRED, NM.DeviceType.ETHERNET],
|
this._wirelessSection = new NMWirelessSection();
|
||||||
[NMConnectionCategory.WIRELESS, NM.DeviceType.WIFI],
|
this._modemSection = new NMModemSection();
|
||||||
[NMConnectionCategory.BLUETOOTH, NM.DeviceType.BT],
|
this._btSection = new NMBluetoothSection();
|
||||||
[NMConnectionCategory.WWAN, NM.DeviceType.MODEM],
|
|
||||||
];
|
this._deviceSections = new Map([
|
||||||
for (const [category, deviceType] of sections) {
|
[NMConnectionCategory.WIRED, this._wiredSection],
|
||||||
this._deviceSections.set(category, new NMDeviceSection(deviceType));
|
[NMConnectionCategory.WIRELESS, this._wirelessSection],
|
||||||
this.menu.addMenuItem(this._deviceSections.get(category));
|
[NMConnectionCategory.WWAN, this._modemSection],
|
||||||
}
|
[NMConnectionCategory.BLUETOOTH, this._btSection],
|
||||||
|
]);
|
||||||
|
for (const section of this._deviceSections.values())
|
||||||
|
this.menu.addMenuItem(section);
|
||||||
|
|
||||||
this._vpnSection = new NMVpnSection(this._client);
|
this._vpnSection = new NMVpnSection(this._client);
|
||||||
this._vpnSection.connect('activation-failed', this._onActivationFailed.bind(this));
|
this._vpnSection.connect('activation-failed', this._onActivationFailed.bind(this));
|
||||||
|
Loading…
Reference in New Issue
Block a user