From ef0db3168772a487cdcb11a195dea10556828280 Mon Sep 17 00:00:00 2001 From: "Peter F. Patel-Schneider" Date: Fri, 6 Jan 2023 08:58:26 -0500 Subject: [PATCH] ui: improve determination of whether pairing possible --- lib/solaar/ui/window.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/lib/solaar/ui/window.py b/lib/solaar/ui/window.py index e32a0898..0366990e 100644 --- a/lib/solaar/ui/window.py +++ b/lib/solaar/ui/window.py @@ -623,7 +623,7 @@ def _update_receiver_panel(receiver, panel, buttons, full=False): devices_count = len(receiver) paired_text = _( - 'No device paired.' + _('No device paired.') ) if devices_count == 0 else ngettext('%(count)s paired device.', '%(count)s paired devices.', devices_count) % { 'count': devices_count } @@ -663,13 +663,9 @@ def _update_receiver_panel(receiver, panel, buttons, full=False): # b._insecure.set_visible(False) buttons._unpair.set_visible(False) - if (receiver.may_unpair or receiver.re_pairs) and not is_pairing and \ - (receiver.remaining_pairings() is None or receiver.remaining_pairings() != 0): - if not receiver.re_pairs and devices_count >= receiver.max_devices: - paired_devices = tuple(n for n in range(1, receiver.max_devices + 1) if n in receiver) - buttons._pair.set_sensitive(len(paired_devices) < receiver.max_devices) - else: - buttons._pair.set_sensitive(True) + if not is_pairing and (receiver.remaining_pairings() is None or receiver.remaining_pairings() != 0) and \ + (receiver.re_pairs or devices_count < receiver.max_devices): + buttons._pair.set_sensitive(True) else: buttons._pair.set_sensitive(False)