This repository has been archived by the owner on Aug 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
ORSCanaryAboutController.m
65 lines (56 loc) · 1.7 KB
/
ORSCanaryAboutController.m
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
54
55
56
57
58
59
60
61
62
63
64
65
//
// ORSCanaryAboutController.m
// Canary
//
// Created by Nicholas Toumpelis on 12/04/2009.
// Copyright 2009 Ocean Road Software. All rights reserved.
//
// Version 0.7
#import "ORSCanaryAboutController.h"
@implementation ORSCanaryAboutController
static ORSCanaryAboutController *sharedAboutController = nil;
+ (ORSCanaryAboutController *)sharedAboutController {
@synchronized(self) {
if (sharedAboutController == nil) {
[[self alloc] initWithWindowNibName:@"About"];
}
}
return sharedAboutController;
}
+ (id) allocWithZone:(NSZone *)zone {
@synchronized(self) {
if (sharedAboutController == nil) {
sharedAboutController = [super allocWithZone:zone];
return sharedAboutController;
}
}
return nil;
}
- (id)copyWithZone:(NSZone *)zone {
return self;
}
- (void) windowWillClose:(NSNotification *)notification {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setFloat:self.window.frame.origin.x
forKey:@"CanaryAboutWindowX"];
[defaults setFloat:self.window.frame.origin.y
forKey:@"CanaryAboutWindowY"];
[defaults setFloat:self.window.frame.size.width
forKey:@"CanaryAboutWindowWidth"];
[defaults setFloat:self.window.frame.size.height
forKey:@"CanaryAboutWindowHeight"];
}
- (void) awakeFromNib {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults floatForKey:@"CanaryAboutWindowX"]) {
NSRect newFrame = NSMakeRect(
[defaults floatForKey:@"CanaryAboutWindowX"],
[defaults floatForKey:@"CanaryAboutWindowY"],
[defaults floatForKey:@"CanaryAboutWindowWidth"],
[defaults floatForKey:@"CanaryAboutWindowHeight"]);
[[self window] setFrame:newFrame display:YES];
} else {
[self.window center];
}
}
@end