From 438bb9e034d496a2fb602efa83982ab739b5fd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vin=C3=ADcius?= Date: Mon, 17 Jan 2022 17:43:36 -0300 Subject: [PATCH] ui: show a different icon if the user types an unknown 8-character hex string --- lib/solaar/ui/diversion_rules.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/solaar/ui/diversion_rules.py b/lib/solaar/ui/diversion_rules.py index 01e5fdb8..1a498405 100644 --- a/lib/solaar/ui/diversion_rules.py +++ b/lib/solaar/ui/diversion_rules.py @@ -15,6 +15,7 @@ ## You should have received a copy of the GNU General Public License along ## with this program; if not, write to the Free Software Foundation, Inc., ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +import string from collections import defaultdict from contextlib import contextmanager as contextlib_contextmanager @@ -1760,7 +1761,14 @@ class SetUI(ActionUI): return a = iter(self.component.args) device_str = next(a, None) - icon = 'dialog-warning' if device_str and not _find_device(self.devices, device_str) else '' + device = _find_device(self.devices, device_str) + if device_str and not device: + if len(device_str) == 8 and all(c in string.hexdigits for c in device_str): + icon = 'dialog-question' + else: + icon = 'dialog-warning' + else: + icon = '' self.device_field.get_child().set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, icon) setting_name = next(a, '') setting, val_class, kind, keys = self._setting_attributes(setting_name)