| | 40 | - (NSImage *) iconForObjectValue:(id)objectValue { |
|---|
| | 41 | NSImage *icon = nil; |
|---|
| | 42 | |
|---|
| | 43 | NSString *path = objectValue; |
|---|
| | 44 | |
|---|
| | 45 | //First try to get a preview (AXCAbstractXtraDocument creates these). |
|---|
| | 46 | if (iconSource.iconSourceBitfield.getPreviewsByFullPath) |
|---|
| | 47 | icon = [NSImage imageNamed:[@"Preview of " stringByAppendingString:path]]; |
|---|
| | 48 | |
|---|
| | 49 | //If there's no preview for the absolute path, try the filename. |
|---|
| | 50 | if (iconSource.iconSourceBitfield.getPreviewsByFilename && (!icon) && [path isAbsolutePath]) |
|---|
| | 51 | icon = [NSImage imageNamed:[@"Preview of " stringByAppendingString:[path lastPathComponent]]]; |
|---|
| | 52 | |
|---|
| | 53 | //If there isn't a preview for either path, just get the file's icon. |
|---|
| | 54 | if (iconSource.iconSourceBitfield.getPreviewsFromFileIcons && !icon) { |
|---|
| | 55 | icon = [[NSWorkspace sharedWorkspace] iconForFile:path]; |
|---|
| | 56 | [icon setFlipped:YES]; |
|---|
| | 57 | } |
|---|
| | 58 | |
|---|
| | 59 | //Fallback on generic file icon. |
|---|
| | 60 | if (!icon) { |
|---|
| | 61 | icon = [[NSWorkspace sharedWorkspace] iconForFileType:@"'docu'"]; |
|---|
| | 62 | [icon setFlipped:YES]; |
|---|
| | 63 | } |
|---|
| | 64 | |
|---|
| | 65 | return icon; |
|---|
| | 66 | } |
|---|
| | 67 | |
|---|
| | 68 | - (NSString *) filenameForObjectValue:(id)objectValue { |
|---|
| | 69 | NSString *path = objectValue; |
|---|
| | 70 | |
|---|
| | 71 | return [[NSFileManager defaultManager] displayNameAtPath:path]; |
|---|
| | 72 | } |
|---|
| | 73 | |
|---|
| 47 | | //first try to get a preview (AXCAbstractXtraDocument creates these). |
|---|
| 48 | | NSImage *icon = nil; |
|---|
| 49 | | if (iconSource.iconSourceBitfield.getPreviewsByFullPath) |
|---|
| 50 | | icon = [NSImage imageNamed:[@"Preview of " stringByAppendingString:path]]; |
|---|
| 51 | | //if there's no preview for the absolute path, try the filename. |
|---|
| 52 | | if (iconSource.iconSourceBitfield.getPreviewsByFilename && (!icon) && [path isAbsolutePath]) |
|---|
| 53 | | icon = [NSImage imageNamed:[@"Preview of " stringByAppendingString:[path lastPathComponent]]]; |
|---|
| 54 | | //if there isn't a preview for either path, just get the file's icon. |
|---|
| 55 | | if (iconSource.iconSourceBitfield.getPreviewsFromFileIcons && !icon) { |
|---|
| 56 | | icon = [[NSWorkspace sharedWorkspace] iconForFile:path]; |
|---|
| 57 | | [icon setFlipped:YES]; |
|---|
| 58 | | } |
|---|
| 59 | | //fallback on generic file icon. |
|---|
| 60 | | if (!icon) { |
|---|
| 61 | | icon = [[NSWorkspace sharedWorkspace] iconForFileType:@"'docu'"]; |
|---|
| 62 | | [icon setFlipped:YES]; |
|---|
| 63 | | } |
|---|
| | 79 | NSImage *icon = [self iconForObjectValue:[self objectValue]]; |
|---|