added notify: method;
authorClaus Gittinger <cg@exept.de>
Mon, 03 Feb 2003 12:19:51 +0100
changeset 4523 ae3d65269e21
parent 4522 917245591672
child 4524 86b5d78f396e
added notify: method;
AbstractFileApplicationNoteBookComponent.st
AbstractFileBrowser.st
FileApplicationNoteBook.st
--- a/AbstractFileApplicationNoteBookComponent.st	Mon Feb 03 11:43:47 2003 +0100
+++ b/AbstractFileApplicationNoteBookComponent.st	Mon Feb 03 12:19:51 2003 +0100
@@ -34,7 +34,6 @@
 !AbstractFileApplicationNoteBookComponent methodsFor:'accessing'!
 
 notifyChannel
-
     notifyChannel isNil ifTrue:[
         self masterApplication notNil ifTrue:[
             notifyChannel := masterApplication notifyChannel.
@@ -190,5 +189,5 @@
 !AbstractFileApplicationNoteBookComponent class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileApplicationNoteBookComponent.st,v 1.4 2002-11-04 10:59:56 penk Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileApplicationNoteBookComponent.st,v 1.5 2003-02-03 11:19:51 cg Exp $'
 ! !
--- a/AbstractFileBrowser.st	Mon Feb 03 11:43:47 2003 +0100
+++ b/AbstractFileBrowser.st	Mon Feb 03 12:19:51 2003 +0100
@@ -176,7 +176,7 @@
 initialCommandFor:fileName in:aDirectory intoBox:aBox
     "set a useful initial command in an execute box."
 
-    |mime cmd select path suffix baseName|
+    |mime cmd select path suffix baseName pathName|
 
     path := aDirectory filenameFor:fileName.
     baseName := path baseName.
@@ -296,7 +296,14 @@
             cmd := cmd , ' %1'.
         ].
 
-        cmd := cmd bindWith:path pathName.
+        pathName := path pathName.
+        OperatingSystem isUNIXlike ifTrue:[
+            pathName includesSeparator ifTrue:[
+                pathName := '"' , pathName , '"'
+            ]
+        ].
+
+        cmd := cmd bindWith:pathName.
         select == false ifTrue:[
             aBox initialText:cmd
         ] ifFalse:[
@@ -1949,14 +1956,14 @@
     "setup and launch a querybox to ask for unix command.
      Then evaluate aBlock passing the command-string as argument."
 
-    |box osName|
+    |box osName commandString|
 
     osName := OperatingSystem platformName.
 
     box := FilenameEnterBox 
                 title:(resources string:'Execute %1 command:' with:osName)
                okText:(resources string:'Execute')
-               action:aBlock.
+               action:[:cmd | commandString := cmd].
 
     fileName notNil ifTrue:[
         self initialCommandFor:fileName into:box.
@@ -1965,6 +1972,10 @@
     box showAtPointer.
     box destroy.
 
+    commandString notNil ifTrue:[
+        aBlock value:commandString
+    ].
+
     "Modified: / 7.9.1995 / 10:31:54 / claus"
     "Modified: / 16.9.1997 / 15:35:10 / stefan"
     "Modified: / 14.8.1998 / 14:12:52 / cg"
@@ -2462,6 +2473,11 @@
         ifAbsent:[ BlockValue with:[self hasTwoFilesSelected] argument:self currentFileNameHolder].
 !
 
+notify:aString
+aString = 'nil' ifTrue:[self halt].
+    self notifyChannel value:aString
+!
+
 notifyChannel
 
     ^ self aspectFor:#notifyChannel ifAbsent:['' asValue]
@@ -2802,7 +2818,9 @@
         dirs size ~= 1 ifTrue:[ ^ self].
         dir := dirs anElement.
     ].
-    ^ [:stream| stream notNil ifTrue:[
+
+    ^ [:stream| 
+        stream notNil ifTrue:[
             OperatingSystem 
                 executeCommand:cmd
                 inputFrom:nil 
@@ -2811,13 +2829,13 @@
                 inDirectory:dir
                 onError:[:status| false].
         ]
-    ].
+      ].
 !
 
 killAllRunningBackgroundProcesses
 
     self backgroundProcesses do:[ : process |
-        self notifyChannel value:'kill ', process name.
+        self notify:'kill ', process name.
         process terminate.    
     ].
 !
@@ -2829,6 +2847,7 @@
     stream := appl resultStream.
     nameString := aString ? 'Execution Result'.
     appl changeTabTo:nameString.
+
     process := [ [aBlock value:stream] 
                     valueNowOrOnUnwindDo:[
                         self backgroundProcesses remove:process ifAbsent:[].
@@ -2953,7 +2972,7 @@
     ].
     stream nextPutAll:'> to clipboard'.
 
-    self notifyChannel value:stream contents.
+    self notify:stream contents.
     stream close.
     clp files:colOfFiles.
     self canPaste value:true.
@@ -3020,9 +3039,9 @@
 
     copy := FileOperation copy copyFile:aSourceFile to:aDestFile withOverWriteWarning:true copyFileIfSame:true.
     copy result ifTrue:[
-        self notifyChannel value:('copy ', aSourceFile baseName, ' to:,', aDestFile baseName).
+        self notify:('copy ', aSourceFile baseName, ' to:,', aDestFile baseName).
     ] ifFalse:[
-        self notifyChannel value:copy errorString.
+        self notify:copy errorString.
     ].
     ^ copy result
 !
@@ -3034,7 +3053,7 @@
 
     copy := FileOperation copy copyFiles:aColOfSourceFiles to:aDirectory.
     copy result ifFalse:[
-        self notifyChannel value:copy errorString.
+        self notify:copy errorString.
     ].
     self updateCurrentDirectory.
     ^ copy colOfCopiedFiles
@@ -3119,7 +3138,7 @@
     self withWaitCursorDo:[
         delete := FileOperation delete deleteFiles:colOfFiles.
         delete result ifFalse:[
-            self notifyChannel value:delete errorString.
+            self notify:delete errorString.
         ].
         self updateCurrentDirectory.
     ].
@@ -3134,9 +3153,9 @@
 
     move := FileOperation move moveFile:aSourceFile to:aDestFile.
     move result ifTrue:[
-        self notifyChannel value:('move ', aSourceFile asString, ' to ', aDestFile asString).
+        self notify:('move ', aSourceFile asString, ' to ', aDestFile asString).
     ] ifFalse:[
-        self notifyChannel value:move errorString.
+        self notify:move errorString.
     ].
     self updateCurrentDirectory.
     ^ move result
@@ -3149,7 +3168,7 @@
 
     move := FileOperation move moveFiles:aColOfSourceFiles to:aDirectory.
     move result ifFalse:[
-        self notifyChannel value:move errorString.
+        self notify:move errorString.
     ].
     self updateCurrentDirectory.
     ^ move colOfMovedFiles
@@ -3288,7 +3307,7 @@
             self updateAndSelect:(rename renamedFiles).
         ].
     ] ifFalse:[
-        self notifyChannel value:rename errorString.
+        self notify:rename errorString.
     ].
     ^ rename result
 !
@@ -3300,7 +3319,7 @@
 
     rename := FileOperation rename renameFiles:aColOfFiles.
     rename result ifFalse:[
-        self notifyChannel value:rename errorString
+        self notify:rename errorString
     ] ifTrue:[
         "/ self updateAndSelect:(rename renamedFiles)
     ].
@@ -3746,7 +3765,7 @@
         self withActivityIndicationDo:[
             self currentFileNameHolder value do:[:fileName |
                 fileName isDirectory ifFalse:[
-                    self notifyChannel value:('Convert to GIF:',  fileName baseName).
+                    self notify:('Convert to GIF:',  fileName baseName).
                     img := Image fromFile:(fileName pathName).
                     img notNil ifTrue:[
                         tempFileXPM  := Filename newTemporary withSuffix:'xpm'.
@@ -3784,7 +3803,7 @@
                     ]
                 ]
             ].
-            self notifyChannel value:''.
+            self notify:''.
         ]
     ] fork.
 !
@@ -3851,10 +3870,10 @@
             | selectedFiles|
             selectedFiles:= self currentSelectedFiles.
             selectedFiles do:[:fileName |
-                self notifyChannel value:('File in:', fileName baseName).
+                self notify:('File in:', fileName baseName).
                 self singleFileFileIn:fileName lazy:lazy
             ].
-            self notifyChannel value:''.
+            self notify:''.
         ]
     ] fork.
 !
