device: use status attribute for notification_flags
This commit is contained in:
parent
6b3f09aa5d
commit
8154cd759f
|
@ -32,7 +32,7 @@ _hidpp10 = hidpp10.Hidpp10()
|
|||
|
||||
ALERT = NamedInts(NONE=0x00, NOTIFICATION=0x01, SHOW_WINDOW=0x02, ATTENTION=0x04, ALL=0xFF)
|
||||
|
||||
KEYS = NamedInts(NOTIFICATION_FLAGS=6, ERROR=7)
|
||||
KEYS = NamedInts(ERROR=7)
|
||||
|
||||
|
||||
def attach_to(device, changed_callback):
|
||||
|
@ -54,9 +54,9 @@ class ReceiverStatus(dict):
|
|||
def __init__(self, receiver, changed_callback):
|
||||
assert receiver
|
||||
self._receiver = receiver
|
||||
|
||||
assert changed_callback
|
||||
self._changed_callback = changed_callback
|
||||
self.notification_flags = None
|
||||
|
||||
self.lock_open = False
|
||||
self.discovering = False
|
||||
|
@ -87,7 +87,7 @@ class ReceiverStatus(dict):
|
|||
|
||||
class DeviceStatus(dict):
|
||||
"""Holds the 'runtime' status of a peripheral
|
||||
Currently _active, battery, link_encrypted -- dict entries are being moved to attributs
|
||||
Currently _active, battery, link_encrypted, notification_flags -- dict entries are being moved to attributs
|
||||
Updates mostly come from incoming notification events from the device itself.
|
||||
"""
|
||||
|
||||
|
@ -99,6 +99,7 @@ class DeviceStatus(dict):
|
|||
self._active = None # is the device active?
|
||||
self.battery = None
|
||||
self.link_encrypted = None
|
||||
self.notification_flags = None
|
||||
|
||||
def to_string(self):
|
||||
return self.battery.to_str() if self.battery is not None else ""
|
||||
|
@ -153,7 +154,7 @@ class DeviceStatus(dict):
|
|||
# get cleared when the device is turned off (but not when the device
|
||||
# goes idle, and we can't tell the difference right now).
|
||||
if d.protocol < 2.0:
|
||||
self[KEYS.NOTIFICATION_FLAGS] = d.enable_connection_notifications()
|
||||
self.notification_flags = d.enable_connection_notifications()
|
||||
# battery information may have changed so try to read it now
|
||||
self.read_battery()
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ class ReceiverListener(_listener.EventsListener):
|
|||
"Receiver on %s might not support connection notifications, GUI might not show its devices",
|
||||
self.receiver.path,
|
||||
)
|
||||
self.receiver.status[_status.KEYS.NOTIFICATION_FLAGS] = nfs
|
||||
self.receiver.notification_flags = nfs
|
||||
self.receiver.notify_devices()
|
||||
self._status_changed(self.receiver)
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ from gi.repository.GObject import TYPE_PYOBJECT
|
|||
from logitech_receiver import hidpp10_constants as _hidpp10_constants
|
||||
from logitech_receiver.common import NamedInt as _NamedInt
|
||||
from logitech_receiver.common import NamedInts as _NamedInts
|
||||
from logitech_receiver.status import KEYS as _K
|
||||
|
||||
from solaar import NAME
|
||||
from solaar.i18n import _, ngettext
|
||||
|
@ -575,7 +574,7 @@ def _update_details(button):
|
|||
elif device.kind is None or device.online:
|
||||
yield (" %s" % _("Firmware"), "...")
|
||||
|
||||
flag_bits = device.status.get(_K.NOTIFICATION_FLAGS)
|
||||
flag_bits = device.status.notification_flags
|
||||
if flag_bits is not None:
|
||||
flag_names = (
|
||||
("(%s)" % _("none"),) if flag_bits == 0 else _hidpp10_constants.NOTIFICATION_FLAG.flag_names(flag_bits)
|
||||
|
|
Loading…
Reference in New Issue