--- a/HierarchicalFileList.st Fri Oct 13 18:07:09 2000 +0200
+++ b/HierarchicalFileList.st Sun Oct 15 14:53:22 2000 +0200
@@ -145,8 +145,13 @@
matchBlock := aBlock.
root notNil ifTrue:[
- root matchBlockChanged.
+ self recursionLock critical:[
+ self stopMonitoringTask.
+ root matchBlockChanged.
+ ].
+ self startMonitoringTask.
].
+
! !
!HierarchicalFileList methodsFor:'protocol'!
@@ -207,9 +212,10 @@
iconFor:anItem
"returns the icon for an item
"
- |fn key|
+ |fn key suff mimeType icn|
fn := anItem fileName.
+ icons isNil ifTrue:[ icons := self class icons ].
fn isDirectory ifTrue:[
(fn isReadable and:[fn isExecutable]) ifTrue:[
@@ -217,27 +223,38 @@
ifFalse:[#directory]
] ifFalse:[
key := #directoryLocked
- ]
- ] ifFalse:[
- fn isReadable ifTrue:[
- fn isSymbolicLink ifTrue:[
- key := #fileLink
- ] ifFalse:[
- (Image isImageFileSuffix:(fn suffix)) ifTrue:[
- key := #imageFile
- ] ifFalse:[
- key := #file
- ]
- ]
- ] ifFalse:[
- key := #fileLocked
- ]
+ ].
+ ^ icons at:key ifAbsent:nil
].
- icons isNil ifTrue:[
- icons := self class icons
+
+ fn isReadable ifFalse:[ ^ icons at:#fileLocked ifAbsent:nil ].
+ fn isSymbolicLink ifTrue:[ ^ icons at:#fileLink ifAbsent:nil ].
+
+ suff := fn suffix.
+
+ (suff = 'bak' or:[suff = 'sav']) ifTrue:[
+ suff := fn withoutSuffix suffix.
].
- ^ icons at:key ifAbsent:nil
+ suff size > 0 ifTrue:[
+ ( #( 'o' 'so' 'a' ) includes:suff) ifTrue:[
+ ^ icons at:#executableFile ifAbsent:nil
+ ].
+ mimeType := MIMETypes mimeTypeForSuffix:suff.
+
+ mimeType notNil ifTrue:[
+ (icn := icons at:mimeType ifAbsent:nil) notNil ifTrue:[^ icn].
+
+ (mimeType startsWith:'image/') ifTrue:[
+ ^ icons at:#imageFile ifAbsent:nil
+ ].
+ ].
+ ].
+
+ fn isExecutableProgram ifTrue:[
+ ^ icons at:#executableFile ifAbsent:nil
+ ].
+ ^ icons at:#file ifAbsent:nil
!
matchBlockFor:anItem
@@ -419,18 +436,23 @@
"
|model list|
- children isNil ifTrue:[
- children := #(). "/ disable reread
- modificationTime := fileName modificationTime.
+ children notNil ifTrue:[
+ ^ children
+ ].
- (model := self model) notNil ifTrue:[
- list := model childrenFor:self.
+ (model := self model) isNil ifTrue:[
+ "/ must reread later
+ modificationTime := children := nil.
+ ^ nil
+ ].
- list size ~~ 0 ifTrue:[
- list do:[:aChild| aChild parent:self].
- children := list.
- ]
- ].
+ children := #().
+ modificationTime := fileName modificationTime.
+ list := model childrenFor:self.
+
+ list size ~~ 0 ifTrue:[
+ list do:[:aChild| aChild parent:self].
+ children := list.
].
^ children
!
@@ -484,18 +506,12 @@
isExpanded ifFalse:[
children := nil.
- ^ self
- ].
+ ] ifTrue:[
+ self monitoringCycle.
- self listIndex isNil ifTrue:[
- "/ not visible
- children := nil.
- ^ self
- ].
- self monitoringCycle.
-
- children size ~~ 0 ifTrue:[
- children do:[:aChild| aChild matchBlockChanged ]
+ children size ~~ 0 ifTrue:[
+ children do:[:aChild| aChild matchBlockChanged ]
+ ]
].
!
@@ -564,5 +580,5 @@
!HierarchicalFileList class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.8 2000-10-13 16:07:09 ca Exp $'
+ ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalFileList.st,v 1.9 2000-10-15 12:53:22 ca Exp $'
! !