Update status icon to assoicated signal strength on scan callback.
authorRoy Marples <roy@marples.name>
Fri, 12 Dec 2014 20:04:54 +0000 (20:04 +0000)
committerRoy Marples <roy@marples.name>
Fri, 12 Dec 2014 20:04:54 +0000 (20:04 +0000)
Thanks to Simon Long.

src/dhcpcd-gtk/main.c
src/dhcpcd-qt/dhcpcd-qt.cpp

index 1081dafa238f8e3c777f3a5d628ba8004ef69506..68cdd3078aeb87115bb441e64c92ecbada3a8260 100644 (file)
@@ -639,6 +639,17 @@ dhcpcd_wpa_scan_cb(DHCPCD_WPA *wpa, _unused void *data)
                }
                menu_update_scans(w, scans);
        }
+
+       if (!ani_timer) {
+               s1 = get_strongest_scan();
+               if (s1)
+                       msg = get_strength_icon_name(s1->strength.value);
+               else if (online)
+                       msg = "network-transmit-receive";
+               else
+                       msg = "network-offline";
+               gtk_status_icon_set_from_icon_name(status_icon, msg);
+       }
 }
 
 static void
index f1589c4fdabe93578e7225374bf2db75f0610c7b..79e7cd0bfb19505692ff1479efba18e25050d3c5 100644 (file)
@@ -113,16 +113,17 @@ QList<DhcpcdWi *> *DhcpcdQt::getWis()
 const char * DhcpcdQt::signalStrengthIcon(DHCPCD_WI_SCAN *scan)
 {
 
+       if (scan == NULL)
+               return "network-wireless-connected-00";
        if (scan->strength.value > 80)
                return "network-wireless-connected-100";
-       else if (scan->strength.value > 55)
+       if (scan->strength.value > 55)
                return "network-wireless-connected-75";
-       else if (scan->strength.value > 30)
+       if (scan->strength.value > 30)
                return "network-wireless-connected-50";
-       else if (scan->strength.value > 5)
+       if (scan->strength.value > 5)
                return "network-wireless-connected-25";
-       else
-               return "network-wireless-connected-00";
+       return "network-wireless-connected-00";
 }
 
 DHCPCD_WI_SCAN * DhcpcdQt::getStrongestSignal()
@@ -431,10 +432,17 @@ void DhcpcdQt::scanCallback(DHCPCD_WPA *wpa)
 
        if (!aniTimer->isActive()) {
                DHCPCD_WI_SCAN *scan;
+               const char *icon;
 
                scan = getStrongestSignal();
                if (scan)
-                       setIcon("status", DhcpcdQt::signalStrengthIcon(scan));
+                       icon = DhcpcdQt::signalStrengthIcon(scan);
+               else if (onLine)
+                       icon = "network-transmit-receive";
+               else
+                       icon = "network-offline";
+
+               setIcon("status", icon);
        }
 }