1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 17:47:37 +00:00
transmission/macosx/ExpandedPathToIconTransformer.m
2006-11-13 17:32:49 +00:00

35 lines
No EOL
859 B
Objective-C

#import "ExpandedPathToIconTransformer.h"
@implementation ExpandedPathToIconTransformer
+ (Class) transformedValueClass
{
return [NSImage class];
}
+ (BOOL) allowsReverseTransformation
{
return NO;
}
- (id) transformedValue: (id) value
{
if (!value)
return nil;
NSString * path = [value stringByExpandingTildeInPath];
NSImage * icon;
//show a folder icon if the folder doesn't exist
if (![[NSFileManager defaultManager] fileExistsAtPath: path] && [[path pathExtension] isEqualToString: @""])
icon = [[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')];
else
icon = [[NSWorkspace sharedWorkspace] iconForFile: [value stringByExpandingTildeInPath]];
[icon setScalesWhenResized: YES];
[icon setSize: NSMakeSize(16.0, 16.0)];
return icon;
}
@end