From 270a17cd86eff991fadfb7129b0d833e93391473 Mon Sep 17 00:00:00 2001 From: James Date: Sun, 23 Jun 2019 22:28:41 +1000 Subject: [PATCH] Use patched web-view to fix dialogs, remove nfd --- Cargo.lock | 28 ++++++---------------------- Cargo.toml | 5 +---- src/frontend/ui/mod.rs | 25 ++++++++----------------- src/main.rs | 3 --- static/js/views.js | 2 ++ 5 files changed, 17 insertions(+), 46 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13082ef..37b48a9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -446,11 +446,6 @@ dependencies = [ "num_cpus 1.10.1 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "gcc" -version = "0.3.55" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "h2" version = "0.1.24" @@ -637,7 +632,6 @@ dependencies = [ "hyper 0.11.27 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "mime_guess 1.8.7 (registry+https://github.com/rust-lang/crates.io-index)", - "nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "number_prefix 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.7 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", @@ -651,7 +645,7 @@ dependencies = [ "toml 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)", "walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "web-view 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", + "web-view 0.4.1 (git+https://github.com/j-selby/web-view.git?rev=752106e4637356cbdb39a0bf1113ea3ae8a14243)", "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "winres 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)", "xz2 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -830,14 +824,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nfd" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nodrop" version = "0.1.13" @@ -1911,17 +1897,17 @@ dependencies = [ [[package]] name = "web-view" version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/j-selby/web-view.git?rev=752106e4637356cbdb39a0bf1113ea3ae8a14243#752106e4637356cbdb39a0bf1113ea3ae8a14243" dependencies = [ "boxfnonce 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "urlencoding 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)", - "webview-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "webview-sys 0.1.2 (git+https://github.com/j-selby/web-view.git?rev=752106e4637356cbdb39a0bf1113ea3ae8a14243)", ] [[package]] name = "webview-sys" version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/j-selby/web-view.git?rev=752106e4637356cbdb39a0bf1113ea3ae8a14243#752106e4637356cbdb39a0bf1113ea3ae8a14243" dependencies = [ "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2067,7 +2053,6 @@ dependencies = [ "checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" "checksum futures 0.1.27 (registry+https://github.com/rust-lang/crates.io-index)" = "a2037ec1c6c1c4f79557762eab1f7eae1f64f6cb418ace90fae88f0942b60139" "checksum futures-cpupool 0.1.8 (registry+https://github.com/rust-lang/crates.io-index)" = "ab90cde24b3319636588d0c35fe03b1333857621051837ed769faefb4c2162e4" -"checksum gcc 0.3.55 (registry+https://github.com/rust-lang/crates.io-index)" = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" "checksum h2 0.1.24 (registry+https://github.com/rust-lang/crates.io-index)" = "69b2a5a3092cbebbc951fe55408402e696ee2ed09019137d1800fc2c411265d2" "checksum http 0.1.17 (registry+https://github.com/rust-lang/crates.io-index)" = "eed324f0f0daf6ec10c474f150505af2c143f251722bf9dbd1261bd1f2ee2c1a" "checksum http-body 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "6741c859c1b2463a423a1dbce98d418e6c3c3fc720fb0d45528657320920292d" @@ -2102,7 +2087,6 @@ dependencies = [ "checksum miow 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum nfd 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8e752e3c216bc8a491c5b59fa46da10f1379ae450b19ac688e07f4bb55042e98" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum num-integer 0.1.41 (registry+https://github.com/rust-lang/crates.io-index)" = "b85e541ef8255f6cf42bbfe4ef361305c6c135d10919ecc26126c4e5ae94bc09" "checksum num-traits 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "6ba9a427cfca2be13aa6f6403b0b7e7368fe982bfa16fccc450ce74c46cd9b32" @@ -2223,8 +2207,8 @@ dependencies = [ "checksum walkdir 2.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "c7904a7e2bb3cdf0cf5e783f44204a85a37a93151738fa349f06680f59a98b45" "checksum want 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "a05d9d966753fa4b5c8db73fcab5eed4549cfe0e1e4e66911e5564a0085c35d1" "checksum want 0.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "797464475f30ddb8830cc529aaaae648d581f99e2036a928877dfde027ddf6b3" -"checksum web-view 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7113d87bfc9396b85b5c64849c53fd55131e7cd7e28b5b4bf36b17097f1a34bb" -"checksum webview-sys 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "db7ae5bc4fd671b1e5916fcf2ae72b2f265356c4b2f16ecce6361bdae5c5d037" +"checksum web-view 0.4.1 (git+https://github.com/j-selby/web-view.git?rev=752106e4637356cbdb39a0bf1113ea3ae8a14243)" = "" +"checksum webview-sys 0.1.2 (git+https://github.com/j-selby/web-view.git?rev=752106e4637356cbdb39a0bf1113ea3ae8a14243)" = "" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" "checksum winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)" = "f10e386af2b13e47c89e7236a7a14a086791a2b88ebad6df9bf42040195cf770" "checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml index 44fee18..5c71c4d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ description = "An adaptable installer for your application." build = "build.rs" [dependencies] -web-view = "0.4.0" +web-view = {git = "https://github.com/j-selby/web-view.git", rev = "752106e4637356cbdb39a0bf1113ea3ae8a14243"} hyper = "0.11.27" futures = "0.1.25" @@ -45,9 +45,6 @@ serde_derive = "1.0.89" toml = "0.5.0" [target.'cfg(windows)'.dependencies] -# NFD is needed on Windows, as web-view doesn't work correctly here -nfd = "0.0.4" - winapi = { version = "0.3", features = ["psapi", "winbase", "winioctl", "winnt"] } [target.'cfg(not(windows))'.dependencies] diff --git a/src/frontend/ui/mod.rs b/src/frontend/ui/mod.rs index be36d3c..d18e359 100644 --- a/src/frontend/ui/mod.rs +++ b/src/frontend/ui/mod.rs @@ -4,8 +4,6 @@ use web_view::Content; -use nfd::Response; - use logging::LoggingErrors; use log::Level; @@ -38,25 +36,18 @@ pub fn start_ui(app_name: &str, http_address: &str, is_launcher: bool) { match command { CallbackType::SelectInstallDir { callback_name } => { - #[cfg(windows)] - let result = match nfd::open_pick_folder(None) - .log_expect("Unable to open folder dialog") - { - Response::Okay(v) => Ok(v), - _ => Err(()), - }; - - #[cfg(not(windows))] let result = wv .dialog() .choose_directory("Select a install directory...", ""); - if result.is_ok() { - let result = serde_json::to_string(&result.ok()) - .log_expect("Unable to serialize response"); - let command = format!("{}({});", callback_name, result); - debug!("Injecting response: {}", command); - cb_result = wv.eval(&command); + if let Ok(Some(new_path)) = result { + if new_path.to_string_lossy().len() > 0 { + let result = serde_json::to_string(&new_path) + .log_expect("Unable to serialize response"); + let command = format!("{}({});", callback_name, result); + debug!("Injecting response: {}", command); + cb_result = wv.eval(&command); + } } } CallbackType::Log { msg, kind } => { diff --git a/src/main.rs b/src/main.rs index ca2ba2d..d34f12d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,9 +7,6 @@ #![deny(unsafe_code)] #![deny(missing_docs)] -#[cfg(windows)] -extern crate nfd; - extern crate web_view; extern crate futures; diff --git a/static/js/views.js b/static/js/views.js index 7766970..764c2b1 100644 --- a/static/js/views.js +++ b/static/js/views.js @@ -84,6 +84,8 @@ const DownloadConfig = { ajax("/api/default-path", function(e) { if (e.path != null) { app.install_location = e.path; + } else { + console.warn("App location received is empty!"); } });