receiver: fix contains for NamedInts and eliminate use of has_element
This commit is contained in:
parent
f6b25a9685
commit
7a9f9972a6
|
@ -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):
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue