From 7651b892b86651804d67020d31add6efd90da6ed Mon Sep 17 00:00:00 2001 From: alfrix Date: Thu, 1 Dec 2022 10:25:59 -0300 Subject: [PATCH] print: allow directory deletion --- panels/print.py | 13 ++++++++++++- screen.py | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/panels/print.py b/panels/print.py index 769dc311..6391ece1 100644 --- a/panels/print.py +++ b/panels/print.py @@ -172,12 +172,13 @@ class PrintPanel(ScreenPanel): info.set_markup(self.get_file_info_str(fullpath)) actions.connect("clicked", self.confirm_print, fullpath) icon = Gtk.Button() + icon.connect("clicked", self.confirm_delete_file, f"gcodes/{fullpath}") GLib.idle_add(self.image_load, fullpath) else: actions.connect("clicked", self.change_dir, fullpath) icon = self._gtk.Button("folder") + icon.connect("clicked", self.confirm_delete_directory, fullpath) icon.set_hexpand(False) - icon.connect("clicked", self.confirm_delete_file, f"gcodes/{fullpath}") file = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=5) file.get_style_context().add_class("frame-item") @@ -220,6 +221,16 @@ class PrintPanel(ScreenPanel): params ) + def confirm_delete_directory(self, widget, dirpath): + logging.debug(f"Sending delete_directory {dirpath}") + params = {"path": f"{dirpath}", "force": True} + self._screen._confirm_send_action( + None, + _("Delete Directory?") + "\n\n" + dirpath, + "server.files.delete_directory", + params + ) + def back(self): if os.path.dirname(self.cur_directory): self.change_dir(None, os.path.dirname(self.cur_directory)) diff --git a/screen.py b/screen.py index e0c79a0c..393a7dfa 100755 --- a/screen.py +++ b/screen.py @@ -761,6 +761,8 @@ class KlipperScreen(Gtk.Window): self.gtk.remove_dialog(dialog) if response_id == Gtk.ResponseType.OK: self._send_action(None, method, params) + if method == "server.files.delete_directory": + GLib.timeout_add_seconds(2, self.files.refresh_files) def _send_action(self, widget, method, params): logging.info(f"{method}: {params}")