Replaced Status with checkbox
This commit is contained in:
@@ -94,3 +94,6 @@ class ClanURI:
|
||||
urlparams = urllib.parse.urlencode(params.__dict__)
|
||||
|
||||
return cls(f"clan://file://{path}?{urlparams}")
|
||||
|
||||
def __str__(self) -> str:
|
||||
return f"ClanURI({self._components.geturl()})"
|
||||
@@ -1,6 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
from dataclasses import dataclass
|
||||
from enum import Enum
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
@@ -13,22 +12,12 @@ from gi.repository import GdkPixbuf
|
||||
from clan_vm_manager import assets
|
||||
|
||||
|
||||
class Status(Enum):
|
||||
OFF = "Off"
|
||||
RUNNING = "Running"
|
||||
# SUSPENDED = "Suspended"
|
||||
# UNKNOWN = "Unknown"
|
||||
|
||||
def __str__(self) -> str:
|
||||
return self.value
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class VMBase:
|
||||
icon: Path | GdkPixbuf.Pixbuf
|
||||
name: str
|
||||
url: str
|
||||
status: Status
|
||||
status: bool
|
||||
_path: Path
|
||||
|
||||
@staticmethod
|
||||
@@ -38,7 +27,7 @@ class VMBase:
|
||||
"Icon": GdkPixbuf.Pixbuf,
|
||||
"Name": str,
|
||||
"URL": str,
|
||||
"Status": str,
|
||||
"Online": bool,
|
||||
"_Path": str,
|
||||
}
|
||||
)
|
||||
@@ -53,7 +42,7 @@ class VMBase:
|
||||
"Icon": str(self.icon),
|
||||
"Name": self.name,
|
||||
"URL": self.url,
|
||||
"Status": str(self.status),
|
||||
"Online": self.status,
|
||||
"_Path": str(self._path),
|
||||
}
|
||||
)
|
||||
@@ -92,7 +81,7 @@ def get_initial_vms(start: int = 0, end: int | None = None) -> list[VM]:
|
||||
name="Cybernet Clan",
|
||||
url="clan://cybernet.lol",
|
||||
_path=Path(__file__).parent.parent / "test_democlan",
|
||||
status=Status.RUNNING,
|
||||
status=False,
|
||||
),
|
||||
),
|
||||
VM(
|
||||
@@ -101,7 +90,7 @@ def get_initial_vms(start: int = 0, end: int | None = None) -> list[VM]:
|
||||
name="Zenith Clan",
|
||||
url="clan://zenith.lol",
|
||||
_path=Path(__file__).parent.parent / "test_democlan",
|
||||
status=Status.OFF,
|
||||
status=False,
|
||||
)
|
||||
),
|
||||
VM(
|
||||
@@ -110,7 +99,7 @@ def get_initial_vms(start: int = 0, end: int | None = None) -> list[VM]:
|
||||
name="Firestorm Clan",
|
||||
url="clan://firestorm.lol",
|
||||
_path=Path(__file__).parent.parent / "test_democlan",
|
||||
status=Status.OFF,
|
||||
status=False,
|
||||
),
|
||||
),
|
||||
VM(
|
||||
@@ -119,7 +108,7 @@ def get_initial_vms(start: int = 0, end: int | None = None) -> list[VM]:
|
||||
name="Placeholder Clan",
|
||||
url="clan://demo.lol",
|
||||
_path=Path(__file__).parent.parent / "test_democlan",
|
||||
status=Status.OFF,
|
||||
status=True,
|
||||
),
|
||||
),
|
||||
]
|
||||
@@ -132,7 +121,7 @@ def get_initial_vms(start: int = 0, end: int | None = None) -> list[VM]:
|
||||
"name": "Demo Clan",
|
||||
"url": "clan://demo.lol",
|
||||
"_path": entry.path,
|
||||
"status": Status.OFF,
|
||||
"status": False,
|
||||
}
|
||||
vms.append(VM(base=VMBase(**new_vm)))
|
||||
|
||||
|
||||
@@ -74,9 +74,9 @@ class ClanList(Gtk.Box):
|
||||
Is the composition of
|
||||
the ClanListToolbar
|
||||
the clanListView
|
||||
# ------------------------#
|
||||
# - Tools <Join> < Edit> #
|
||||
# ------------------------#
|
||||
# ------------------------ #
|
||||
# - Tools <Start> <Stop> < Edit> #
|
||||
# ------------------------ #
|
||||
# - List Items
|
||||
# - <...>
|
||||
# ------------------------#
|
||||
@@ -153,10 +153,14 @@ class ClanListToolbar(Gtk.Toolbar):
|
||||
) -> None:
|
||||
super().__init__(orientation=Gtk.Orientation.HORIZONTAL)
|
||||
|
||||
self.start_button = Gtk.ToolButton(label="Join")
|
||||
self.start_button = Gtk.ToolButton(label="Start")
|
||||
self.start_button.connect("clicked", on_start_clicked)
|
||||
self.add(self.start_button)
|
||||
|
||||
self.stop_button = Gtk.ToolButton(label="Stop")
|
||||
self.stop_button.connect("clicked", on_stop_clicked)
|
||||
self.add(self.stop_button)
|
||||
|
||||
self.edit_button = Gtk.ToolButton(label="Edit")
|
||||
self.edit_button.connect("clicked", on_edit_clicked)
|
||||
self.add(self.edit_button)
|
||||
@@ -165,9 +169,11 @@ class ClanListToolbar(Gtk.Toolbar):
|
||||
if s:
|
||||
self.edit_button.set_sensitive(True)
|
||||
self.start_button.set_sensitive(True)
|
||||
self.stop_button.set_sensitive(True)
|
||||
else:
|
||||
self.edit_button.set_sensitive(False)
|
||||
self.start_button.set_sensitive(False)
|
||||
self.stop_button.set_sensitive(False)
|
||||
|
||||
|
||||
class ClanEditToolbar(Gtk.Toolbar):
|
||||
@@ -224,7 +230,6 @@ class ClanListView(Gtk.Box):
|
||||
return
|
||||
selection = self.tree_view.get_selection()
|
||||
idx = self.find_vm(vm)
|
||||
print(f"Set selected vm: {vm.name} at {idx}")
|
||||
selection.select_path(idx)
|
||||
|
||||
def insertVM(self, vm: VMBase) -> None:
|
||||
@@ -239,7 +244,6 @@ class ClanListView(Gtk.Box):
|
||||
model, row = selection.get_selected()
|
||||
if row is not None:
|
||||
vm = VMBase(*model[row])
|
||||
print(f"Selected {vm.name}")
|
||||
self.on_select_row(vm)
|
||||
|
||||
def _on_double_click(
|
||||
@@ -259,13 +263,18 @@ def setColRenderers(tree_view: Gtk.TreeView) -> None:
|
||||
|
||||
if key.startswith("_"):
|
||||
continue
|
||||
match gtype:
|
||||
case GdkPixbuf.Pixbuf:
|
||||
renderer = Gtk.CellRendererPixbuf()
|
||||
col = Gtk.TreeViewColumn(key, renderer, pixbuf=idx)
|
||||
case str: # noqa
|
||||
renderer = Gtk.CellRendererText()
|
||||
col = Gtk.TreeViewColumn(key, renderer, text=idx)
|
||||
|
||||
if issubclass(gtype, GdkPixbuf.Pixbuf):
|
||||
renderer = Gtk.CellRendererPixbuf()
|
||||
col = Gtk.TreeViewColumn(key, renderer, pixbuf=idx)
|
||||
elif issubclass(gtype, bool):
|
||||
renderer = Gtk.CellRendererToggle()
|
||||
col = Gtk.TreeViewColumn(key, renderer, active=idx)
|
||||
elif issubclass(gtype, str):
|
||||
renderer = Gtk.CellRendererText()
|
||||
col = Gtk.TreeViewColumn(key, renderer, text=idx)
|
||||
else:
|
||||
raise Exception(f"Unknown type: {gtype}")
|
||||
|
||||
# CommonSetup for all columns
|
||||
if col:
|
||||
|
||||
@@ -26,6 +26,8 @@ class JoinWindow(Gtk.ApplicationWindow):
|
||||
self.notebook = Gtk.Notebook()
|
||||
self.stack = Gtk.Stack()
|
||||
|
||||
self.stack.add_titled(Gtk.Label("Join cLan"), "join", "Join")
|
||||
|
||||
vbox.add(self.stack)
|
||||
|
||||
# Must be called AFTER all components were added
|
||||
|
||||
Reference in New Issue
Block a user