Skip to content

Commit b28afa1

Browse files
committed
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.
1 parent e56ca10 commit b28afa1

6 files changed

+101
-18
lines changed

GitXTextFieldCell.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
//
88

99
#import <Cocoa/Cocoa.h>
10+
#import "PBRefContextDelegate.h"
1011

1112

1213
@interface GitXTextFieldCell : NSTextFieldCell {
13-
14+
IBOutlet id<PBRefContextDelegate> contextMenuDelegate;
1415
}
1516

1617
@end

GitXTextFieldCell.m

+17
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
//
88

99
#import "GitXTextFieldCell.h"
10+
#import "PBGitCommit.h"
11+
#import "PBRefController.h"
1012

1113

1214
@implementation GitXTextFieldCell
@@ -17,4 +19,19 @@ - (NSColor *)highlightColorWithFrame:(NSRect)cellFrame inView:(NSView *)controlV
1719
return nil;
1820
}
1921

22+
- (NSMenu *)menuForEvent:(NSEvent *)anEvent inRect:(NSRect)cellFrame ofView:(NSTableView *)commitList
23+
{
24+
NSInteger rowIndex = [commitList rowAtPoint:(cellFrame.origin)];
25+
NSArray *items = [contextMenuDelegate menuItemsForRow:rowIndex];
26+
if (!items)
27+
return nil;
28+
29+
NSMenu *menu = [[NSMenu alloc] init];
30+
[menu setAutoenablesItems:NO];
31+
for (NSMenuItem *item in items)
32+
[menu addItem:item];
33+
34+
return menu;
35+
}
36+
2037
@end

PBGitHistoryView.xib

