small tweaks on how the devices info is displayed
This commit is contained in:
parent
66531635bc
commit
f25d2ba183
|
@ -4,6 +4,7 @@
|
|||
|
||||
from logging import getLogger as _Logger
|
||||
from struct import pack as _pack
|
||||
from time import time as _timestamp
|
||||
|
||||
from logitech.unifying_receiver import base as _base
|
||||
from logitech.unifying_receiver import api as _api
|
||||
|
@ -126,6 +127,7 @@ class DeviceInfo(_api.PairedDevice):
|
|||
assert status_changed_callback
|
||||
self.status_changed_callback = status_changed_callback
|
||||
self._status = status
|
||||
self.status_updated = _timestamp()
|
||||
self.props = {}
|
||||
|
||||
self._features = _FeaturesArray(self)
|
||||
|
@ -149,6 +151,7 @@ class DeviceInfo(_api.PairedDevice):
|
|||
self._features._check()
|
||||
self.protocol, self.codename, self.name, self.kind
|
||||
|
||||
self.status_updated = _timestamp()
|
||||
old_status = self._status
|
||||
if new_status != old_status and not (new_status == STATUS.CONNECTED and old_status > new_status):
|
||||
self.LOG.debug("status %d => %d", old_status, new_status)
|
||||
|
|
|
@ -130,11 +130,26 @@ if __name__ == '__main__':
|
|||
# print ("opened receiver", listener, listener.receiver)
|
||||
notify_missing = True
|
||||
status_changed(listener.receiver, None, STATUS.UI_NOTIFY)
|
||||
GObject.timeout_add(5 * 1000, _check_still_scanning, listener)
|
||||
GObject.timeout_add(3 * 1000, _check_still_scanning, listener)
|
||||
pairing.state = pairing.State(listener)
|
||||
listener.trigger_device_events()
|
||||
|
||||
_DEVICE_TIMEOUT = 3 * 60 # seconds
|
||||
_DEVICE_STATUS_CHECK = 30 # seconds
|
||||
from time import time as _timestamp
|
||||
|
||||
def check_for_inactive_devices():
|
||||
if listener and listener.receiver:
|
||||
for dev in listener.receiver.devices.values():
|
||||
if (dev.status < STATUS.CONNECTED and
|
||||
dev.props and
|
||||
_timestamp() - dev.status_updated > _DEVICE_TIMEOUT):
|
||||
dev.props.clear()
|
||||
status_changed(listener.receiver, dev)
|
||||
return True
|
||||
|
||||
GObject.timeout_add(50, check_for_listener, False)
|
||||
GObject.timeout_add(_DEVICE_STATUS_CHECK * 1000, check_for_inactive_devices)
|
||||
Gtk.main()
|
||||
|
||||
if listener is not None:
|
||||
|
|
|
@ -277,17 +277,17 @@ def _update_device_box(frame, dev):
|
|||
|
||||
if dev.status < STATUS.CONNECTED:
|
||||
label.set_sensitive(False)
|
||||
for c in status_icons[2:-1]:
|
||||
c.set_visible(False)
|
||||
|
||||
battery_icon, battery_label = status_icons[0:2]
|
||||
battery_icon.set_sensitive(False)
|
||||
battery_label.set_sensitive(False)
|
||||
battery_level = dev.props.get(PROPS.BATTERY_LEVEL)
|
||||
if battery_level is None:
|
||||
battery_label.set_markup('<small>(%s)</small>' % dev.status_text)
|
||||
battery_label.set_markup('<small>%s</small>' % dev.status_text)
|
||||
else:
|
||||
battery_label.set_markup('%d%% <small>(%s)</small>' % (battery_level, dev.status_text))
|
||||
for c in status_icons[2:-1]:
|
||||
c.set_visible(False)
|
||||
battery_label.set_markup('%d%%' % battery_level)
|
||||
|
||||
else:
|
||||
label.set_sensitive(True)
|
||||
|
@ -299,7 +299,7 @@ def _update_device_box(frame, dev):
|
|||
battery_icon.set_from_icon_name('battery_unknown', _STATUS_ICON_SIZE)
|
||||
text = 'no status' if dev.protocol < 2.0 else 'waiting for status...'
|
||||
battery_label.set_markup('<small>%s</small>' % text)
|
||||
battery_label.set_sensitive(False)
|
||||
battery_label.set_sensitive(True)
|
||||
else:
|
||||
battery_icon.set_from_icon_name(ui.get_battery_icon(battery_level), _STATUS_ICON_SIZE)
|
||||
battery_icon.set_sensitive(True)
|
||||
|
|
|
@ -45,10 +45,10 @@ def update(icon, receiver):
|
|||
if p:
|
||||
p = '\t' + p
|
||||
if dev.status < STATUS.CONNECTED:
|
||||
p += ' (<small>' + dev.status_text + '</small>)'
|
||||
p += ' <small>(' + dev.status_text + ')</small>'
|
||||
lines.append(p)
|
||||
elif dev.status < STATUS.CONNECTED:
|
||||
lines.append('\t(<small>' + dev.status_text + '</small>)')
|
||||
lines.append('\t<small>(' + dev.status_text + ')</small>')
|
||||
elif dev.protocol < 2.0:
|
||||
lines.append('\t' + '<small>no status</small>')
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue