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



commit 2050c13857981801809114e9ebbac9d139baeba7
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 | 30 +++++++++++--
 panels/network/connection-editor/details-page.ui   | 50 ++++++++++++++++++----
 2 files changed, 69 insertions(+), 11 deletions(-)
---
diff --git a/panels/network/connection-editor/ce-page-details.c 
b/panels/network/connection-editor/ce-page-details.c
index 18de6a5d4..31252716d 100644
--- a/panels/network/connection-editor/ce-page-details.c
+++ b/panels/network/connection-editor/ce-page-details.c
@@ -37,6 +37,8 @@ struct _CEPageDetails
         GtkLabel *dns_heading_label;
         GtkLabel *dns_label;
         GtkButton *forget_button;
+        GtkLabel *freq_heading_label;
+        GtkLabel *freq_label;
         GtkLabel *ipv4_heading_label;
         GtkLabel *ipv4_label;
         GtkLabel *ipv6_heading_label;
@@ -212,6 +214,7 @@ connect_details_page (CEPageDetails *self)
 {
         NMSettingConnection *sc;
         guint speed;
+        NMDeviceWifiCapabilities wifi_caps;
         guint strength;
         NMDeviceState state;
         NMAccessPoint *active_ap;
@@ -219,6 +222,7 @@ connect_details_page (CEPageDetails *self)
         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;
         NMIPConfig *ipv4_config = NULL, *ipv6_config = NULL;
@@ -236,10 +240,13 @@ connect_details_page (CEPageDetails *self)
 
         device_is_active = FALSE;
         speed = 0;
+        wifi_caps = 0;
         if (active_ap && self->ap == active_ap && state != NM_DEVICE_STATE_UNAVAILABLE) {
                 device_is_active = TRUE;
-                if (NM_IS_DEVICE_WIFI (self->device))
+                if (NM_IS_DEVICE_WIFI (self->device)) {
                         speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (self->device)) / 1000;
+                        wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (self->device));
+                }
         } else if (self->device) {
                 NMActiveConnection *ac;
                 const gchar *p1, *p2;
@@ -249,9 +256,10 @@ connect_details_page (CEPageDetails *self)
                 p2 = nm_connection_get_uuid (self->connection);
                 if (g_strcmp0 (p1, p2) == 0) {
                         device_is_active = TRUE;
-                        if (NM_IS_DEVICE_WIFI (self->device))
+                        if (NM_IS_DEVICE_WIFI (self->device)) {
                                 speed = nm_device_wifi_get_bitrate (NM_DEVICE_WIFI (self->device)) / 1000;
-                        else if (NM_IS_DEVICE_ETHERNET (self->device))
+                                wifi_caps = nm_device_wifi_get_capabilities (NM_DEVICE_WIFI (self->device));
+                        } else if (NM_IS_DEVICE_ETHERNET (self->device))
                                 speed = nm_device_ethernet_get_speed (NM_DEVICE_ETHERNET (self->device));
                 }
         }
@@ -270,6 +278,20 @@ connect_details_page (CEPageDetails *self)
         gtk_widget_set_visible (GTK_WIDGET (self->mac_heading_label), hw_address != NULL);
         gtk_widget_set_visible (GTK_WIDGET (self->mac_label), hw_address != NULL);
 
+        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"));
+        }
+
+        gtk_label_set_label (self->freq_label, freq_string);
+        gtk_widget_set_visible (GTK_WIDGET (self->freq_heading_label), freq_string != NULL);
+        gtk_widget_set_visible (GTK_WIDGET (self->freq_label), freq_string != NULL);
+
         if (device_is_active && active_ap)
                 security_string = get_ap_security_string (active_ap);
         gtk_label_set_label (self->security_label, security_string);
@@ -434,6 +456,8 @@ ce_page_details_class_init (CEPageDetailsClass *klass)
         gtk_widget_class_bind_template_child (widget_class, CEPageDetails, dns_heading_label);
         gtk_widget_class_bind_template_child (widget_class, CEPageDetails, dns_label);
         gtk_widget_class_bind_template_child (widget_class, CEPageDetails, forget_button);
+        gtk_widget_class_bind_template_child (widget_class, CEPageDetails, freq_heading_label);
+        gtk_widget_class_bind_template_child (widget_class, CEPageDetails, freq_label);
         gtk_widget_class_bind_template_child (widget_class, CEPageDetails, ipv4_heading_label);
         gtk_widget_class_bind_template_child (widget_class, CEPageDetails, ipv4_label);
         gtk_widget_class_bind_template_child (widget_class, CEPageDetails, ipv6_heading_label);
diff --git a/panels/network/connection-editor/details-page.ui 
b/panels/network/connection-editor/details-page.ui
index c66b7ee56..241ef4be5 100644
--- a/panels/network/connection-editor/details-page.ui
+++ b/panels/network/connection-editor/details-page.ui
@@ -154,6 +154,24 @@
         <property name="height">1</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkLabel" id="freq_heading_label">
+        <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">freq_label</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="route_heading_label">
         <property name="visible">True</property>
@@ -167,7 +185,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>
@@ -186,7 +204,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>
@@ -204,7 +222,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>
@@ -281,6 +299,22 @@
         <property name="height">1</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkLabel" id="freq_label">
+        <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="route_label">
         <property name="visible">True</property>
@@ -294,7 +328,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>
@@ -314,7 +348,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>
@@ -332,7 +366,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>
@@ -419,7 +453,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>
@@ -440,7 +474,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]