Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfQT/XspfQTAppDelegate.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 357 - (hide annotations) (download)
Sun Jul 31 14:49:52 2011 UTC (12 years, 8 months ago) by masakih
File size: 7426 byte(s)
[New] XspfMAppleRemoteSupportクラスをXspfManagerから流用。ボタン類の動作はXspfManagerと同一になった。
1 masaki 2 //
2 masaki 72 // XspfQTAppDelegate.m
3 masaki 2 // XspfQT
4     //
5     // Created by Hori,Masaki on 08/08/31.
6     //
7    
8 masakih 312 /*
9 masakih 316 This source code is release under the New BSD License.
10 masakih 312 Copyright (c) 2008-2010, masakih
11     All rights reserved.
12    
13 masakih 316 ソースコード形式かバイナリ形式か、変更するかしないかを問わず、以下の条件を満たす場合に
14     限り、再頒布および使用が許可されます。
15    
16     1, ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、および下記免責条項を含
17     めること。
18     2, バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の資料に、上記の著作権表
19     示、本条件一覧、および下記免責条項を含めること。
20     3, 書面による特別の許可なしに、本ソフトウェアから派生した製品の宣伝または販売促進に、
21     コントリビューターの名前を使用してはならない。
22     本ソフトウェアは、著作権者およびコントリビューターによって「現状のまま」提供されており、
23     明示黙示を問わず、商業的な使用可能性、および特定の目的に対する適合性に関する暗黙の保証
24     も含め、またそれに限定されない、いかなる保証もありません。著作権者もコントリビューター
25     も、事由のいかんを問わず、 損害発生の原因いかんを問わず、かつ責任の根拠が契約であるか
26     厳格責任であるか(過失その他の)不法行為であるかを問わず、仮にそのような損害が発生する
27     可能性を知らされていたとしても、本ソフトウェアの使用によって発生した(代替品または代用
28     サービスの調達、使用の喪失、データの喪失、利益の喪失、業務の中断も含め、またそれに限定
29     されない)直接損害、間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害につい
30     て、一切責任を負わないものとします。
31 masakih 312 -------------------------------------------------------------------
32     Copyright (c) 2008-2010, masakih
33     All rights reserved.
34    
35 masakih 316 Redistribution and use in source and binary forms, with or without
36     modification, are permitted provided that the following conditions
37     are met:
38 masakih 312
39 masakih 316 1, Redistributions of source code must retain the above copyright
40     notice, this list of conditions and the following disclaimer.
41     2, Redistributions in binary form must reproduce the above copyright
42     notice, this list of conditions and the following disclaimer in
43     the documentation and/or other materials provided with the
44     distribution.
45     3, The names of its contributors may be used to endorse or promote
46     products derived from this software without specific prior
47     written permission.
48     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
51     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
52     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
53     INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
54     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
56     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
58     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59     POSSIBILITY OF SUCH DAMAGE.
60 masakih 312 */
61    
62 masaki 72 #import "XspfQTAppDelegate.h"
63 masaki 205
64     #import "XspfQTPreference.h"
65 masaki 72 #import "XspfQTValueTransformers.h"
66 masaki 63 #import "XspfQTInformationWindowController.h"
67 masaki 184 #import "XspfQTPreferenceWindowController.h"
68 masaki 2
69 masaki 201
70 masakih 357 #import "XspfMAppleRemoteSupport.h"
71 masakih 322
72    
73 masakih 357
74 masaki 72 @implementation XspfQTAppDelegate
75 masaki 2
76     + (void)initialize
77     {
78 masaki 205 [XspfQTPreference sharedInstance];
79 masaki 2 }
80    
81 masaki 50 - (void)awakeFromNib
82     {
83 masakih 357 appleRemoteSupprt = [[XspfMAppleRemoteSupport alloc] init];
84 masakih 324
85 masakih 322
86 masaki 50 NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
87     [nc addObserver:self
88     selector:@selector(windowDidBecomeMain:)
89     name:NSWindowDidBecomeMainNotification
90     object:nil];
91     [nc addObserver:self
92     selector:@selector(windowWillClose:)
93     name:NSWindowWillCloseNotification
94     object:nil];
95     }
96     - (void)dealloc
97     {
98     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
99     [nc removeObserver:self];
100    
101 masakih 357 [appleRemoteSupprt release];
102 masakih 322
103 masaki 50 [super dealloc];
104     }
105 masaki 204
106 masaki 50 #pragma mark ### Actions ###
107     - (IBAction)playedTrack:(id)sender
108     {
109     // do noting.
110     }
111 masaki 63 - (IBAction)openInformationPanel:(id)sender
112     {
113     XspfQTInformationWindowController *wc;
114     wc = [XspfQTInformationWindowController sharedInstance];
115     [wc showWindow:sender];
116     }
117 masaki 184 - (IBAction)showPreferenceWindow:(id)sender
118     {
119     XspfQTPreferenceWindowController *pw;
120     pw = [XspfQTPreferenceWindowController sharedInstance];
121     [pw showWindow:self];
122     }
123 masaki 63 - (IBAction)togglePlayAndPause:(id)sender
124     {
125 masakih 310 id windowController = [mainWindowStore windowController];
126     if(![windowController respondsToSelector:@selector(togglePlayAndPause:)]) return;
127     [windowController togglePlayAndPause:sender];
128 masaki 63 }
129     - (IBAction)nextTrack:(id)sender
130     {
131 masakih 310 id windowController = [mainWindowStore windowController];
132     if(![windowController respondsToSelector:@selector(nextTrack:)]) return;
133 masaki 63 [[mainWindowStore windowController] nextTrack:sender];
134     }
135     - (IBAction)previousTrack:(id)sender
136     {
137 masakih 310 id windowController = [mainWindowStore windowController];
138     if(![windowController respondsToSelector:@selector(previousTrack:)]) return;
139 masaki 63 [[mainWindowStore windowController] previousTrack:sender];
140     }
141 masaki 50
142     #pragma mark ### NSMenu valivation ###
143     - (BOOL)validateMenuItem:(NSMenuItem *)menuItem
144     {
145 masakih 341 SEL action = [menuItem action];
146    
147 masakih 310 id windowController = [mainWindowStore windowController];
148 masakih 341 if(action == @selector(togglePlayAndPause:)) {
149 masakih 310 if(![windowController respondsToSelector:@selector(togglePlayAndPause:)]) return NO;
150 masaki 63 }
151 masakih 341 if(action == @selector(nextTrack:)) {
152 masakih 310 if(![windowController respondsToSelector:@selector(nextTrack:)]) return NO;
153 masaki 184 }
154 masakih 341 if(action == @selector(previousTrack:)) {
155 masakih 310 if(![windowController respondsToSelector:@selector(previousTrack:)]) return NO;
156     }
157 masakih 341 if(action == @selector(showPreferenceWindow:)) return YES;
158 masaki 63
159 masaki 50 if([menuItem tag] == 10000) {
160     NSWindow *m = mainWindowStore;
161     if(!m) {
162     m = [NSApp mainWindow];
163     }
164     NSString *title = [m valueForKeyPath:@"windowController.document.trackList.currentTrack.title"];
165     if(title) {
166     [menuItem setTitle:[NSString stringWithFormat:@"%@ played", title]];
167     } else {
168     [menuItem setTitle:@"Played Track Title"];
169     }
170     return NO;
171     }
172     if(!mainWindowStore) {
173     return NO;
174     }
175    
176     return YES;
177     }
178    
179 masaki 2 - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
180     {
181     return NO;
182     }
183    
184 masaki 50 - (void)storeMainWindow
185     {
186     mainWindowStore = [NSApp mainWindow];
187     }
188     - (void)unsaveMainWindow
189     {
190     mainWindowStore = nil;
191     }
192     - (void)applicationWillHide:(NSNotification *)notification
193     {
194     [self storeMainWindow];
195     }
196     - (void)applicationWillResignActive:(NSNotification *)notification
197     {
198     [self storeMainWindow];
199     }
200     - (void)applicationDidUnhide:(NSNotification *)notification
201     {
202     [self unsaveMainWindow];
203     }
204     - (void)applicationDidBecomeActive:(NSNotification *)notification
205     {
206     [self unsaveMainWindow];
207     }
208    
209     - (void)windowDidBecomeMain:(NSNotification *)notification
210     {
211     [self storeMainWindow];
212     }
213     - (void)windowWillClose:(NSNotification *)notification
214     {
215     [self unsaveMainWindow];
216     }
217    
218 masaki 2 @end

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