diff options
author | Robin Krahl <robin.krahl@ireas.org> | 2019-12-10 20:09:59 +0100 |
---|---|---|
committer | Robin Krahl <robin.krahl@ireas.org> | 2019-12-10 20:09:59 +0100 |
commit | aa8148b958daac4b35173a1d28806b2fdc8609bd (patch) | |
tree | d3c438f91a911f8e4bd0fb96dc833edaac4f21e6 /src/backends/mod.rs | |
parent | 10462c2c9f4ae2ffd3c32dd4628e0052067c15fa (diff) | |
parent | 202c49a327b7a3dc3bfa199da2ac7484ee105f65 (diff) | |
download | dialog-rs-master.tar.gz dialog-rs-master.tar.bz2 |
Diffstat (limited to 'src/backends/mod.rs')
-rw-r--r-- | src/backends/mod.rs | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backends/mod.rs b/src/backends/mod.rs index 5ae3cef..09013b1 100644 --- a/src/backends/mod.rs +++ b/src/backends/mod.rs @@ -2,10 +2,12 @@ // SPDX-License-Identifier: MIT mod dialog; +mod kdialog; mod stdio; mod zenity; pub use crate::backends::dialog::Dialog; +pub use crate::backends::kdialog::KDialog; pub use crate::backends::stdio::Stdio; pub use crate::backends::zenity::Zenity; @@ -21,7 +23,7 @@ use crate::Result; /// backend and create an instance manually. To use a backend, pass it to the [`show_with`][] /// method of a dialog box. /// -/// [`default_backend`]: ../function.default_backend.html +/// [`default_backend`]: ../fn.default_backend.html /// [`show_with`]: ../trait.DialogBox.html#method.show_with pub trait Backend { /// Shows the given input dialog and returns the input. @@ -35,11 +37,14 @@ pub trait Backend { /// Shows the given question dialog and returns the choice. fn show_question(&self, question: &super::Question) -> Result<super::Choice>; + + /// Shows the given file selection dialog and returns the file name. + fn show_file_selection(&self, file_selection: &super::FileSelection) -> Result<Option<String>>; } pub(crate) fn is_available(name: &str) -> bool { if let Ok(path) = env::var("PATH") { - for part in path.split(":") { + for part in path.split(':') { if path::Path::new(part).join(name).exists() { return true; } @@ -51,6 +56,7 @@ pub(crate) fn is_available(name: &str) -> bool { pub(crate) fn from_str(s: &str) -> Option<Box<dyn Backend>> { match s.to_lowercase().as_ref() { "dialog" => Some(Box::new(Dialog::new())), + "kdialog" => Some(Box::new(KDialog::new())), "stdio" => Some(Box::new(Stdio::new())), "zenity" => Some(Box::new(Zenity::new())), _ => None, |