Show the file icon in the "Name" cell

Changed 0.5-cvs to 0.5-svn
This commit is contained in:
Eric Petit 2006-01-29 19:18:03 +00:00
parent 0ed06f109d
commit f6a70e2a8f
3 changed files with 20 additions and 5 deletions

View File

@ -8,7 +8,7 @@ if ! $(DEFINES)
VERSION_MAJOR = 0 ;
VERSION_MINOR = 4 ;
# VERSION_STRING = $(VERSION_MAJOR).$(VERSION_MINOR) ;
VERSION_STRING = 0.5-cvs ;
VERSION_STRING = 0.5-svn ;
DEFINES += VERSION_MAJOR=$(VERSION_MAJOR)
VERSION_MINOR=$(VERSION_MINOR)

View File

@ -35,6 +35,8 @@
NSString * fSizeString;
NSString * fTimeString;
NSString * fPeersString;
NSImage * fIcon;
}
- (void) setStat: (tr_stat_t *) stat whiteText: (BOOL) w;
@end

View File

@ -33,6 +33,12 @@
fNameString = [NSString stringWithUTF8String: stat->info.name];
fSizeString = [NSString stringWithFormat: @" (%@)",
[NSString stringForFileSize: stat->info.totalSize]];
fIcon = [[NSWorkspace sharedWorkspace] iconForFile:
[[NSString stringWithUTF8String: stat->folder]
stringByAppendingPathComponent: fNameString]];
[fIcon setFlipped: YES];
fTimeString = @"";
fPeersString = @"";
@ -97,6 +103,13 @@
}
pen = cellFrame.origin;
float cellWidth = cellFrame.size.width;
pen.x += 5;
pen.y += 5;
[fIcon drawAtPoint: pen fromRect:
NSMakeRect(0,0,[fIcon size].width,[fIcon size].height)
operation: NSCompositeSourceOver fraction: 1.0];
attributes = [NSMutableDictionary dictionaryWithCapacity: 2];
[attributes setObject: fWhiteText ? [NSColor whiteColor] :
@ -105,9 +118,9 @@
[attributes setObject: [NSFont messageFontOfSize: 12.0]
forKey: NSFontAttributeName];
pen.x += 5; pen.y += 5;
string = [[fNameString stringFittingInWidth: cellFrame.size.width -
35 - [fSizeString sizeWithAttributes: attributes].width
pen.x += 37;
string = [[fNameString stringFittingInWidth: cellWidth -
72 - [fSizeString sizeWithAttributes: attributes].width
withAttributes: attributes] stringByAppendingString: fSizeString];
[string drawAtPoint: pen withAttributes: attributes];
@ -119,7 +132,7 @@
pen.x += 0; pen.y += 15;
string = [fPeersString stringFittingInWidth: cellFrame.size.width -
40 withAttributes: attributes];
77 withAttributes: attributes];
[string drawAtPoint: pen withAttributes: attributes];
[view unlockFocus];