[gnome-shell] status/network: Rename DeviceCategory and base on device type



commit cad3ec1ecd0e80449d73bb89ad6b34ee3f030985
Author: Florian Müllner <fmuellner gnome org>
Date:   Mon Aug 1 16:19:43 2022 +0200

    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>

 js/ui/status/network.js | 40 ++++++++++++++++++++--------------------
 1 file changed, 20 insertions(+), 20 deletions(-)
---
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index 8b08dd56be..71c16d748d 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -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));
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]