Use last selected directory when using default file name in dialog.showSaveDialog()

Prior to this change, attempting to use
`dialog.showSaveDialog({ defaultPath: 'foo.png' })` would open the save
dialog to the current directory with the default file name set to
`foo.png`. We now use the last selected directory instead of the current
directory.

Absolute paths are not affected by this change.
This commit is contained in:
Birunthan Mohanathas 2017-05-26 02:11:58 +03:00
parent fea165bef8
commit 19555bbab2
4 changed files with 16 additions and 6 deletions

View file

@ -72,8 +72,12 @@ class FileChooserDialog {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog_),
settings.default_path.value().c_str());
} else {
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog_),
settings.default_path.DirName().value().c_str());
if (settings.default_path.IsAbsolute()) {
gtk_file_chooser_set_current_folder(
GTK_FILE_CHOOSER(dialog_),
settings.default_path.DirName().value().c_str());
}
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog_),
settings.default_path.BaseName().value().c_str());
}