refactor(src/window/controlcenter): migrate WiFi handling to use │
│ network_service abstraction │ │ │ │ Updated logic to delegate network operations through NetworkService, renamed │ │ signal listeners, and simplified connectivity checks focusing on service │ │ availability rather than session object emission.
This commit is contained in:
1 file changed
+13
-20
@@ -193,12 +193,8 @@ class NetworkIndicator(Box):
|
|||||||
self.wifi_window._pointing_widget = self.network_button
|
self.wifi_window._pointing_widget = self.network_button
|
||||||
|
|
||||||
modus_service.connect("wlan-changed", self.on_wlan_changed)
|
modus_service.connect("wlan-changed", self.on_wlan_changed)
|
||||||
self.network_service.connect("wifi-device-added", self.on_wifi_device_added)
|
self.network_service.connect("device-ready", self.on_wifi_device_added)
|
||||||
self.network_service.connect(
|
self.network_service.connect("device-ready", self.on_ethernet_device_added)
|
||||||
"ethernet-device-added", self.on_ethernet_device_added
|
|
||||||
)
|
|
||||||
self.network_service.connect("changed", self.on_network_changed)
|
|
||||||
|
|
||||||
self.update_modus_service_wlan_state()
|
self.update_modus_service_wlan_state()
|
||||||
self.update_state()
|
self.update_state()
|
||||||
|
|
||||||
@@ -236,13 +232,12 @@ class NetworkIndicator(Box):
|
|||||||
|
|
||||||
if self.network_service.wifi_device:
|
if self.network_service.wifi_device:
|
||||||
wifi = self.network_service.wifi_device
|
wifi = self.network_service.wifi_device
|
||||||
if not wifi.wireless_enabled:
|
if not wifi.enabled:
|
||||||
wlan_state = "disabled"
|
wlan_state = "disabled"
|
||||||
elif wifi.active_access_point:
|
elif wifi.ssid:
|
||||||
ap = wifi.active_access_point
|
wlan_state = f"connected:{wifi.ssid}"
|
||||||
wlan_state = f"connected:{ap.ssid}"
|
if wifi.strength >= 0:
|
||||||
if ap.strength >= 0:
|
wlan_state += f":{wifi.strength}%"
|
||||||
wlan_state += f":{ap.strength}%"
|
|
||||||
else:
|
else:
|
||||||
wlan_state = "enabled"
|
wlan_state = "enabled"
|
||||||
|
|
||||||
@@ -267,17 +262,15 @@ class NetworkIndicator(Box):
|
|||||||
# Check WiFi first (prioritize WiFi over Ethernet)
|
# Check WiFi first (prioritize WiFi over Ethernet)
|
||||||
if self.network_service.wifi_device:
|
if self.network_service.wifi_device:
|
||||||
wifi = self.network_service.wifi_device
|
wifi = self.network_service.wifi_device
|
||||||
if not wifi.wireless_enabled:
|
if not wifi.enabled:
|
||||||
icon_file = "wifi-off-clear.svg"
|
icon_file = "wifi-off-clear.svg"
|
||||||
tooltip = "WiFi disabled"
|
tooltip = "WiFi disabled"
|
||||||
elif wifi.active_access_point:
|
elif wifi.ssid:
|
||||||
ap = wifi.active_access_point
|
wifi_icon_path = get_wifi_icon_for_strength(wifi.strength)
|
||||||
# Use dynamic WiFi icon based on signal strength
|
|
||||||
wifi_icon_path = get_wifi_icon_for_strength(ap.strength)
|
|
||||||
self.network_icon.set_from_file(wifi_icon_path)
|
self.network_icon.set_from_file(wifi_icon_path)
|
||||||
tooltip = f"Connected to {ap.ssid}"
|
tooltip = f"Connected to {wifi.ssid}"
|
||||||
if ap.strength >= 0:
|
if wifi.strength >= 0:
|
||||||
tooltip += f" ({ap.strength}%)"
|
tooltip += f" ({wifi.strength}%)"
|
||||||
self.network_button.set_tooltip_text(tooltip)
|
self.network_button.set_tooltip_text(tooltip)
|
||||||
return # Early return to avoid setting icon again
|
return # Early return to avoid setting icon again
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in new issue
Block a user