source: trunk/macosx/ExpandedPathToIconTransformer.m @ 1078

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

If the folder doesn't exist, still show a folder icon for the download/incomplete folder prefs.

File size: 860 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
36@end
Note: See TracBrowser for help on using the repository browser.