forked from pieter/gitx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pieter#8 from tsparber/fix-openfiles
Fix Open File and Show in Finder context menu entries
- Loading branch information
Showing
7 changed files
with
101 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// PBOpenFiles.h | ||
// GitX | ||
// | ||
// Created by Tommy Sparber on 02/08/16. | ||
// Based on code by Etienne | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface PBOpenFiles : NSObject | ||
|
||
+ (void)showInFinderAction:(id)sender with:(NSURL *)workingDirectoryURL; | ||
+ (void)openFilesAction:(id)sender with:(NSURL *)workingDirectoryURL; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// | ||
// PBOpenFiles.m | ||
// GitX | ||
// | ||
// Created by Tommy Sparber on 02/08/16. | ||
// Based on code by Etienne | ||
// | ||
|
||
#import "PBOpenFiles.h" | ||
|
||
@implementation PBOpenFiles | ||
|
||
+ (NSArray *)selectedURLsFromSender:(id)sender with:(NSURL *)workingDirectoryURL { | ||
NSArray *selectedFiles = [sender representedObject]; | ||
if ([selectedFiles count] == 0) | ||
return nil; | ||
|
||
NSMutableArray *URLs = [NSMutableArray array]; | ||
for (id file in selectedFiles) { | ||
NSString *path = file; | ||
// Those can be PBChangedFiles sent by PBGitIndexController. Get their path. | ||
if ([file respondsToSelector:@selector(path)]) { | ||
path = [file path]; | ||
} | ||
|
||
if (![path isKindOfClass:[NSString class]]) | ||
continue; | ||
[URLs addObject:[workingDirectoryURL URLByAppendingPathComponent:path]]; | ||
} | ||
|
||
return URLs; | ||
} | ||
|
||
+ (void)showInFinderAction:(id)sender with:(NSURL *)workingDirectoryURL { | ||
NSArray *URLs = [self selectedURLsFromSender:sender with:workingDirectoryURL]; | ||
if ([URLs count] == 0) | ||
return; | ||
|
||
[[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs:URLs]; | ||
} | ||
|
||
+ (void)openFilesAction:(id)sender with:(NSURL *)workingDirectoryURL { | ||
NSArray *URLs = [self selectedURLsFromSender:sender with:workingDirectoryURL]; | ||
|
||
if ([URLs count] == 0) | ||
return; | ||
|
||
[[NSWorkspace sharedWorkspace] openURLs:URLs | ||
withAppBundleIdentifier:nil | ||
options:0 | ||
additionalEventParamDescriptor:nil | ||
launchIdentifiers:NULL]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters