ui: don't show wireless link or battery information when unknown or not present
This commit is contained in:
parent
dcbf547195
commit
57c0c5d4b3
|
@ -293,13 +293,14 @@ class DeviceStatus(dict):
|
|||
_settings.apply_all_settings(d)
|
||||
|
||||
else:
|
||||
if was_active:
|
||||
battery = self.get(KEYS.BATTERY_LEVEL)
|
||||
self.clear()
|
||||
# If we had a known battery level before, assume it's not going
|
||||
# to change much while the device is offline.
|
||||
if battery is not None:
|
||||
self[KEYS.BATTERY_LEVEL] = battery
|
||||
if was_active: # don't clear status when devices go inactive
|
||||
## battery = self.get(KEYS.BATTERY_LEVEL)
|
||||
## self.clear()
|
||||
## # If we had a known battery level before, assume it's not going
|
||||
## # to change much while the device is offline.
|
||||
## if battery is not None:
|
||||
## self[KEYS.BATTERY_LEVEL] = battery
|
||||
pass
|
||||
|
||||
# A device that is not active on the first status notification
|
||||
# but becomes active afterwards does not produce a pop-up notification
|
||||
|
|
|
@ -141,7 +141,7 @@ def _create_device_panel():
|
|||
p._lux = _status_line(_('Lighting'))
|
||||
p.pack_start(p._lux, False, False, 0)
|
||||
|
||||
p.pack_start(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL), False, False, 0) # spacer
|
||||
# p.pack_start(Gtk.Separator.new(Gtk.Orientation.HORIZONTAL), False, False, 0) # spacer
|
||||
|
||||
p._config = _config_panel.create()
|
||||
p.pack_end(p._config, True, True, 4)
|
||||
|
@ -683,14 +683,9 @@ def _update_device_panel(device, panel, buttons, full=False):
|
|||
battery_level = device.status.get(_K.BATTERY_LEVEL)
|
||||
battery_voltage = device.status.get(_K.BATTERY_VOLTAGE)
|
||||
if battery_level is None and battery_voltage is None:
|
||||
icon_name = _icons.battery()
|
||||
panel._battery._icon.set_from_icon_name(icon_name, _INFO_ICON_SIZE)
|
||||
panel._battery._icon.set_sensitive(False)
|
||||
panel._battery._text.set_sensitive(is_online)
|
||||
panel._battery._label.set_text(_('Battery'))
|
||||
panel._battery._text.set_markup('<small>%s</small>' % (_('none') if is_online else _('unknown')))
|
||||
panel._battery.set_tooltip_text(_('Battery not found.') if is_online else _('Battery information unknown.'))
|
||||
panel._battery.set_visible(False)
|
||||
else:
|
||||
panel._battery.set_visible(True)
|
||||
battery_next_level = device.status.get(_K.BATTERY_NEXT_LEVEL)
|
||||
charging = device.status.get(_K.BATTERY_CHARGING)
|
||||
icon_name = _icons.battery(battery_level, charging)
|
||||
|
@ -725,9 +720,16 @@ def _update_device_panel(device, panel, buttons, full=False):
|
|||
panel._battery._text.set_markup(text)
|
||||
panel._battery.set_tooltip_text(tooltip_text)
|
||||
|
||||
if is_online:
|
||||
not_secure = device.status.get(_K.LINK_ENCRYPTED) is False
|
||||
if not_secure:
|
||||
if device.status.get(_K.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.get(_K.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.'))
|
||||
else:
|
||||
panel._secure._text.set_text(_('not encrypted'))
|
||||
panel._secure._icon.set_from_icon_name('security-low', _INFO_ICON_SIZE)
|
||||
panel._secure.set_tooltip_text(
|
||||
|
@ -737,13 +739,9 @@ def _update_device_panel(device, panel, buttons, full=False):
|
|||
)
|
||||
)
|
||||
else:
|
||||
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.'))
|
||||
panel._secure._icon.set_visible(True)
|
||||
else:
|
||||
panel._secure._text.set_markup('<small>%s</small>' % _('offline'))
|
||||
panel._secure.set_visible(True)
|
||||
panel._secure._icon.set_visible(False)
|
||||
panel._secure._text.set_markup('<small>%s</small>' % _('offline'))
|
||||
panel._secure.set_tooltip_text('')
|
||||
|
||||
if is_online:
|
||||
|
|
Loading…
Reference in New Issue