DRYer
This commit is contained in:
parent
1665b06d59
commit
16e659c477
2 changed files with 15 additions and 4 deletions
|
|
@ -445,9 +445,7 @@ def serialize(self, all_windows: WindowList) -> dict[str, Any]:
|
|||
ans = self.layout_state()
|
||||
ans['opts'] = self.layout_opts.serialized()
|
||||
ans['class'] = self.__class__.__name__
|
||||
ans['all_windows'] = aw = all_windows.serialize_state()
|
||||
for wg in aw['window_groups']:
|
||||
wg['window_ids'] = tuple(w['id'] for w in aw.pop('windows'))
|
||||
ans['all_windows'] = all_windows.serialize_layout_state()
|
||||
return ans
|
||||
|
||||
def unserialize(
|
||||
|
|
|
|||
|
|
@ -96,7 +96,13 @@ def remove_window(self, window: WindowType) -> None:
|
|||
def serialize_state(self) -> dict[str, Any]:
|
||||
return {
|
||||
'id': self.id,
|
||||
'windows': [w.serialize_state() for w in self.windows]
|
||||
'windows': tuple(w.serialize_state() for w in self.windows),
|
||||
}
|
||||
|
||||
def serialize_layout_state(self) -> dict[str, Any]:
|
||||
return {
|
||||
'id': self.id,
|
||||
'window_ids': tuple(w.id for w in self.windows),
|
||||
}
|
||||
|
||||
def unserialize_layout_state(self, window_ids: Sequence[int]) -> None:
|
||||
|
|
@ -185,6 +191,13 @@ def serialize_state(self) -> dict[str, Any]:
|
|||
'window_groups': [g.serialize_state() for g in self.groups]
|
||||
}
|
||||
|
||||
def serialize_layout_state(self) -> dict[str, Any]:
|
||||
return {
|
||||
'active_group_idx': self.active_group_idx,
|
||||
'active_group_history': list(self.active_group_history),
|
||||
'window_groups': [g.serialize_layout_state() for g in self.groups]
|
||||
}
|
||||
|
||||
def unserialize_layout_state(self, state: dict[str, Any], window_id_map: dict[int, int]) -> dict[int, int] | None:
|
||||
if set(window_id_map.values()) != set(self.id_map):
|
||||
# some window in this collection does not correspond to a
|
||||
|
|
|
|||
Loading…
Reference in a new issue