AbstractFileBrowser.st
changeset 4922 599d7ee3a4fb
parent 4915 be97c8dbd840
child 4930 a1d871f949af
equal deleted inserted replaced
4921:cd47f919e8f9 4922:599d7ee3a4fb
  4082 convertImageToPNG
  4082 convertImageToPNG
  4083     self convertImageToSuffix:'png'
  4083     self convertImageToSuffix:'png'
  4084 !
  4084 !
  4085 
  4085 
  4086 convertImageToSuffix:outSuffix
  4086 convertImageToSuffix:outSuffix
  4087     |image writer tempFileXPM chainOfConversions conversionStream skipSignal |
  4087     |image writer tempFileXPM chainOfConversions conversionStream skipSignal 
       
  4088      inFile outFile eachConversionSuffixCommandPair doneWithThisFile
       
  4089      eachConversionSuffix eachConversionCommand tempFileTemplate|
  4088 
  4090 
  4089 "/    [
  4091 "/    [
  4090         skipSignal := Signal new.
  4092         skipSignal := Signal new.
  4091 
  4093 
  4092         self withActivityIndicationDo:[
  4094         self withActivityIndicationDo:[
  4093             self currentFileNameHolder value do:[:fileName |
  4095             self currentFileNameHolder value do:[:fileName |
  4094                 |imageOrNil inFile outFile eachConversionSuffixCommandPair doneWithThisFile
       
  4095                  eachConversionSuffix eachConversionCommand tempFileTemplate|
       
  4096 
       
  4097                 skipSignal handle:[:ex | ] 
  4096                 skipSignal handle:[:ex | ] 
  4098                 do:[
  4097                 do:[
  4099                     |answer|
  4098                     |answer|
  4100 
  4099 
  4101                     self notify:(resources string:'Converting: %1...' with:fileName baseName).
  4100                     self notify:(resources string:'Converting: %1...' with:fileName baseName).
  4111                                 skipSignal raise.
  4110                                 skipSignal raise.
  4112                             ].
  4111                             ].
  4113                         ].
  4112                         ].
  4114 
  4113 
  4115                         image := Image fromFile:fileName.
  4114                         image := Image fromFile:fileName.
  4116                         image isNil ifTrue:[
  4115                         image notNil ifTrue:[
  4117                             chainOfConversions := self conversionChainFrom:(fileName suffix) to:outSuffix.
       
  4118                         ] ifFalse:[
       
  4119                             writer := MIMETypes imageReaderForSuffix:outSuffix.
  4116                             writer := MIMETypes imageReaderForSuffix:outSuffix.
  4120                             (writer notNil and:[writer canRepresent:image]) ifTrue:[
  4117                             (writer notNil and:[writer canRepresent:image]) ifTrue:[
  4121                                 writer save:image onFile:outFile.
  4118                                 writer save:image onFile:outFile.
  4122                                 skipSignal raise.
  4119                                 skipSignal raise.
  4123                             ].
  4120                             ].
  4124                         ].
  4121                         ].
       
  4122                         chainOfConversions := self conversionChainFrom:(fileName suffix) to:outSuffix.
  4125 
  4123 
  4126                         chainOfConversions isNil ifTrue:[ skipSignal raise ].
  4124                         chainOfConversions isNil ifTrue:[ skipSignal raise ].
  4127                         conversionStream := chainOfConversions readStream.
  4125                         conversionStream := chainOfConversions readStream.
  4128 
  4126 
  4129                         doneWithThisFile := false.
  4127                         doneWithThisFile := false.
  4160                                 command := eachConversionCommand 
  4158                                 command := eachConversionCommand 
  4161                                                 bindWith:(inFile pathName)
  4159                                                 bindWith:(inFile pathName)
  4162                                                 with:(outFile pathName).
  4160                                                 with:(outFile pathName).
  4163 
  4161 
  4164                                 errOutput := '' writeStream.
  4162                                 errOutput := '' writeStream.
       
  4163 
  4165                                 (OperatingSystem executeCommand:command errorTo:errOutput)
  4164                                 (OperatingSystem executeCommand:command errorTo:errOutput)
  4166                                 ifFalse:[
  4165                                 ifFalse:[
  4167                                     Dialog warn:(
  4166                                     Dialog warn:(
  4168                                             resources
  4167                                             resources
  4169                                                 stringWithCRs:'Conversion of %1 to %2 using %3 failed:\\%4.' 
  4168                                                 stringWithCRs:'Conversion of %1 to %2 using %3 failed:\\%4.' 
  6177 ! !
  6176 ! !
  6178 
  6177 
  6179 !AbstractFileBrowser class methodsFor:'documentation'!
  6178 !AbstractFileBrowser class methodsFor:'documentation'!
  6180 
  6179 
  6181 version
  6180 version
  6182     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.145 2003-05-19 13:40:59 cg Exp $'
  6181     ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.146 2003-05-22 15:51:19 cg Exp $'
  6183 ! !
  6182 ! !