[gnome-control-center/wip/hadess/wifi-freqs: 193/194] wifi: Show Wi-Fi frequencies the hardware supports



commit ad4b2dbba78553ef867684e5547bc577685a786b
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Aug 10 15:57:09 2018 +0200

    wifi: Show Wi-Fi frequencies the hardware supports
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722550

 panels/network/connection-editor/ce-page-details.c | 24 +++++++++--
 panels/network/connection-editor/details-page.ui   | 50 ++++++++++++++++++----
 2 files changed, 63 insertions(+), 11 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-details.c 
b/panels/network/connection-editor/ce-page-details.c
index dbcc3d363..1aff91c44 100644
--- a/panels/network/connection-editor/ce-page-details.c
+++ b/panels/network/connection-editor/ce-page-details.c
@@ -183,6 +183,7 @@ connect_details_page (CEPageDetails *page)
         NMSettingConnection *sc;
         GtkWidget *widget;
         guint speed;
+        NMDeviceWifiCapabilities wifi_caps;
         guint strength;
         NMDeviceState state;
         NMAccessPoint *active_ap;
@@ -190,6 +191,7 @@ connect_details_page (CEPageDetails *page)
         const gchar *type;
         const gchar *hw_address = NULL;
         g_autofree gchar *security_string = NULL;
+        g_autofree gchar *freq_string = NULL;
         const gchar *strength_label;
         gboolean device_is_active;
 
@@ -205,10 +207,13 @@ connect_details_page (CEPageDetails *page)
 
         device_is_active = FALSE;
         speed = 0;
+        wifi_caps = 0;
         if (active_ap && page->ap == active_ap && state != NM_DEVICE_STATE_UNAVAILABLE) {
                 device_is_active = TRUE;
-                if (NM_IS_DEVICE_WIFI (page->device))
+                if (NM_IS_DEVICE_WIFI (page->device)) {
                         speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (page->device)) / 1000;
+                        wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (page->device));
+                }
         } else if (page->device) {
                 NMActiveConnection *ac;
                 const gchar *p1, *p2;
@@ -218,9 +223,10 @@ connect_details_page (CEPageDetails *page)
                 p2 = nm_connection_get_uuid (CE_PAGE (page)->connection);
                 if (g_strcmp0 (p1, p2) == 0) {
                         device_is_active = TRUE;
-                        if (NM_IS_DEVICE_WIFI (page->device))
+                        if (NM_IS_DEVICE_WIFI (page->device)) {
                                 speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (page->device)) / 1000;
-                        else if (NM_IS_DEVICE_ETHERNET (page->device))
+                                wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (page->device));
+                        } else if (NM_IS_DEVICE_ETHERNET (page->device))
                                 speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (page->device));
                 }
         }
@@ -235,6 +241,18 @@ connect_details_page (CEPageDetails *page)
 
         panel_set_device_widget_details (CE_PAGE (page)->builder, "mac", hw_address);
 
+        if (wifi_caps & NM_WIFI_DEVICE_CAP_FREQ_VALID) {
+                if (wifi_caps & NM_WIFI_DEVICE_CAP_FREQ_2GHZ &&
+                    wifi_caps & NM_WIFI_DEVICE_CAP_FREQ_5GHZ)
+                        freq_string = g_strdup (_("2.4 GHz / 5 GHz"));
+                else if (wifi_caps & NM_WIFI_DEVICE_CAP_FREQ_2GHZ)
+                        freq_string = g_strdup (_("2.4 GHz"));
+                else if (wifi_caps & NM_WIFI_DEVICE_CAP_FREQ_5GHZ)
+                        freq_string = g_strdup (_("5 GHz"));
+        }
+
+        panel_set_device_widget_details (CE_PAGE (page)->builder, "freq", freq_string);
+
         if (device_is_active && active_ap)
                 security_string = get_ap_security_string (active_ap);
         panel_set_device_widget_details (CE_PAGE (page)->builder, "security", security_string);
diff --git a/panels/network/connection-editor/details-page.ui 
b/panels/network/connection-editor/details-page.ui
index 5c3891e70..bfaa34c26 100644
--- a/panels/network/connection-editor/details-page.ui
+++ b/panels/network/connection-editor/details-page.ui
@@ -150,6 +150,24 @@
         <property name="height">1</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkLabel" id="heading_freq">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="xalign">1</property>
+        <property name="label" translatable="yes">Supported Frequencies</property>
+        <property name="mnemonic_widget">label_freq</property>
+        <style>
+          <class name="dim-label"/>
+        </style>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">6</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkLabel" id="heading_route">
         <property name="visible">True</property>
@@ -163,7 +181,7 @@
       </object>
       <packing>
         <property name="left_attach">0</property>
-        <property name="top_attach">6</property>
+        <property name="top_attach">7</property>
         <property name="width">1</property>
         <property name="height">1</property>
       </packing>
@@ -182,7 +200,7 @@
       </object>
       <packing>
         <property name="left_attach">0</property>
-        <property name="top_attach">7</property>
+        <property name="top_attach">8</property>
         <property name="width">1</property>
         <property name="height">1</property>
       </packing>
@@ -200,7 +218,7 @@
       </object>
       <packing>
         <property name="left_attach">0</property>
-        <property name="top_attach">8</property>
+        <property name="top_attach">9</property>
         <property name="width">1</property>
         <property name="height">1</property>
       </packing>
@@ -269,6 +287,22 @@
         <property name="height">1</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkLabel" id="label_freq">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="xalign">0</property>
+        <property name="label">2.4 GHz / 5 GHz</property>
+        <property name="selectable">True</property>
+        <property name="hexpand">True</property>
+      </object>
+      <packing>
+        <property name="left_attach">1</property>
+        <property name="top_attach">6</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
     <child>
       <object class="GtkLabel" id="label_route">
         <property name="visible">True</property>
@@ -280,7 +314,7 @@
       </object>
       <packing>
         <property name="left_attach">1</property>
-        <property name="top_attach">6</property>
+        <property name="top_attach">7</property>
         <property name="width">1</property>
         <property name="height">1</property>
       </packing>
@@ -298,7 +332,7 @@
       </object>
       <packing>
         <property name="left_attach">1</property>
-        <property name="top_attach">7</property>
+        <property name="top_attach">8</property>
         <property name="width">1</property>
         <property name="height">1</property>
       </packing>
@@ -314,7 +348,7 @@
       </object>
       <packing>
         <property name="left_attach">1</property>
-        <property name="top_attach">8</property>
+        <property name="top_attach">9</property>
         <property name="width">1</property>
         <property name="height">1</property>
       </packing>
@@ -400,7 +434,7 @@
       </object>
       <packing>
         <property name="left_attach">0</property>
-        <property name="top_attach">11</property>
+        <property name="top_attach">12</property>
         <property name="width">2</property>
         <property name="height">1</property>
       </packing>
@@ -421,7 +455,7 @@
       </object>
       <packing>
         <property name="left_attach">0</property>
-        <property name="top_attach">12</property>
+        <property name="top_attach">13</property>
         <property name="width">2</property>
         <property name="height">1</property>
       </packing>


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