Add the contextual menu to the other columns of the commit list

Now all the columns have the menu for the commit, not just the subject column.
This commit is contained in:
Nathan Kinsinger
2010-09-04 17:57:12 -06:00
parent e56ca103ca
commit b28afa1644
6 changed files with 101 additions and 18 deletions
+2 -1
View File
@@ -7,10 +7,11 @@
//
#import <Cocoa/Cocoa.h>
#import "PBRefContextDelegate.h"
@interface GitXTextFieldCell : NSTextFieldCell {
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
}
@end
+17
View File
@@ -7,6 +7,8 @@
//
#import "GitXTextFieldCell.h"
#import "PBGitCommit.h"
#import "PBRefController.h"
@implementation GitXTextFieldCell
@@ -17,4 +19,19 @@
return nil;
}
- (NSMenu *)menuForEvent:(NSEvent *)anEvent inRect:(NSRect)cellFrame ofView:(NSTableView *)commitList
{
NSInteger rowIndex = [commitList rowAtPoint:(cellFrame.origin)];
NSArray *items = [contextMenuDelegate menuItemsForRow:rowIndex];
if (!items)
return nil;
NSMenu *menu = [[NSMenu alloc] init];
[menu setAutoenablesItems:NO];
for (NSMenuItem *item in items)
[menu addItem:item];
return menu;
}
@end
+68 -17
View File
@@ -1616,14 +1616,6 @@
</object>
<int key="connectionID">95</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="254268962"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">96</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
@@ -1696,14 +1688,6 @@
</object>
<int key="connectionID">234</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="254268962"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">235</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
@@ -2097,13 +2081,69 @@
</object>
<int key="connectionID">436</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
<reference key="source" ref="746918365"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">438</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
<reference key="source" ref="853819733"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">439</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
<reference key="source" ref="750921840"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">440</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
<reference key="source" ref="671609291"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">441</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">contextMenuDelegate</string>
<reference key="source" ref="493129112"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">442</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="254268962"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">444</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">dataSource</string>
<reference key="source" ref="254268962"/>
<reference key="destination" ref="892732705"/>
</object>
<int key="connectionID">445</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">searchController</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="596748029"/>
</object>
<int key="connectionID">437</int>
<int key="connectionID">446</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
@@ -3064,6 +3104,17 @@
<object class="IBPartialClassDescription">
<string key="className">GitXTextFieldCell</string>
<string key="superclassName">NSTextFieldCell</string>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">contextMenuDelegate</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">contextMenuDelegate</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">contextMenuDelegate</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">GitXTextFieldCell.h</string>
+4
View File
@@ -7,8 +7,12 @@
//
@class PBGitRef;
@class PBGitCommit;
@protocol PBRefContextDelegate
- (NSArray *) menuItemsForRef:(PBGitRef *)ref;
- (NSArray *) menuItemsForCommit:(PBGitCommit *)commit;
- (NSArray *)menuItemsForRow:(NSInteger)rowIndex;
@end
+1
View File
@@ -43,6 +43,7 @@
- (NSArray *) menuItemsForRef:(PBGitRef *)ref;
- (NSArray *) menuItemsForCommit:(PBGitCommit *)commit;
- (NSArray *)menuItemsForRow:(NSInteger)rowIndex;
@end
+9
View File
@@ -275,6 +275,15 @@
return [PBRefMenuItem defaultMenuItemsForCommit:commit target:self];
}
- (NSArray *)menuItemsForRow:(NSInteger)rowIndex
{
NSArray *commits = [commitController arrangedObjects];
if ([commits count] <= rowIndex)
return nil;
return [self menuItemsForCommit:[commits objectAtIndex:rowIndex]];
}
# pragma mark Tableview delegate methods