-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathSSYTempWindowController.m
61 lines (46 loc) · 1.42 KB
/
SSYTempWindowController.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
#import "SSYTempWindowController.h"
static NSMutableSet* static_windowControllers = nil ;
@implementation SSYTempWindowController
+ (NSString*)nibName {
NSLog(@"Internal Error 235-0832") ;
return nil ;
}
- (void)goAway:(NSNotification*)note {
[[NSNotificationCenter defaultCenter] removeObserver:self] ;
[[self window] setWindowController:nil] ;
[[self retain] autorelease] ;
[static_windowControllers removeObject:self] ;
}
- (id)init {
self = [super initWithWindowNibName:[[self class] nibName]] ;
if (self) {
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(goAway:)
name:NSWindowWillCloseNotification
object:[self window]] ;
}
return self ;
}
+ (id)showWindow {
SSYTempWindowController* instance = nil ;
// See if a window with a window controller of this class already exists
for (NSWindow* window in [NSApp windows]) {
NSWindowController* candidate = [window windowController] ;
if ([candidate isMemberOfClass:[self class]]) {
instance = (SSYTempWindowController*)candidate ;
[instance retain] ;
break ;
}
}
if (!instance) {
instance = [[self alloc] init] ;
}
if (!static_windowControllers) {
static_windowControllers = [[NSMutableSet alloc] init] ;
}
[static_windowControllers addObject:instance] ;
[instance release] ;
[instance showWindow:self] ;
return instance ;
}
@end