-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcommon.jst
40 lines (34 loc) · 1.25 KB
/
common.jst
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Sketch Plugin: Export to ICNS
// Source: https://github.com/solicomo/export-to-icns
// Version: 0.1.1
// Author: Soli
function save_path() {
var curPath = [doc fileURL] ? [[[doc fileURL] path] stringByDeletingLastPathComponent] : @"~"
var curName = [[doc displayName] stringByDeletingPathExtension]
var savePanel = [NSSavePanel savePanel]
[savePanel setTitle:@"Export"]
[savePanel setNameFieldLabel:@"Export To:"]
[savePanel setPrompt:@"Export"]
[savePanel setAllowedFileTypes: [NSArray arrayWithObject:@"icns"]]
[savePanel setAllowsOtherFileTypes:false]
[savePanel setCanCreateDirectories:true]
[savePanel setDirectoryURL:[NSURL fileURLWithPath:curPath]]
[savePanel setNameFieldStringValue:curName]
if ([savePanel runModal] != NSOKButton) {
exit
}
return [[savePanel URL] path]
}
function convert_iconset_to_icns(iconsetPath, iconPath) {
var createCmd = "iconutil -c icns \"" + iconsetPath + "\" -o \"" + iconPath + "\""
var createTask = [[NSTask alloc] init]
[createTask setLaunchPath:@"/bin/bash"]
[createTask setArguments:["-c", createCmd]]
[createTask launch]
[createTask waitUntilExit]
if ([createTask terminationStatus] == 0) {
[doc showMessage:@"Done"]
} else {
[doc showMessage:@"Failed:" + [createTask terminationReason]]
}
}