aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/backend-kdialog.rs18
-rw-r--r--examples/file_selection.rs21
2 files changed, 39 insertions, 0 deletions
diff --git a/examples/backend-kdialog.rs b/examples/backend-kdialog.rs
new file mode 100644
index 0000000..5c3fb46
--- /dev/null
+++ b/examples/backend-kdialog.rs
@@ -0,0 +1,18 @@
+// Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
+// SPDX-License-Identifier: MIT
+
+use dialog::backends;
+use dialog::DialogBox;
+
+fn main() -> dialog::Result<()> {
+ let mut backend = backends::KDialog::new();
+
+ dialog::Message::new("This is a message.")
+ .title("And this is a title:")
+ .show_with(&backend)?;
+
+ backend.set_icon("error");
+ dialog::Message::new("This is an error message.")
+ .title("Error")
+ .show_with(&backend)
+}
diff --git a/examples/file_selection.rs b/examples/file_selection.rs
new file mode 100644
index 0000000..5d2d860
--- /dev/null
+++ b/examples/file_selection.rs
@@ -0,0 +1,21 @@
+// Copyright (C) 2019 Robin Krahl <robin.krahl@ireas.org>
+// SPDX-License-Identifier: MIT
+
+use dialog::DialogBox;
+
+fn main() -> dialog::Result<()> {
+ let choice = dialog::FileSelection::new("Please select a file")
+ .title("File Chooser Example (Open)")
+ .path("/etc")
+ .show()?;
+ println!("The user chose: {:?}", choice);
+
+ let choice = dialog::FileSelection::new("Please select a file")
+ .title("File Chooser Example (Save)")
+ .mode(dialog::FileSelectionMode::Save)
+ .path("/etc")
+ .show()?;
+ println!("The user chose: {:?}", choice);
+
+ Ok(())
+}