From f6a70e2a8f85bc3f8e8ec33092d19bb0614425f4 Mon Sep 17 00:00:00 2001 From: Eric Petit Date: Sun, 29 Jan 2006 19:18:03 +0000 Subject: [PATCH] Show the file icon in the "Name" cell Changed 0.5-cvs to 0.5-svn --- Jamrules | 2 +- macosx/NameCell.h | 2 ++ macosx/NameCell.m | 21 +++++++++++++++++---- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/Jamrules b/Jamrules index 9f5939a21..3f3b7d4e2 100644 --- a/Jamrules +++ b/Jamrules @@ -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) diff --git a/macosx/NameCell.h b/macosx/NameCell.h index eaa20ffa2..a0b93dae5 100644 --- a/macosx/NameCell.h +++ b/macosx/NameCell.h @@ -35,6 +35,8 @@ NSString * fSizeString; NSString * fTimeString; NSString * fPeersString; + + NSImage * fIcon; } - (void) setStat: (tr_stat_t *) stat whiteText: (BOOL) w; @end diff --git a/macosx/NameCell.m b/macosx/NameCell.m index c569c7f5a..9af470fab 100644 --- a/macosx/NameCell.m +++ b/macosx/NameCell.m @@ -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];