aboutsummaryrefslogtreecommitdiff
path: root/src/backends/dialog.rs
diff options
context:
space:
mode:
authorReyk Floeter <reyk.floeter@googlemail.com>2019-12-10 15:24:36 +0000
committerRobin Krahl <robin.krahl@ireas.org>2019-12-10 19:56:09 +0100
commit2f3e2b5474834e3d733edf09b831c5607d451f49 (patch)
tree4b94e0e6874ae300f595e8dd9bffd06aec867543 /src/backends/dialog.rs
parent3b76a0a46ce38eef7fe3e5a969cec6ffee47f227 (diff)
downloaddialog-rs-2f3e2b5474834e3d733edf09b831c5607d451f49.tar.gz
dialog-rs-2f3e2b5474834e3d733edf09b831c5607d451f49.tar.bz2
Add FileSelection dialog type
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.
Diffstat (limited to 'src/backends/dialog.rs')
-rw-r--r--src/backends/dialog.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/backends/dialog.rs b/src/backends/dialog.rs
index 8061d98..668cf57 100644
--- a/src/backends/dialog.rs
+++ b/src/backends/dialog.rs
@@ -3,7 +3,7 @@
use std::process;
-use crate::{Choice, Error, Input, Message, Password, Question, Result};
+use crate::{Choice, Error, FileSelection, Input, Message, Password, Question, Result};
/// The `dialog` backend.
///
@@ -160,4 +160,11 @@ impl super::Backend for Dialog {
self.execute(args, vec![], &question.title)
.and_then(|output| get_choice(output.status))
}
+
+ fn show_file_selection(&self, file_selection: &FileSelection) -> Result<Option<String>> {
+ let dir = file_selection.path_to_string().ok_or("path not valid")?;
+ let args = vec!["--fselect", &dir];
+ self.execute(args, vec![], &file_selection.title)
+ .and_then(get_stderr)
+ }
}