You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to use the save_file API with a default directory and file_name but the GTK usage is wrong, it doesn't work when the file already exists. I've adapted the save example to test this:
#[cfg(not(target_arch = "wasm32"))]fnmain(){let path = std::env::current_dir().unwrap().join("examples");let res = rfd::FileDialog::new().set_file_name("async.rs").set_directory(&path).save_file();println!("The user choose: {:#?}", res);}#[cfg(target_arch = "wasm32")]fnmain(){// On wasm only async dialogs are possible}
If I remove the set_file_name call, at least it changes to the examples folder.
Same thing applies to the pick_file APIs. The following example doesn't work:
#[cfg(not(target_arch = "wasm32"))]fnmain(){let path = std::env::current_dir().unwrap().join("examples");let res = rfd::FileDialog::new().add_filter("text",&["txt","rs"]).add_filter("rust",&["rs","toml"]).set_directory(&path).set_file_name("async.rs").pick_file();println!("The user choose: {:#?}", res);}#[cfg(target_arch = "wasm32")]fnmain(){// On wasm only async dialogs are possible}
But it does work if I remove the set_directory call and use .set_file_name(&path.join("async.rs").display().to_string()) instead. Which makes sense if you read the GTK documentation for gtk_file_chooser_set_filename.
In short, I think I could get along with the current API if we could expose set_current_name (only available on Linux). Let me know what you think about this.
Thanks in advance! I love this crate.
The text was updated successfully, but these errors were encountered:
I'm trying to use the
save_file
API with a default directory and file_name but the GTK usage is wrong, it doesn't work when the file already exists. I've adapted thesave
example to test this:If I remove the
set_file_name
call, at least it changes to theexamples
folder.Same thing applies to the
pick_file
APIs. The following example doesn't work:But it does work if I remove the
set_directory
call and use.set_file_name(&path.join("async.rs").display().to_string())
instead. Which makes sense if you read the GTK documentation forgtk_file_chooser_set_filename
.In short, I think I could get along with the current API if we could expose
set_current_name
(only available on Linux). Let me know what you think about this.Thanks in advance! I love this crate.
The text was updated successfully, but these errors were encountered: