Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfQT/XspfQTInformationWindowController.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 110 - (hide annotations) (download)
Thu Sep 25 15:21:48 2008 UTC (15 years, 6 months ago) by masaki
File size: 3855 byte(s)
documentがない時に前回表示したムービー情報のタイトルが残る事があったのを修正。
後ろのウインドウを閉じたときムービーが選択されていないようになる現象を修正。
ソースコードの整理。
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 masaki 110 - (void)notify
71     {
72     [self willChangeValueForKey:@"movieAttributes"];
73     [self didChangeValueForKey:@"movieAttributes"];
74     [self willChangeValueForKey:@"currentTrack"];
75     [self didChangeValueForKey:@"currentTrack"];
76     }
77    
78 masaki 63 - (void)windowDidLoad
79     {
80     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
81     [nc addObserver:self
82     selector:@selector(notifee:)
83     name:NSWindowDidBecomeMainNotification
84     object:nil];
85     [nc addObserver:self
86     selector:@selector(notifee:)
87     name:NSWindowDidResignMainNotification
88     object:nil];
89     [nc addObserver:self
90     selector:@selector(notifee:)
91     name:NSApplicationDidBecomeActiveNotification
92     object:NSApp];
93     [nc addObserver:self
94     selector:@selector(notifee:)
95     name:NSApplicationDidHideNotification
96     object:NSApp];
97     [nc addObserver:self
98     selector:@selector(notifee:)
99     name:NSApplicationDidHideNotification
100     object:NSApp];
101     [nc addObserver:self
102     selector:@selector(xspfDocumentWillCloseNotification:)
103 masaki 72 name:XspfQTDocumentWillCloseNotification
104 masaki 63 object:nil];
105    
106     }
107     - (void)dealloc
108     {
109     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
110     [nc removeObserver:self];
111    
112     [observedDocs release];
113    
114     [super dealloc];
115     }
116    
117     - (id)currentTrack
118     {
119     id doc = [[NSDocumentController sharedDocumentController] currentDocument];
120     if(!doc) return nil;
121    
122     if(![observedDocs containsObject:doc]) {
123     [doc addObserver:self
124     forKeyPath:@"trackList.qtMovie"
125     options:0
126     context:NULL];
127     [observedDocs addObject:doc];
128     }
129    
130     return [doc valueForKeyPath:@"trackList.currentTrack"];
131     }
132     - (id)movieAttributes
133     {
134     id doc = [[NSDocumentController sharedDocumentController] currentDocument];
135     if(!doc) return nil;
136    
137     if(![observedDocs containsObject:doc]) {
138     [doc addObserver:self
139     forKeyPath:@"trackList.qtMovie"
140     options:0
141     context:NULL];
142     [observedDocs addObject:doc];
143     }
144    
145     return [doc valueForKeyPath:@"trackList.qtMovie.movieAttributes"];
146     }
147     - (void)observeValueForKeyPath:(NSString *)keyPath
148     ofObject:(id)object
149     change:(NSDictionary *)change
150     context:(void *)context
151     {
152     if([keyPath isEqualToString:@"trackList.qtMovie"]) {
153 masaki 110 [self notify];
154 masaki 63 }
155     }
156    
157     - (void)xspfDocumentWillCloseNotification:(id)notification
158     {
159     id doc = [notification object];
160    
161 masaki 110 if(![observedDocs containsObject:doc]) return;
162    
163 masaki 63 [doc removeObserver:self forKeyPath:@"trackList.qtMovie"];
164     [observedDocs removeObject:doc];
165     [docController setContent:nil];
166 masaki 110 [currentTrackController setContent:nil];
167    
168     [self notify];
169 masaki 63 }
170     - (void)notifee:(id)notification
171     {
172 masaki 110 [self notify];
173 masaki 63 }
174    
175     @end

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