Revision: 3065 http://skim-app.svn.sourceforge.net/skim-app/?rev=3065&view=rev Author: hofman Date: 2007-10-23 10:38:43 -0700 (Tue, 23 Oct 2007)
Log Message: ----------- Display icon with question mark for bookmarks with missing links. Modified Paths: -------------- trunk/NSImage_SKExtensions.h trunk/NSImage_SKExtensions.m trunk/SKBookmark.m Modified: trunk/NSImage_SKExtensions.h =================================================================== --- trunk/NSImage_SKExtensions.h 2007-10-23 17:10:49 UTC (rev 3064) +++ trunk/NSImage_SKExtensions.h 2007-10-23 17:38:43 UTC (rev 3065) @@ -46,6 +46,9 @@ + (NSImage *)iconWithSize:(NSSize)iconSize forToolboxCode:(OSType)code; + (NSImage *)imageWithIconForToolboxCode:(OSType)code; ++ (NSImage *)smallMissingFileImage; ++ (NSImage *)missingFileImage; + - (void)drawFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(float)delta; - (void)drawFlipped:(BOOL)isFlipped inRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(float)delta; Modified: trunk/NSImage_SKExtensions.m =================================================================== --- trunk/NSImage_SKExtensions.m 2007-10-23 17:10:49 UTC (rev 3064) +++ trunk/NSImage_SKExtensions.m 2007-10-23 17:38:43 UTC (rev 3065) @@ -601,6 +601,34 @@ return [self iconWithSize:NSMakeSize(32,32) forToolboxCode:code]; } ++ (NSImage *)missingFileImage { + static NSImage *image = nil; + if(image == nil){ + image = [[NSImage alloc] initWithSize:NSMakeSize(32, 32)]; + NSImage *genericDocImage = [self iconWithSize:NSMakeSize(32, 32) forToolboxCode:kGenericDocumentIcon]; + NSImage *questionMark = [self iconWithSize:NSMakeSize(20, 20) forToolboxCode:kQuestionMarkIcon]; + [image lockFocus]; + [genericDocImage compositeToPoint:NSZeroPoint operation:NSCompositeCopy fraction:0.7]; + [questionMark compositeToPoint:NSMakePoint(6, 4) operation:NSCompositeSourceOver fraction:0.7]; + [image unlockFocus]; + } + return image; +} + ++ (NSImage *)smallMissingFileImage { + static NSImage *image = nil; + if(image == nil){ + image = [[NSImage alloc] initWithSize:NSMakeSize(16, 16)]; + NSImage *genericDocImage = [self iconWithSize:NSMakeSize(16, 16) forToolboxCode:kGenericDocumentIcon]; + NSImage *questionMark = [self iconWithSize:NSMakeSize(10, 10) forToolboxCode:kQuestionMarkIcon]; + [image lockFocus]; + [genericDocImage compositeToPoint:NSZeroPoint operation:NSCompositeCopy fraction:0.7]; + [questionMark compositeToPoint:NSMakePoint(3, 2) operation:NSCompositeSourceOver fraction:0.7]; + [image unlockFocus]; + } + return image; +} + - (void)drawFlippedInRect:(NSRect)dstRect fromRect:(NSRect)srcRect operation:(NSCompositingOperation)op fraction:(float)delta { [NSGraphicsContext saveGraphicsState]; NSAffineTransform *transform = [NSAffineTransform transform]; Modified: trunk/SKBookmark.m =================================================================== --- trunk/SKBookmark.m 2007-10-23 17:10:49 UTC (rev 3064) +++ trunk/SKBookmark.m 2007-10-23 17:38:43 UTC (rev 3065) @@ -39,6 +39,7 @@ #import "SKBookmark.h" #import "SKBookmarkController.h" #import "BDAlias.h" +#import "NSImage_SKExtensions.h" NSString *SKBookmarkChangedNotification = @"SKBookmarkChangedNotification"; NSString *SKBookmarkWillBeRemovedNotification = @"SKBookmarkWillBeRemovedNotification"; @@ -57,18 +58,19 @@ + (NSImage *)smallImageForFile:(NSString *)filePath { static NSMutableDictionary *smallIcons = nil; - if (smallIcons == nil) - smallIcons = [[NSMutableDictionary alloc] init]; + if (filePath == nil) + return [NSImage smallMissingFileImage]; + NSString *extension = [filePath pathExtension]; - if (extension == nil) - return nil; - NSImage *icon = [smallIcons objectForKey:extension]; if (icon == nil) { + if (smallIcons == nil) + smallIcons = [[NSMutableDictionary alloc] init]; NSImage *image = [[NSWorkspace sharedWorkspace] iconForFileType:extension]; - if (image) {NSRect sourceRect = {NSZeroPoint, [image size]}; + if (image) { + NSRect sourceRect = {NSZeroPoint, [image size]}; NSRect targetRect = NSMakeRect(0.0, 0.0, 16.0, 16.0); icon = [[NSImage alloc] initWithSize:targetRect.size]; [icon lockFocus]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Skim-app-commit mailing list Skim-app-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/skim-app-commit