diff --git a/lib/logitech_receiver/common.py b/lib/logitech_receiver/common.py index 31deee99..d357f8af 100644 --- a/lib/logitech_receiver/common.py +++ b/lib/logitech_receiver/common.py @@ -211,7 +211,9 @@ class NamedInts: self._indexed[int(value)] = value def __contains__(self, value): - if isinstance(value, int): + if isinstance(value, NamedInt): + return self[value] == value + elif isinstance(value, int): return value in self._indexed elif is_string(value): return value in self.__dict__ or value in self._values @@ -228,9 +230,6 @@ class NamedInts: def __or__(self, other): return NamedInts(**self.__dict__, **other.__dict__) - def has_element(self, value): - return self[value] == value - class UnsortedNamedInts(NamedInts): def _sort_values(self): diff --git a/lib/solaar/ui/diversion_rules.py b/lib/solaar/ui/diversion_rules.py index 9cd50689..dd96f22d 100644 --- a/lib/solaar/ui/diversion_rules.py +++ b/lib/solaar/ui/diversion_rules.py @@ -898,9 +898,7 @@ class SmartComboBox(Gtk.ComboBox): values = self._all_values[:] if include_new and only is not None: values += [v for v in only if v not in self._value_to_idx] - self.set_all_values( - values, (lambda v: only is None or (only.has_element(v) if isinstance(only, NamedInts) else (v in only))) - ) + self.set_all_values(values, (lambda v: only is None or (v in only))) @dataclass