#FEATURE by sr expeccoALM_1_13
authorsr
Tue, 27 Nov 2018 11:38:28 +0100
changeset 8596 455635f6de84
parent 8594 78eb83b097ef
child 8597 4de00d0b9545
#FEATURE by sr class: WinWorkstation comment/format in: #nativeFileDialogBinaryPath changed: #primCheckForErrorInFileDialogInitializeByCreationData: #primNativeFileDialogWithTitle:defaultBaseName:defaultDirectory:owningViewId:filterString:filterIndex:trueForSave:trueForMultiSelect:trueForPromptOverwrite:
WinWorkstation.st
--- a/WinWorkstation.st	Fri Nov 23 15:09:55 2018 +0100
+++ b/WinWorkstation.st	Tue Nov 27 11:38:28 2018 +0100
@@ -17,7 +17,8 @@
 
 DeviceWorkstation subclass:#WinWorkstation
 	instanceVariableNames:'blackpixel whitepixel listOfFonts rootWin rootDC buttonsPressed
-		eventTrace eventBuffer lastClipboardSequenceNumber'
+		eventTrace eventBuffer lastClipboardSequenceNumber
+		lastNativeFileDialogOutputStream'
 	classVariableNames:'BeepDuration NativeDialogs NativeFileDialogs NativeWidgets
 		NativeWidgetClassTable StandardColorValues IgnoreSysColorChanges
 		IgnoreFontChanges SystemColorValues CanEndSession
@@ -16670,18 +16671,8 @@
         Display nativeFileDialogBinaryPath
     "
 
-    |directory pointerSize baseName|
-
-    Smalltalk isStandAloneApp ifTrue:[
-        "if you have a standalone like expecco,
-         copy the binary to your binary folder (by nsis or etc)"
-        directory := OperatingSystem pathOfSTXExecutable asFilename directory.
-    ] ifFalse:[
-        directory := (Smalltalk
-            packageDirectoryForPackageId:self class package)
-                directory
-                    / 'support/win32/nativeFileDialog'
-    ].
+    |pointerSize baseName
+     packageId directory|
 
     pointerSize := ExternalAddress pointerSize.
     pointerSize == 4 ifTrue:[
@@ -16694,10 +16685,18 @@
         ].
     ].
 
+    packageId := 'stx:support/win32/nativeFileDialog'.
+    directory := Smalltalk packageDirectoryForPackageId:packageId.
+    directory isNil ifTrue:[
+        NativeFileDialogInitializeError 
+            raiseErrorString:('Could not find package directory for package id "%1"' 
+                bindWith:packageId).
+    ].
+
     ^ (directory / baseName) pathName
 
     "Created: / 08-11-2018 / 16:06:59 / sr"
-    "Modified: / 19-11-2018 / 14:50:05 / sr"
+    "Modified: / 27-11-2018 / 11:32:32 / sr"
 !
 
 nativeFileDialogWithTitle:dialogTitleArg
@@ -16991,7 +16990,8 @@
     "checks if the file dialog has been created succesfully,
      otherwise raises NativeFileDialogInitializeError"
 
-    |dataAddress sharedMemoryMapFileHandleAddress errorInFileDialogInitialize|
+    |dataAddress sharedMemoryMapFileHandleAddress errorInFileDialogInitialize
+     output errorString|
 
     dataAddress := nativeFileDialogCreationData dataAddress.
     sharedMemoryMapFileHandleAddress := nativeFileDialogCreationData sharedMemoryMapFileHandleAddress.
@@ -17011,10 +17011,16 @@
 %}.
 
     errorInFileDialogInitialize ifTrue:[
-        NativeFileDialogInitializeError raise.
+        output := lastNativeFileDialogOutputStream.
+        output notNil ifTrue:[
+            errorString := output contents.
+        ].
+
+        NativeFileDialogInitializeError raiseErrorString:errorString.
     ].
 
     "Created: / 19-11-2018 / 16:00:04 / sr"
+    "Modified: / 27-11-2018 / 11:24:10 / sr"
 !
 
 primCloseNativeFileDialogByCreationData:nativeFileDialogCreationData
@@ -17136,9 +17142,11 @@
             trueForPromptOverwrite:true
     "
 
-    |uuidString dataAddress sharedMemoryMapFileHandleAddress fileDialogStxProcess|
+    |uuidString nativeFileDialogBinaryPath dataAddress sharedMemoryMapFileHandleAddress fileDialogStxProcess 
+     outputStream executeCommandReturn|
 
     uuidString := UUID genRandomUUID printString.
+    nativeFileDialogBinaryPath := self nativeFileDialogBinaryPath.
 
 %{  /* STACK: 100000 */
     HANDLE hMapFile;
@@ -17218,13 +17226,21 @@
      the file dialog needs to do its cleanup(s).
      otherwise we get frozen views... etc."
     [
-        (OperatingSystem
+        outputStream := '' writeStream.
+
+        executeCommandReturn := OperatingSystem
             executeCommand:('"%1" %2'
-                bindWith:self nativeFileDialogBinaryPath
-                with:uuidString)) ifFalse:[
-                    self primTriggerNativeFileDialogInitializeErrorByDataAddress:dataAddress.
-                    'native file dialog via could not be initialized' errorPrintCR.
-                ].
+                bindWith:nativeFileDialogBinaryPath
+                with:uuidString)
+            outputTo:outputStream
+            errorTo:outputStream.
+
+        lastNativeFileDialogOutputStream := outputStream.
+
+        executeCommandReturn ifFalse:[
+            self primTriggerNativeFileDialogInitializeErrorByDataAddress:dataAddress.
+            'native file dialog via could not be initialized' errorPrintCR.
+        ].
     ] fork.
 
     ^ NativeFileDialogCreationData new
@@ -17233,6 +17249,7 @@
         yourself
 
     "Created: / 19-11-2018 / 15:57:21 / sr"
+    "Modified: / 27-11-2018 / 11:31:02 / sr"
 !
 
 primTriggerNativeFileDialogInitializeErrorByDataAddress:dataAddress