Gtk.jl icon indicating copy to clipboard operation
Gtk.jl copied to clipboard

Allow specifying current folder and suggesting filenames in file dialogs

Open halleysfifthinc opened this issue 4 years ago • 3 comments

  • open_dialog only supports current_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.
  • 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

halleysfifthinc avatar Apr 14 '20 23:04 halleysfifthinc

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.

tknopp avatar Apr 22 '20 19:04 tknopp

This seems useful, I was just looking for how to set this. Any chance it can be merged?

bilderbuchi avatar Feb 06 '23 14:02 bilderbuchi

:+1: I'll try to get back to this sometime this week.

halleysfifthinc avatar Feb 06 '23 15:02 halleysfifthinc