Add history stack
This commit is contained in:
parent
2472f80111
commit
ba24b8b5b7
1 changed files with 12 additions and 0 deletions
|
@ -33,6 +33,9 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||
def __init__(self, *args: Any, **kwargs: Any):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
# Directory history stack
|
||||
self.directory_history: list[str] = []
|
||||
|
||||
# For overlay text timeout
|
||||
self.overlay_hide_time = 0.0
|
||||
self.last_position_save = 0.0
|
||||
|
@ -148,6 +151,8 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||
file_item = cast(FileItem, selected_item)
|
||||
|
||||
if file_item.file_type == FileType.DIRECTORY:
|
||||
# Save current directory before changing
|
||||
self.directory_history.append(os.getcwd())
|
||||
os.chdir(file_item.full_path)
|
||||
self._populate_file_list()
|
||||
return
|
||||
|
@ -369,6 +374,13 @@ class MainWindow(Gtk.ApplicationWindow):
|
|||
self._toggle_watched_status()
|
||||
return True
|
||||
|
||||
elif keyval == Gdk.keyval_from_name("BackSpace"):
|
||||
if self.directory_history:
|
||||
prev_dir = self.directory_history.pop()
|
||||
os.chdir(prev_dir)
|
||||
self._populate_file_list()
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def _on_key_pressed(
|
||||
|
|
Loading…
Reference in a new issue