My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones  
Changes to /AppKit/NSApplication.m
e5277a40a7e8 vs. 2470bd80abf4 Compare: vs.  Format:
Revision 2470bd80abf4
Go to: 
Project members, sign in to write a code review
/AppKit/NSApplication.m   e5277a40a7e8 /AppKit/NSApplication.m   2470bd80abf4
1 /* Copyright (c) 2006 Christopher J. W. Lloyd 1 /* Copyright (c) 2006-2007 Christopher J. W. Lloyd
2 2
3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 3 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4 4
5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 5 The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6 6
7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ 7 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
8 8
9 // "Window" menu - David Young <daver@geeks.org> 9 // "Window" menu - David Young <daver@geeks.org>
10 // Original - Christopher Lloyd <cjwl@objc.net> 10 // Original - Christopher Lloyd <cjwl@objc.net>
11 #import <AppKit/NSApplication.h> 11 #import <AppKit/NSApplication.h>
12 #import <AppKit/NSWindow-Private.h> 12 #import <AppKit/NSWindow-Private.h>
13 #import <AppKit/NSPanel.h> 13 #import <AppKit/NSPanel.h>
14 #import <AppKit/NSMenu.h> 14 #import <AppKit/NSMenu.h>
15 #import <AppKit/NSMenuItem.h> 15 #import <AppKit/NSMenuItem.h>
16 #import <AppKit/NSEvent.h> 16 #import <AppKit/NSEvent.h>
17 #import <AppKit/NSModalSessionX.h> 17 #import <AppKit/NSModalSessionX.h>
18 #import <AppKit/NSNibLoading.h> 18 #import <AppKit/NSNibLoading.h>
19 #import <AppKit/NSScreen.h> 19 #import <AppKit/NSScreen.h>
20 #import <AppKit/NSColorPanel.h> 20 #import <AppKit/NSColorPanel.h>
21 #import <AppKit/NSDisplay.h> 21 #import <AppKit/NSDisplay.h>
22 #import <AppKit/NSPageLayout.h> 22 #import <AppKit/NSPageLayout.h>
23 #import <AppKit/NSPlatform.h> 23 #import <AppKit/NSPlatform.h>
24 #import <AppKit/NSDocumentController.h> 24 #import <AppKit/NSDocumentController.h>
25 #import <AppKit/NSSheetContext.h> 25 #import <AppKit/NSSheetContext.h>
26 26
27 NSString *NSModalPanelRunLoopMode=@"NSModalPanelRunLoopMode"; 27 NSString *NSModalPanelRunLoopMode=@"NSModalPanelRunLoopMode";
28 NSString *NSEventTrackingRunLoopMode=@"NSEventTrackingRunLoopMode"; 28 NSString *NSEventTrackingRunLoopMode=@"NSEventTrackingRunLoopMode";
29 29
30 NSString *NSApplicationWillFinishLaunchingNotification=@"NSApplicationWillFinishLaunchingNotification"; 30 NSString *NSApplicationWillFinishLaunchingNotification=@"NSApplicationWillFinishLaunchingNotification";
31 NSString *NSApplicationDidFinishLaunchingNotification=@"NSApplicationDidFinishLaunchingNotification"; 31 NSString *NSApplicationDidFinishLaunchingNotification=@"NSApplicationDidFinishLaunchingNotification";
32 32
33 NSString *NSApplicationDidBecomeActiveNotification=@"NSApplicationDidBecomeActiveNotification"; 33 NSString *NSApplicationDidBecomeActiveNotification=@"NSApplicationDidBecomeActiveNotification";
34 NSString *NSApplicationWillResignActiveNotification=@"NSApplicationWillResignActiveNotification"; 34 NSString *NSApplicationWillResignActiveNotification=@"NSApplicationWillResignActiveNotification";
35 35
36 @implementation NSApplication 36 @implementation NSApplication
37 37
38 id NSApp=nil; 38 id NSApp=nil;
39 39
40 +(void)initialize { 40 +(void)initialize {
41 if(self==[NSApplication class]){ 41 if(self==[NSApplication class]){
42 Win32UseRunningCopyOfApplication(); 42 Win32UseRunningCopyOfApplication();
43 } 43 }
44 } 44 }
45 45
46 +(NSApplication *)sharedApplication { 46 +(NSApplication *)sharedApplication {
47 47
48 if(NSApp==nil){ 48 if(NSApp==nil){
49 NSApp=[self alloc]; // NSApp must be valid inside init 49 NSApp=[self alloc]; // NSApp must be valid inside init
50 NSApp=[NSApp init]; 50 NSApp=[NSApp init];
51 } 51 }
52 52
53 return NSApp; 53 return NSApp;
54 } 54 }
55 55
56 -init { 56 -init {
57 _display=[[NSDisplay currentDisplay] retain]; 57 _display=[[NSDisplay currentDisplay] retain];
58 [_display showSplashImage]; 58 [_display showSplashImage];
59 59
60 _windows=[NSMutableArray new]; 60 _windows=[NSMutableArray new];
61 _mainMenu=nil; 61 _mainMenu=nil;
62 62
63 _modalStack=[NSMutableArray new]; 63 _modalStack=[NSMutableArray new];
64 64
65 return self; 65 return self;
66 } 66 }
67 67
68 -delegate { 68 -delegate {
69 return _delegate; 69 return _delegate;
70 } 70 }
71 71
72 -(NSArray *)windows { 72 -(NSArray *)windows {
73 return _windows; 73 return _windows;
74 } 74 }
75 75
76 -(NSMenu *)mainMenu { 76 -(NSMenu *)mainMenu {
77 return _mainMenu; 77 return _mainMenu;
78 } 78 }
79 79
80 -(NSMenu *)menu { 80 -(NSMenu *)menu {
81 return [self mainMenu]; 81 return [self mainMenu];
82 } 82 }
83 83
84 // FIX should be a better way to determine this... IB? special tags? 84 // FIX should be a better way to determine this... IB? special tags?
85 /* This info is in the NSMenuTemplate? */ 85 /* This info is in the NSMenuTemplate? */
86 86
87 -(NSMenu *)windowsMenu { 87 -(NSMenu *)windowsMenu {
88 #if 1 88 #if 1
89 if(_windowsMenu==nil) 89 if(_windowsMenu==nil)
90 _windowsMenu=[[[[self mainMenu] itemWithTitle:@"Window"] submenu] retain]; 90 _windowsMenu=[[[[self mainMenu] itemWithTitle:@"Window"] submenu] retain];
91 if(_windowsMenu==nil) // Some apps use "Windows" 91 if(_windowsMenu==nil) // Some apps use "Windows"
92 _windowsMenu=[[[[self mainMenu] itemWithTitle:@"Windows"] submenu] retain]; 92 _windowsMenu=[[[[self mainMenu] itemWithTitle:@"Windows"] submenu] retain];
93 93
94 #endif 94 #endif
95 return _windowsMenu; 95 return _windowsMenu;
96 } 96 }
97 97
98 -(NSWindow *)mainWindow { 98 -(NSWindow *)mainWindow {
99 int i,count=[_windows count]; 99 int i,count=[_windows count];
100 100
101 for(i=0;i<count;i++) 101 for(i=0;i<count;i++)
102 if([[_windows objectAtIndex:i] isMainWindow]) 102 if([[_windows objectAtIndex:i] isMainWindow])
103 return [_windows objectAtIndex:i]; 103 return [_windows objectAtIndex:i];
104 104
105 return nil; 105 return nil;
106 } 106 }
107 107
108 -(NSWindow *)keyWindow { 108 -(NSWindow *)keyWindow {
109 int i,count=[_windows count]; 109 int i,count=[_windows count];
110 110
111 for(i=0;i<count;i++) 111 for(i=0;i<count;i++)
112 if([[_windows objectAtIndex:i] isKeyWindow]) 112 if([[_windows objectAtIndex:i] isKeyWindow])
113 return [_windows objectAtIndex:i]; 113 return [_windows objectAtIndex:i];
114 114
115 return nil; 115 return nil;
116 } 116 }
117 117
118 -(NSImage *)applicationIconImage { 118 -(NSImage *)applicationIconImage {
119 NSUnimplementedMethod(); 119 NSUnimplementedMethod();
120 return nil; 120 return nil;
121 } 121 }
122 122
123 -(BOOL)isActive { 123 -(BOOL)isActive {
124 int count=[_windows count]; 124 int count=[_windows count];
125 125
126 while(--count>=0){ 126 while(--count>=0){
127 NSWindow *check=[_windows objectAtIndex:count]; 127 NSWindow *check=[_windows objectAtIndex:count];
128 128
129 if([check _isActive]) 129 if([check _isActive])
130 return YES; 130 return YES;
131 } 131 }
132 132
133 return NO; 133 return NO;
134 } 134 }
135 135
136 -(void)registerDelegate { 136 -(void)registerDelegate {
137 if([_delegate respondsToSelector:@selector(applicationWillFinishLaunching:)]){ 137 if([_delegate respondsToSelector:@selector(applicationWillFinishLaunching:)]){
138 [[NSNotificationCenter defaultCenter] addObserver:_delegate 138 [[NSNotificationCenter defaultCenter] addObserver:_delegate
139 selector:@selector(applicationWillFinishLaunching:) 139 selector:@selector(applicationWillFinishLaunching:)
140 name:NSApplicationWillFinishLaunchingNotification object:self]; 140 name:NSApplicationWillFinishLaunchingNotification object:self];
141 } 141 }
142 if([_delegate respondsToSelector:@selector(applicationDidFinishLaunching:)]){ 142 if([_delegate respondsToSelector:@selector(applicationDidFinishLaunching:)]){
143 [[NSNotificationCenter defaultCenter] addObserver:_delegate 143 [[NSNotificationCenter defaultCenter] addObserver:_delegate
144 selector:@selector(applicationDidFinishLaunching:) 144 selector:@selector(applicationDidFinishLaunching:)
145 name:NSApplicationDidFinishLaunchingNotification object:self]; 145 name:NSApplicationDidFinishLaunchingNotification object:self];
146 } 146 }
147 if([_delegate respondsToSelector:@selector(applicationDidBecomeActive:)]){ 147 if([_delegate respondsToSelector:@selector(applicationDidBecomeActive:)]){
148 [[NSNotificationCenter defaultCenter] addObserver:_delegate 148 [[NSNotificationCenter defaultCenter] addObserver:_delegate
149 selector:@selector(applicationDidBecomeActive:) 149 selector:@selector(applicationDidBecomeActive:)
150 name: NSApplicationDidBecomeActiveNotification object:self]; 150 name: NSApplicationDidBecomeActiveNotification object:self];
151 } 151 }
152 } 152 }
153 153
154 -(void)setDelegate:delegate { 154 -(void)setDelegate:delegate {
155 _delegate=delegate; 155 _delegate=delegate;
156 [self registerDelegate]; 156 [self registerDelegate];
157 } 157 }
158 158
159 -(void)setMainMenu:(NSMenu *)menu { 159 -(void)setMainMenu:(NSMenu *)menu {
160 int i,count=[_windows count]; 160 int i,count=[_windows count];
161 161
162 [_mainMenu autorelease]; 162 [_mainMenu autorelease];
163 _mainMenu=[menu copy]; 163 _mainMenu=[menu copy];
164 164
165 for(i=0;i<count;i++){ 165 for(i=0;i<count;i++){
166 NSWindow *window=[_windows objectAtIndex:i]; 166 NSWindow *window=[_windows objectAtIndex:i];
167 167
168 if(![window isKindOfClass:[NSPanel class]]) 168 if(![window isKindOfClass:[NSPanel class]])
169 [window setMenu:_mainMenu]; 169 [window setMenu:_mainMenu];
170 } 170 }
171 } 171 }
172 172
173 -(void)setMenu:(NSMenu *)menu { 173 -(void)setMenu:(NSMenu *)menu {
174 [self setMainMenu:menu]; 174 [self setMainMenu:menu];
175 } 175 }
176 176
177 -(void)setApplicationIconImage:(NSImage *)image { 177 -(void)setApplicationIconImage:(NSImage *)image {
178 NSUnimplementedMethod(); 178 NSUnimplementedMethod();
179 } 179 }
180 180
181 -(void)setWindowsMenu:(NSMenu *)menu { 181 -(void)setWindowsMenu:(NSMenu *)menu {
182 //NSLog(@"%s %@",SELNAME(_cmd),menu); 182 //NSLog(@"%s %@",SELNAME(_cmd),menu);
183 [_windowsMenu autorelease]; 183 [_windowsMenu autorelease];
184 _windowsMenu=[menu retain]; 184 _windowsMenu=[menu retain];
185 } 185 }
186 186
187 -(void)addWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)isFilename { 187 -(void)addWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)isFilename {
188 NSMenuItem *windowItem; 188 NSMenuItem *windowItem;
189 189
190 if ([[self windowsMenu] indexOfItemWithTarget:window andAction:@selector(makeKeyAndOrderFront:)] != -1) 190 if ([[self windowsMenu] indexOfItemWithTarget:window andAction:@selector(makeKeyAndOrderFront:)] != -1)
191 return; 191 return;
192 192
193 // separator management... shouldn't +separatorItem be a singleton? i dunno.. 193 // separator management... shouldn't +separatorItem be a singleton? i dunno..
194 // e.g. here, lastObject] == [NSMenuItem separatorItem] ? 194 // e.g. here, lastObject] == [NSMenuItem separatorItem] ?
195 windowItem = [[[self windowsMenu] itemArray] lastObject]; 195 windowItem = [[[self windowsMenu] itemArray] lastObject];
196 if ([windowItem title] != nil && ![[windowItem target] isKindOfClass:[NSWindow class]]) 196 if ([windowItem title] != nil && ![[windowItem target] isKindOfClass:[NSWindow class]])
197 [[self windowsMenu] addItem:[NSMenuItem separatorItem]]; 197 [[self windowsMenu] addItem:[NSMenuItem separatorItem]];
198 198
199 if (isFilename) 199 if (isFilename)
200 title = [NSString stringWithFormat:@"%@ -- %@", [title lastPathComponent], 200 title = [NSString stringWithFormat:@"%@ -- %@", [title lastPathComponent],
201 [title stringByDeletingLastPathComponent]]; 201 [title stringByDeletingLastPathComponent]];
202 202
203 windowItem = [[[NSMenuItem alloc] initWithTitle:title 203 windowItem = [[[NSMenuItem alloc] initWithTitle:title
204 action:@selector(makeKeyAndOrderFront:) 204 action:@selector(makeKeyAndOrderFront:)
205 keyEquivalent:@""] autorelease]; 205 keyEquivalent:@""] autorelease];
206 [windowItem setTarget:window]; 206 [windowItem setTarget:window];
207 207
208 [[self windowsMenu] addItem:windowItem]; 208 [[self windowsMenu] addItem:windowItem];
209 //NSLog(@"add: %@ %@ %@", [self windowsMenu], title, windowItem); 209 //NSLog(@"add: %@ %@ %@", [self windowsMenu], title, windowItem);
210 } 210 }
211 211
212 -(void)changeWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)isFilename { 212 -(void)changeWindowsItem:(NSWindow *)window title:(NSString *)title filename:(BOOL)isFilename {
213 int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window 213 int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window
214 andAction:@selector(makeKeyAndOrderFront:)]; 214 andAction:@selector(makeKeyAndOrderFront:)];
215 215
216 if (itemIndex != -1) { 216 if (itemIndex != -1) {
217 NSMenuItem *windowItem = [[self windowsMenu] itemAtIndex:itemIndex]; 217 NSMenuItem *windowItem = [[self windowsMenu] itemAtIndex:itemIndex];
218 218
219 if (isFilename) 219 if (isFilename)
220 title = [NSString stringWithFormat:@"%@ -- %@", 220 title = [NSString stringWithFormat:@"%@ -- %@",
221 [title lastPathComponent], [title stringByDeletingLastPathComponent]]; 221 [title lastPathComponent], [title stringByDeletingLastPathComponent]];
222 222
223 [windowItem setTitle:title]; 223 [windowItem setTitle:title];
224 [[self windowsMenu] itemChanged:windowItem]; 224 [[self windowsMenu] itemChanged:windowItem];
225 } 225 }
226 else 226 else
227 [self addWindowsItem:window title:title filename:isFilename]; 227 [self addWindowsItem:window title:title filename:isFilename];
228 } 228 }
229 229
230 -(void)removeWindowsItem:(NSWindow *)window { 230 -(void)removeWindowsItem:(NSWindow *)window {
231 int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window 231 int itemIndex = [[self windowsMenu] indexOfItemWithTarget:window
232 andAction:@selector(makeKeyAndOrderFront:)]; 232 andAction:@selector(makeKeyAndOrderFront:)];
233 if (itemIndex != -1) { 233 if (itemIndex != -1) {
234 [[self windowsMenu] removeItemAtIndex:itemIndex]; 234 [[self windowsMenu] removeItemAtIndex:itemIndex];
235 235
236 // separator 236 // separator
237 if ([[[[self windowsMenu] itemArray] lastObject] title] == nil) 237 if ([[[[self windowsMenu] itemArray] lastObject] title] == nil)
238 [[self windowsMenu] removeItem:[[[self windowsMenu] itemArray] lastObject]]; 238 [[self windowsMenu] removeItem:[[[self windowsMenu] itemArray] lastObject]];
239 } 239 }
240 } 240 }
241 241
242 -(void)finishLaunching { 242 -(void)finishLaunching {
243 NSAutoreleasePool *pool=[NSAutoreleasePool new]; 243 NSAutoreleasePool *pool=[NSAutoreleasePool new];
244 BOOL needsUntitled=YES; 244 BOOL needsUntitled=YES;
245 245
246 NS_DURING 246 NS_DURING
247 [[NSNotificationCenter defaultCenter] postNotificationName: NSApplicationWillFinishLaunchingNotification object:self]; 247 [[NSNotificationCenter defaultCenter] postNotificationName: NSApplicationWillFinishLaunchingNotification object:self];
248 NS_HANDLER 248 NS_HANDLER
249 [self reportException:localException]; 249 [self reportException:localException];
250 NS_ENDHANDLER 250 NS_ENDHANDLER
251 251
252 // Give us a first event 252 // Give us a first event
253 [NSTimer scheduledTimerWithTimeInterval:0.1 target:nil 253 [NSTimer scheduledTimerWithTimeInterval:0.1 target:nil
254 selector:NULL userInfo:nil repeats:NO]; 254 selector:NULL userInfo:nil repeats:NO];
255 255
256 [_display closeSplashImage]; 256 [_display closeSplashImage];
257 257
258 if(_delegate==nil){ 258 if(_delegate==nil){
259 id types=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDocumentTypes"]; 259 id types=[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleDocumentTypes"];
260 260
261 if([types count]>0) 261 if([types count]>0)
262 _delegate=[NSDocumentController sharedDocumentController]; 262 _delegate=[NSDocumentController sharedDocumentController];
263 } 263 }
264 264
265 if([_delegate respondsToSelector:@selector(application:openFile:)]){ 265 if([_delegate respondsToSelector:@selector(application:openFile:)]){
266 NSString *openFile=[[NSUserDefaults standardUserDefaults] stringForKey:@"NSOpen"]; 266 NSString *openFile=[[NSUserDefaults standardUserDefaults] stringForKey:@"NSOpen"];
267 267
268 if([openFile length]>0){ 268 if([openFile length]>0){
269 if([_delegate application:self openFile:openFile]) 269 if([_delegate application:self openFile:openFile])
270 needsUntitled=NO; 270 needsUntitled=NO;
271 } 271 }
272 } 272 }
273 273
274 if(needsUntitled && [_delegate isKindOfClass:[NSDocumentController class]]) 274 if(needsUntitled && [_delegate isKindOfClass:[NSDocumentController class]])
275 [_delegate newDocument:self]; 275 [_delegate newDocument:self];
276 276
277 NS_DURING 277 NS_DURING
278 [[NSNotificationCenter defaultCenter] postNotificationName:NSApplicationDidFinishLaunchingNotification object:self]; 278 [[NSNotificationCenter defaultCenter] postNotificationName:NSApplicationDidFinishLaunchingNotification object:self];
279 NS_HANDLER 279 NS_HANDLER
280 [self reportException:localException]; 280 [self reportException:localException];
281 NS_ENDHANDLER 281 NS_ENDHANDLER
282 282
283 [pool release]; 283 [pool release];
284 } 284 }
285 285
286 -(void)_checkForReleasedWindows { 286 -(void)_checkForReleasedWindows {
287 int count=[_windows count]; 287 int count=[_windows count];
288 288
289 while(--count>=0){ 289 while(--count>=0){
290 NSWindow *check=[_windows objectAtIndex:count]; 290 NSWindow *check=[_windows objectAtIndex:count];
291 291
292 if([check retainCount]==1) 292 if([check retainCount]==1)
293 [_windows removeObjectAtIndex:count]; 293 [_windows removeObjectAtIndex:count];
294 } 294 }
295 } 295 }
296 296
297 -(void)_checkForTerminate { 297 -(void)_checkForTerminate {
298 int count=[_windows count]; 298 int count=[_windows count];
299 299
300 while(--count>=0){ 300 while(--count>=0){
301 NSWindow *check=[_windows objectAtIndex:count]; 301 NSWindow *check=[_windows objectAtIndex:count];
302 302
303 if(![check isKindOfClass:[NSPanel class]] && [check isVisible]){ 303 if(![check isKindOfClass:[NSPanel class]] && [check isVisible]){
304 return; 304 return;
305 } 305 }
306 } 306 }
307 307
308 [self terminate:self]; 308 [self terminate:self];
309 } 309 }
310 310
311 -(void)_checkForAppActivation { 311 -(void)_checkForAppActivation {
312 #if 1 312 #if 1
313 if([self isActive]) 313 if([self isActive])
314 [_windows makeObjectsPerformSelector:@selector(_showForActivation)]; 314 [_windows makeObjectsPerformSelector:@selector(_showForActivation)];
315 else 315 else
316 [_windows makeObjectsPerformSelector:@selector(_hideForDeactivation)]; 316 [_windows makeObjectsPerformSelector:@selector(_hideForDeactivation)];
317 #endif 317 #endif
318 } 318 }
319 319
320 -(void)run { 320 -(void)run {
321 321
322 [self finishLaunching]; 322 [self finishLaunching];
323 323
324 do { 324 do {
325 NSAutoreleasePool *pool=[NSAutoreleasePool new]; 325 NSAutoreleasePool *pool=[NSAutoreleasePool new];
326 NSEvent *event; 326 NSEvent *event;
327 327
328 //OBJCReportStatistics(); 328 //OBJCReportStatistics();
329 329
330 event=[self nextEventMatchingMask:NSAnyEventMask 330 event=[self nextEventMatchingMask:NSAnyEventMask
331 untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES]; 331 untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:YES];
332 332
333 NS_DURING 333 NS_DURING
334 [self sendEvent:event]; 334 [self sendEvent:event];
335 335
336 NS_HANDLER 336 NS_HANDLER
337 [self reportException:localException]; 337 [self reportException:localException];
338 NS_ENDHANDLER 338 NS_ENDHANDLER
339 339
340 [self _checkForReleasedWindows]; 340 [self _checkForReleasedWindows];
341 [self _checkForTerminate]; 341 [self _checkForTerminate];
342 342
343 [pool release]; 343 [pool release];
344 }while(YES); 344 }while(YES);
345 } 345 }
346 346
347 -(BOOL)_performKeyEquivalent:(NSEvent *)event { 347 -(BOOL)_performKeyEquivalent:(NSEvent *)event {
348 if([[self mainMenu] performKeyEquivalent:event]) 348 if([[self mainMenu] performKeyEquivalent:event])
349 return YES; 349 return YES;
350 if([[self keyWindow] performKeyEquivalent:event]) 350 if([[self keyWindow] performKeyEquivalent:event])
351 return YES; 351 return YES;
352 if([[self mainWindow] performKeyEquivalent:event]) 352 if([[self mainWindow] performKeyEquivalent:event])
353 return YES; 353 return YES;
354 // documentation says to send it to all windows 354 // documentation says to send it to all windows
355 return NO; 355 return NO;
356 } 356 }
357 357
358 -(void)sendEvent:(NSEvent *)event { 358 -(void)sendEvent:(NSEvent *)event {
359 if([event type]==NSKeyDown){ 359 if([event type]==NSKeyDown){
360 unsigned modifierFlags=[event modifierFlags]; 360 unsigned modifierFlags=[event modifierFlags];
361 361
362 if(modifierFlags&(NSCommandKeyMask|NSAlternateKeyMask)) 362 if(modifierFlags&(NSCommandKeyMask|NSAlternateKeyMask))
363 if([self _performKeyEquivalent:event]) 363 if([self _performKeyEquivalent:event])
364 return; 364 return;
365 } 365 }
366 366
367 [[event window] sendEvent:event]; 367 [[event window] sendEvent:event];
368 } 368 }
369 369
370 -(NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)untilDate inMode:(NSString *)mode dequeue:(BOOL)dequeue { 370 -(NSEvent *)nextEventMatchingMask:(unsigned int)mask untilDate:(NSDate *)untilDate inMode:(NSString *)mode dequeue:(BOOL)dequeue {
371 NSAutoreleasePool *pool=[NSAutoreleasePool new]; 371 NSAutoreleasePool *pool=[NSAutoreleasePool new];
372 NSEvent *nextEvent; 372 NSEvent *nextEvent;
373 373
374 NS_DURING 374 NS_DURING
375 [NSClassFromString(@"Win32RunningCopyPipe") performSelector:@selector(createRunningCopyPipe)]; 375 [NSClassFromString(@"Win32RunningCopyPipe") performSelector:@selector(createRunningCopyPipe)];
376 [[NSApp windows] makeObjectsPerformSelector:@selector(_makeSureIsOnAScreen)]; 376 [[NSApp windows] makeObjectsPerformSelector:@selector(_makeSureIsOnAScreen)];
377 377
378 [self _checkForReleasedWindows]; 378 [self _checkForReleasedWindows];
379 [self _checkForAppActivation]; 379 [self _checkForAppActivation];
380 [[NSApp windows] makeObjectsPerformSelector:@selector(displayIfNeeded)]; 380 [[NSApp windows] makeObjectsPerformSelector:@selector(displayIfNeeded)];
381 381
382 nextEvent=[_display nextEventMatchingMask:mask untilDate:untilDate inMode:mode dequeue:dequeue]; 382 nextEvent=[_display nextEventMatchingMask:mask untilDate:untilDate inMode:mode dequeue:dequeue];
383 383
384 [_currentEvent release]; 384 [_currentEvent release];
385 _currentEvent=[nextEvent retain]; 385 _currentEvent=[nextEvent retain];
386 386
387 NS_HANDLER 387 NS_HANDLER
388 [self reportException:localException]; 388 [self reportException:localException];
389 NS_ENDHANDLER 389 NS_ENDHANDLER
390 390
391 [pool release]; 391 [pool release];
392 392
393 return [[_currentEvent retain] autorelease]; 393 return [[_currentEvent retain] autorelease];
394 } 394 }
395 395
396 -(NSEvent *)currentEvent { 396 -(NSEvent *)currentEvent {
397 return _currentEvent; 397 return _currentEvent;
398 } 398 }
399 399
400 -(void)discardEventsMatchingMask:(unsigned)mask beforeEvent:(NSEvent *)event { 400 -(void)discardEventsMatchingMask:(unsigned)mask beforeEvent:(NSEvent *)event {
401 [_display discardEventsMatchingMask:mask beforeEvent:event]; 401 [_display discardEventsMatchingMask:mask beforeEvent:event];
402 } 402 }
403 403
404 -(void)postEvent:(NSEvent *)event atStart:(BOOL)atStart { 404 -(void)postEvent:(NSEvent *)event atStart:(BOOL)atStart {
405 [_display postEvent:event atStart:atStart]; 405 [_display postEvent:event atStart:atStart];
406 } 406 }
407 407
408 -targetForAction:(SEL)action { 408 -targetForAction:(SEL)action {
409 NSWindow *window; 409 NSWindow *window;
410 NSResponder *check; 410 NSResponder *check;
411 411
412 window=[self keyWindow]; 412 window=[self keyWindow];
413 413
414 for(check=[window firstResponder];check!=nil;check=[check nextResponder]){ 414 for(check=[window firstResponder];check!=nil;check=[check nextResponder]){
415 if([check respondsToSelector:action]) 415 if([check respondsToSelector:action])
416 return check; 416 return check;
417 } 417 }
418 418
419 if([window respondsToSelector:action]) 419 if([window respondsToSelector:action])
420 return window; 420 return window;
421 421
422 if([[window delegate] respondsToSelector:action]) 422 if([[window delegate] respondsToSelector:action])
423 return [window delegate]; 423 return [window delegate];
424 424
425 window=[self mainWindow]; 425 window=[self mainWindow];
426 426
427 for(check=[window firstResponder];check!=nil;check=[check nextResponder]){ 427 for(check=[window firstResponder];check!=nil;check=[check nextResponder]){
428 if([check respondsToSelector:action]) 428 if([check respondsToSelector:action])
429 return check; 429 return check;
430 } 430 }
431 431
432 if([window respondsToSelector:action]) 432 if([window respondsToSelector:action])
433 return window; 433 return window;
434 434
435 if([[window delegate] respondsToSelector:action]) 435 if([[window delegate] respondsToSelector:action])
436 return [window delegate]; 436 return [window delegate];
437 437
438 if([self respondsToSelector:action]) 438 if([self respondsToSelector:action])
439 return self; 439 return self;
440 440
441 if([[self delegate] respondsToSelector:action]) 441 if([[self delegate] respondsToSelector:action])
442 return [self delegate]; 442 return [self delegate];
443 443
444 return nil; 444 return nil;
445 } 445 }
446 446
447 -(BOOL)sendAction:(SEL)action to:target from:sender { 447 -(BOOL)sendAction:(SEL)action to:target from:sender {
448 448
449 //NSLog(@"%s %s %@ %@",SELNAME(_cmd),action,target,sender); 449 //NSLog(@"%s %s %@ %@",SELNAME(_cmd),action,target,sender);
450 450
451 if(target!=nil){ 451 if(target!=nil){
452 if([target respondsToSelector:action]){ 452 if([target respondsToSelector:action]){
453 [target performSelector:action withObject:sender]; 453 [target performSelector:action withObject:sender];
454 return YES; 454 return YES;
455 } 455 }
456 } 456 }
457 else if((target=[self targetForAction:action])!=nil){ 457 else if((target=[self targetForAction:action])!=nil){
458 [target performSelector:action withObject:sender]; 458 [target performSelector:action withObject:sender];
459 return YES; 459 return YES;
460 } 460 }
461 461
462 return NO; 462 return NO;
463 } 463 }
464 464
465 -(void)updateWindows { 465 -(void)updateWindows {
466 [_windows makeObjectsPerformSelector:@selector(update)]; 466 [_windows makeObjectsPerformSelector:@selector(update)];
467 } 467 }
468 468
469 -(void)activateIgnoringOtherApps:(BOOL)flag { 469 -(void)activateIgnoringOtherApps:(BOOL)flag {
470 NSUnimplementedMethod(); 470 NSUnimplementedMethod();
471 } 471 }
472 472
473 -(NSWindow *)modalWindow { 473 -(NSWindow *)modalWindow {
474 return [[_modalStack lastObject] modalWindow]; 474 return [[_modalStack lastObject] modalWindow];
475 } 475 }
476 476
477 -(NSModalSession)beginModalSessionForWindow:(NSWindow *)window { 477 -(NSModalSession)beginModalSessionForWindow:(NSWindow *)window {
478 NSModalSessionX *session=[NSModalSessionX sessionWithWindow:window]; 478 NSModalSessionX *session=[NSModalSessionX sessionWithWindow:window];
479 479
480 [_modalStack addObject:session]; 480 [_modalStack addObject:session];
481 481
482 [window center]; 482 [window center];
483 [window makeKeyAndOrderFront:self]; 483 [window makeKeyAndOrderFront:self];
484 484
485 return session; 485 return session;
486 } 486 }
487 487
488 -(int)runModalSession:(NSModalSession)session { 488 -(int)runModalSession:(NSModalSession)session {
489 NSAutoreleasePool *pool=[NSAutoreleasePool new]; 489 NSAutoreleasePool *pool=[NSAutoreleasePool new];
490 NSDate *future=[NSDate distantFuture]; 490 NSDate *future=[NSDate distantFuture];
491 NSEvent *event=[self nextEventMatchingMask:NSAnyEventMask 491 NSEvent *event=[self nextEventMatchingMask:NSAnyEventMask
492 untilDate:future inMode:NSModalPanelRunLoopMode dequeue:YES]; 492 untilDate:future inMode:NSModalPanelRunLoopMode dequeue:YES];
493 NSWindow *window=[event window]; 493 NSWindow *window=[event window];
494 494
495 // in theory this could get weird, but all we want is the ESC-cancel keybinding, afaik NSApp doesn't respond to any other doCommandBySelectors... 495 // in theory this could get weird, but all we want is the ESC-cancel keybinding, afaik NSApp doesn't respond to any other doCommandBySelectors...
496 if([event type]==NSKeyDown && window == [session modalWindow]) 496 if([event type]==NSKeyDown && window == [session modalWindow])
497 [self interpretKeyEvents:[NSArray arrayWithObject:event]]; 497 [self interpretKeyEvents:[NSArray arrayWithObject:event]];
498 498
499 if(window==[session modalWindow] || [window worksWhenModal]) 499 if(window==[session modalWindow] || [window worksWhenModal])
500 [self sendEvent:event]; 500 [self sendEvent:event];
501 else if([event type]==NSLeftMouseDown) 501 else if([event type]==NSLeftMouseDown)
502 [[session modalWindow] makeKeyAndOrderFront:self]; 502 [[session modalWindow] makeKeyAndOrderFront:self];
503 503
504 [pool release]; 504 [pool release];
505 505
506 return [session stopCode]; 506 return [session stopCode];
507 } 507 }
508 508
509 -(void)endModalSession:(NSModalSession)session { 509 -(void)endModalSession:(NSModalSession)session {
510 [_modalStack removeLastObject]; 510 [_modalStack removeLastObject];
511 } 511 }
512 512
513 -(void)stopModalWithCode:(int)code { 513 -(void)stopModalWithCode:(int)code {
514 if([_modalStack lastObject]==nil) 514 if([_modalStack lastObject]==nil)
515 [NSException raise:NSInvalidArgumentException 515 [NSException raise:NSInvalidArgumentException
516 format:@"-[%@ %s] no modal session running",isa,SELNAME(_cmd)]; 516 format:@"-[%@ %s] no modal session running",isa,SELNAME(_cmd)];
517 517
518 [[_modalStack lastObject] stopModalWithCode:code]; 518 [[_modalStack lastObject] stopModalWithCode:code];
519 } 519 }
520 520
521 -(int)runModalForWindow:(NSWindow *)window { 521 -(int)runModalForWindow:(NSWindow *)window {
522 NSModalSession session=[self beginModalSessionForWindow:window]; 522 NSModalSession session=[self beginModalSessionForWindow:window];
523 int result; 523 int result;
524 524
525 525
526 while((result=[NSApp runModalSession:session])==NSRunContinuesResponse) 526 while((result=[NSApp runModalSession:session])==NSRunContinuesResponse)
527 ; 527 ;
528 528
529 [self endModalSession:session]; 529 [self endModalSession:session];
530 530
531 return result; 531 return result;
532 } 532 }
533 533
534 -(void)stopModal { 534 -(void)stopModal {
535 [self stopModalWithCode:NSRunStoppedResponse]; 535 [self stopModalWithCode:NSRunStoppedResponse];
536 } 536 }
537 537
538 -(void)abortModal { 538 -(void)abortModal {
539 [self stopModalWithCode:NSRunAbortedResponse]; 539 [self stopModalWithCode:NSRunAbortedResponse];
540 } 540 }
541 541
542 // cancel modal windows 542 // cancel modal windows
543 -(void)cancel:sender { 543 -(void)cancel:sender {
544 if ([self modalWindow] != nil) 544 if ([self modalWindow] != nil)
545 [self abortModal]; 545 [self abortModal];
546 } 546 }
547 547
548 -(void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)window modalDelegate:modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo { 548 -(void)beginSheet:(NSWindow *)sheet modalForWindow:(NSWindow *)window modalDelegate:modalDelegate didEndSelector:(SEL)didEndSelector contextInfo:(void *)contextInfo {
549 NSSheetContext *context=[NSSheetContext sheetContextWithSheet:sheet modalDelegate:modalDelegate didEndSelector:didEndSelector contextInfo:contextInfo frame:[sheet frame]]; 549 NSSheetContext *context=[NSSheetContext sheetContextWithSheet:sheet modalDelegate:modalDelegate didEndSelector:didEndSelector contextInfo:contextInfo frame:[sheet frame]];
550 // // Hmmm 550 // // Hmmm
551 #if 1 551 #if 1
552 if ([sheet styleMask] != NSDocModalWindowMask) 552 if ([sheet styleMask] != NSDocModalWindowMask)
553 [sheet _setStyleMask:NSDocModalWindowMask]; 553 [sheet _setStyleMask:NSDocModalWindowMask];
554 #endif 554 #endif
555 // if ([sheet styleMask] != NSBorderlessWindowMask) 555 // if ([sheet styleMask] != NSBorderlessWindowMask)
556 // [sheet _setStyleMask:NSBorderlessWindowMask]; 556 // [sheet _setStyleMask:NSBorderlessWindowMask];
557 557
558 [window _attachSheetContextOrderFrontAndAnimate:context]; 558 [window _attachSheetContextOrderFrontAndAnimate:context];
559 } 559 }
560 560
561 -(void)endSheet:(NSWindow *)sheet returnCode:(int)returnCode { 561 -(void)endSheet:(NSWindow *)sheet returnCode:(int)returnCode {
562 int count=[_windows count]; 562 int count=[_windows count];
563 563
564 while(--count>=0){ 564 while(--count>=0){
565 NSWindow *check=[_windows objectAtIndex:count]; 565 NSWindow *check=[_windows objectAtIndex:count];
566 NSSheetContext *context=[check _sheetContext]; 566 NSSheetContext *context=[check _sheetContext];
567 IMP function; 567 IMP function;
568 568
569 if([context sheet]==sheet){ 569 if([context sheet]==sheet){
570 [[context retain] autorelease]; 570 [[context retain] autorelease];
571 571
572 [check _detachSheetContextAnimateAndOrderOut]; 572 [check _detachSheetContextAnimateAndOrderOut];
573 573
574 function=objc_msg_lookup([context modalDelegate],[context didEndSelector]); 574 function=objc_msg_lookup([context modalDelegate],[context didEndSelector]);
575 function([context modalDelegate],[context didEndSelector],sheet,returnCode,[context contextInfo]); 575 function([context modalDelegate],[context didEndSelector],sheet,returnCode,[context contextInfo]);
576 576
577 return; 577 return;
578 } 578 }
579 } 579 }
580 } 580 }
581 581
582 -(void)endSheet:(NSWindow *)sheet { 582 -(void)endSheet:(NSWindow *)sheet {
583 [self endSheet:sheet returnCode:0]; 583 [self endSheet:sheet returnCode:0];
584 } 584 }
585 585
586 -(void)reportException:(NSException *)exception { 586 -(void)reportException:(NSException *)exception {
587 NSLog(@"NSApplication got exception: %@",exception); 587 NSLog(@"NSApplication got exception: %@",exception);
588 } 588 }
589 589
590 -(void)runPageLayout:sender { 590 -(void)runPageLayout:sender {
591 [[NSPageLayout pageLayout] runModal]; 591 [[NSPageLayout pageLayout] runModal];
592 } 592 }
593 593
594 -(void)orderFrontColorPanel:(id)sender { 594 -(void)orderFrontColorPanel:(id)sender {
595 [[NSColorPanel sharedColorPanel] orderFront:sender]; 595 [[NSColorPanel sharedColorPanel] orderFront:sender];
596 } 596 }
597 597
598 -(void)hide:sender { 598 -(void)hide:sender {
599 NSUnimplementedMethod(); 599 NSUnimplementedMethod();
600 } 600 }
601 601
602 -(void)unhide:sender { 602 -(void)unhide:sender {
603 NSUnimplementedMethod(); 603 NSUnimplementedMethod();
604 } 604 }
605 605
606 -(void)terminate:sender { 606 -(void)terminate:sender {
607 if([_delegate respondsToSelector:@selector(applicationShouldTerminate:)]){ 607 if([_delegate respondsToSelector:@selector(applicationShouldTerminate:)]){
608 if(![_delegate applicationShouldTerminate:self]){ 608 if(![_delegate applicationShouldTerminate:self]){
609 return; 609 return;
610 } 610 }
611 } 611 }
612 612
613 [NSClassFromString(@"Win32RunningCopyPipe") performSelector:@selector(invalidateRunningCopyPipe)]; 613 [NSClassFromString(@"Win32RunningCopyPipe") performSelector:@selector(invalidateRunningCopyPipe)];
614 614
615 exit(0); 615 exit(0);
616 } 616 }
617 617
618 -(void)arrangeInFront:sender { 618 -(void)arrangeInFront:sender {
619 #define CASCADE_DELTA 20 // ? isn't there a call for this? 619 #define CASCADE_DELTA 20 // ? isn't there a call for this?
620 NSMutableArray *visibleWindows = [NSMutableArray new]; 620 NSMutableArray *visibleWindows = [NSMutableArray new];
621 NSRect rect=[[[NSScreen screens] objectAtIndex:0] frame], winRect; 621 NSRect rect=[[[NSScreen screens] objectAtIndex:0] frame], winRect;
622 NSArray *windowsItems = [[self windowsMenu] itemArray]; 622 NSArray *windowsItems = [[self windowsMenu] itemArray];
623 int i, count=[windowsItems count]; 623 int i, count=[windowsItems count];
624 624
625 for (i = 0 ; i < count; ++i) { 625 for (i = 0 ; i < count; ++i) {
626 id target = [[windowsItems objectAtIndex:i] target]; 626 id target = [[windowsItems objectAtIndex:i] target];
627 627
628 if ([target isKindOfClass:[NSWindow class]]) 628 if ([target isKindOfClass:[NSWindow class]])
629 [visibleWindows addObject:target]; 629 [visibleWindows addObject:target];
630 } 630 }
631 631
632 count = [visibleWindows count]; 632 count = [visibleWindows count];
633 if (count == 0) 633 if (count == 0)
634 return; 634 return;
635 635
636 // find screen center. 636 // find screen center.
637 // subtract window w,h /2 637 // subtract window w,h /2
638 winRect = [[visibleWindows objectAtIndex:0] frame]; 638 winRect = [[visibleWindows objectAtIndex:0] frame];
639 rect.origin.x = (rect.size.width/2) - (winRect.size.width/2); 639 rect.origin.x = (rect.size.width/2) - (winRect.size.width/2);
640 rect.origin.x -= count*CASCADE_DELTA/2; 640 rect.origin.x -= count*CASCADE_DELTA/2;
641 rect.origin.x=floor(rect.origin.x); 641 rect.origin.x=floor(rect.origin.x);
642 642
643 rect.origin.y = (rect.size.height/2) + (winRect.size.height/2); 643 rect.origin.y = (rect.size.height/2) + (winRect.size.height/2);
644 rect.origin.y += count*CASCADE_DELTA/2; 644 rect.origin.y += count*CASCADE_DELTA/2;
645 rect.origin.y=floor(rect.origin.y); 645 rect.origin.y=floor(rect.origin.y);
646 646
647 for (i = 0; i < count; ++i) { 647 for (i = 0; i < count; ++i) {
648 [[visibleWindows objectAtIndex:i] setFrameTopLeftPoint:rect.origin]; 648 [[visibleWindows objectAtIndex:i] setFrameTopLeftPoint:rect.origin];
649 [[visibleWindows objectAtIndex:i] orderFront:nil]; 649 [[visibleWindows objectAtIndex:i] orderFront:nil];
650 650
651 rect.origin.x += CASCADE_DELTA; 651 rect.origin.x += CASCADE_DELTA;
652 rect.origin.y -= CASCADE_DELTA; 652 rect.origin.y -= CASCADE_DELTA;
653 } 653 }
654 } 654 }
655 655
656 -(void)showHelp:sender { 656 -(void)showHelp:sender {
657 NSUnimplementedMethod(); 657 NSUnimplementedMethod();
658 } 658 }
659 659
660 -servicesProvider { 660 -servicesProvider {
661 //NSUnsupportedMethod(); 661 //NSUnsupportedMethod();
662 return nil; 662 return nil;
663 } 663 }
664 664
665 -(void)setServicesProvider:provider { 665 -(void)setServicesProvider:provider {
666 //NSUnsupportedMethod(); 666 //NSUnsupportedMethod();
667 } 667 }
668 668
669 -(void)registerServicesMenuSendTypes:(NSArray *)sendTypes returnTypes:(NSArray *)returnTypes { 669 -(void)registerServicesMenuSendTypes:(NSArray *)sendTypes returnTypes:(NSArray *)returnTypes {
670 //tiredofthesewarnings NSUnsupportedMethod(); 670 //tiredofthesewarnings NSUnsupportedMethod();
671 } 671 }
672 672
673 - (void)doCommandBySelector:(SEL)selector { 673 - (void)doCommandBySelector:(SEL)selector {
674 if ([_delegate respondsToSelector:selector]) 674 if ([_delegate respondsToSelector:selector])
675 [_delegate performSelector:selector withObject:nil]; 675 [_delegate performSelector:selector withObject:nil];
676 else 676 else
677 [super doCommandBySelector:selector]; 677 [super doCommandBySelector:selector];
678 } 678 }
679 679
680 -(void)_addWindow:(NSWindow *)window { 680 -(void)_addWindow:(NSWindow *)window {
681 [_windows addObject:window]; 681 [_windows addObject:window];
682 } 682 }
683 683
684 @end 684 @end
685 685
686 int NSApplicationMain(int argc, const char *argv[]) { 686 int NSApplicationMain(int argc, const char *argv[]) {
687 NSInitializeProcess(__argc,(const char **)__argv); 687 NSInitializeProcess(__argc,(const char **)__argv);
688 { 688 {
689 NSAutoreleasePool *pool=[NSAutoreleasePool new]; 689 NSAutoreleasePool *pool=[NSAutoreleasePool new];
690 NSBundle *bundle=[NSBundle mainBundle]; 690 NSBundle *bundle=[NSBundle mainBundle];
691 Class class=[bundle principalClass]; 691 Class class=[bundle principalClass];
692 NSString *nibFile=[[bundle infoDictionary] objectForKey:@"NSMainNibFile"]; 692 NSString *nibFile=[[bundle infoDictionary] objectForKey:@"NSMainNibFile"];
693 693
694 if(class==Nil) 694 if(class==Nil)
695 class=[NSApplication class]; 695 class=[NSApplication class];
696 696
697 [class sharedApplication]; 697 [class sharedApplication];
698 698
699 nibFile=[nibFile stringByDeletingPathExtension]; 699 nibFile=[nibFile stringByDeletingPathExtension];
700 700
701 if(![NSBundle loadNibNamed:nibFile owner:NSApp]) 701 if(![NSBundle loadNibNamed:nibFile owner:NSApp])
702 NSLog(@"Unable to load main nib file %@",nibFile); 702 NSLog(@"Unable to load main nib file %@",nibFile);
703 703
704 [pool release]; 704 [pool release];
705 705
706 [NSApp run]; 706 [NSApp run];
707 } 707 }
708 return 0; 708 return 0;
709 } 709 }
710 710
711 void NSUpdateDynamicServices(void) { 711 void NSUpdateDynamicServices(void) {
712 NSUnimplementedFunction(); 712 NSUnimplementedFunction();
713 } 713 }
714 714
715 BOOL NSPerformService(NSString *itemName, NSPasteboard *pasteboard) { 715 BOOL NSPerformService(NSString *itemName, NSPasteboard *pasteboard) {
716 NSUnimplementedFunction(); 716 NSUnimplementedFunction();
717 return NO; 717 return NO;
718 } 718 }
719 719
Powered by Google Project Hosting