forked from kornelski/ImageAlpha
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImageAlphaApplication.m
More file actions
53 lines (42 loc) · 1.83 KB
/
ImageAlphaApplication.m
File metadata and controls
53 lines (42 loc) · 1.83 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
#import "ImageAlphaApplication.h"
@implementation ImageAlphaApplication
@synthesize imageOptimPath, ditheredMenu;
+(void)initialize {
if (self == [ImageAlphaApplication class]) {
// Register default values for user preferences
NSDictionary *defaults = @{
// General settings
@"defaultLosslessMode": @1, // 0=none, 1=oxipng, 2=zopflipng
@"rememberColorCount": @NO,
@"lastColorCount": @256,
@"Optimize": @NO,
// oxipng settings
@"oxipng.optimizationLevel": @4,
@"oxipng.maxOptimization": @NO,
@"oxipng.stripMetadata": @1, // 0=none, 1=safe, 2=all
@"oxipng.alphaOptimization": @NO,
@"oxipng.interlace": @0, // 0=keep, 1=on, 2=off
@"oxipng.threads": @0, // 0=auto
@"oxipng.timeout": @0, // 0=disabled
// zopflipng settings
@"zopflipng.iterations": @15,
@"zopflipng.maxCompression": @NO,
@"zopflipng.quickMode": @NO,
@"zopflipng.keepChunks": @"",
};
[[NSUserDefaults standardUserDefaults] registerDefaults:defaults];
}
}
-(void)applicationDidFinishLaunching:(NSApplication*)sender {
NSURL *appURL = [[NSWorkspace sharedWorkspace] URLForApplicationWithBundleIdentifier:@"net.pornel.imageoptim"];
self.imageOptimPath = appURL.path;
id dithered = [[NSUserDefaults standardUserDefaults] objectForKey:@"dithered"];
int tag = dithered != nil ? [dithered boolValue] : -1;
for (NSMenuItem *item in self.ditheredMenu.itemArray) {
[item setState:item.tag == tag ? NSControlStateValueOn : NSControlStateValueOff];
}
}
- (IBAction)checkForUpdates:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/erutan/ImageAlpha/releases"]];
}
@end