From a23de9787bccde4b6244312f04cb7cfc3b528db6 Mon Sep 17 00:00:00 2001 From: Stephan Sokolow Date: Thu, 24 Oct 2019 20:36:42 -0400 Subject: Add a backend based on KDE's `kdialog` --- examples/backend-kdialog.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 examples/backend-kdialog.rs (limited to 'examples') 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 +// 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) +} -- cgit v1.2.1 From 2f3e2b5474834e3d733edf09b831c5607d451f49 Mon Sep 17 00:00:00 2001 From: Reyk Floeter Date: Tue, 10 Dec 2019 15:24:36 +0000 Subject: Add FileSelection dialog type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds the FileSelection struct representing a file selection dialog. It can be displayed using the backend’s show_file_selection function. Currently, we only support file open dialogs (i. e. choosing an existing file). Support for save dialogs should be added in the future. --- examples/file_selection.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 examples/file_selection.rs (limited to 'examples') diff --git a/examples/file_selection.rs b/examples/file_selection.rs new file mode 100644 index 0000000..5436742 --- /dev/null +++ b/examples/file_selection.rs @@ -0,0 +1,13 @@ +// Copyright (C) 2019 Robin Krahl +// SPDX-License-Identifier: MIT + +use dialog::DialogBox; + +fn main() -> dialog::Result<()> { + let choice = dialog::FileSelection::new("Please select a file") + .title("File Chooser Example") + .path("/etc") + .show()?; + println!("The user chose: {:?}", choice); + Ok(()) +} -- cgit v1.2.1 From 89afcb4844dd484f0c9cdfef7e5ff8d751647c43 Mon Sep 17 00:00:00 2001 From: Robin Krahl Date: Tue, 10 Dec 2019 18:46:44 +0000 Subject: Add Open/Save mode to the file selection dialog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds the option to set a FileSelectionMode, either Open or Save. Not all backends might support this – currently, only zenity and kdialog do. Per default, the Open mode is used (as before). --- examples/file_selection.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/file_selection.rs b/examples/file_selection.rs index 5436742..5d2d860 100644 --- a/examples/file_selection.rs +++ b/examples/file_selection.rs @@ -5,9 +5,17 @@ use dialog::DialogBox; fn main() -> dialog::Result<()> { let choice = dialog::FileSelection::new("Please select a file") - .title("File Chooser Example") + .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(()) } -- cgit v1.2.1