// // NSMenu+Additions.m // Perforce // // Created by Adam Czubernat on 30/10/2013. // Copyright (c) 2013 Perforce Software, Inc. All rights reserved. // #import "NSMenu+Additions.h" #import "P4Item.h" #import "BrowserViewController.h" @implementation NSMenu (Additions) - (void)setItem:(P4Item *)item delegate:(id)delegate { [self removeAllItems]; if (!item) return; [self setAutoenablesItems:NO]; [self addItemWithTitle:item.name action:nil keyEquivalent:@""]; [[self itemAtIndex:0] setEnabled:NO]; [self addItem:[NSMenuItem separatorItem]]; for (P4ItemAction *action in item.actions) { SEL selector = action.selector; if ([self itemAtIndex:[self numberOfItems]-1] != [NSMenuItem separatorItem]) { if (selector == @selector(markAsRead) || selector == @selector(markAllAsRead) || selector == @selector(showInFinder) || selector == @selector(revertIfUnchanged) || selector == @selector(deleteItem) || selector == @selector(createDirectory) || selector == @selector(unmapFromWorkspace) || selector == @selector(unshelve)) [self addItem:[NSMenuItem separatorItem]]; } action.delegate = delegate; NSMenuItem *menuItem = [[NSMenuItem alloc] init]; [menuItem setTitle:action.name]; [menuItem setTarget:action]; [menuItem setRepresentedObject:action]; // Strong [menuItem setAction:@selector(performAction)]; [menuItem setEnabled:!action.disabled]; [self addItem:menuItem]; // // Back separators // if (selector == @selector(...)) // [self addItem:[NSMenuItem separatorItem]]; } } - (void)setItems:(NSArray *)items delegate:(id)controller { [self removeAllItems]; if (!items.count) return; [self setAutoenablesItems:NO]; [self addItemWithTitle:@"Multiple Files" action:nil keyEquivalent:@""]; [[self itemAtIndex:0] setEnabled:NO]; [self addItem:[NSMenuItem separatorItem]]; for (P4ItemAction *action in [[items lastObject] actionsForItems:items]) { action.delegate = controller; NSMenuItem *menuItem = [[NSMenuItem alloc] init]; [menuItem setTitle:action.name]; [menuItem setTarget:action]; [menuItem setRepresentedObject:action]; // Strong [menuItem setAction:@selector(performAction)]; [menuItem setEnabled:YES]; [self addItem:menuItem]; } } @end
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 16817 | christoph_leithner | "Forking branch Main of perforce-software-piper to christoph_leithner-piper." | ||
//guest/perforce_software/piper/main/mac/R1.0/Perforce/Classes/Helpers/NSMenu+Additions.m | |||||
#1 | 16507 | perforce_software | Move to main branch. | ||
//guest/perforce_software/piper/mac/R1.0/Perforce/Classes/Helpers/NSMenu+Additions.m | |||||
#1 | 11254 | alan_petersen |
Populate //guest/perforce_software/piper/mac/R1.0/... from //guest/perforce_software/piper/mac/main/.... |
||
//guest/perforce_software/piper/mac/main/Perforce/Classes/Helpers/NSMenu+Additions.m | |||||
#1 | 11252 | alan_petersen | Rename/move file(s) | ||
//guest/perforce_software/piper/mac/Perforce/Classes/Helpers/NSMenu+Additions.m | |||||
#1 | 10744 | alan_petersen | Rename/move file(s) | ||
//guest/perforce_software/piper/Perforce/Classes/Helpers/NSMenu+Additions.m | |||||
#1 | 8919 | Matt Attaway | Initial add of Piper, a lightweight Perforce client for artists and designers. |