@@ -4172,11 +4191,11 @@
         self withActivityIndicationDo:[
             self allItemsOfCurrentDirectory do:[:fileItem |
                 (fileItem hasMimeType and:[fileItem mimeType isSmalltalkSource]) ifTrue:[
-                    self notifyChannel value:('Install as Autoloaded:', fileItem baseName).
+                    self notify:('Install as Autoloaded:', fileItem baseName).
                     self installAsAutoloaded:(fileItem fileName).
                 ]
             ].
-            self notifyChannel value:''.
+            self notify:''.
         ]
     ] fork.
 !
@@ -4540,13 +4559,13 @@
                     ].
                     notifyString := 'unloading old ' , p , ' ...'.
                     Transcript showCR:notifyString.
-                    self notifyChannel value:notifyString.
+                    self notify:notifyString.
                     ObjectFileLoader unloadObjectFile:p. 
                 ].
 
                 notifyString := 'loading ' , p , ' ...'.
                 Transcript showCR:notifyString.
-                self notifyChannel value:notifyString.
+                self notify:notifyString.
                 ObjectFileLoader loadObjectFile:p.
                 Class addInfoRecord:('fileIn ' , fileName asFilename pathName) 
             ]
@@ -5566,5 +5585,5 @@
 !AbstractFileBrowser class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.87 2003-02-03 10:41:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.88 2003-02-03 11:19:23 cg Exp $'
 ! !
