diff --git a/PBGitHistoryController.h b/PBGitHistoryController.h
index 0007760..f7298c4 100644
--- a/PBGitHistoryController.h
+++ b/PBGitHistoryController.h
@@ -41,6 +41,10 @@
- (IBAction) toggleQuickView: sender;
- (IBAction) openSelectedFile: sender;
- (void) updateQuicklookForce: (BOOL) force;
+
+// Context menu methods
+- (NSMenu *)contextMenuForTreeView;
+- (NSArray *)menuItemsForPaths:(NSArray *)paths;
- (void)showCommitsFromTree:(id)sender;
- (void)showInFinderAction:(id)sender;
diff --git a/PBGitHistoryController.m b/PBGitHistoryController.m
index 00a09c7..a02c041 100644
--- a/PBGitHistoryController.m
+++ b/PBGitHistoryController.m
@@ -226,8 +226,8 @@
// TODO: Enable this from webview as well!
NSMutableArray *filePaths = [NSMutableArray arrayWithObjects:@"HEAD", @"--", NULL];
- for (PBGitTree *tree in [treeController selectedObjects])
- [filePaths addObject:[tree fullPath]];
+ [filePaths addObjectsFromArray:[sender representedObject]];
+
PBGitRevSpecifier *revSpec = [[PBGitRevSpecifier alloc] initWithParameters:filePaths];
repository.currentBranch = [repository addBranch:revSpec];
@@ -239,12 +239,40 @@
NSString *path;
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
- for (PBGitTree *tree in [treeController selectedObjects]) {
- path = [workingDirectory stringByAppendingPathComponent:[tree fullPath]];
+ for (NSString *filePath in [sender representedObject]) {
+ path = [workingDirectory stringByAppendingPathComponent:filePath];
[ws selectFile: path inFileViewerRootedAtPath:path];
}
}
+- (NSMenu *)contextMenuForTreeView
+{
+ NSArray *filePaths = [[treeController selectedObjects] valueForKey:@"fullPath"];
+
+ NSMenu *menu = [[NSMenu alloc] init];
+ for (NSMenuItem *item in [self menuItemsForPaths:filePaths])
+ [menu addItem:item];
+ return menu;
+}
+
+- (NSArray *)menuItemsForPaths:(NSArray *)paths
+{
+ BOOL multiple = [paths count] != 1;
+ NSMenuItem *finderItem = [[NSMenuItem alloc] initWithTitle:multiple? @"Show items in Finder" : @"Show item in Finder"
+ action:@selector(showInFinderAction:)
+ keyEquivalent:@""];
+ NSMenuItem *historyItem = [[NSMenuItem alloc] initWithTitle:multiple? @"Show history of files" : @"Show history of file"
+ action:@selector(showCommitsFromTree:)
+ keyEquivalent:@""];
+
+ NSArray *menuItems = [NSArray arrayWithObjects:historyItem, finderItem, nil];
+ for (NSMenuItem *item in menuItems) {
+ [item setTarget:self];
+ [item setRepresentedObject:paths];
+ }
+
+ return menuItems;
+}
@end
diff --git a/PBGitHistoryView.xib b/PBGitHistoryView.xib
index 6e44446..329d003 100644
--- a/PBGitHistoryView.xib
+++ b/PBGitHistoryView.xib
@@ -8,9 +8,8 @@
353.00
-
-
-
- showCommitsFromTree:
-
-
-
- 281
-
-
-
- menu
-
-
-
- 282
-
-
-
- showInFinderAction:
-
-
-
- 285
-
@@ -2784,26 +2737,6 @@
-
- 276
-
-
- YES
-
-
-
-
-
-
- 275
-
-
-
-
- 284
-
-
-
@@ -2883,12 +2816,8 @@
27.ImportedFromIB2
272.IBPluginDependency
273.IBPluginDependency
- 275.IBPluginDependency
- 276.IBEditorWindowLastContentRect
- 276.IBPluginDependency
28.IBPluginDependency
28.IBShouldRemoveOnLegacySave
- 284.IBPluginDependency
29.IBPluginDependency
29.IBShouldRemoveOnLegacySave
3.IBPluginDependency
@@ -3018,12 +2947,8 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- {{225, 683}, {202, 43}}
- com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -3055,7 +2980,7 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
- {{76, 44}, {852, 432}}
+ {{358, 67}, {852, 432}}
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
@@ -3090,7 +3015,7 @@
- 285
+ 286
@@ -3154,6 +3079,7 @@
commitList
fileBrowser
searchField
+ treeContextMenu
treeController
webView
@@ -3163,6 +3089,7 @@
NSTableView
NSOutlineView
NSSearchField
+ NSMenu
NSTreeController
id
diff --git a/PBQLOutlineView.m b/PBQLOutlineView.m
index 24f43e1..459d908 100644
--- a/PBQLOutlineView.m
+++ b/PBQLOutlineView.m
@@ -74,7 +74,7 @@
[self selectRow:row byExtendingSelection:NO];
}
- return [super menuForEvent:theEvent];
+ return [controller contextMenuForTreeView];
}
/* Implemented to satisfy datasourcee protocol */