+68-17
Original file line numberDiff line numberDiff line change
@@ -1616,14 +1616,6 @@
16161616
</object>
16171617
<int key="connectionID">95</int>
16181618
</object>
1619-
<object class="IBConnectionRecord">
1620-
<object class="IBOutletConnection" key="connection">
1621-
<string key="label">delegate</string>
1622-
<reference key="source" ref="254268962"/>
1623-
<reference key="destination" ref="1001"/>
1624-
</object>
1625-
<int key="connectionID">96</int>
1626-
</object>
16271619
<object class="IBConnectionRecord">
16281620
<object class="IBOutletConnection" key="connection">
16291621
<string key="label">delegate</string>
@@ -1696,14 +1688,6 @@
16961688
</object>
16971689
<int key="connectionID">234</int>
16981690
</object>
1699-
<object class="IBConnectionRecord">
1700-
<object class="IBOutletConnection" key="connection">
1701-
<string key="label">dataSource</string>
1702-
<reference key="source" ref="254268962"/>
1703-
<reference key="destination" ref="892732705"/>
1704-
</object>
1705-
<int key="connectionID">235</int>
1706-
</object>
17071691
<object class="IBConnectionRecord">
17081692
<object class="IBOutletConnection" key="connection">
17091693
<string key="label">contextMenuDelegate</string>
@@ -2097,13 +2081,69 @@
20972081
</object>
20982082
<int key="connectionID">436</int>
20992083
</object>
2084+
<object class="IBConnectionRecord">
2085+
<object class="IBOutletConnection" key="connection">
2086+
<string key="label">contextMenuDelegate</string>
2087+
<reference key="source" ref="746918365"/>
2088+
<reference key="destination" ref="892732705"/>
2089+
</object>
2090+
<int key="connectionID">438</int>
2091+
</object>
2092+
<object class="IBConnectionRecord">
2093+
<object class="IBOutletConnection" key="connection">
2094+
<string key="label">contextMenuDelegate</string>
2095+
<reference key="source" ref="853819733"/>
2096+
<reference key="destination" ref="892732705"/>
2097+
</object>
2098+
<int key="connectionID">439</int>
2099+
</object>
2100+
<object class="IBConnectionRecord">
2101+
<object class="IBOutletConnection" key="connection">
2102+
<string key="label">contextMenuDelegate</string>
2103+
<reference key="source" ref="750921840"/>
2104+
<reference key="destination" ref="892732705"/>
2105+
</object>
2106+
<int key="connectionID">440</int>
2107+
</object>
2108+
<object class="IBConnectionRecord">
2109+
<object class="IBOutletConnection" key="connection">
2110+
<string key="label">contextMenuDelegate</string>
2111+
<reference key="source" ref="671609291"/>
2112+
<reference key="destination" ref="892732705"/>
2113+
</object>
2114+
<int key="connectionID">441</int>
2115+
</object>
2116+
<object class="IBConnectionRecord">
2117+
<object class="IBOutletConnection" key="connection">
2118+
<string key="label">contextMenuDelegate</string>
2119+
<reference key="source" ref="493129112"/>
2120+
<reference key="destination" ref="892732705"/>
2121+
</object>
2122+
<int key="connectionID">442</int>
2123+
</object>
2124+
<object class="IBConnectionRecord">
2125+
<object class="IBOutletConnection" key="connection">
2126+
<string key="label">delegate</string>
2127+
<reference key="source" ref="254268962"/>
2128+
<reference key="destination" ref="1001"/>
2129+
</object>
2130+
<int key="connectionID">444</int>
2131+
</object>
2132+
<object class="IBConnectionRecord">
2133+
<object class="IBOutletConnection" key="connection">
2134+
<string key="label">dataSource</string>
2135+
<reference key="source" ref="254268962"/>
2136+
<reference key="destination" ref="892732705"/>
2137+
</object>
2138+
<int key="connectionID">445</int>
2139+
</object>
21002140
<object class="IBConnectionRecord">
21012141
<object class="IBOutletConnection" key="connection">
21022142
<string key="label">searchController</string>
21032143
<reference key="source" ref="1001"/>
21042144
<reference key="destination" ref="596748029"/>
21052145
</object>
2106-
<int key="connectionID">437</int>
2146+
<int key="connectionID">446</int>
21072147
</object>
21082148
<object class="IBConnectionRecord">
21092149
<object class="IBOutletConnection" key="connection">
@@ -3064,6 +3104,17 @@
30643104
<object class="IBPartialClassDescription">
30653105
<string key="className">GitXTextFieldCell</string>
30663106
<string key="superclassName">NSTextFieldCell</string>
3107+
<object class="NSMutableDictionary" key="outlets">
3108+
<string key="NS.key.0">contextMenuDelegate</string>
3109+
<string key="NS.object.0">id</string>
3110+
</object>
3111+
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
3112+
<string key="NS.key.0">contextMenuDelegate</string>
3113+
<object class="IBToOneOutletInfo" key="NS.object.0">
3114+
<string key="name">contextMenuDelegate</string>
3115+
<string key="candidateClassName">id</string>
3116+
</object>
3117+
</object>
30673118
<object class="IBClassDescriptionSource" key="sourceIdentifier">
30683119
<string key="majorKey">IBProjectSource</string>
30693120
<string key="minorKey">GitXTextFieldCell.h</string>

PBRefContextDelegate.h

+4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,12 @@
77
//
88

99

10+
@class PBGitRef;
11+
@class PBGitCommit;
12+
1013

1114
@protocol PBRefContextDelegate
1215
- (NSArray *) menuItemsForRef:(PBGitRef *)ref;
1316
- (NSArray *) menuItemsForCommit:(PBGitCommit *)commit;
17+
- (NSArray *)menuItemsForRow:(NSInteger)rowIndex;
1418
@end

PBRefController.h

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343

4444
- (NSArray *) menuItemsForRef:(PBGitRef *)ref;
4545
- (NSArray *) menuItemsForCommit:(PBGitCommit *)commit;
46+
- (NSArray *)menuItemsForRow:(NSInteger)rowIndex;
4647

4748

4849
@end

PBRefController.m

+9
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,15 @@ - (NSArray *) menuItemsForCommit:(PBGitCommit *)commit
275275
return [PBRefMenuItem defaultMenuItemsForCommit:commit target:self];
276276
}
277277

278+
- (NSArray *)menuItemsForRow:(NSInteger)rowIndex
279+
{
280+
NSArray *commits = [commitController arrangedObjects];
281+
if ([commits count] <= rowIndex)
282+
return nil;
283+
284+
return [self menuItemsForCommit:[commits objectAtIndex:rowIndex]];
285+
}
286+
278287

279288
# pragma mark Tableview delegate methods
280289

0 commit comments

Comments
 (0)