Skip to content

Commit

Permalink
util.py: Remember the last location for the send dialog.
Browse files Browse the repository at this point in the history
This isn't saved permanently, just for the session.
  • Loading branch information
mtwebster committed Aug 14, 2020
1 parent 7679525 commit 7a78f34
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ def initialize_rpc_threadpool():
STOP_TRANSFER_BY_RECEIVER \
REMOVE_TRANSFER')

last_location = Gio.File.new_for_path(GLib.get_home_dir())
# A normal GtkFileChooserDialog only lets you pick folders OR files, not
# both in the same dialog. This does.
def create_file_and_folder_picker(dialog_parent=None):
Expand All @@ -86,8 +87,19 @@ def create_file_and_folder_picker(dialog_parent=None):

chooser = Gtk.FileChooserWidget(action=Gtk.FileChooserAction.OPEN,
select_multiple=True)

chooser.set_current_folder_file(last_location)
chooser.connect("file-activated", lambda chooser: window.response(Gtk.ResponseType.ACCEPT))

def update_last_location(dialog, response_id, data=None):
if response_id != Gtk.ResponseType.ACCEPT:
return

global last_location
last_location = chooser.get_current_folder_file()

window.connect("response", update_last_location)

chooser.show_all()
window.get_content_area().add(chooser)
window.get_content_area().set_border_width(0)
Expand Down

0 comments on commit 7a78f34

Please sign in to comment.