--- a/FileApplicationNoteBook.st	Mon Feb 03 11:43:47 2003 +0100
+++ b/FileApplicationNoteBook.st	Mon Feb 03 12:19:51 2003 +0100
@@ -826,7 +826,8 @@
     fileName := anAppl fileName.
     index := self getIndexFor:anAppl.
     self changeFileBrowserTitleTo:(self privateTabList at:index ifAbsent:nil).
-    self notifyChannel value:(fileName asString).
+    
+    self notify:(fileName isNil ifTrue:[nil] ifFalse:[fileName asString]).
 "/        self gotoFile:fileName.
     index notNil ifTrue:[
         canvasHolder value:(anAppl window).
@@ -1865,9 +1866,9 @@
         ].
     ].
     locBlock := [   [        
-                    self notifyChannel value:string.
+                    self notify:string.
                     aBlock value.
-                    self notifyChannel value:''.
+                    self notify:''.
                     ] valueNowOrOnUnwindDo:[ 
                         process := nil.
                         self enableStopButton value:false.
@@ -2760,7 +2761,7 @@
 
     myProcess := self process value.
     myProcess notNil ifTrue:[
-        self notifyChannel value:('kill ', myProcess name).
+        self notify:('kill ', myProcess name).
         myProcess terminate.    
     ].
 ! !
@@ -3299,7 +3300,7 @@
                 with:image height
                 with:image depth.
     ].
-    self notifyChannel value:msg.
+    self notify:msg.
 ! !
 
 !FileApplicationNoteBook::ImageViewApplication methodsFor:'actions'!
@@ -3550,7 +3551,7 @@
         string := ' - closed'.
         master tabStringAdd:string for:self.
     ].
-    self notifyChannel value:'shell in ' , self fileName asString, ' finished'.
+    self notify:'shell in ' , self fileName asString, ' finished'.
     terminalView cr.
 
     text := '>> shell closed' asText allBold.
@@ -3799,13 +3800,13 @@
     self masterApplication class openAnotherApplicationOnSameItem ifTrue:[
         self updateSameFiles ifFalse:[ ^ self ].
     ].
-    self notifyChannel value:self fileName asString, ' saved'.
+    self notify:self fileName asString, ' saved'.
     dir := self fileName directory.
     dir exists not ifTrue:[
         dir recursiveMakeDirectory.
     ].
     editView saveAs:(self fileName).
-    self notifyChannel value:self fileName asString, ' saved'.
+    self notify:self fileName asString, ' saved'.
     self semaChangeItem critical:[
         textEditorChangeModificationTime := nil.
         self itemChanged value:false.
@@ -4254,7 +4255,7 @@
             ((textEditorChangeModificationTime = time) not) ifTrue:[
                 "/ contents changed by someone else
                 textEditorChangeModificationTime := time.
-                self notifyChannel value:item fileName asString, ' was changed by someone else'.
+                self notify:item fileName asString, ' was changed by someone else'.
                 self itemChanged value:true.
             ].
         ]
@@ -4926,5 +4927,5 @@
 !FileApplicationNoteBook class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.55 2003-02-03 10:41:39 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libtool/FileApplicationNoteBook.st,v 1.56 2003-02-03 11:19:41 cg Exp $'
 ! !