status/network: Rename DeviceCategory and base on device type

Right now DeviceCategory is a small section wrapper that shows
a summary instead of its content if it contains too many items.

It will eventually eventually turn into the base class for
network device quick toggles. Who would have thought that
when it was added for the "there's a computer with 32 ethernet
cards" fringe case?!

For now, give it a more appropriate name and use device types
instead of our made-up categories, now that the two map neatly.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2406>
This commit is contained in:
Florian Müllner 2022-08-01 16:19:43 +02:00
parent 73f4bb13d0
commit cad3ec1ecd

View File

@ -1509,11 +1509,11 @@ var NMVpnSection = class extends NMConnectionSection {
}
};
var DeviceCategory = class extends PopupMenu.PopupMenuSection {
constructor(category) {
var NMDeviceSection = class extends PopupMenu.PopupMenuSection {
constructor(deviceType) {
super();
this._category = category;
this._deviceType = deviceType;
this.devices = [];
@ -1541,33 +1541,33 @@ var DeviceCategory = class extends PopupMenu.PopupMenuSection {
}
_getSummaryIcon() {
switch (this._category) {
case NMConnectionCategory.WIRED:
switch (this._deviceType) {
case NM.DeviceType.ETHERNET:
return 'network-wired-symbolic';
case NMConnectionCategory.WIRELESS:
case NMConnectionCategory.BLUETOOTH:
case NMConnectionCategory.WWAN:
case NM.DeviceType.WIFI:
case NM.DeviceType.BT:
case NM.DeviceType.MODEM:
return 'network-wireless-symbolic';
}
return '';
}
_getSummaryLabel(nDevices) {
switch (this._category) {
case NMConnectionCategory.WIRED:
switch (this._deviceType) {
case NM.DeviceType.ETHERNET:
return ngettext("%s Wired Connection",
"%s Wired Connections",
nDevices).format(nDevices);
case NMConnectionCategory.WIRELESS:
case NM.DeviceType.WIFI:
return ngettext("%s Wi-Fi Connection",
"%s Wi-Fi Connections",
nDevices).format(nDevices);
case NMConnectionCategory.BLUETOOTH:
case NM.DeviceType.BT:
return ngettext(
'%s Bluetooth Connection',
'%s Bluetooth Connections',
nDevices).format(nDevices);
case NMConnectionCategory.WWAN:
case NM.DeviceType.MODEM:
return ngettext("%s Modem Connection",
"%s Modem Connections",
nDevices).format(nDevices);
@ -1618,14 +1618,14 @@ class Indicator extends PanelMenu.SystemIndicator {
this._nmDevices = [];
this._deviceSections = new Map();
const categories = [
NMConnectionCategory.WIRED,
NMConnectionCategory.WIRELESS,
NMConnectionCategory.BLUETOOTH,
NMConnectionCategory.WWAN,
const sections = [
[NMConnectionCategory.WIRED, NM.DeviceType.ETHERNET],
[NMConnectionCategory.WIRELESS, NM.DeviceType.WIFI],
[NMConnectionCategory.BLUETOOTH, NM.DeviceType.BT],
[NMConnectionCategory.WWAN, NM.DeviceType.MODEM],
];
for (let category of categories) {
this._deviceSections.set(category, new DeviceCategory(category));
for (const [category, deviceType] of sections) {
this._deviceSections.set(category, new NMDeviceSection(deviceType));
this.menu.addMenuItem(this._deviceSections.get(category));
}