diff --git a/GitX.xcodeproj/project.pbxproj b/GitX.xcodeproj/project.pbxproj index c3ceb36..2a34336 100644 --- a/GitX.xcodeproj/project.pbxproj +++ b/GitX.xcodeproj/project.pbxproj @@ -207,6 +207,7 @@ F5EF8C8D0E9D4A5D0050906B /* PBWebController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBWebController.m; sourceTree = ""; }; F5FC41F20EBCBD4300191D80 /* PBGitXProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitXProtocol.h; sourceTree = ""; }; F5FC41F30EBCBD4300191D80 /* PBGitXProtocol.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBGitXProtocol.m; sourceTree = ""; }; + F5FC43C30EBD050800191D80 /* PBRefContextDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBRefContextDelegate.h; sourceTree = ""; }; F5FE6C010EB13BC900F30D12 /* PBServicesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBServicesController.h; sourceTree = ""; }; F5FE6C020EB13BC900F30D12 /* PBServicesController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PBServicesController.m; sourceTree = ""; }; F5FF4E160E0829C20006317A /* PBGitRevList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PBGitRevList.h; sourceTree = ""; }; @@ -469,6 +470,7 @@ F53FF2040E7ABB5300389171 /* PBGitRevSpecifier.m */, F56174550E058893001DCD79 /* PBGitTree.h */, F56174560E058893001DCD79 /* PBGitTree.m */, + F5FC43C30EBD050800191D80 /* PBRefContextDelegate.h */, ); name = History; sourceTree = ""; diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib index 818202e..d32f9d3 100644 --- a/PBGitHistoryView.xib +++ b/PBGitHistoryView.xib @@ -9,7 +9,7 @@ YES - + YES @@ -1030,7 +1030,7 @@ PBRefController - + 15 2 {{196, 376}, {346, 134}} @@ -1039,26 +1039,26 @@ NSWindow {3.40282e+38, 3.40282e+38} - + 256 YES - - + + 268 {{145, 61}, {96, 22}} - + YES - + -1804468671 272630784 topic - + YES - + 6 System textBackgroundColor @@ -1072,50 +1072,50 @@ - - + + 268 {{17, 63}, {123, 17}} - + YES - + 68288064 272630784 New Branch Name: - + - - + + 268 {{17, 97}, {134, 17}} - + YES - + 68288064 272630784 Create a new branch - + - - + + 268 {{236, 12}, {96, 32}} - + YES - + 67239424 134217728 OK - + -2038284033 129 @@ -1124,18 +1124,18 @@ 25 - - + + 268 {{139, 13}, {96, 32}} - + YES - + 67239424 134217728 Cancel - + -2038284033 129 @@ -1220,7 +1220,7 @@ YES 0 - + 6F542219-165D-4621-B546-D8E7DF547248 @@ -1264,7 +1264,7 @@ YES 1 - + 130560 @@ -1471,7 +1471,7 @@ YES - + @@ -1481,7 +1481,7 @@ - + @@ -2046,8 +2046,8 @@ performClick: - - + + 248 @@ -2055,7 +2055,7 @@ newBranchSheet - + 249 @@ -2063,7 +2063,7 @@ newBranchName - + 250 @@ -2071,7 +2071,7 @@ closeSheet: - + 252 @@ -2079,7 +2079,7 @@ saveSheet: - + 253 @@ -2087,7 +2087,7 @@ addRef: - + 255 @@ -2099,6 +2099,14 @@ 258 + + + contextMenuDelegate + + + + 259 + @@ -2483,95 +2491,95 @@ 236 - + YES - + 237 - + YES - - - - - + + + + + - + 238 - + YES - + - + 239 - + YES - + - + 240 - + YES - + - + 241 - + YES - + - + 242 - + YES - + - + 243 - - + + 244 - - + + 245 - - + + 246 - - + + 247 - - + + 113 @@ -2583,7 +2591,7 @@ - + History Toolbar @@ -2627,7 +2635,7 @@ 254 - + @@ -2909,7 +2917,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{161, 574}, {852, 432}} + {{289, 574}, {852, 432}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2939,7 +2947,7 @@ - 258 + 259 @@ -2958,7 +2966,7 @@ YES PBGitHistoryController - PBWebHistoryController + id WebView @@ -3034,11 +3042,13 @@ YES YES + contextMenuDelegate controller objectValue YES + id PBGitHistoryController id diff --git a/PBGitRevisionCell.h b/PBGitRevisionCell.h index a87944f..57478bb 100644 --- a/PBGitRevisionCell.h +++ b/PBGitRevisionCell.h @@ -10,12 +10,14 @@ #import "PBGitGrapher.h" #import "PBGraphCellInfo.h" #import "PBGitHistoryController.h" +#import "PBRefContextDelegate.h" @interface PBGitRevisionCell : NSActionCell { id objectValue; PBGraphCellInfo *cellInfo; NSTextFieldCell *textCell; IBOutlet PBGitHistoryController *controller; + IBOutlet id contextMenuDelegate; } - (int) indexAtX:(float)x; diff --git a/PBGitRevisionCell.m b/PBGitRevisionCell.m index 698627e..ac28c9e 100644 --- a/PBGitRevisionCell.m +++ b/PBGitRevisionCell.m @@ -278,4 +278,27 @@ return [[[self rectsForRefsinRect:refRect] objectAtIndex:index] rectValue]; } +# pragma mark context menu delegate methods + +- (NSMenu *) menuForEvent:(NSEvent *)event inRect:(NSRect)rect ofView:(NSView *)view +{ + if (!contextMenuDelegate) + return [self menu]; + + int i = [self indexAtX:[view convertPointFromBase:[event locationInWindow]].x]; + if (i < 0) + return [self menu]; + + id ref = [[[self objectValue] refs] objectAtIndex:i]; + if (!ref) + return [self menu]; + + NSArray *items = [contextMenuDelegate menuItemsForRef:ref commit:[self objectValue]]; + NSMenu *menu = [[NSMenu alloc] init]; + for (NSMenuItem *item in items) + [menu addItem:item]; + return menu; + + return [self menu]; +} @end diff --git a/PBRefContextDelegate.h b/PBRefContextDelegate.h new file mode 100644 index 0000000..81019ce --- /dev/null +++ b/PBRefContextDelegate.h @@ -0,0 +1,13 @@ +// +// PBRefContextDelegate.m +// GitX +// +// Created by Pieter de Bie on 01-11-08. +// Copyright 2008 Pieter de Bie. All rights reserved. +// + + + +@protocol PBRefContextDelegate +- (NSArray *) menuItemsForRef:(PBGitRef *)ref commit:(PBGitCommit *)commit; +@end diff --git a/PBRefController.h b/PBRefController.h index f7dcfcc..3b844a3 100644 --- a/PBRefController.h +++ b/PBRefController.h @@ -11,8 +11,9 @@ #import "PBCommitList.h" #import "PBGitRef.h" #import "PBGitCommit.h" +#import "PBRefContextDelegate.h" -@interface PBRefController : NSObject { +@interface PBRefController : NSObject { IBOutlet __weak PBGitHistoryController *historyController; IBOutlet NSArrayController *commitController; IBOutlet PBCommitList *commitList; diff --git a/PBWebHistoryController.h b/PBWebHistoryController.h index 17723c2..749725a 100644 --- a/PBWebHistoryController.h +++ b/PBWebHistoryController.h @@ -11,11 +11,11 @@ #import "PBGitCommit.h" #import "PBGitHistoryController.h" -#import "PBRefController.h" +#import "PBRefContextDelegate.h" @interface PBWebHistoryController : PBWebController { IBOutlet PBGitHistoryController* historyController; - IBOutlet PBRefController *refController; + IBOutlet id contextMenuDelegate; NSString* currentSha; NSString* diff; diff --git a/PBWebHistoryController.m b/PBWebHistoryController.m index a909ccd..d546c8b 100644 --- a/PBWebHistoryController.m +++ b/PBWebHistoryController.m @@ -86,7 +86,7 @@ contextMenuItemsForElement:(NSDictionary *)element for (PBGitRef *ref in historyController.webCommit.refs) { if ([[ref shortName] isEqualToString:selectedRefString]) - return [refController menuItemsForRef:ref commit:historyController.webCommit]; + return [contextMenuDelegate menuItemsForRef:ref commit:historyController.webCommit]; } NSLog(@"Could not find selected ref!");