device: move link_encrypted from status to Device

This commit is contained in:
Peter F. Patel-Schneider 2024-03-09 16:50:26 -05:00
parent 15d425c365
commit 1fe2eab1a4
5 changed files with 5 additions and 6 deletions

View File

@ -94,6 +94,7 @@ class Device:
self._profiles = self._backlight = self._registers = self._settings = None
self.notification_flags = None
self.battery_info = None
self.link_encrypted = None
self._feature_settings_checked = False
self._gestures_lock = _threading.Lock()
@ -361,7 +362,6 @@ class Device:
info.level = self.battery_info.level
changed = self.battery_info != info
print("SBI", changed, info, self.battery_info)
self.battery_info, old_info = info, self.battery_info
alert, reason = ALERT.NONE, None

View File

@ -266,7 +266,7 @@ def _process_hidpp10_notification(device, status, n):
link_established,
bool(flags & 0x80),
)
status.link_encrypted = link_encrypted
device.link_encrypted = link_encrypted
status.changed(active=link_established)
return True

View File

@ -68,7 +68,6 @@ class DeviceStatus:
assert changed_callback
self._changed_callback = changed_callback
self._active = None # is the device active?
self.link_encrypted = None
def __bool__(self):
return bool(self._active)

View File

@ -232,7 +232,7 @@ def _pairing_succeeded(assistant, receiver, device):
def _check_encrypted(dev):
if assistant.is_drawable():
if device.status.link_encrypted is False:
if device.link_encrypted is False:
hbox.pack_start(Gtk.Image.new_from_icon_name("security-low", Gtk.IconSize.MENU), False, False, 0)
hbox.pack_start(Gtk.Label(_("The wireless link is not encrypted") + "!"), False, False, 0)
hbox.show_all()

View File

@ -725,12 +725,12 @@ def _update_device_panel(device, panel, buttons, full=False):
panel._battery._text.set_markup(text)
panel._battery.set_tooltip_text(tooltip_text)
if device.status.link_encrypted is None:
if device.link_encrypted is None:
panel._secure.set_visible(False)
elif is_online:
panel._secure.set_visible(True)
panel._secure._icon.set_visible(True)
if device.status.link_encrypted is True:
if device.link_encrypted is True:
panel._secure._text.set_text(_("encrypted"))
panel._secure._icon.set_from_icon_name("security-high", _INFO_ICON_SIZE)
panel._secure.set_tooltip_text(_("The wireless link between this device and its receiver is encrypted."))