Gtk.jl
Gtk.jl copied to clipboard
Allow specifying current folder and suggesting filenames in file dialogs
-
open_dialog
only supportscurrent_folder
- Suggesting a filename to open seems unlikely to be needed or helpful, but we could still support setting
current_name
if that seems like a more thorough support of these features.
- Suggesting a filename to open seems unlikely to be needed or helpful, but we could still support setting
-
save_dialog
supports both new kwargs
Gtk documentation recommends against setting the current folder due to some heuristics in GtkFileChooser
which are supposed to set sensible/helpful folders, in my experience the dialogs only ever opened to the "Recent" folder.
I tested that all of the combinations of function & kwargs works properly; it doesn't seem like there is any other way to test these features via code?
open_dialog("Select a file"; current_folder=pkgdir(Gtk))
open_dialog("Select a file"; select_multiple=true, current_folder=pkgdir(Gtk))
open_dialog_native("Select a file"; current_folder=pkgdir(Gtk))
save_dialog("Save as..."; current_folder=pkgdir(Gtk))
save_dialog_native("Save as..."; current_folder=pkgdir(Gtk))
save_dialog("Save as..."; current_folder=pkgdir(Gtk), current_name="README.md")
save_dialog_native("Save as..."; current_folder=pkgdir(Gtk), current_name="README.md")
I also added examples to the documentation.
Fixes #500.
Refs: https://developer.gnome.org/gtk3/stable/GtkFileChooser.html#gtk-file-chooser-set-current-name https://developer.gnome.org/gtk3/stable/GtkFileChooser.html#gtk-file-chooser-set-current-folder
Great, could you still add a test, where at least the code is run? In that way at least we can guarantee that the code is runnable.
This seems useful, I was just looking for how to set this. Any chance it can be merged?
:+1: I'll try to get back to this sometime this week.