Skip to content

Commit

Permalink
HistoryController: Add "Open Files" menu item
Browse files Browse the repository at this point in the history
  • Loading branch information
pieter committed Jun 16, 2009
1 parent a002e33 commit 7427cbe
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions PBGitHistoryController.h
Expand Up @@ -47,6 +47,7 @@
- (NSArray *)menuItemsForPaths:(NSArray *)paths;
- (void)showCommitsFromTree:(id)sender;
- (void)showInFinderAction:(id)sender;
- (void)openFilesAction:(id)sender;

- (void) copyCommitInfo;

Expand Down
24 changes: 20 additions & 4 deletions PBGitHistoryController.m
Expand Up @@ -246,6 +246,19 @@ - (void)showInFinderAction:(id)sender

}

- (void)openFilesAction:(id)sender
{
NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"];
NSString *path;
NSWorkspace *ws = [NSWorkspace sharedWorkspace];

for (NSString *filePath in [sender representedObject]) {
path = [workingDirectory stringByAppendingPathComponent:filePath];
[ws openFile:path];
}
}


- (NSMenu *)contextMenuForTreeView
{
NSArray *filePaths = [[treeController selectedObjects] valueForKey:@"fullPath"];
Expand All @@ -259,14 +272,17 @@ - (NSMenu *)contextMenuForTreeView
- (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:@""];
NSMenuItem *finderItem = [[NSMenuItem alloc] initWithTitle:@"Show in Finder"
action:@selector(showInFinderAction:)
keyEquivalent:@""];
NSMenuItem *openFilesItem = [[NSMenuItem alloc] initWithTitle:multiple? @"Open Files" : @"Open File"
action:@selector(openFilesAction:)
keyEquivalent:@""];

NSArray *menuItems = [NSArray arrayWithObjects:historyItem, finderItem, nil];
NSArray *menuItems = [NSArray arrayWithObjects:historyItem, finderItem, openFilesItem, nil];
for (NSMenuItem *item in menuItems) {
[item setTarget:self];
[item setRepresentedObject:paths];
Expand Down

0 comments on commit 7427cbe

Please sign in to comment.