diff --git a/daemon/core/gui/coreclient.py b/daemon/core/gui/coreclient.py index 23f7adc0..e367608a 100644 --- a/daemon/core/gui/coreclient.py +++ b/daemon/core/gui/coreclient.py @@ -415,9 +415,8 @@ class CoreClient: if len(sessions) == 0: self.create_new_session() else: - dialog = SessionsDialog(self.app, self.app) + dialog = SessionsDialog(self.app, self.app, True) dialog.show() - response = self.client.get_service_defaults(self.session_id) self.default_services = { x.node_type: set(x.services) for x in response.defaults diff --git a/daemon/core/gui/data/icons/cancel.png b/daemon/core/gui/data/icons/cancel.png new file mode 100644 index 00000000..1d95ba0c Binary files /dev/null and b/daemon/core/gui/data/icons/cancel.png differ diff --git a/daemon/core/gui/data/icons/delete.png b/daemon/core/gui/data/icons/delete.png new file mode 100644 index 00000000..01b498d4 Binary files /dev/null and b/daemon/core/gui/data/icons/delete.png differ diff --git a/daemon/core/gui/data/icons/shutdown.png b/daemon/core/gui/data/icons/shutdown.png new file mode 100644 index 00000000..532f2cb9 Binary files /dev/null and b/daemon/core/gui/data/icons/shutdown.png differ diff --git a/daemon/core/gui/dialogs/sessions.py b/daemon/core/gui/dialogs/sessions.py index ad348280..0ec1a8cf 100644 --- a/daemon/core/gui/dialogs/sessions.py +++ b/daemon/core/gui/dialogs/sessions.py @@ -13,8 +13,9 @@ from core.gui.themes import PADX, PADY class SessionsDialog(Dialog): - def __init__(self, master, app): + def __init__(self, master, app, is_start_app=False): super().__init__(master, app, "Sessions", modal=True) + self.is_start_app = is_start_app self.selected = False self.selected_id = None self.tree = None @@ -89,7 +90,7 @@ class SessionsDialog(Dialog): def draw_buttons(self): frame = ttk.Frame(self.top) - for i in range(4): + for i in range(5): frame.columnconfigure(i, weight=1) frame.grid(sticky="ew") @@ -111,7 +112,7 @@ class SessionsDialog(Dialog): b.image = image b.grid(row=0, column=1, padx=PADX, sticky="ew") - image = Images.get(ImageEnum.EDITDELETE, 16) + image = Images.get(ImageEnum.SHUTDOWN, 16) b = ttk.Button( frame, image=image, @@ -122,8 +123,32 @@ class SessionsDialog(Dialog): b.image = image b.grid(row=0, column=2, padx=PADX, sticky="ew") - b = ttk.Button(frame, text="Cancel", command=self.click_new) - b.grid(row=0, column=3, sticky="ew") + image = Images.get(ImageEnum.DELETE, 16) + b = ttk.Button( + frame, + image=image, + text="Delete", + compound=tk.LEFT, + command=self.click_delete, + ) + b.image = image + b.grid(row=0, column=3, padx=PADX, sticky="ew") + + image = Images.get(ImageEnum.CANCEL, 16) + if self.is_start_app: + b = ttk.Button( + frame, image=image, text="Exit", compound=tk.LEFT, command=self.destroy + ) + else: + b = ttk.Button( + frame, + image=image, + text="Cancel", + compound=tk.LEFT, + command=self.destroy, + ) + b.image = image + b.grid(row=0, column=4, sticky="ew") def click_new(self): self.app.core.create_new_session() @@ -177,3 +202,13 @@ class SessionsDialog(Dialog): self.app.core.stop_session(sid) self.click_new() self.destroy() + + def click_delete(self): + logging.debug("Click delete") + item = self.tree.selection() + if item: + sid = int(self.tree.item(item, "text")) + self.app.core.delete_session(sid) + self.tree.delete(item[0]) + if sid == self.app.core.session_id: + self.click_new() diff --git a/daemon/core/gui/images.py b/daemon/core/gui/images.py index 0d55f650..a1ac922b 100644 --- a/daemon/core/gui/images.py +++ b/daemon/core/gui/images.py @@ -68,3 +68,6 @@ class ImageEnum(Enum): DOCKER = "docker" LXC = "lxc" ALERT = "alert" + DELETE = "delete" + SHUTDOWN = "shutdown" + CANCEL = "cancel" diff --git a/daemon/core/gui/themes.py b/daemon/core/gui/themes.py index 66565f8d..54ae3ce0 100644 --- a/daemon/core/gui/themes.py +++ b/daemon/core/gui/themes.py @@ -73,9 +73,7 @@ def load(style): "shiftrelief": [("pressed", 1)], }, }, - "TMenubutton": { - "configure": {"width": 11, "padding": (5, 1), "relief": tk.RAISED} - }, + "TMenubutton": {"configure": {"padding": (5, 1), "relief": tk.RAISED}}, "TCheckbutton": { "configure": { "indicatorbackground": Colors.white,