mirror of
https://github.com/kennethreitz-archive/gitx.git
synced 2026-06-05 23:40:18 +00:00
HistoryController: Add "Open Files" menu item
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
- (NSArray *)menuItemsForPaths:(NSArray *)paths;
|
||||
- (void)showCommitsFromTree:(id)sender;
|
||||
- (void)showInFinderAction:(id)sender;
|
||||
- (void)openFilesAction:(id)sender;
|
||||
|
||||
- (void) copyCommitInfo;
|
||||
|
||||
|
||||
@@ -246,6 +246,19 @@
|
||||
|
||||
}
|
||||
|
||||
- (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"];
|
||||
@@ -259,14 +272,17 @@
|
||||
- (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];
|
||||
|
||||
Reference in New Issue
Block a user