Truncuate Wifi and Bluetooth name
This commit is contained in:
1 parent
a6b378b83d
commit
a07adeb629
1 file changed
+18
-20
@@ -72,7 +72,9 @@ class ModusControlCenter(Window):
|
|||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
self.wlan_label = Label(wlan, name="wifi-widget-label", h_align="start")
|
self.wlan_label = Label(
|
||||||
|
label=wlan, name="wifi-widget-label", max_chars_width=20, h_align="start"
|
||||||
|
)
|
||||||
if bluetooth != "disabled":
|
if bluetooth != "disabled":
|
||||||
if bluetooth.startswith("connected:"):
|
if bluetooth.startswith("connected:"):
|
||||||
parts = bluetooth.split(":")
|
parts = bluetooth.split(":")
|
||||||
@@ -83,7 +85,10 @@ class ModusControlCenter(Window):
|
|||||||
bluetooth_display = "Off"
|
bluetooth_display = "Off"
|
||||||
|
|
||||||
self.bluetooth_label = Label(
|
self.bluetooth_label = Label(
|
||||||
bluetooth_display, name="bluetooth-widget-label", h_align="start"
|
label=bluetooth_display,
|
||||||
|
name="bluetooth-widget-label",
|
||||||
|
max_chars_width=20,
|
||||||
|
h_align="start",
|
||||||
)
|
)
|
||||||
self.volume_scale = Scale(
|
self.volume_scale = Scale(
|
||||||
value=volume,
|
value=volume,
|
||||||
@@ -538,7 +543,7 @@ class ModusControlCenter(Window):
|
|||||||
"""Toggle bluetooth on/off"""
|
"""Toggle bluetooth on/off"""
|
||||||
try:
|
try:
|
||||||
# Access the bluetooth client from the bluetooth manager
|
# Access the bluetooth client from the bluetooth manager
|
||||||
if hasattr(self, 'bluetooth_man') and hasattr(self.bluetooth_man, 'client'):
|
if hasattr(self, "bluetooth_man") and hasattr(self.bluetooth_man, "client"):
|
||||||
current_state = self.bluetooth_man.client.enabled
|
current_state = self.bluetooth_man.client.enabled
|
||||||
self.bluetooth_man.client.set_enabled(not current_state)
|
self.bluetooth_man.client.set_enabled(not current_state)
|
||||||
else:
|
else:
|
||||||
@@ -551,6 +556,7 @@ class ModusControlCenter(Window):
|
|||||||
try:
|
try:
|
||||||
# Import and use the network service
|
# Import and use the network service
|
||||||
from services.network import WiFiDevice
|
from services.network import WiFiDevice
|
||||||
|
|
||||||
wifi_device = WiFiDevice.get_default()
|
wifi_device = WiFiDevice.get_default()
|
||||||
if wifi_device:
|
if wifi_device:
|
||||||
wifi_device.toggle_wifi()
|
wifi_device.toggle_wifi()
|
||||||
@@ -640,17 +646,13 @@ 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(
|
GLib.idle_add(lambda: self.wlan_label.set_label(wifi_name))
|
||||||
lambda: self.wlan_label.set_property("label", wifi_name)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(
|
GLib.idle_add(lambda: self.wlan_label.set_label("Connected"))
|
||||||
lambda: self.wlan_label.set_property("label", "Connected")
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan))
|
GLib.idle_add(lambda: self.wlan_label.set_label(wlan))
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(lambda: self.wlan_label.set_property("label", wlan))
|
GLib.idle_add(lambda: self.wlan_label.set_label(wlan))
|
||||||
|
|
||||||
def bluetooth_changed(self, _, bluetooth):
|
def bluetooth_changed(self, _, bluetooth):
|
||||||
self.bluetooth_svg.set_from_file(
|
self.bluetooth_svg.set_from_file(
|
||||||
@@ -665,19 +667,15 @@ class ModusControlCenter(Window):
|
|||||||
parts = bluetooth.split(":")
|
parts = bluetooth.split(":")
|
||||||
if len(parts) >= 2:
|
if len(parts) >= 2:
|
||||||
device_name = parts[1]
|
device_name = parts[1]
|
||||||
GLib.idle_add(
|
GLib.idle_add(lambda: self.bluetooth_label.set_label(device_name))
|
||||||
lambda: self.bluetooth_label.set_property("label", device_name)
|
|
||||||
)
|
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(
|
GLib.idle_add(lambda: self.bluetooth_label.set_label("Connected"))
|
||||||
lambda: self.bluetooth_label.set_property("label", "Connected")
|
|
||||||
)
|
|
||||||
elif bluetooth == "enabled":
|
elif bluetooth == "enabled":
|
||||||
GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "On"))
|
GLib.idle_add(lambda: self.bluetooth_label.set_label("On"))
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "On"))
|
GLib.idle_add(lambda: self.bluetooth_label.set_label("On"))
|
||||||
else:
|
else:
|
||||||
GLib.idle_add(lambda: self.bluetooth_label.set_property("label", "Off"))
|
GLib.idle_add(lambda: self.bluetooth_label.set_label("Off"))
|
||||||
|
|
||||||
def audio_changed(self, *_):
|
def audio_changed(self, *_):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in new issue
Block a user