WinWorkstation.st
changeset 8592 20d28aee8271
parent 8591 159a30c96939
child 8593 89a67a6d8af3
--- a/WinWorkstation.st	Tue Nov 20 09:42:13 2018 +0100
+++ b/WinWorkstation.st	Tue Nov 20 16:32:06 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
 COPYRIGHT (c) 1996 by Claus Gittinger
 	      All Rights Reserved
@@ -2141,7 +2143,7 @@
 		    }
 		    goto again;
 		}
-		/* fail evtl. später ändern und in st verzögert aufrufen
+		/* fail evtl. später ändern und in st verzögert aufrufen
 		*/
 		console_fprintf(stderr, "WinWorkstation [info]: UnregisterClass %s failed.\n",(char*)ev->ev_arg1);
 	    }
@@ -16611,6 +16613,58 @@
 
 !WinWorkstation methodsFor:'native file dialog'!
 
+addPathToExplorerHistory:aPathName
+    "
+        when opening or saving a file via the native file dialog,
+        this method is called with the file's directory.
+        so the user has the last visited directory inside the explorer address bar history
+
+        Display addPathToExplorerHistory:'Z:\A'.
+        Display addPathToExplorerHistory:'Z:\B'.
+    "
+
+    |typedPathsRegistryKey 
+     index history currValue|
+
+    typedPathsRegistryKey := Win32OperatingSystem registryEntry 
+        key:'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\TypedPaths'
+        createIfAbsent:true.
+
+    typedPathsRegistryKey isNil ifTrue:[
+        "/ not supported somehow
+        ^ self
+    ].
+
+    index := 1.
+    history := OrderedSet new.
+
+    [
+        currValue := typedPathsRegistryKey valueNamed:'url', index printString.   
+        currValue notNil 
+    ] whileTrue:[
+        (index == 1 
+        and:[currValue = aPathName]) ifTrue:[
+            "/ already the first entry
+            ^ self
+        ].
+
+        history add:currValue.
+        index := index + 1.
+    ].
+
+    history := history copyWithout:aPathName.
+    history addFirst:aPathName.
+    history := history asOrderedCollection.
+    history := history copyTo:(25 min:history size). "/ seems like windows explorer only shows up to 25
+    history doWithIndex:[:eachUrl :idx |
+        typedPathsRegistryKey
+            valueNamed:'url', idx printString  
+            put:eachUrl.
+    ].
+
+    "Created: / 20-11-2018 / 16:06:29 / sr"
+!
+
 nativeFileDialogBinaryPath
     "
         Display nativeFileDialogBinaryPath
@@ -16793,6 +16847,9 @@
     targetFileOrDirectory := nativeFileDialogReturnData targetFileOrDirectory.
     multiSelectBaseNames := nativeFileDialogReturnData multiSelectBaseNames.
     multiSelectBaseNames notEmptyOrNil ifTrue:[
+        "/ add the direcotry to the explorer history
+        self addPathToExplorerHistory:targetFileOrDirectory. 
+
         needsSlash := targetFileOrDirectory last ~= $\.
 
         ^ (multiSelectBaseNames
@@ -16807,6 +16864,9 @@
                 ]
     ].
 
+    "/ add the direcotry to the explorer history
+    self addPathToExplorerHistory:targetFileOrDirectory asFilename directory pathName. 
+
     (trueForSave
     and:[filterArrayOrPairs notEmptyOrNil
     and:[targetFileOrDirectory asFilename suffix isEmptyOrNil]]) ifTrue:[
@@ -16823,7 +16883,6 @@
             and:[selectedSuffix ~= '*']) ifTrue:[
                 ^ targetFileOrDirectory, '.', selectedSuffix
             ].
-
         ].
     ].
 
@@ -16925,7 +16984,7 @@
     "
 
     "Created: / 25-10-2018 / 10:54:52 / sr"
-    "Modified: / 20-11-2018 / 09:41:34 / sr"
+    "Modified: / 20-11-2018 / 16:12:03 / sr"
 !
 
 primCheckForErrorInFileDialogInitializeByCreationData:nativeFileDialogCreationData
@@ -19899,7 +19958,7 @@
     }
 %}
     "
-     (StandardSystemView new label:'äöü') open
+     (StandardSystemView new label:'äöü') open
     "
 !