source: trunk/macosx/ExpandedPathToIconTransformer.m @ 1125

Last change on this file since 1125 was 1088, checked in by livings124, 15 years ago

quick fix for last commit

File size: 859 bytes
Line 
1
2#import "ExpandedPathToIconTransformer.h"
3
4@implementation ExpandedPathToIconTransformer
5
6+ (Class) transformedValueClass
7{
8    return [NSImage class];
9}
10
11+ (BOOL) allowsReverseTransformation
12{
13    return NO;
14}
15
16- (id) transformedValue: (id) value
17{
18    if (!value)
19        return nil;
20   
21    NSString * path = [value stringByExpandingTildeInPath];
22    NSImage * icon;
23    //show a folder icon if the folder doesn't exist
24    if (![[NSFileManager defaultManager] fileExistsAtPath: path] && [[path pathExtension] isEqualToString: @""])
25        icon = [[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')];
26    else
27        icon = [[NSWorkspace sharedWorkspace] iconForFile: [value stringByExpandingTildeInPath]];
28   
29    [icon setScalesWhenResized: YES];
30    [icon setSize: NSMakeSize(16.0, 16.0)];
31   
32    return icon;
33}
34
35@end
Note: See TracBrowser for help on using the repository browser.