also remember last directory in requestFileName dialogs
authorClaus Gittinger <cg@exept.de>
Thu, 23 Oct 1997 20:02:18 +0200
changeset 1360 ede30cea2827
parent 1359 d1d0c157a85f
child 1361 139f8063319c
also remember last directory in requestFileName dialogs
DialogBox.st
--- a/DialogBox.st	Thu Oct 23 16:50:19 1997 +0200
+++ b/DialogBox.st	Thu Oct 23 20:02:18 1997 +0200
@@ -10,8 +10,6 @@
  hereby transferred.
 "
 
-'From Smalltalk/X, Version:3.2.1 on 18-oct-1997 at 3:24:10 pm'                  !
-
 ModalBox subclass:#DialogBox
 	instanceVariableNames:'buttonPanel okButton okAction abortButton abortAction
 		acceptReturnAsOK yPosition leftIndent rightIndent addedComponents
@@ -1322,19 +1320,32 @@
 requestDirectoryName:title default:aFileName ifFail:failBlock
     "same as requestFileName, but only show directories"
 
-    |fileBox|
+    |dir fileBox enteredName|
 
     fileBox := FileSelectionBox
                     title:title
                     okText:'ok'
                     abortText:'cancel'
-                    action:[:fileName | fileBox destroy. ^ fileName].
+                    action:[:fileName | enteredName := fileName].
+
+    dir := FileSelectionBox lastFileSelectionDirectory.
+    dir notNil ifTrue:[
+        fileBox directory:dir.
+    ].
 
     fileBox initialText:aFileName.
     fileBox selectingDirectory:true.
     fileBox showAtPointer.
     fileBox destroy.
-    ^ failBlock value
+
+    (enteredName isNil 
+    or:[enteredName isEmpty]) ifTrue:[
+        ^ failBlock value
+    ].
+
+    FileSelectionBox lastFileSelectionDirectory:(enteredName asFilename directoryName).
+
+    ^ enteredName
 
     "
      Dialog
@@ -1344,7 +1355,7 @@
     "
 
     "Created: 19.4.1996 / 14:31:04 / cg"
-    "Modified: 29.5.1996 / 15:24:30 / cg"
+    "Modified: 23.10.1997 / 19:24:41 / cg"
 !
 
 requestFileName
@@ -1459,7 +1470,7 @@
      The matchPattern is set to pattern initially.
      Return the string, or nil if cancel was pressed."
 
-    |box defaultDir defaultNm|
+    |box defaultDir defaultNm dir enteredName|
 
     defaultNm := defaultName.
     defaultDir := aDirectoryPath.
@@ -1467,6 +1478,11 @@
         defaultNm notNil ifTrue:[
             defaultDir := defaultName asFilename directoryName.
             defaultNm := defaultNm asFilename baseName.
+            defaultDir = Filename currentDirectory name ifTrue:[
+                defaultName asFilename isExplicitRelative ifFalse:[
+                    defaultDir := nil
+                ]
+            ]
         ].
     ].
 
@@ -1474,15 +1490,28 @@
                title:titleString
                okText:okText 
                abortText:abortText
-               action:[:fileName | box destroy. ^ fileName].
-
-    defaultDir notNil ifTrue:[box directory:defaultDir].
+               action:[:fileName | enteredName := fileName].
+
+    defaultDir notNil ifTrue:[
+        box directory:defaultDir
+    ] ifFalse:[
+        dir := FileSelectionBox lastFileSelectionDirectory.
+        dir notNil ifTrue:[
+            box directory:dir.
+        ].
+    ].
     box pattern:pattern.
     box initialText:defaultNm.
     box showAtPointer.
     box action:nil.
     box destroy.
-    ^ nil
+
+    (enteredName notNil 
+    and:[enteredName notEmpty]) ifTrue:[
+        FileSelectionBox lastFileSelectionDirectory:(enteredName asFilename directoryName).
+    ].
+
+    ^ enteredName
 
     "
      Dialog 
@@ -1494,7 +1523,7 @@
         fromDirectory:'/etc'  
     "
 
-    "Modified: 20.2.1997 / 18:12:49 / cg"
+    "Modified: 23.10.1997 / 19:59:01 / cg"
 !
 
 requestFileName:titleString default:defaultName pattern:pattern
@@ -5516,6 +5545,6 @@
 !DialogBox class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.108 1997-10-21 18:27:24 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/DialogBox.st,v 1.109 1997-10-23 18:02:18 cg Exp $'
 ! !
 DialogBox initialize!