Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfQT/XspfQTInformationWindowController.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 72 - (hide annotations) (download)
Mon Sep 15 12:02:46 2008 UTC (15 years, 7 months ago) by masaki
File size: 3889 byte(s)
プレフィクスXspfをXspfQTに変更。
1 masaki 63 //
2     // XspfQTInformationWindowController.m
3     // XspfQT
4     //
5     // Created by Hori,Masaki on 08/09/14.
6     // Copyright 2008 masakih. All rights reserved.
7     //
8    
9     #import "XspfQTInformationWindowController.h"
10 masaki 72 #import "XspfQTDocument.h"
11 masaki 63
12    
13     @implementation XspfQTInformationWindowController
14     static XspfQTInformationWindowController *sharedInstance = nil;
15    
16     + (XspfQTInformationWindowController *)sharedInstance
17     {
18     @synchronized(self) {
19     if (sharedInstance == nil) {
20     [[self alloc] init]; // assignment not done here
21     }
22     }
23     return sharedInstance;
24     }
25    
26     + (id)allocWithZone:(NSZone *)zone
27     {
28     @synchronized(self) {
29     if (sharedInstance == nil) {
30     sharedInstance = [super allocWithZone:zone];
31     return sharedInstance; // assignment and return on first allocation
32     }
33     }
34     return nil; //on subsequent allocation attempts return nil
35     }
36    
37     - (id)copyWithZone:(NSZone *)zone
38     {
39     return self;
40     }
41    
42     - (id)retain
43     {
44     return self;
45     }
46    
47     - (unsigned)retainCount
48     {
49     return UINT_MAX; //denotes an object that cannot be released
50     }
51    
52     - (void)release
53     {
54     //do nothing
55     }
56    
57     - (id)autorelease
58     {
59     return self;
60     }
61    
62     #pragma mark-
63     - (id)init
64     {
65     [super initWithWindowNibName:@"XspfQTImformation"];
66     observedDocs = [[NSMutableArray array] retain];
67     return self;
68     }
69    
70     - (void)windowDidLoad
71     {
72     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
73     [nc addObserver:self
74     selector:@selector(notifee:)
75     name:NSWindowDidBecomeMainNotification
76     object:nil];
77     [nc addObserver:self
78     selector:@selector(notifee:)
79     name:NSWindowDidResignMainNotification
80     object:nil];
81     [nc addObserver:self
82     selector:@selector(notifee:)
83     name:NSApplicationDidBecomeActiveNotification
84     object:NSApp];
85     [nc addObserver:self
86     selector:@selector(notifee:)
87     name:NSApplicationDidHideNotification
88     object:NSApp];
89     [nc addObserver:self
90     selector:@selector(notifee:)
91     name:NSApplicationDidHideNotification
92     object:NSApp];
93     [nc addObserver:self
94     selector:@selector(xspfDocumentWillCloseNotification:)
95 masaki 72 name:XspfQTDocumentWillCloseNotification
96 masaki 63 object:nil];
97    
98     }
99     - (void)dealloc
100     {
101     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
102     [nc removeObserver:self];
103    
104     [observedDocs release];
105    
106     [super dealloc];
107     }
108    
109     - (id)currentTrack
110     {
111     id doc = [[NSDocumentController sharedDocumentController] currentDocument];
112     if(!doc) return nil;
113    
114     if(![observedDocs containsObject:doc]) {
115     [doc addObserver:self
116     forKeyPath:@"trackList.qtMovie"
117     options:0
118     context:NULL];
119     [observedDocs addObject:doc];
120     }
121    
122     return [doc valueForKeyPath:@"trackList.currentTrack"];
123     }
124     - (id)movieAttributes
125     {
126     id doc = [[NSDocumentController sharedDocumentController] currentDocument];
127     if(!doc) return nil;
128    
129     if(![observedDocs containsObject:doc]) {
130     [doc addObserver:self
131     forKeyPath:@"trackList.qtMovie"
132     options:0
133     context:NULL];
134     [observedDocs addObject:doc];
135     }
136    
137     return [doc valueForKeyPath:@"trackList.qtMovie.movieAttributes"];
138     }
139     - (void)observeValueForKeyPath:(NSString *)keyPath
140     ofObject:(id)object
141     change:(NSDictionary *)change
142     context:(void *)context
143     {
144     if([keyPath isEqualToString:@"trackList.qtMovie"]) {
145     [self willChangeValueForKey:@"movieAttributes"];
146     [self didChangeValueForKey:@"movieAttributes"];
147     [self willChangeValueForKey:@"currentTrack"];
148     [self didChangeValueForKey:@"currentTrack"];
149     }
150     }
151    
152     - (void)xspfDocumentWillCloseNotification:(id)notification
153     {
154     id doc = [notification object];
155    
156     [doc removeObserver:self forKeyPath:@"trackList.qtMovie"];
157     [observedDocs removeObject:doc];
158     [docController setContent:nil];
159     }
160     - (void)notifee:(id)notification
161     {
162     [self willChangeValueForKey:@"movieAttributes"];
163     [self didChangeValueForKey:@"movieAttributes"];
164     [self willChangeValueForKey:@"currentTrack"];
165     [self didChangeValueForKey:@"currentTrack"];
166     }
167    
168    
169     @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26