Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Allow specifying current folder and suggesting filenames in file dialogs #501

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

halleysfifthinc
Copy link

@halleysfifthinc halleysfifthinc commented Apr 14, 2020

  • 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

@tknopp
Copy link
Collaborator

tknopp commented Apr 22, 2020

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.

@bilderbuchi
Copy link

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

@halleysfifthinc
Copy link
Author

👍 I'll try to get back to this sometime this week.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow setting current_name/folder in save_dialog
3 participants