diff options
author | OJ Kwon <kwon.ohjoong@gmail.com> | 2018-03-30 12:06:31 -0700 |
---|---|---|
committer | OJ Kwon <kwon.ohjoong@gmail.com> | 2018-04-27 12:21:18 -0700 |
commit | f69b12444471937245bdde0dc54782e7296dc1ae (patch) | |
tree | abffcf543367c238866299fd756d3c99c976d6b7 /components/net/filemanager_thread.rs | |
parent | 4125b54c0d1e27ad5090e246d1c877adc5b335b0 (diff) | |
download | servo-f69b12444471937245bdde0dc54782e7296dc1ae.tar.gz servo-f69b12444471937245bdde0dc54782e7296dc1ae.zip |
refactor(filemanager): remove awareness to ui behavior
Diffstat (limited to 'components/net/filemanager_thread.rs')
-rw-r--r-- | components/net/filemanager_thread.rs | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/components/net/filemanager_thread.rs b/components/net/filemanager_thread.rs index bc433895ba9..97807f3f01e 100644 --- a/components/net/filemanager_thread.rs +++ b/components/net/filemanager_thread.rs @@ -21,71 +21,9 @@ use std::sync::atomic::{self, AtomicBool, AtomicUsize, Ordering}; use std::sync::mpsc::Sender; use std::thread; #[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))] -use tinyfiledialogs; use url::Url; use uuid::Uuid; -/// The provider of file-dialog UI should implement this trait. -/// It will be used to initialize a generic FileManager. -/// For example, we can choose a dummy UI for testing purpose. -pub trait UIProvider where Self: Sync { - fn open_file_dialog(&self, path: &str, patterns: Vec<FilterPattern>) -> Option<String>; - - fn open_file_dialog_multi(&self, path: &str, patterns: Vec<FilterPattern>) -> Option<Vec<String>>; -} - -pub struct TFDProvider; - -impl UIProvider for TFDProvider { - #[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))] - fn open_file_dialog(&self, path: &str, patterns: Vec<FilterPattern>) -> Option<String> { - if opts::get().headless { - return None; - } - - let mut filter = vec![]; - for p in patterns { - let s = "*.".to_string() + &p.0; - filter.push(s) - } - - let filter_ref = &(filter.iter().map(|s| s.as_str()).collect::<Vec<&str>>()[..]); - - let filter_opt = if filter.len() > 0 { Some((filter_ref, "")) } else { None }; - - tinyfiledialogs::open_file_dialog("Pick a file", path, filter_opt) - } - - #[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))] - fn open_file_dialog_multi(&self, path: &str, patterns: Vec<FilterPattern>) -> Option<Vec<String>> { - if opts::get().headless { - return None; - } - - let mut filter = vec![]; - for p in patterns { - let s = "*.".to_string() + &p.0; - filter.push(s) - } - - let filter_ref = &(filter.iter().map(|s| s.as_str()).collect::<Vec<&str>>()[..]); - - let filter_opt = if filter.len() > 0 { Some((filter_ref, "")) } else { None }; - - tinyfiledialogs::open_file_dialog_multi("Pick files", path, filter_opt) - } - - #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] - fn open_file_dialog(&self, _path: &str, _patterns: Vec<FilterPattern>) -> Option<String> { - None - } - - #[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))] - fn open_file_dialog_multi(&self, _path: &str, _patterns: Vec<FilterPattern>) -> Option<Vec<String>> { - None - } -} - /// FileManagerStore's entry struct FileStoreEntry { /// Origin of the entry's "creator" |