Fixed WifiLabel
This commit is contained in:
1 parent
58fb6af79a
commit
79625b36a3
1 file changed
+24
-14
@@ -64,7 +64,7 @@ class ModusControlCenter(Window):
|
|||||||
self.wifi_service = None
|
self.wifi_service = None
|
||||||
|
|
||||||
# Wait for network service to be ready
|
# Wait for network service to be ready
|
||||||
self.network_service.connect("wifi-device-added", self.on_network_ready)
|
# self.network_service.connect("wifi-device-added", self.on_network_ready)
|
||||||
|
|
||||||
self.add_keybinding("Escape", self.hide_controlcenter)
|
self.add_keybinding("Escape", self.hide_controlcenter)
|
||||||
|
|
||||||
@@ -82,6 +82,7 @@ class ModusControlCenter(Window):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print(wlan)
|
||||||
self.wlan_label = Label(
|
self.wlan_label = Label(
|
||||||
label=wlan,
|
label=wlan,
|
||||||
name="wifi-widget-label",
|
name="wifi-widget-label",
|
||||||
@@ -584,17 +585,17 @@ class ModusControlCenter(Window):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"Failed to toggle bluetooth: {e}")
|
logger.warning(f"Failed to toggle bluetooth: {e}")
|
||||||
|
|
||||||
def on_network_ready(self, *_):
|
# def on_network_ready(self, *_):
|
||||||
"""Called when network service is ready"""
|
# """Called when network service is ready"""
|
||||||
self.wifi_service = self.network_service.wifi_device
|
# self.wifi_service = self.network_service.wifi_device
|
||||||
if self.wifi_service:
|
# if self.wifi_service:
|
||||||
# Connect to WiFi state changes to update icon
|
# # Connect to WiFi state changes to update icon
|
||||||
self.wifi_service.connect("notify::wireless-enabled", self.update_wifi_icon)
|
# self.wifi_service.connect("notify::wireless-enabled", self.update_wifi_icon)
|
||||||
|
|
||||||
def update_wifi_icon(self, *_):
|
def update_wifi_icon(self, *_):
|
||||||
"""Update WiFi icon based on current state"""
|
"""Update WiFi icon based on current state"""
|
||||||
try:
|
try:
|
||||||
if self.wifi_service and hasattr(self, 'wifi_svg'):
|
if self.wifi_service and hasattr(self, "wifi_svg"):
|
||||||
is_enabled = self.wifi_service.wireless_enabled
|
is_enabled = self.wifi_service.wireless_enabled
|
||||||
icon_file = (
|
icon_file = (
|
||||||
"../../config/assets/icons/applets/wifi.svg"
|
"../../config/assets/icons/applets/wifi.svg"
|
||||||
@@ -605,12 +606,17 @@ class ModusControlCenter(Window):
|
|||||||
|
|
||||||
# Also update the label
|
# Also update the label
|
||||||
if is_enabled:
|
if is_enabled:
|
||||||
if hasattr(self.wifi_service, 'active_access_point') and self.wifi_service.active_access_point:
|
if (
|
||||||
|
hasattr(self.wifi_service, "active_access_point")
|
||||||
|
and self.wifi_service.active_access_point
|
||||||
|
):
|
||||||
# Connected to a network
|
# Connected to a network
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_label("Connected"))
|
GLib.idle_add(lambda: self.wlan_label.set_label("Connected"))
|
||||||
else:
|
else:
|
||||||
# WiFi enabled but not connected
|
# WiFi enabled but not connected
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_label("Not Connected"))
|
GLib.idle_add(
|
||||||
|
lambda: self.wlan_label.set_label("Not Connected")
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
# WiFi disabled
|
# WiFi disabled
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_label("No Connection"))
|
GLib.idle_add(lambda: self.wlan_label.set_label("No Connection"))
|
||||||
@@ -710,13 +716,17 @@ class ModusControlCenter(Window):
|
|||||||
parts = wlan.split(":")
|
parts = wlan.split(":")
|
||||||
if len(parts) >= 2:
|
if len(parts) >= 2:
|
||||||
wifi_name = parts[1]
|
wifi_name = parts[1]
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_label(wifi_name))
|
GLib.idle_add(
|
||||||
|
lambda: self.wlan_label.set_property("label", wifi_name)
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_label("Connected"))
|
GLib.idle_add(
|
||||||
|
lambda: self.wlan_label.set_property("label", "Connected")
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_label(wlan))
|
GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan))
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_label(wlan))
|
GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan))
|
||||||
|
|
||||||
def bluetooth_changed(self, _, bluetooth):
|
def bluetooth_changed(self, _, bluetooth):
|
||||||
self.bluetooth_svg.set_from_file(
|
self.bluetooth_svg.set_from_file(
|
||||||
|
|||||||
Reference in new issue
Block a user