mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Support tinyfiledialogs on Windows
This commit is contained in:
parent
521f8c0135
commit
06142b37b8
9 changed files with 22 additions and 21 deletions
|
@ -46,5 +46,5 @@ git = "https://github.com/servo/webrender_traits"
|
|||
default_features = false
|
||||
features = ["serde_macros"]
|
||||
|
||||
[target.'cfg(any(target_os = "macos", target_os = "linux"))'.dependencies]
|
||||
[target.'cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))'.dependencies]
|
||||
tinyfiledialogs = {git = "https://github.com/jdm/tinyfiledialogs"}
|
||||
|
|
|
@ -14,7 +14,7 @@ use std::ops::Index;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::sync::atomic::{self, AtomicUsize, AtomicBool, Ordering};
|
||||
use std::sync::{Arc, RwLock};
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
use tinyfiledialogs;
|
||||
use url::Url;
|
||||
use util::prefs::PREFS;
|
||||
|
@ -37,7 +37,7 @@ pub trait UIProvider where Self: Sync {
|
|||
pub struct TFDProvider;
|
||||
|
||||
impl UIProvider for TFDProvider {
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
fn open_file_dialog(&self, path: &str, patterns: Vec<FilterPattern>) -> Option<String> {
|
||||
let mut filter = vec![];
|
||||
for p in patterns {
|
||||
|
@ -52,7 +52,7 @@ impl UIProvider for TFDProvider {
|
|||
tinyfiledialogs::open_file_dialog("Pick a file", path, filter_opt)
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
#[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>> {
|
||||
let mut filter = vec![];
|
||||
for p in patterns {
|
||||
|
@ -67,13 +67,13 @@ impl UIProvider for TFDProvider {
|
|||
tinyfiledialogs::open_file_dialog_multi("Pick files", path, filter_opt)
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
|
||||
fn open_file_dialog(&self, path: &str, patterns: Vec<FilterPattern>) -> Option<String> {
|
||||
#[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")))]
|
||||
fn open_file_dialog_multi(&self, path: &str, patterns: Vec<FilterPattern>) -> Option<Vec<String>> {
|
||||
#[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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ use std::sync::mpsc::Sender;
|
|||
use std::sync::{Arc, RwLock};
|
||||
use time;
|
||||
use time::Tm;
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
use tinyfiledialogs;
|
||||
use url::{Url, Position};
|
||||
use util::prefs::PREFS;
|
||||
|
@ -843,13 +843,13 @@ pub trait UIProvider {
|
|||
}
|
||||
|
||||
impl UIProvider for TFDProvider {
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
fn input_username_and_password(&self, prompt: &str) -> (Option<String>, Option<String>) {
|
||||
(tinyfiledialogs::input_box(prompt, "Username:", ""),
|
||||
tinyfiledialogs::input_box(prompt, "Password:", ""))
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux")))]
|
||||
#[cfg(not(any(target_os = "macos", target_os = "linux", target_os = "windows")))]
|
||||
fn input_username_and_password(&self, _prompt: &str) -> (Option<String>, Option<String>) {
|
||||
(None, None)
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ extern crate rand;
|
|||
extern crate rustc_serialize;
|
||||
extern crate threadpool;
|
||||
extern crate time;
|
||||
#[cfg(any(target_os = "macos", target_os = "linux"))]
|
||||
#[cfg(any(target_os = "macos", target_os = "linux", target_os = "windows"))]
|
||||
extern crate tinyfiledialogs;
|
||||
extern crate unicase;
|
||||
extern crate url;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue