Browse files

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.
  • Loading branch information...
1 parent e56ca10 commit b28afa1644e149a36f10e19bc156093a9e3c6afa @brotherbard committed Sep 4, 2010
Showing with 101 additions and 18 deletions.
  1. +2 −1 GitXTextFieldCell.h
  2. +17 −0 GitXTextFieldCell.m
  3. +68 −17 PBGitHistoryView.xib
  4. +4 −0 PBRefContextDelegate.h
  5. +1 −0 PBRefController.h
  6. +9 −0 PBRefController.m
View
3 GitXTextFieldCell.h
@@ -7,10 +7,11 @@
//
#import <Cocoa/Cocoa.h>
+#import "PBRefContextDelegate.h"
@interface GitXTextFieldCell : NSTextFieldCell {
-
+ IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
}
@end
View
17 GitXTextFieldCell.m
@@ -7,6 +7,8 @@
//
#import "GitXTextFieldCell.h"
+#import "PBGitCommit.h"
+#import "PBRefController.h"
@implementation GitXTextFieldCell
@@ -17,4 +19,19 @@ - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlV
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
View
85 PBGitHistoryView.xib
@@ -1619,14 +1619,6 @@
<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>
<reference key="source" ref="202620420"/>
<reference key="destination" ref="1001"/>
</object>
@@ -1698,14 +1690,6 @@
</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>
<reference key="source" ref="977219207"/>
<reference key="destination" ref="892732705"/>
@@ -2099,11 +2083,67 @@
</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>
View
4 PBRefContextDelegate.h
@@ -7,8 +7,12 @@
//
+@class PBGitRef;
+@class PBGitCommit;
+
@protocol PBRefContextDelegate
- (NSArray *) menuItemsForRef:(PBGitRef *)ref;
- (NSArray *) menuItemsForCommit:(PBGitCommit *)commit;
+- (NSArray *)menuItemsForRow:(NSInteger)rowIndex;
@end
View
1 PBRefController.h
@@ -43,6 +43,7 @@
- (NSArray *) menuItemsForRef:(PBGitRef *)ref;
- (NSArray *) menuItemsForCommit:(PBGitCommit *)commit;
+- (NSArray *)menuItemsForRow:(NSInteger)rowIndex;
@end
View
9 PBRefController.m
@@ -275,6 +275,15 @@ - (NSArray *) menuItemsForCommit:(PBGitCommit *)commit
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

0 comments on commit b28afa1

Please sign in to comment.