pub struct FileDialogBuilder {
pub filename: Option<String>,
pub location: Option<PathBuf>,
pub filters: Vec<Filter>,
pub owner: UnsafeWindowHandle,
pub title: Option<String>,
}Expand description
Builder for file dialogs.
Fields§
§filename: Option<String>§location: Option<PathBuf>§filters: Vec<Filter>§owner: UnsafeWindowHandle§title: Option<String>Implementations§
Source§impl FileDialogBuilder
impl FileDialogBuilder
Sourcepub fn set_filename(self, filename: impl ToString) -> Self
pub fn set_filename(self, filename: impl ToString) -> Self
Sets the default value of the filename text field in the dialog. For open dialogs of macOS and zenity, this is a no-op because there’s no such text field on the dialog.
Sourcepub fn reset_filename(self) -> Self
pub fn reset_filename(self) -> Self
Resets the default value of the filename field in the dialog.
Sourcepub fn set_location<P: AsRef<Path> + ?Sized>(self, path: &P) -> Self
pub fn set_location<P: AsRef<Path> + ?Sized>(self, path: &P) -> Self
Sets the default directory that the dialog shows at open.
Examples found in repository?
12fn main() {
13 let result = DialogBuilder::message()
14 .set_title("Tour")
15 .set_text("Do you want to begin the tour?")
16 .set_level(MessageLevel::Warning)
17 .confirm()
18 .show()
19 .unwrap();
20 if !result {
21 return;
22 }
23 echo("show_confirm", &result);
24
25 let result = DialogBuilder::file()
26 .set_location("~")
27 .open_single_file()
28 .show()
29 .unwrap();
30 echo("show_open_single_file", &result);
31
32 let result = DialogBuilder::file()
33 .add_filter("Rust Source", &["rs"])
34 .add_filter("Image", &["png", "jpg", "gif"])
35 .open_multiple_file()
36 .show()
37 .unwrap();
38 echo("show_open_multiple_file", &result);
39
40 let result = DialogBuilder::file().open_single_dir().show().unwrap();
41 echo("show_open_single_dir", &result);
42
43 let result = DialogBuilder::file()
44 .add_filter("Rust Source", &["rs"])
45 .add_filter("Image", &["png", "jpg", "gif"])
46 .save_single_file()
47 .show()
48 .unwrap();
49 echo("show_save_single_file", &result);
50
51 DialogBuilder::message()
52 .set_title("End")
53 .set_text("That's the end!")
54 .alert()
55 .show()
56 .unwrap();
57}Sourcepub fn reset_location(self) -> Self
pub fn reset_location(self) -> Self
Resets the default directory that the dialog shows at open. If a location is not set, the dialog will probably go to the current working directory.
Sourcepub fn add_filter(
self,
description: impl ToString,
extensions: &[impl ToString],
) -> Self
pub fn add_filter( self, description: impl ToString, extensions: &[impl ToString], ) -> Self
Adds a file type filter. The filter must contains at least one extension, otherwise this method will be a no-op. For dialogs that open directories, this is also a no-op.
Examples found in repository?
12fn main() {
13 let result = DialogBuilder::message()
14 .set_title("Tour")
15 .set_text("Do you want to begin the tour?")
16 .set_level(MessageLevel::Warning)
17 .confirm()
18 .show()
19 .unwrap();
20 if !result {
21 return;
22 }
23 echo("show_confirm", &result);
24
25 let result = DialogBuilder::file()
26 .set_location("~")
27 .open_single_file()
28 .show()
29 .unwrap();
30 echo("show_open_single_file", &result);
31
32 let result = DialogBuilder::file()
33 .add_filter("Rust Source", &["rs"])
34 .add_filter("Image", &["png", "jpg", "gif"])
35 .open_multiple_file()
36 .show()
37 .unwrap();
38 echo("show_open_multiple_file", &result);
39
40 let result = DialogBuilder::file().open_single_dir().show().unwrap();
41 echo("show_open_single_dir", &result);
42
43 let result = DialogBuilder::file()
44 .add_filter("Rust Source", &["rs"])
45 .add_filter("Image", &["png", "jpg", "gif"])
46 .save_single_file()
47 .show()
48 .unwrap();
49 echo("show_save_single_file", &result);
50
51 DialogBuilder::message()
52 .set_title("End")
53 .set_text("That's the end!")
54 .alert()
55 .show()
56 .unwrap();
57}Sourcepub fn reset_filters(self) -> Self
pub fn reset_filters(self) -> Self
Removes all file type filters.
Sourcepub fn set_owner<W: HasWindowHandle>(self, window: &W) -> Self
pub fn set_owner<W: HasWindowHandle>(self, window: &W) -> Self
Sets the owner of the dialog.
Sourcepub fn reset_owner(self) -> Self
pub fn reset_owner(self) -> Self
Resets the owner of the dialog to nothing.
Sourcepub fn open_single_file(self) -> OpenSingleFile
pub fn open_single_file(self) -> OpenSingleFile
Builds a dialog that let users to open one file.
Examples found in repository?
12fn main() {
13 let result = DialogBuilder::message()
14 .set_title("Tour")
15 .set_text("Do you want to begin the tour?")
16 .set_level(MessageLevel::Warning)
17 .confirm()
18 .show()
19 .unwrap();
20 if !result {
21 return;
22 }
23 echo("show_confirm", &result);
24
25 let result = DialogBuilder::file()
26 .set_location("~")
27 .open_single_file()
28 .show()
29 .unwrap();
30 echo("show_open_single_file", &result);
31
32 let result = DialogBuilder::file()
33 .add_filter("Rust Source", &["rs"])
34 .add_filter("Image", &["png", "jpg", "gif"])
35 .open_multiple_file()
36 .show()
37 .unwrap();
38 echo("show_open_multiple_file", &result);
39
40 let result = DialogBuilder::file().open_single_dir().show().unwrap();
41 echo("show_open_single_dir", &result);
42
43 let result = DialogBuilder::file()
44 .add_filter("Rust Source", &["rs"])
45 .add_filter("Image", &["png", "jpg", "gif"])
46 .save_single_file()
47 .show()
48 .unwrap();
49 echo("show_save_single_file", &result);
50
51 DialogBuilder::message()
52 .set_title("End")
53 .set_text("That's the end!")
54 .alert()
55 .show()
56 .unwrap();
57}Sourcepub fn open_multiple_file(self) -> OpenMultipleFile
pub fn open_multiple_file(self) -> OpenMultipleFile
Builds a dialog that let users to open multiple files.
Examples found in repository?
12fn main() {
13 let result = DialogBuilder::message()
14 .set_title("Tour")
15 .set_text("Do you want to begin the tour?")
16 .set_level(MessageLevel::Warning)
17 .confirm()
18 .show()
19 .unwrap();
20 if !result {
21 return;
22 }
23 echo("show_confirm", &result);
24
25 let result = DialogBuilder::file()
26 .set_location("~")
27 .open_single_file()
28 .show()
29 .unwrap();
30 echo("show_open_single_file", &result);
31
32 let result = DialogBuilder::file()
33 .add_filter("Rust Source", &["rs"])
34 .add_filter("Image", &["png", "jpg", "gif"])
35 .open_multiple_file()
36 .show()
37 .unwrap();
38 echo("show_open_multiple_file", &result);
39
40 let result = DialogBuilder::file().open_single_dir().show().unwrap();
41 echo("show_open_single_dir", &result);
42
43 let result = DialogBuilder::file()
44 .add_filter("Rust Source", &["rs"])
45 .add_filter("Image", &["png", "jpg", "gif"])
46 .save_single_file()
47 .show()
48 .unwrap();
49 echo("show_save_single_file", &result);
50
51 DialogBuilder::message()
52 .set_title("End")
53 .set_text("That's the end!")
54 .alert()
55 .show()
56 .unwrap();
57}Sourcepub fn open_single_dir(self) -> OpenSingleDir
pub fn open_single_dir(self) -> OpenSingleDir
Builds a dialog that let users to open one directory.
Examples found in repository?
12fn main() {
13 let result = DialogBuilder::message()
14 .set_title("Tour")
15 .set_text("Do you want to begin the tour?")
16 .set_level(MessageLevel::Warning)
17 .confirm()
18 .show()
19 .unwrap();
20 if !result {
21 return;
22 }
23 echo("show_confirm", &result);
24
25 let result = DialogBuilder::file()
26 .set_location("~")
27 .open_single_file()
28 .show()
29 .unwrap();
30 echo("show_open_single_file", &result);
31
32 let result = DialogBuilder::file()
33 .add_filter("Rust Source", &["rs"])
34 .add_filter("Image", &["png", "jpg", "gif"])
35 .open_multiple_file()
36 .show()
37 .unwrap();
38 echo("show_open_multiple_file", &result);
39
40 let result = DialogBuilder::file().open_single_dir().show().unwrap();
41 echo("show_open_single_dir", &result);
42
43 let result = DialogBuilder::file()
44 .add_filter("Rust Source", &["rs"])
45 .add_filter("Image", &["png", "jpg", "gif"])
46 .save_single_file()
47 .show()
48 .unwrap();
49 echo("show_save_single_file", &result);
50
51 DialogBuilder::message()
52 .set_title("End")
53 .set_text("That's the end!")
54 .alert()
55 .show()
56 .unwrap();
57}Sourcepub fn save_single_file(self) -> SaveSingleFile
pub fn save_single_file(self) -> SaveSingleFile
Builds a dialog that let users to save one file.
Examples found in repository?
12fn main() {
13 let result = DialogBuilder::message()
14 .set_title("Tour")
15 .set_text("Do you want to begin the tour?")
16 .set_level(MessageLevel::Warning)
17 .confirm()
18 .show()
19 .unwrap();
20 if !result {
21 return;
22 }
23 echo("show_confirm", &result);
24
25 let result = DialogBuilder::file()
26 .set_location("~")
27 .open_single_file()
28 .show()
29 .unwrap();
30 echo("show_open_single_file", &result);
31
32 let result = DialogBuilder::file()
33 .add_filter("Rust Source", &["rs"])
34 .add_filter("Image", &["png", "jpg", "gif"])
35 .open_multiple_file()
36 .show()
37 .unwrap();
38 echo("show_open_multiple_file", &result);
39
40 let result = DialogBuilder::file().open_single_dir().show().unwrap();
41 echo("show_open_single_dir", &result);
42
43 let result = DialogBuilder::file()
44 .add_filter("Rust Source", &["rs"])
45 .add_filter("Image", &["png", "jpg", "gif"])
46 .save_single_file()
47 .show()
48 .unwrap();
49 echo("show_save_single_file", &result);
50
51 DialogBuilder::message()
52 .set_title("End")
53 .set_text("That's the end!")
54 .alert()
55 .show()
56 .unwrap();
57}Trait Implementations§
Source§impl Clone for FileDialogBuilder
impl Clone for FileDialogBuilder
Source§fn clone(&self) -> FileDialogBuilder
fn clone(&self) -> FileDialogBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FileDialogBuilder
impl Debug for FileDialogBuilder
Source§impl Default for FileDialogBuilder
impl Default for FileDialogBuilder
Source§fn default() -> FileDialogBuilder
fn default() -> FileDialogBuilder
Auto Trait Implementations§
impl Freeze for FileDialogBuilder
impl RefUnwindSafe for FileDialogBuilder
impl Send for FileDialogBuilder
impl Sync for FileDialogBuilder
impl Unpin for FileDialogBuilder
impl UnwindSafe for FileDialogBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more