@@ -8,13 +8,8 @@ use dirs_sys::known_folder;
88use serde_derive:: { Deserialize , Serialize } ;
99use serde_json;
1010use web_view:: * ;
11- use winapi:: shared:: winerror;
12- use winapi:: um:: combaseapi;
11+
1312use winapi:: um:: knownfolders;
14- use winapi:: um:: shlobj;
15- use winapi:: um:: shtypes;
16- use winapi:: um:: winbase;
17- use winapi:: um:: winnt;
1813
1914use crate :: backend:: Backend ;
2015use crate :: compact:: system_supports_compression;
@@ -140,7 +135,10 @@ impl<T> GuiWrapper<T> {
140135 pub fn choose_folder ( & self ) -> Receiver < WVResult < Option < PathBuf > > > {
141136 let ( tx, rx) = bounded :: < WVResult < Option < PathBuf > > > ( 1 ) ;
142137 let _ = self . 0 . dispatch ( move |wv| {
143- let _ = tx. send ( choose_folder ( wv) ) ;
138+ let _ = tx. send ( wv. dialog ( ) . choose_directory (
139+ "Select Directory" ,
140+ known_folder ( & knownfolders:: FOLDERID_ProgramFiles ) . expect ( "Program files path" ) ,
141+ ) ) ;
144142 Ok ( ( ) )
145143 } ) ;
146144
@@ -310,36 +308,3 @@ fn set_dpi_aware() {
310308
311309 unsafe { SetProcessDpiAwareness ( PROCESS_SYSTEM_DPI_AWARE ) } ;
312310}
313-
314- fn program_files ( ) -> PathBuf {
315- known_folder ( & knownfolders:: FOLDERID_ProgramFiles ) . expect ( "Program files path" )
316- }
317-
318- use lazy_static:: lazy_static;
319- use std:: sync:: Mutex ;
320-
321- lazy_static ! {
322- static ref LAST_FILE : Mutex <Option <PathBuf >> = Mutex :: new( None ) ;
323- }
324-
325- // WebView has an irritatingly stupid bug here, failing to initialize variables
326- // causing the dialog to fail to open and this to return None depending on the
327- // random junk on the stack. (#214)
328- //
329- // The message loop seems to be broken on Windows too (#220, #221).
330- //
331- // Sadly nobody seems interested in merging these. For now, use a locally modified
332- // copy.
333- fn choose_folder < T > ( webview : & mut web_view:: WebView < ' _ , T > ) -> WVResult < Option < PathBuf > > {
334- let mut last = LAST_FILE . lock ( ) . unwrap ( ) ;
335- if let Some ( path) = webview. dialog ( ) . choose_directory (
336- "Select Directory" ,
337- last. clone ( ) . unwrap_or_else ( program_files) ,
338- ) ? {
339- last. replace ( path. clone ( ) ) ;
340-
341- Ok ( Some ( path) )
342- } else {
343- Ok ( None )
344- }
345- }
0 commit comments