print: add delete file

this is temporary, to delete a file click the thumbnail
TODO: context menu or other solution to be decided
This commit is contained in:
alfrix authored and Alfredo Monclus committed 2022-08-01 12:23:40 -03:00
1 parent 752e53ff56
commit aa2bfcbaee
1 file changed
+17 -2
+17 -2
View File
@@ -229,7 +229,11 @@ class PrintPanel(ScreenPanel):
else:
icon = self._gtk.Image("file", 1.6)
file.add(icon)
img = Gtk.Button()
img.set_image(icon)
img.connect("clicked", self.confirm_delete_file, f"gcodes/{filepath}")
file.add(img)
file.add(labels)
if os.path.splitext(filename)[1] in [".gcode", ".g", ".gco"]:
file.add(actions)
@@ -242,6 +246,16 @@ class PrintPanel(ScreenPanel):
"name": name
}
def confirm_delete_file(self, widget, filepath):
logging.debug(f"Sending delete_file {filepath}")
params = {"path": f"{filepath}"}
self._screen._confirm_send_action(
None,
_("Delete File?") + "\n\n" + filepath,
"server.files.delete_file",
params
)
def back(self):
if len(self.cur_directory.split('/')) > 1:
self.change_dir(None, '/'.join(self.cur_directory.split('/')[:-1]))
@@ -352,7 +366,8 @@ class PrintPanel(ScreenPanel):
if "size" in fileinfo:
info += _("Size") + f': <b>{self.format_size(fileinfo["size"])}</b>\n'
if "estimated_time" in fileinfo:
info += _("Print Time") + f': <b>{self.format_time(fileinfo["estimated_time"])}</b></small>'
info += _("Print Time") + f': <b>{self.format_time(fileinfo["estimated_time"])}</b>'
info += "</small>"
return info