fixed initialization sequence for newly detected devices
This commit is contained in:
parent
50fedab19e
commit
bcc2bf123e
|
@ -307,12 +307,12 @@ class ReceiverListener(_EventsListener):
|
||||||
dev = DeviceInfo(self.handle, event.devnumber, status, self.status_changed)
|
dev = DeviceInfo(self.handle, event.devnumber, status, self.status_changed)
|
||||||
self.LOG.info("new device %s", dev)
|
self.LOG.info("new device %s", dev)
|
||||||
|
|
||||||
self.receiver.devices[event.devnumber] = dev
|
self.change_status(STATUS.CONNECTED + 1 + len(self.receiver.devices))
|
||||||
self.change_status(STATUS.CONNECTED + len(self.receiver.devices))
|
|
||||||
|
|
||||||
if status == STATUS.CONNECTED:
|
if status == STATUS.CONNECTED:
|
||||||
dev.protocol, dev.name, dev.kind
|
dev.protocol, dev.name, dev.kind
|
||||||
self.status_changed(dev, STATUS.UI_NOTIFY)
|
self.status_changed(dev, STATUS.UI_NOTIFY)
|
||||||
|
self.receiver.devices[event.devnumber] = dev
|
||||||
if status == STATUS.CONNECTED:
|
if status == STATUS.CONNECTED:
|
||||||
dev.serial, dev.firmware
|
dev.serial, dev.firmware
|
||||||
return dev
|
return dev
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
from gi.repository import Gtk
|
from gi.repository import Gtk
|
||||||
import ui
|
import ui
|
||||||
|
from logitech.devices.constants import (STATUS, PROPS)
|
||||||
|
|
||||||
|
|
||||||
def create(window, menu_actions=None):
|
def create(window, menu_actions=None):
|
||||||
|
@ -33,22 +34,28 @@ def create(window, menu_actions=None):
|
||||||
def update(icon, receiver):
|
def update(icon, receiver):
|
||||||
icon.set_from_icon_name(ui.appicon(receiver.status))
|
icon.set_from_icon_name(ui.appicon(receiver.status))
|
||||||
|
|
||||||
|
# device_with_battery = None
|
||||||
|
|
||||||
if receiver.devices:
|
if receiver.devices:
|
||||||
lines = []
|
lines = []
|
||||||
if receiver.status < 1:
|
if receiver.status < STATUS.CONNECTED:
|
||||||
lines += (receiver.status_text, '')
|
lines += (receiver.status_text, '')
|
||||||
|
|
||||||
devlist = [receiver.devices[d] for d in range(1, 1 + receiver.max_devices) if d in receiver.devices]
|
devlist = list(receiver.devices.values())
|
||||||
|
devlist.sort(lambda x, y: x.number < y.number)
|
||||||
for dev in devlist:
|
for dev in devlist:
|
||||||
name = '<b>' + dev.name + '</b>'
|
name = '<b>' + dev.name + '</b>'
|
||||||
if dev.status < 1:
|
if dev.status < STATUS.CONNECTED:
|
||||||
lines.append(name + ' (' + dev.status_text + ')')
|
lines.append(name + ' (' + dev.status_text + ')')
|
||||||
else:
|
else:
|
||||||
lines.append(name)
|
lines.append(name)
|
||||||
if dev.status > 1:
|
if dev.status > STATUS.CONNECTED:
|
||||||
lines.append(' ' + dev.status_text)
|
lines.append(' ' + dev.status_text)
|
||||||
lines.append('')
|
lines.append('')
|
||||||
|
|
||||||
|
# if device_with_battery is None and PROPS.BATTERY_LEVEL in dev.props:
|
||||||
|
# device_with_battery = dev
|
||||||
|
|
||||||
text = '\n'.join(lines).rstrip('\n')
|
text = '\n'.join(lines).rstrip('\n')
|
||||||
icon.set_tooltip_markup(ui.NAME + ':\n' + text)
|
icon.set_tooltip_markup(ui.NAME + ':\n' + text)
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -63,8 +63,7 @@ FIRMWARE_KIND = FallbackDict(lambda x: 'Unknown', list2dict(_FIRMWARE_KINDS))
|
||||||
|
|
||||||
|
|
||||||
_BATTERY_STATUSES = ('Discharging (in use)', 'Recharging', 'Almost full',
|
_BATTERY_STATUSES = ('Discharging (in use)', 'Recharging', 'Almost full',
|
||||||
'Full', 'Slow recharge', 'Invalid battery', 'Thermal error',
|
'Full', 'Slow recharge', 'Invalid battery', 'Thermal error')
|
||||||
'Charging error')
|
|
||||||
BATTERY_OK = lambda status: status < 5
|
BATTERY_OK = lambda status: status < 5
|
||||||
|
|
||||||
"""Names for possible battery status values."""
|
"""Names for possible battery status values."""
|
||||||
|
|
Loading…
Reference in New Issue