Skip to content

Commit

Permalink
💄
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno committed Jul 3, 2018
1 parent 8a39060 commit d80a102
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 20 deletions.
18 changes: 8 additions & 10 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
22 changes: 14 additions & 8 deletions src/gui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 => {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -88,8 +94,8 @@ impl ProgressWindow {

pub fn run_progress_window(silent: bool, tx: Sender<ProgressWindow>) {
use resources;
use winapi::um::winuser::{DialogBoxParamW, MAKEINTRESOURCEW};
use winapi::um::libloaderapi::GetModuleHandleW;
use winapi::um::winuser::{DialogBoxParamW, MAKEINTRESOURCEW};

let data = DialogData { silent, tx };

Expand All @@ -99,7 +105,7 @@ pub fn run_progress_window(silent: bool, tx: Sender<ProgressWindow>) {
MAKEINTRESOURCEW(resources::PROGRESS_DIALOG),
ptr::null_mut(),
Some(dlgproc),
(&data as *const DialogData) as LPARAM
(&data as *const DialogData) as LPARAM,
);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
Expand Down
7 changes: 6 additions & 1 deletion src/resources.rs
Original file line number Diff line number Diff line change
@@ -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;
pub const PROGRESS_SLIDER: i32 = 10001;

0 comments on commit d80a102

Please sign in to comment.