aboutsummaryrefslogtreecommitdiff
path: root/src/backends/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/backends/mod.rs')
-rw-r--r--src/backends/mod.rs10
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,