print: refactors

This commit is contained in:
alfrix 2023-03-21 20:54:09 -06:00
parent 3417765223
commit da9f970231

View File

@ -332,7 +332,10 @@ class PrintPanel(ScreenPanel):
directory = os.path.join("gcodes", os.path.dirname(filename)) if os.path.dirname(filename) else "gcodes" directory = os.path.join("gcodes", os.path.dirname(filename)) if os.path.dirname(filename) else "gcodes"
if directory not in self.filelist or os.path.basename(filename).startswith("."): if directory not in self.filelist or os.path.basename(filename).startswith("."):
return return
try:
self.filelist[directory]["files"].pop(self.filelist[directory]["files"].index(os.path.basename(filename))) self.filelist[directory]["files"].pop(self.filelist[directory]["files"].index(os.path.basename(filename)))
except Exception as e:
logging.exception(e)
dir_parts = directory.split(os.sep) dir_parts = directory.split(os.sep)
i = len(dir_parts) i = len(dir_parts)
while i > 1: while i > 1:
@ -352,7 +355,10 @@ class PrintPanel(ScreenPanel):
self.dir_panels[parent_dir].show_all() self.dir_panels[parent_dir].show_all()
i -= 1 i -= 1
try:
self.dir_panels[directory].remove(self.files[filename]) self.dir_panels[directory].remove(self.files[filename])
except Exception as e:
logging.exception(e)
self.dir_panels[directory].show_all() self.dir_panels[directory].show_all()
self.files.pop(filename) self.files.pop(filename)
@ -417,6 +423,13 @@ class PrintPanel(ScreenPanel):
self.content.remove(child) self.content.remove(child)
if "rename_file" not in self.labels: if "rename_file" not in self.labels:
self._create_rename_box(fullpath)
self.content.add(self.labels['rename_file'])
self.labels['new_name'].set_text(fullpath[7:])
self.labels['new_name'].grab_focus_without_selecting()
self.showing_rename = True
def _create_rename_box(self, fullpath):
lbl = self._gtk.Label(_("Rename/Move:")) lbl = self._gtk.Label(_("Rename/Move:"))
lbl.set_halign(Gtk.Align.START) lbl.set_halign(Gtk.Align.START)
lbl.set_hexpand(False) lbl.set_hexpand(False)
@ -441,11 +454,6 @@ class PrintPanel(ScreenPanel):
self.labels['rename_file'].pack_start(lbl, True, True, 5) self.labels['rename_file'].pack_start(lbl, True, True, 5)
self.labels['rename_file'].pack_start(box, True, True, 5) self.labels['rename_file'].pack_start(box, True, True, 5)
self.content.add(self.labels['rename_file'])
self.labels['new_name'].set_text(fullpath[7:])
self.labels['new_name'].grab_focus_without_selecting()
self.showing_rename = True
def hide_rename(self): def hide_rename(self):
self._screen.remove_keyboard() self._screen.remove_keyboard()
for child in self.content.get_children(): for child in self.content.get_children():