Skip to content

Commit 7427cbe

Browse files
committed
HistoryController: Add "Open Files" menu item
1 parent a002e33 commit 7427cbe

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

PBGitHistoryController.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- (NSArray *)menuItemsForPaths:(NSArray *)paths;
4848
- (void)showCommitsFromTree:(id)sender;
4949
- (void)showInFinderAction:(id)sender;
50+
- (void)openFilesAction:(id)sender;
5051

5152
- (void) copyCommitInfo;
5253

PBGitHistoryController.m

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,19 @@ - (void)showInFinderAction:(id)sender
246246

247247
}
248248

249+
- (void)openFilesAction:(id)sender
250+
{
251+
NSString *workingDirectory = [[repository workingDirectory] stringByAppendingString:@"/"];
252+
NSString *path;
253+
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
254+
255+
for (NSString *filePath in [sender representedObject]) {
256+
path = [workingDirectory stringByAppendingPathComponent:filePath];
257+
[ws openFile:path];
258+
}
259+
}
260+
261+
249262
- (NSMenu *)contextMenuForTreeView
250263
{
251264
NSArray *filePaths = [[treeController selectedObjects] valueForKey:@"fullPath"];
@@ -259,14 +272,17 @@ - (NSMenu *)contextMenuForTreeView
259272
- (NSArray *)menuItemsForPaths:(NSArray *)paths
260273
{
261274
BOOL multiple = [paths count] != 1;
262-
NSMenuItem *finderItem = [[NSMenuItem alloc] initWithTitle:multiple? @"Show items in Finder" : @"Show item in Finder"
263-
action:@selector(showInFinderAction:)
264-
keyEquivalent:@""];
265275
NSMenuItem *historyItem = [[NSMenuItem alloc] initWithTitle:multiple? @"Show history of files" : @"Show history of file"
266276
action:@selector(showCommitsFromTree:)
267277
keyEquivalent:@""];
278+
NSMenuItem *finderItem = [[NSMenuItem alloc] initWithTitle:@"Show in Finder"
279+
action:@selector(showInFinderAction:)
280+
keyEquivalent:@""];
281+
NSMenuItem *openFilesItem = [[NSMenuItem alloc] initWithTitle:multiple? @"Open Files" : @"Open File"
282+
action:@selector(openFilesAction:)
283+
keyEquivalent:@""];
268284

269-
NSArray *menuItems = [NSArray arrayWithObjects:historyItem, finderItem, nil];
285+
NSArray *menuItems = [NSArray arrayWithObjects:historyItem, finderItem, openFilesItem, nil];
270286
for (NSMenuItem *item in menuItems) {
271287
[item setTarget:self];
272288
[item setRepresentedObject:paths];

0 commit comments

Comments
 (0)