forked from clan/clan-core
VMBase dataclass added
This commit is contained in:
parent
cfe7f4b50f
commit
8012bd5870
@ -13,6 +13,7 @@ class VMBase:
|
|||||||
name: str
|
name: str
|
||||||
url: str
|
url: str
|
||||||
running: bool
|
running: bool
|
||||||
|
_path: Path
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def name_to_type_map() -> OrderedDict[str, type]:
|
def name_to_type_map() -> OrderedDict[str, type]:
|
||||||
@ -22,6 +23,7 @@ class VMBase:
|
|||||||
"Name": str,
|
"Name": str,
|
||||||
"URL": str,
|
"URL": str,
|
||||||
"Running": bool,
|
"Running": bool,
|
||||||
|
"_Path": str,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -32,13 +34,13 @@ class VMBase:
|
|||||||
"Name": self.name,
|
"Name": self.name,
|
||||||
"URL": self.url,
|
"URL": self.url,
|
||||||
"Running": self.running,
|
"Running": self.running,
|
||||||
|
"_Path": str(self._path),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@dataclass(frozen=True)
|
@dataclass(frozen=True)
|
||||||
class VM(VMBase):
|
class VM(VMBase):
|
||||||
path: Path
|
|
||||||
autostart: bool = False
|
autostart: bool = False
|
||||||
|
|
||||||
|
|
||||||
@ -50,28 +52,28 @@ def list_vms() -> list[VM]:
|
|||||||
icon=assets / "cybernet.jpeg",
|
icon=assets / "cybernet.jpeg",
|
||||||
name="Cybernet Clan",
|
name="Cybernet Clan",
|
||||||
url="clan://cybernet.lol",
|
url="clan://cybernet.lol",
|
||||||
path=Path(__file__).parent.parent / "test_democlan",
|
_path=Path(__file__).parent.parent / "test_democlan",
|
||||||
running=True,
|
running=True,
|
||||||
),
|
),
|
||||||
VM(
|
VM(
|
||||||
icon=assets / "zenith.jpeg",
|
icon=assets / "zenith.jpeg",
|
||||||
name="Zenith Clan",
|
name="Zenith Clan",
|
||||||
url="clan://zenith.lol",
|
url="clan://zenith.lol",
|
||||||
path=Path(__file__).parent.parent / "test_democlan",
|
_path=Path(__file__).parent.parent / "test_democlan",
|
||||||
running=False,
|
running=False,
|
||||||
),
|
),
|
||||||
VM(
|
VM(
|
||||||
icon=assets / "firestorm.jpeg",
|
icon=assets / "firestorm.jpeg",
|
||||||
name="Firestorm Clan",
|
name="Firestorm Clan",
|
||||||
url="clan://firestorm.lol",
|
url="clan://firestorm.lol",
|
||||||
path=Path(__file__).parent.parent / "test_democlan",
|
_path=Path(__file__).parent.parent / "test_democlan",
|
||||||
running=False,
|
running=False,
|
||||||
),
|
),
|
||||||
VM(
|
VM(
|
||||||
icon=assets / "placeholder.jpeg",
|
icon=assets / "placeholder.jpeg",
|
||||||
name="Demo Clan",
|
name="Demo Clan",
|
||||||
url="clan://demo.lol",
|
url="clan://demo.lol",
|
||||||
path=Path(__file__).parent.parent / "test_democlan",
|
_path=Path(__file__).parent.parent / "test_democlan",
|
||||||
running=False,
|
running=False,
|
||||||
),
|
),
|
||||||
]
|
]
|
||||||
|
@ -88,7 +88,7 @@ class ClanSelectList(Gtk.Box):
|
|||||||
self,
|
self,
|
||||||
*,
|
*,
|
||||||
vms: list[VM],
|
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_select_row: Callable[[Gtk.TreeSelection], None],
|
||||||
on_double_click: Callable[[Gtk.TreeSelection], None],
|
on_double_click: Callable[[Gtk.TreeSelection], None],
|
||||||
) -> None:
|
) -> None:
|
||||||
@ -105,6 +105,8 @@ class ClanSelectList(Gtk.Box):
|
|||||||
|
|
||||||
self.tree_view = Gtk.TreeView(self.list_store, expand=True)
|
self.tree_view = Gtk.TreeView(self.list_store, expand=True)
|
||||||
for idx, (key, value) in enumerate(vm.list_data().items()):
|
for idx, (key, value) in enumerate(vm.list_data().items()):
|
||||||
|
if key.startswith("_"):
|
||||||
|
continue
|
||||||
match key:
|
match key:
|
||||||
case "Icon":
|
case "Icon":
|
||||||
renderer = Gtk.CellRendererPixbuf()
|
renderer = Gtk.CellRendererPixbuf()
|
||||||
|
@ -1 +1 @@
|
|||||||
Subproject commit 6287f4e19194a6c13a2623736404cd91a88e0a1b
|
Subproject commit e004b50ec6b35f415584977bb982ff8072b2e596
|
Loading…
Reference in New Issue
Block a user