From 9d2c62ef20a3bc1f61b9f6b0b4168edab0653e37 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Sun, 12 Nov 2023 16:50:53 -0600 Subject: [PATCH] File open sets default path to current path if any --- src/core/widgets/base/notebook/key_input_controller.py | 5 +++-- src/core/widgets/controls/open_file_button.py | 8 +++++++- src/core/widgets/save_file_dialog.py | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/core/widgets/base/notebook/key_input_controller.py b/src/core/widgets/base/notebook/key_input_controller.py index b9140cc..21f21be 100644 --- a/src/core/widgets/base/notebook/key_input_controller.py +++ b/src/core/widgets/base/notebook/key_input_controller.py @@ -50,7 +50,8 @@ class KeyInputController: if keyname == "t": self._create_view() if keyname == "o": - event_system.emit("open_files") + page_num, container, source_view = self.get_active_view() + event_system.emit("open_files", (source_view,)) return True @@ -65,4 +66,4 @@ class KeyInputController: if keyname == "Right": self.keyboard_move_tab_right(page_num) - return True + return True \ No newline at end of file diff --git a/src/core/widgets/controls/open_file_button.py b/src/core/widgets/controls/open_file_button.py index 411b857..3b98d65 100644 --- a/src/core/widgets/controls/open_file_button.py +++ b/src/core/widgets/controls/open_file_button.py @@ -46,6 +46,12 @@ class OpenFileButton(Gtk.Button): Gtk.FileChooserAction.OPEN, (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL, Gtk.STOCK_OPEN, Gtk.ResponseType.OK)) + + try: + folder = widget.get_current_file().get_parent() + chooser.set_current_folder( folder.get_uri() ) + except Exception as e: + ... response = chooser.run() if response == Gtk.ResponseType.OK: @@ -55,4 +61,4 @@ class OpenFileButton(Gtk.Button): _gfile = Gio.File.new_for_path(path) event_system.emit("keyboard_open_file", (_gfile,)) - chooser.destroy() + chooser.destroy() \ No newline at end of file diff --git a/src/core/widgets/save_file_dialog.py b/src/core/widgets/save_file_dialog.py index 1a20096..75edede 100644 --- a/src/core/widgets/save_file_dialog.py +++ b/src/core/widgets/save_file_dialog.py @@ -57,7 +57,7 @@ class SaveFileDialog: dlg.set_current_name("new.txt") dlg.set_current_folder(os.path.expanduser('~')) else: - dlg.set_current_folder(current_file.get_parent().get_path()) + dlg.set_current_folder(current_file.get_parent().get_uri()) dlg.set_current_name(current_filename) response = dlg.run()