Uncommitted changes from Tycho Station
This commit is contained in:
parent
ded2c8676e
commit
c9e3ccab59
@ -79,15 +79,25 @@ class ContextMngrInterface(
|
||||
return ""
|
||||
return json.dumps(workspace.__json__())
|
||||
|
||||
def __get_workspace_data(self) -> dict:
|
||||
async def __get_workspace_data(self) -> dict:
|
||||
"""Get the workspace tree."""
|
||||
try:
|
||||
active = self.workspace_tree.current_context.active_workspace
|
||||
return {
|
||||
"ws": self.workspace_tree.__json__(),
|
||||
"current": self.workspace_tree.current_context.active_workspace.__json__(),
|
||||
"current": active is not None and active.__json__() or None,
|
||||
"context": self.workspace_tree.current_context.name,
|
||||
"visible": {
|
||||
name: ws.__json__()
|
||||
name: ws is not None
|
||||
and ws.__json__()
|
||||
or {
|
||||
"name": f"<undefined:{name}>",
|
||||
"index": -1,
|
||||
"active": True,
|
||||
"visible": True,
|
||||
"focused": False,
|
||||
"alerted": False,
|
||||
}
|
||||
for name, ws in self.workspace_tree.current_context.visible_workspaces.items()
|
||||
},
|
||||
}
|
||||
@ -98,7 +108,7 @@ class ContextMngrInterface(
|
||||
@dbus_method_async(input_signature="", result_signature="s")
|
||||
async def get_workspace_data(self) -> str:
|
||||
"""Get the workspace tree."""
|
||||
data = self.__get_workspace_data()
|
||||
data = await self.__get_workspace_data()
|
||||
return json.dumps(data)
|
||||
|
||||
@dbus_method_async(input_signature="", result_signature="s")
|
||||
@ -114,4 +124,4 @@ class ContextMngrInterface(
|
||||
|
||||
async def on_tree_changed(self, workspace_tree: str):
|
||||
print("tree changed, emitting signal")
|
||||
self.tree_changed.emit(json.dumps(self.__get_workspace_data()))
|
||||
self.tree_changed.emit(json.dumps(await self.__get_workspace_data()))
|
||||
|
||||
@ -54,7 +54,14 @@ class Workspace:
|
||||
}
|
||||
|
||||
def __json__(self):
|
||||
return self.__dict__()
|
||||
return {
|
||||
"index": str(self.index),
|
||||
"name": self.name,
|
||||
"active": self.active,
|
||||
"visible": self.visible,
|
||||
"focused": self.focused,
|
||||
"alerted": self.alerted,
|
||||
}
|
||||
|
||||
def __repr__(self):
|
||||
return f"Workspace({self.index}, '{self.name}')"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user