diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-12-10 20:02:59 +0100 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-12-10 20:02:59 +0100 |
commit | e152b4f4b6aa274774d1c750c3106528ebd4f1d4 (patch) | |
tree | f23e994a66ec562685ca44caa6ba939de34acdf1 /src/backends/kdialog.rs | |
parent | 3b76a0a46ce38eef7fe3e5a969cec6ffee47f227 (diff) | |
parent | 89afcb4844dd484f0c9cdfef7e5ff8d751647c43 (diff) | |
download | dialog-rs-e152b4f4b6aa274774d1c750c3106528ebd4f1d4.tar.gz dialog-rs-e152b4f4b6aa274774d1c750c3106528ebd4f1d4.tar.bz2 |
Merge branch 'file-selection' into next
This patch series introduces a new FileSelection dialog type, see [0].
[0] https://lists.sr.ht/~ireas/dialog-rs-dev/%3C20191203122011.GA64086%40kunshan.atexit.net%3E
Diffstat (limited to 'src/backends/kdialog.rs')
-rw-r--r-- | src/backends/kdialog.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/backends/kdialog.rs b/src/backends/kdialog.rs index c2ddcd0..21928f8 100644 --- a/src/backends/kdialog.rs +++ b/src/backends/kdialog.rs @@ -4,7 +4,9 @@ use std::process; -use crate::{Choice, Error, Input, Message, Password, Question, Result}; +use crate::{ + Choice, Error, FileSelection, FileSelectionMode, Input, Message, Password, Question, Result, +}; /// Subprocess exit codes /// @@ -136,4 +138,15 @@ impl super::Backend for KDialog { self.execute(args, &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 option = match file_selection.mode { + FileSelectionMode::Open => "--getopenfilename", + FileSelectionMode::Save => "--getsavefilename", + }; + let args = vec![option, &dir]; + self.execute(args, &file_selection.title) + .and_then(get_stdout) + } } |