print: allow directory deletion

This commit is contained in:
alfrix 2022-12-01 10:25:59 -03:00
parent 91b505bfef
commit 7651b892b8
2 changed files with 14 additions and 1 deletions

View File

@ -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))

View File

@ -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}")