--- a/AbstractFileBrowser.st Mon Jan 27 15:24:49 2003 +0100
+++ b/AbstractFileBrowser.st Mon Jan 27 16:45:50 2003 +0100
@@ -2,10 +2,10 @@
ApplicationModel subclass:#AbstractFileBrowser
instanceVariableNames:'aspects'
- classVariableNames:'DirectoryHistory DefaultCommandPerMIME RuntimeAspects
- DirectoryBookmarks LastEnforcedNameSpace CommandHistory
- DefaultCommandPerSuffix CommandHistorySize LastFileDiffFile
- DefaultFilters CurrentSelection RootHolder'
+ classVariableNames:'DirectoryHistory RuntimeAspects DirectoryBookmarks
+ LastEnforcedNameSpace CommandHistory DefaultCommandPerSuffix
+ CommandHistorySize LastFileDiffFile DefaultFilters
+ CurrentSelection RootHolder'
poolDictionaries:''
category:'Interface-Tools-File'
!
@@ -139,14 +139,6 @@
^ CommandHistorySize
!
-defaultCommandPerMIME
-
- DefaultCommandPerMIME isNil ifTrue:[
- self initializeDefaultCommands
- ].
- ^ DefaultCommandPerMIME
-!
-
defaultFilterList
DefaultFilters isNil ifTrue:[
@@ -181,15 +173,146 @@
"/ DirectoryBookmarks := nil
!
-initializeDefaultCommands
- DefaultCommandPerMIME := Dictionary new.
-
- DefaultCommandPerMIME at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'.
- DefaultCommandPerMIME at:'application/pdf' put:'acroread -display %2 %1'.
-
- "
- self initializeDefaultCommands
- "
+initialCommandFor:fileName in:aDirectory intoBox:aBox
+ "set a useful initial command in an execute box."
+
+ |mime cmd select path suffix baseName|
+
+ path := aDirectory filenameFor:fileName.
+ baseName := path baseName.
+ suffix := path suffix.
+
+ mime := MIMETypes mimeTypeForSuffix:suffix.
+"/ mime notNil ifTrue:[
+"/ cmd := self initialCommandForMIME:mime file:path
+"/ ].
+
+ "/ XXX should be changed to take stuff from a config file
+ "/ XXX or from resources.
+
+ (path type == #regular) ifTrue:[
+ path isExecutableProgram ifTrue:[
+ aBox initialText:(path pathName , ' <arguments>').
+ ^ self
+ ].
+
+ select := true.
+
+ "some heuristics - my personal preferences ...
+ (actually this should come from a configfile)"
+
+ (baseName endsWith:'akefile') ifTrue:[
+ aBox initialText:'make target' selectFrom:6 to:11.
+ ^ self
+ ].
+
+ cmd := MIMETypes defaultCommandPerMIME at:mime ifAbsent:nil.
+ cmd notNil ifTrue:[
+ select := false
+ ].
+
+ cmd isNil ifTrue:[
+ suffix := path suffix.
+ (suffix = 'C') ifTrue:[
+ cmd := 'g++ -c %1'.
+ select := 6.
+ ] ifFalse:[
+ suffix := suffix asLowercase.
+
+ (suffix = 'taz') ifTrue:[
+ aBox initialText:'zcat %1 | tar tvf -'.
+ select := false.
+ ].
+ (suffix = 'tar') ifTrue:[
+ cmd := 'tar tvf %1'.
+ select := 7.
+ ].
+ (suffix = 'zoo') ifTrue:[
+ cmd := 'zoo -list %1'.
+ select := 9.
+ ].
+ (suffix = 'zip') ifTrue:[
+ cmd := 'unzip -l %1'.
+ select := 8.
+ ].
+ (suffix = 'jar') ifTrue:[
+ cmd := 'unzip -l %1'.
+ select := 8.
+ ].
+ (suffix = 'z') ifTrue:[
+ (baseName asLowercase endsWith:'tar.z') ifTrue:[
+ cmd := 'zcat %1 | tar tvf -'.
+ select := false.
+ ] ifFalse:[
+ cmd := 'uncompress %1'
+ ].
+ ].
+ (suffix = 'gz') ifTrue:[
+ (baseName asLowercase endsWith:'tar.gz') ifTrue:[
+ cmd := ('gunzip < %1 | tar tvf -' ).
+ select := false.
+ ] ifFalse:[
+ cmd := 'gunzip %1'.
+ ].
+ ].
+ (suffix = 'html') ifTrue:[
+ cmd := 'netscape %1'
+ ].
+ (suffix = 'htm') ifTrue:[
+ cmd := 'netscape %1'
+ ].
+ (suffix = 'uue') ifTrue:[
+ cmd := 'uudecode %1'
+ ].
+ (suffix = 'c') ifTrue:[
+ cmd := 'cc -c %1'.
+ select := 5.
+ ].
+ (suffix = 'cc') ifTrue:[
+ cmd := 'g++ -c %1'.
+ select := 6.
+ ].
+ (suffix = 'xbm') ifTrue:[
+ cmd := 'bitmap %1'
+ ].
+ (suffix = 'ps') ifTrue:[
+ cmd := 'ghostview %1'
+ ].
+ ((suffix = '1') or:[suffix = 'man']) ifTrue:[
+ cmd := 'nroff -man %1'.
+ select := 10.
+ ].
+ ].
+ ].
+
+ cmd isNil ifTrue:[
+ DefaultCommandPerSuffix isNil ifTrue:[
+ cmd := '<cmd>'
+ ] ifFalse:[
+ cmd := DefaultCommandPerSuffix
+ at:suffix
+ ifAbsent:'<cmd>'.
+ ].
+ cmd := cmd , ' %1'.
+ ].
+
+ cmd := cmd bindWith:path pathName.
+ select == false ifTrue:[
+ aBox initialText:cmd
+ ] ifFalse:[
+ select class == Interval ifTrue:[
+ aBox initialText:cmd selectFrom:select start to:select stop
+ ] ifFalse:[
+ select isInteger ifFalse:[
+ select := (cmd indexOf:Character space ifAbsent:[cmd size + 1]) - 1.
+ ].
+ aBox initialText:cmd selectFrom:1 to:select
+ ].
+ ]
+ ]
+
+ "Modified: / 24.9.1997 / 16:34:52 / stefan"
+ "Modified: / 9.4.1998 / 17:15:57 / cg"
!
listOfRuntimeValuesToRemark
@@ -4706,146 +4829,7 @@
initialCommandFor:fileName into:aBox
"set a useful initial command for execute box."
- |mime cmd select path suffix|
-
- path := self getDirWithoutFileName:fileName.
- suffix := fileName asFilename suffix.
- DefaultCommandPerSuffix notNil ifTrue:[
- cmd := DefaultCommandPerSuffix at:suffix ifAbsent:nil.
- cmd notNil ifTrue:[
- aBox initialText:(cmd , ' ' , fileName baseName) selectFrom:1 to:cmd size.
- ^ self
- ].
- ].
- mime := MIMETypes mimeTypeForSuffix:suffix.
-"/ mime notNil ifTrue:[
-"/ cmd := self initialCommandForMIME:mime file:path
-"/ ].
-
- "/ XXX should be changed to take stuff from a config file
- "/ XXX or from resources.
-
- (path type == #regular) ifTrue:[
- path isExecutableProgram ifTrue:[
- aBox initialText:(fileName , ' <arguments>').
- ^ self
- ].
-
- select := true.
-
- "some heuristics - my personal preferences ...
- (actually this should come from a configfile)"
-
- (fileName endsWith:'akefile') ifTrue:[
- aBox initialText:'make target' selectFrom:6 to:11.
- ^ self
- ].
-
- cmd := self class defaultCommandPerMIME at:mime ifAbsent:nil.
- cmd notNil ifTrue:[
- select := false
- ].
-
- cmd isNil ifTrue:[
-
- suffix := path suffix.
- (suffix = 'C') ifTrue:[
- cmd := 'g++ -c %1'.
- select := 6.
- ] ifFalse:[
- suffix := suffix asLowercase.
-
- (suffix = 'taz') ifTrue:[
- aBox initialText:'zcat %1 | tar tvf -'.
- select := false.
- ].
- (suffix = 'tar') ifTrue:[
- cmd := 'tar tvf %1'.
- select := 7.
- ].
- (suffix = 'zoo') ifTrue:[
- cmd := 'zoo -list %1'.
- select := 9.
- ].
- (suffix = 'zip') ifTrue:[
- cmd := 'unzip -l %1'.
- select := 8.
- ].
- (suffix = 'jar') ifTrue:[
- cmd := 'unzip -l %1'.
- select := 8.
- ].
- (suffix = 'z') ifTrue:[
- (fileName asLowercase endsWith:'tar.z') ifTrue:[
- cmd := 'zcat %1 | tar tvf -'.
- select := false.
- ] ifFalse:[
- cmd := 'uncompress %1'
- ].
- ].
- (suffix = 'gz') ifTrue:[
- (fileName asLowercase endsWith:'tar.gz') ifTrue:[
- cmd := ('gunzip < %1 | tar tvf -' ).
- select := false.
- ] ifFalse:[
- cmd := 'gunzip %1'.
- ].
- ].
- (suffix = 'html') ifTrue:[
- cmd := 'netscape %1'
- ].
- (suffix = 'htm') ifTrue:[
- cmd := 'netscape %1'
- ].
- (suffix = 'uue') ifTrue:[
- cmd := 'uudecode %1'
- ].
- (suffix = 'c') ifTrue:[
- cmd := 'cc -c %1'.
- select := 5.
- ].
- (suffix = 'cc') ifTrue:[
- cmd := 'g++ -c %1'.
- select := 6.
- ].
- (suffix = 'xbm') ifTrue:[
- cmd := 'bitmap %1'
- ].
- (suffix = 'ps') ifTrue:[
- cmd := 'ghostview %1'
- ].
- ((suffix = '1') or:[suffix = 'man']) ifTrue:[
- cmd := 'nroff -man %1'.
- select := 10.
- ].
- ].
- ].
-
- cmd isNil ifTrue:[
- DefaultCommandPerSuffix isNil ifTrue:[
- cmd := '<cmd>'
- ] ifFalse:[
- cmd := DefaultCommandPerSuffix
- at:suffix
- ifAbsent:'<cmd>'.
- ].
- cmd := cmd , ' %1'.
- ].
-
- cmd := cmd bindWith:fileName.
- select == false ifTrue:[
- aBox initialText:cmd
- ] ifFalse:[
- select class == Interval ifTrue:[
- aBox initialText:cmd selectFrom:select start to:select stop
- ] ifFalse:[
- select isInteger ifFalse:[
- select := (cmd indexOf:Character space ifAbsent:[cmd size + 1]) - 1.
- ].
- aBox initialText:cmd selectFrom:1 to:select
- ].
- ]
- ]
+ self class initialCommandFor:fileName in:Filename currentDirectory intoBox:aBox
!
isAbstractFileBrowser
@@ -5553,5 +5537,5 @@
!AbstractFileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.84 2003-01-27 13:49:21 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.85 2003-01-27 15:45:09 cg Exp $'
! !
--- a/FileBrowser.st Mon Jan 27 15:24:49 2003 +0100
+++ b/FileBrowser.st Mon Jan 27 16:45:50 2003 +0100
@@ -25,7 +25,7 @@
doNotShowFontDialog lastEnforcedNameSpace'
classVariableNames:'DirectoryBookmarks HistorySize DefaultIcon CommandHistory
CommandHistorySize Icons MatchedIcons DefaultCommandPerSuffix
- DefaultCommandPerMIME VisitedFileHistory LastEnforcedNameSpace'
+ VisitedFileHistory LastEnforcedNameSpace'
poolDictionaries:''
category:'Interface-Tools-File'
!
@@ -166,19 +166,6 @@
^ Icons
!
-initializeDefaultCommands
- DefaultCommandPerMIME := Dictionary new.
-
- DefaultCommandPerMIME at:'application/x-tar-compressed' put:'gunzip < %1 | tar tvf -'.
- DefaultCommandPerMIME at:'application/pdf' put:'acroread -display %2 %1'.
-
- "
- self initializeDefaultCommands
- "
-
- "Modified: / 1.8.1998 / 17:39:27 / cg"
-!
-
initializeFileTypeIcons
|resources|
@@ -5584,10 +5571,7 @@
|cmd|
(aFilename asFilename hasSuffix:'pdf') ifTrue:[
- DefaultCommandPerMIME isNil ifTrue:[
- self class initializeDefaultCommands
- ].
- cmd := DefaultCommandPerMIME at:'application/pdf' ifAbsent:nil.
+ cmd := MIMETypes defaultCommandPerMIME at:'application/pdf' ifAbsent:nil.
cmd notNil ifTrue:[
(OperatingSystem
executeCommand:(cmd bindWith:aFilename with:Display displayName)
@@ -5908,155 +5892,9 @@
!
initialCommandFor:fileName into:aBox
- "set a useful initial command for execute box."
-
- |mime cmd select path suffix|
-
- path := currentDirectory filenameFor:fileName.
- suffix := fileName asFilename suffix.
- DefaultCommandPerSuffix notNil ifTrue:[
- cmd := DefaultCommandPerSuffix at:suffix ifAbsent:nil.
- cmd notNil ifTrue:[
- aBox initialText:(cmd , ' ' , fileName) selectFrom:1 to:cmd size.
- ^ self
- ].
- ].
- mime := MIMETypes mimeTypeForSuffix:suffix.
-"/ mime notNil ifTrue:[
-"/ cmd := self initialCommandForMIME:mime file:path
-"/ ].
-
- "/ XXX should be changed to take stuff from a config file
- "/ XXX or from resources.
-
- (path type == #regular) ifTrue:[
- path isExecutableProgram ifTrue:[
- aBox initialText:(fileName , ' <arguments>').
- ^ self
- ].
-
- select := true.
-
- "some heuristics - my personal preferences ...
- (actually this should come from a configfile)"
-
- (fileName endsWith:'akefile') ifTrue:[
- aBox initialText:'make target' selectFrom:6 to:11.
- ^ self
- ].
-
- DefaultCommandPerMIME isNil ifTrue:[
- self class initializeDefaultCommands
- ].
-
- cmd := DefaultCommandPerMIME at:mime ifAbsent:nil.
- cmd notNil ifTrue:[
- select := false
- ].
-
- cmd isNil ifTrue:[
-
- suffix := path suffix.
- (suffix = 'C') ifTrue:[
- cmd := 'g++ -c %1'.
- select := 6.
- ] ifFalse:[
- suffix := suffix asLowercase.
-
- (suffix = 'taz') ifTrue:[
- aBox initialText:'zcat %1 | tar tvf -'.
- select := false.
- ].
- (suffix = 'tar') ifTrue:[
- cmd := 'tar tvf %1'.
- select := 7.
- ].
- (suffix = 'zoo') ifTrue:[
- cmd := 'zoo -list %1'.
- select := 9.
- ].
- (suffix = 'zip') ifTrue:[
- cmd := 'unzip -l %1'.
- select := 8.
- ].
- (suffix = 'jar') ifTrue:[
- cmd := 'unzip -l %1'.
- select := 8.
- ].
- (suffix = 'z') ifTrue:[
- (fileName asLowercase endsWith:'tar.z') ifTrue:[
- cmd := 'zcat %1 | tar tvf -'.
- select := false.
- ] ifFalse:[
- cmd := 'uncompress %1'
- ].
- ].
- (suffix = 'gz') ifTrue:[
- (fileName asLowercase endsWith:'tar.gz') ifTrue:[
- cmd := ('gunzip < %1 | tar tvf -' ).
- select := false.
- ] ifFalse:[
- cmd := 'gunzip %1'.
- ].
- ].
- (suffix = 'html') ifTrue:[
- cmd := 'netscape %1'
- ].
- (suffix = 'htm') ifTrue:[
- cmd := 'netscape %1'
- ].
- (suffix = 'uue') ifTrue:[
- cmd := 'uudecode %1'
- ].
- (suffix = 'c') ifTrue:[
- cmd := 'cc -c %1'.
- select := 5.
- ].
- (suffix = 'cc') ifTrue:[
- cmd := 'g++ -c %1'.
- select := 6.
- ].
- (suffix = 'xbm') ifTrue:[
- cmd := 'bitmap %1'
- ].
- (suffix = 'ps') ifTrue:[
- cmd := 'ghostview %1'
- ].
- ((suffix = '1') or:[suffix = 'man']) ifTrue:[
- cmd := 'nroff -man %1'.
- select := 10.
- ].
- ].
- ].
-
- cmd isNil ifTrue:[
- DefaultCommandPerSuffix isNil ifTrue:[
- cmd := '<cmd>'
- ] ifFalse:[
- cmd := DefaultCommandPerSuffix
- at:suffix
- ifAbsent:'<cmd>'.
- ].
- cmd := cmd , ' %1'.
- ].
-
- cmd := cmd bindWith:fileName.
- select == false ifTrue:[
- aBox initialText:cmd
- ] ifFalse:[
- select class == Interval ifTrue:[
- aBox initialText:cmd selectFrom:select start to:select stop
- ] ifFalse:[
- select isInteger ifFalse:[
- select := (cmd indexOf:Character space ifAbsent:[cmd size + 1]) - 1.
- ].
- aBox initialText:cmd selectFrom:1 to:select
- ].
- ]
- ]
-
- "Modified: / 24.9.1997 / 16:34:52 / stefan"
- "Modified: / 9.4.1998 / 17:15:57 / cg"
+ "set a useful initial command in execute-command box."
+
+ self class initialCommandFor:fileName in:currentDirectory intoBox:aBox.
!
nonBinaryFileAction:aFilename
@@ -8055,5 +7893,5 @@
!FileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.518 2003-01-27 13:50:43 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/FileBrowser.st,v 1.519 2003-01-27 15:45:50 cg Exp $'
! !