[PATCH newui] (v2) Network spoke: skip standalone spoke if network is up.

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

 



---
 pyanaconda/ui/gui/spokes/network.py |   66 +++++++++++++++++++---------------
 1 files changed, 37 insertions(+), 29 deletions(-)

diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 4f81bca..fab315f 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -332,36 +332,18 @@ class NetworkControlBox():
         device = self.selected_device()
         self.refresh_ui(device)
 
-    def status(self):
-        active_wired_devs = []
-        active_wireless_devs = []
+    def active_connections(self):
+        """Returns list of tuples (device_name, ssid), ssid is None for wired."""
+        active_devs = []
 
         for con in self.client.get_active_connections():
             device = con.get_devices()[0]
             if device.get_device_type() == NetworkManager.DeviceType.ETHERNET:
-                active_wired_devs.append(device.get_iface())
+                active_devs.append((device.get_iface(), None))
             elif device.get_device_type() == NetworkManager.DeviceType.WIFI:
-                active_wireless_devs.append([device.get_iface(),
-                                    device.get_active_access_point().get_ssid()])
-
-        numdevs = len(active_wired_devs) + len(active_wireless_devs)
-        if numdevs:
-            if numdevs == 1:
-                if active_wired_devs:
-                    msg = _("Wired (%s) connected") % active_wired_devs[0]
-                else:
-                    msg = _("Wireless (%s) connected to %s" %
-                            tuple(active_wireless_devs[0]))
-
-            else:
-                devlist = ", ".join(active_wired_devs +
-                                    ["%s (%s)" % (iface, ap) for iface, ap in
-                                     active_wireless_devs])
-                msg = _("Connected devices: %s") % devlist
-        else:
-            msg = _("Not connected")
-
-        return msg
+                active_devs.append((device.get_iface(),
+                                    device.get_active_access_point().get_ssid()))
+        return active_devs
 
     # Signal handlers.
     def on_device_selection_changed(self, *args):
@@ -945,12 +927,34 @@ class NetworkSpoke(NormalSpoke):
 
     @property
     def completed(self):
-        return self.status != _("Not connected")
+        return len(self.network_control_box.active_connections()) > 0
 
     @property
     def status(self):
         """ A short string describing which devices are connected. """
-        return self.network_control_box.status()
+        msg = _("Not connected")
+
+        ac = self.network_control_box.active_connections()
+        if ac:
+            if len(ac) == 1:
+                device, ssid = ac[0]
+                if ssid:
+                    msg = _("Wireless (%s) connected to %s" %
+                            (device, ssid))
+                else:
+                    msg = _("Wired (%s) connected") % device
+            else:
+
+                devlist = ", ".join(["%s" % device for device, ssid
+                                     in ac
+                                     if ssid is None] +
+                                    ["%s (%s)" % (device, ssid) for device, ssid
+                                     in ac
+                                     if ssid is not None])
+
+                msg = _("Connected devices: %s") % devlist
+
+        return msg
 
     def initialize(self):
         NormalSpoke.initialize(self)
@@ -984,7 +988,7 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
             if network_data is not None:
                 self.data.network.network.append(network_data)
 
-        self._now_available = self.network_control_box.status() != _("Not connected")
+        self._now_available = self.completed
 
         if not self.payload.baseRepo and not self._initially_available and self._now_available:
             from pyanaconda.packaging import payloadInitialize
@@ -996,6 +1000,10 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
 
             threadMgr.add(AnacondaThread(name="AnaPayloadThread", target=payloadInitialize, args=(self.storage, self.data, self.payload)))
 
+    @property
+    def completed(self):
+        return len(self.network_control_box.active_connections()) > 0
+
     def initialize(self):
         StandaloneSpoke.initialize(self)
         self.network_control_box.initialize()
@@ -1004,7 +1012,7 @@ class NetworkStandaloneSpoke(StandaloneSpoke):
         StandaloneSpoke.refresh(self)
         self.network_control_box.refresh()
 
-        self._initially_available = self.network_control_box.status() != _("Not connected")
+        self._initially_available = self.completed
 
     def on_back_clicked(self, window):
         self.window.hide()
-- 
1.7.4

_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux