Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to load images from files which can be used as custom ico…
…ns in modals (#226)
- Loading branch information
Showing
7 changed files
with
90 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Phoenix is released under the MIT License. Refer to https://github.com/kasper/phoenix/blob/master/LICENSE.md | ||
*/ | ||
|
||
@import Cocoa; | ||
@import JavaScriptCore; | ||
|
||
#import "PHIdentifiableJSExport.h" | ||
|
||
@protocol NSImageJSExport <JSExport, PHIdentifiableJSExport> | ||
|
||
#pragma mark - Constructing | ||
|
||
+ (instancetype) fromFile:(NSString *)path; | ||
|
||
@end | ||
|
||
@interface NSImage (PHExtension) <NSImageJSExport> | ||
|
||
#pragma mark - Initialising | ||
|
||
+ (instancetype) fromFile:(NSString *)path; | ||
|
||
@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,22 @@ | ||
/* | ||
* Phoenix is released under the MIT License. Refer to https://github.com/kasper/phoenix/blob/master/LICENSE.md | ||
*/ | ||
|
||
#import "NSImage+PHExtension.h" | ||
|
||
@implementation NSImage (PHExtension) | ||
|
||
#pragma mark - Initialising | ||
|
||
+ (instancetype) fromFile:(NSString *)path { | ||
|
||
NSString *resolvedPath = path.stringByResolvingSymlinksInPath; | ||
|
||
if (![[NSFileManager defaultManager] fileExistsAtPath:resolvedPath]) { | ||
NSLog(@"Warning: Trying to initialise an image from a non-existent path “%@”.", resolvedPath); | ||
} | ||
|
||
return [[self alloc] initWithContentsOfFile:resolvedPath]; | ||
} | ||
|
||
@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
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