1
0
forked from clan/clan-core

VMBase dataclass added

This commit is contained in:
Luis Hebendanz 2023-12-01 23:13:36 +01:00
parent cfe7f4b50f
commit 8012bd5870
3 changed files with 11 additions and 7 deletions

View File

@ -13,6 +13,7 @@ class VMBase:
name: str
url: str
running: bool
_path: Path
@staticmethod
def name_to_type_map() -> OrderedDict[str, type]:
@ -22,6 +23,7 @@ class VMBase:
"Name": str,
"URL": str,
"Running": bool,
"_Path": str,
}
)
@ -32,13 +34,13 @@ class VMBase:
"Name": self.name,
"URL": self.url,
"Running": self.running,
"_Path": str(self._path),
}
)
@dataclass(frozen=True)
class VM(VMBase):
path: Path
autostart: bool = False
@ -50,28 +52,28 @@ def list_vms() -> list[VM]:
icon=assets / "cybernet.jpeg",
name="Cybernet Clan",
url="clan://cybernet.lol",
path=Path(__file__).parent.parent / "test_democlan",
_path=Path(__file__).parent.parent / "test_democlan",
running=True,
),
VM(
icon=assets / "zenith.jpeg",
name="Zenith Clan",
url="clan://zenith.lol",
path=Path(__file__).parent.parent / "test_democlan",
_path=Path(__file__).parent.parent / "test_democlan",
running=False,
),
VM(
icon=assets / "firestorm.jpeg",
name="Firestorm Clan",
url="clan://firestorm.lol",
path=Path(__file__).parent.parent / "test_democlan",
_path=Path(__file__).parent.parent / "test_democlan",
running=False,
),
VM(
icon=assets / "placeholder.jpeg",
name="Demo Clan",
url="clan://demo.lol",
path=Path(__file__).parent.parent / "test_democlan",
_path=Path(__file__).parent.parent / "test_democlan",
running=False,
),
]

View File

@ -88,7 +88,7 @@ class ClanSelectList(Gtk.Box):
self,
*,
vms: list[VM],
on_cell_toggled: Callable[[Gtk.Widget, str], None],
on_cell_toggled: Callable[[VMBase, str], None],
on_select_row: Callable[[Gtk.TreeSelection], None],
on_double_click: Callable[[Gtk.TreeSelection], None],
) -> None:
@ -105,6 +105,8 @@ class ClanSelectList(Gtk.Box):
self.tree_view = Gtk.TreeView(self.list_store, expand=True)
for idx, (key, value) in enumerate(vm.list_data().items()):
if key.startswith("_"):
continue
match key:
case "Icon":
renderer = Gtk.CellRendererPixbuf()

@ -1 +1 @@
Subproject commit 6287f4e19194a6c13a2623736404cd91a88e0a1b
Subproject commit e004b50ec6b35f415584977bb982ff8072b2e596