From d80a10299588dcf87ed15daa45afef4c66544fc1 Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Tue, 3 Jul 2018 11:27:44 +0100 Subject: [PATCH] :lipstick: --- build.rs | 18 ++++++++---------- src/gui.rs | 22 ++++++++++++++-------- src/main.rs | 3 ++- src/resources.rs | 7 ++++++- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/build.rs b/build.rs index aa7b5bb..9ab4ab5 100644 --- a/build.rs +++ b/build.rs @@ -2,18 +2,16 @@ use std::process::Command; fn main() { let mut rc = Command::new(".\\tools\\rc.exe") - .arg("/r") - .arg("/fo") - .arg(".\\resources\\resources.lib") - .arg(".\\resources\\resources.rc") - .spawn() - .expect("Failed to spawn resource compiler"); + .arg("/r") + .arg("/fo") + .arg(".\\resources\\resources.lib") + .arg(".\\resources\\resources.rc") + .spawn() + .expect("Failed to spawn resource compiler"); - let ecode = rc - .wait() - .expect("Failed to wait on resource compiler"); + let ecode = rc.wait().expect("Failed to wait on resource compiler"); assert!(ecode.success(), "Resource compiler failed"); println!("cargo:rustc-link-lib=static=.\\resources\\resources"); -} \ No newline at end of file +} diff --git a/src/gui.rs b/src/gui.rs index 3caa881..b1ec733 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -3,14 +3,13 @@ * Licensed under the MIT License. See LICENSE in the project root for license information. *----------------------------------------------------------------------------------------*/ -use std::{mem, ptr}; use std::sync::mpsc::Sender; +use std::{mem, ptr}; use strings::to_utf16; use winapi::shared::basetsd::INT_PTR; use winapi::shared::minwindef::{BOOL, DWORD, LPARAM, UINT, WPARAM}; use winapi::shared::ntdef::LPCWSTR; use winapi::shared::windef::HWND; -use winapi::um::libloaderapi::GetModuleHandleW; extern "system" { pub fn ShutdownBlockReasonCreate(hWnd: HWND, pwszReason: LPCWSTR) -> BOOL; @@ -25,10 +24,12 @@ struct DialogData { unsafe extern "system" fn dlgproc(hwnd: HWND, msg: UINT, _: WPARAM, l: LPARAM) -> INT_PTR { use resources; use winapi::shared::windef::RECT; - use winapi::um::winuser::{GetDesktopWindow, GetWindowRect, SendDlgItemMessageW, SetWindowPos, ShowWindow, - HWND_TOPMOST, SW_HIDE, WM_INITDIALOG, WM_DESTROY}; - use winapi::um::processthreadsapi::GetCurrentThreadId; use winapi::um::commctrl::PBM_SETMARQUEE; + use winapi::um::processthreadsapi::GetCurrentThreadId; + use winapi::um::winuser::{ + GetDesktopWindow, GetWindowRect, SendDlgItemMessageW, SetWindowPos, ShowWindow, HWND_TOPMOST, + SW_HIDE, WM_DESTROY, WM_INITDIALOG, + }; match msg { WM_INITDIALOG => { @@ -57,7 +58,12 @@ unsafe extern "system" fn dlgproc(hwnd: HWND, msg: UINT, _: WPARAM, l: LPARAM) - ShowWindow(hwnd, SW_HIDE); } - data.tx.send(ProgressWindow { ui_thread_id: GetCurrentThreadId() }).unwrap(); + data + .tx + .send(ProgressWindow { + ui_thread_id: GetCurrentThreadId(), + }) + .unwrap(); ShutdownBlockReasonCreate(hwnd, to_utf16("VS Code is updating...").as_ptr()); 0 @@ -88,8 +94,8 @@ impl ProgressWindow { pub fn run_progress_window(silent: bool, tx: Sender) { use resources; - use winapi::um::winuser::{DialogBoxParamW, MAKEINTRESOURCEW}; use winapi::um::libloaderapi::GetModuleHandleW; + use winapi::um::winuser::{DialogBoxParamW, MAKEINTRESOURCEW}; let data = DialogData { silent, tx }; @@ -99,7 +105,7 @@ pub fn run_progress_window(silent: bool, tx: Sender) { MAKEINTRESOURCEW(resources::PROGRESS_DIALOG), ptr::null_mut(), Some(dlgproc), - (&data as *const DialogData) as LPARAM + (&data as *const DialogData) as LPARAM, ); } } diff --git a/src/main.rs b/src/main.rs index 5eb3cba..42a0905 100644 --- a/src/main.rs +++ b/src/main.rs @@ -262,7 +262,8 @@ fn update( gui::run_progress_window(silent, tx); }); - let window = rx.recv() + let window = rx + .recv() .map_err(|_| io::Error::new(io::ErrorKind::Other, "Could not receive GUI window handle"))?; do_update(&log, code_path, update_folder_name)?; diff --git a/src/resources.rs b/src/resources.rs index f137c5f..86af04e 100644 --- a/src/resources.rs +++ b/src/resources.rs @@ -1,6 +1,11 @@ +/*----------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See LICENSE in the project root for license information. + *----------------------------------------------------------------------------------------*/ + #[allow(dead_code)] pub const ICON_CODE: u16 = 101; pub const PROGRESS_DIALOG: u16 = 1001; -pub const PROGRESS_SLIDER: i32 = 10001; \ No newline at end of file +pub const PROGRESS_SLIDER: i32 = 10001;