From: <ho...@us...> - 2008-06-25 20:44:48
|
Revision: 4072 http://skim-app.svn.sourceforge.net/skim-app/?rev=4072&view=rev Author: hofman Date: 2008-06-25 13:44:40 -0700 (Wed, 25 Jun 2008) Log Message: ----------- Use static set for selection action items to remove from the PDFView contextual menu. Modified Paths: -------------- trunk/BDSKZoomablePDFView.m trunk/SKSecondaryPDFView.m Modified: trunk/BDSKZoomablePDFView.m =================================================================== --- trunk/BDSKZoomablePDFView.m 2008-06-25 20:42:03 UTC (rev 4071) +++ trunk/BDSKZoomablePDFView.m 2008-06-25 20:44:40 UTC (rev 4072) @@ -327,14 +327,16 @@ } - (NSMenu *)menuForEvent:(NSEvent *)theEvent { + static NSSet *selectionActions = nil; + if (selectionActions == nil) + selectionActions = [[NSSet alloc] initWithObjects:@"_searchInSpotlight:", @"_searchInGoogle:", @"_searchInDictionary:", nil]; NSMenu *menu = [super menuForEvent:theEvent]; int i, count = [menu numberOfItems]; [self setCurrentSelection:nil]; while ([menu numberOfItems]) { NSMenuItem *item = [menu itemAtIndex:0]; - NSString *action = NSStringFromSelector([item action]); - if ([item isSeparatorItem] || [action isEqualToString:@"_searchInSpotlight:"] || [action isEqualToString:@"_searchInGoogle:"] || [action isEqualToString:@"_searchInDictionary:"] || [self validateMenuItem:item] == NO) + if ([item isSeparatorItem] || [self validateMenuItem:item] == NO || [selectionActions containsObject:NSStringFromSelector([item action])]) [menu removeItemAtIndex:0]; else break; Modified: trunk/SKSecondaryPDFView.m =================================================================== --- trunk/SKSecondaryPDFView.m 2008-06-25 20:42:03 UTC (rev 4071) +++ trunk/SKSecondaryPDFView.m 2008-06-25 20:44:40 UTC (rev 4072) @@ -353,6 +353,9 @@ } - (NSMenu *)menuForEvent:(NSEvent *)theEvent { + static NSSet *selectionActions = nil; + if (selectionActions == nil) + selectionActions = [[NSSet alloc] initWithObjects:@"_searchInSpotlight:", @"_searchInGoogle:", @"_searchInDictionary:", nil]; NSMenu *menu = [super menuForEvent:theEvent]; int i = [menu indexOfItemWithTarget:self andAction:NSSelectorFromString(@"_toggleContinuous:")]; NSMenuItem *item; @@ -360,9 +363,8 @@ [self setCurrentSelection:nil]; while ([menu numberOfItems]) { - item = [menu itemAtIndex:0]; - NSString *action = NSStringFromSelector([item action]); - if ([item isSeparatorItem] || [action isEqualToString:@"_searchInSpotlight:"] || [action isEqualToString:@"_searchInGoogle:"] || [action isEqualToString:@"_searchInDictionary:"] || [self validateMenuItem:item] == NO) + NSMenuItem *item = [menu itemAtIndex:0]; + if ([item isSeparatorItem] || [self validateMenuItem:item] == NO || [selectionActions containsObject:NSStringFromSelector([item action])]) [menu removeItemAtIndex:0]; else break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |