Minor tidyup - use NSBundle to get info dictionary.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4113 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
richard 1999-04-22 12:18:08 +00:00
parent 5c47b2b844
commit dc098d16e6

View file

@ -103,7 +103,7 @@ NSApplication *NSApp = nil;
//
// Class methods
//
+ (void)initialize
+ (void) initialize
{
if (self == [NSApplication class])
{
@ -126,7 +126,7 @@ NSApplication *NSApp = nil;
}
}
+ (NSApplication *)sharedApplication
+ (NSApplication *) sharedApplication
{ // If the global application does
if (!NSApp) // not yet exist then create it
{
@ -140,7 +140,7 @@ NSApplication *NSApp = nil;
//
// Instance methods
//
- init
- (id) init
{
if (NSApp != self)
{
@ -161,51 +161,42 @@ NSApplication *NSApp = nil;
current_event = [NSEvent new]; // no current event
null_event = [NSEvent new]; // create dummy event
[self setNextResponder:NULL]; // We are the end of
[self setNextResponder: nil]; // We are the end of
// the responder chain
// Set up the run loop
// object for the
// current thread
[self setupRunLoopInputSourcesForMode:NSDefaultRunLoopMode];
[self setupRunLoopInputSourcesForMode:NSConnectionReplyMode];
[self setupRunLoopInputSourcesForMode:NSModalPanelRunLoopMode];
[self setupRunLoopInputSourcesForMode:NSEventTrackingRunLoopMode];
// Set up the run loop object for the current thread
[self setupRunLoopInputSourcesForMode: NSDefaultRunLoopMode];
[self setupRunLoopInputSourcesForMode: NSConnectionReplyMode];
[self setupRunLoopInputSourcesForMode: NSModalPanelRunLoopMode];
[self setupRunLoopInputSourcesForMode: NSEventTrackingRunLoopMode];
return self;
}
- (void)finishLaunching
- (void) finishLaunching
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSBundle* mainBundle = [NSBundle mainBundle];
NSString* resourcePath = [mainBundle resourcePath];
NSString* infoFilePath = [resourcePath
stringByAppendingPathComponent:@"Info-gnustep.plist"];
NSDictionary* infoDict;
NSString* mainModelFile;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSBundle *mainBundle = [NSBundle mainBundle];
NSDictionary *infoDict = [mainBundle infoDictionary];
NSString *mainModelFile;
infoDict = [[NSString stringWithContentsOfFile:infoFilePath] propertyList];
mainModelFile = [infoDict objectForKey:@"NSMainNibFile"];
mainModelFile = [infoDict objectForKey: @"NSMainNibFile"];
if (mainModelFile && ![mainModelFile isEqual:@""])
if (mainModelFile && ![mainModelFile isEqual: @""])
{
if (![GMModel loadIMFile:mainModelFile
owner:[NSApplication sharedApplication]])
if (![GMModel loadIMFile: mainModelFile
owner: [NSApplication sharedApplication]])
NSLog (@"Cannot load the main model file '%@", mainModelFile);
}
// post notification that
// launch will finish
/* post notification that launch will finish */
[nc postNotificationName: NSApplicationWillFinishLaunchingNotification
object: self];
// Register our listener to
// handle incoming services
// requests etc.
/* Register our listener to incoming services requests etc. */
[listener registerAsServiceProvider];
// finish the launching
// post notification that
// launching has finished
/* finish the launching post notification that launching has finished */
[nc postNotificationName: NSApplicationDidFinishLaunchingNotification
object: self];
}
@ -213,16 +204,18 @@ NSString* mainModelFile;
- (void) dealloc
{
NSDebugLog(@"Freeing NSApplication\n");
// Let ourselves know we
gnustep_gui_app_is_in_dealloc = YES; // are within dealloc
/* Let ourselves know we are within dealloc */
gnustep_gui_app_is_in_dealloc = YES;
[listener release];
[event_queue release];
[current_event release];
while (session != 0) // We may need to tidy up
{ // nested modal session
NSModalSession tmp = session; // structures.
/* We may need to tidy up nested modal session structures. */
while (session != 0)
{
NSModalSession tmp = session;
session = tmp->previous;
NSZoneFree(NSDefaultMallocZone(), tmp);
@ -310,10 +303,10 @@ NSString* mainModelFile;
{
pool = [arpClass new];
e = [self nextEventMatchingMask:NSAnyEventMask
untilDate:[NSDate distantFuture]
inMode:NSDefaultRunLoopMode
dequeue:YES];
e = [self nextEventMatchingMask: NSAnyEventMask
untilDate: [NSDate distantFuture]
inMode: NSDefaultRunLoopMode
dequeue: YES];
if (e)
[self sendEvent: e];
@ -368,7 +361,7 @@ NSString* mainModelFile;
if (theSession == 0)
[NSException raise: NSInvalidArgumentException
format: @"null pointer passed to endModalSession:"];
format: @"null pointer passed to endModalSession: "];
// Remove this session from
// linked list of sessions.
@ -377,7 +370,7 @@ NSString* mainModelFile;
if (tmp == 0)
[NSException raise: NSInvalidArgumentException
format: @"unknown session passed to endModalSession:"];
format: @"unknown session passed to endModalSession: "];
while (session != theSession)
{
@ -400,7 +393,7 @@ NSString* mainModelFile;
NS_DURING
{
theSession = [self beginModalSessionForWindow:theWindow];
theSession = [self beginModalSessionForWindow: theWindow];
while (code == NSRunContinuesResponse)
{
code = [self runModalSession: theSession];
@ -536,7 +529,7 @@ NSString* mainModelFile;
{
if (session == 0)
[NSException raise: NSInvalidArgumentException
format:@"stopModalWithCode: when not in a modal session"];
format: @"stopModalWithCode: when not in a modal session"];
else
if (returnCode == NSRunContinuesResponse)
[NSException raise: NSInvalidArgumentException
@ -548,7 +541,7 @@ NSString* mainModelFile;
//
// Getting, removing, and posting events
//
- (void)sendEvent:(NSEvent *)theEvent
- (void) sendEvent: (NSEvent *)theEvent
{
if (theEvent == null_event) // Don't send null event
{
@ -564,14 +557,14 @@ NSString* mainModelFile;
case NSKeyDown:
{
NSDebugLog(@"send key down event\n");
[[theEvent window] sendEvent:theEvent];
[[theEvent window] sendEvent: theEvent];
break;
}
case NSKeyUp:
{
NSDebugLog(@"send key up event\n");
[[theEvent window] sendEvent:theEvent];
[[theEvent window] sendEvent: theEvent];
break;
}
@ -585,9 +578,9 @@ NSString* mainModelFile;
copyOfMainMenu = [main_menu copy]; // under the mouse
copyMenuWindow = [copyOfMainMenu menuWindow];
[copyOfMainMenu _rightMouseDisplay];
[copyMenuWindow _captureMouse:self];
[[copyOfMainMenu menuCells] mouseDown:theEvent];
[copyMenuWindow _releaseMouse:self];
[copyMenuWindow _captureMouse: self];
[[copyOfMainMenu menuCells] mouseDown: theEvent];
[copyMenuWindow _releaseMouse: self];
}
break;
@ -602,7 +595,7 @@ NSString* mainModelFile;
NSDebugLog([window description]);
if (!window)
NSDebugLog(@"no window");
[window sendEvent:theEvent];
[window sendEvent: theEvent];
}
}
}
@ -612,18 +605,18 @@ NSString* mainModelFile;
return current_event;
}
- (void) discardEventsMatchingMask:(unsigned int)mask
beforeEvent:(NSEvent *)lastEvent
- (void) discardEventsMatchingMask: (unsigned int)mask
beforeEvent: (NSEvent *)lastEvent
{
int i = 0, count, loop;
NSEvent* event = nil;
BOOL match;
unsigned i = 0, count, loop;
NSEvent *event = nil;
BOOL match;
// if queue contains
if ((count = [event_queue count])) // events check them
{
for (loop = 0; ((event != lastEvent) && (loop < count)); loop++)
{
event = [event_queue objectAtIndex:i]; // Get next event from
event = [event_queue objectAtIndex: i]; // Get next event from
match = NO; // the events queue
if (mask == NSAnyEventMask) // the any event mask
@ -707,18 +700,18 @@ BOOL match;
} } // remove event from
// the queue if it
if (match) // matched the mask
[event_queue removeObjectAtIndex:i];
[event_queue removeObjectAtIndex: i];
else // inc queue cntr only
i++; // if not a match else
} // we will run off the
} // end of the queue
}
- (NSEvent*)_eventMatchingMask:(unsigned int)mask dequeue:(BOOL)flag
- (NSEvent*) _eventMatchingMask: (unsigned int)mask dequeue: (BOOL)flag
{
NSEvent* event; // return the next
int i, count; // event in the queue
BOOL match = NO; // which matches mask
NSEvent *event; // return the next
unsigned i, count; // event in the queue
BOOL match = NO; // which matches mask
[self _nextEvent];
@ -726,7 +719,7 @@ BOOL match = NO; // which matches mask
{ // events check them
for (i = 0; i < count; i++)
{ // Get next event from
event = [event_queue objectAtIndex:i]; // the events queue
event = [event_queue objectAtIndex: i]; // the events queue
if (mask == NSAnyEventMask) // the any event mask
match = YES; // matches all events
@ -738,7 +731,7 @@ BOOL match = NO; // which matches mask
if (flag) // dequeue null event
{ // if flag is set
[event retain];
[event_queue removeObjectAtIndex:i];
[event_queue removeObjectAtIndex: i];
}
}
else
@ -825,7 +818,7 @@ BOOL match = NO; // which matches mask
if (flag) // dequeue the event if
{ // flag is set
[event retain];
[event_queue removeObjectAtIndex:i];
[event_queue removeObjectAtIndex: i];
}
ASSIGN(current_event, event);
@ -837,20 +830,20 @@ BOOL match = NO; // which matches mask
return nil; // queue matches mask
}
- (NSEvent*) nextEventMatchingMask:(unsigned int)mask
untilDate:(NSDate *)expiration
inMode:(NSString *)mode
dequeue:(BOOL)flag
- (NSEvent*) nextEventMatchingMask: (unsigned int)mask
untilDate: (NSDate *)expiration
inMode: (NSString *)mode
dequeue: (BOOL)flag
{
NSEvent *event;
BOOL done = NO;
NSEvent *event;
BOOL done = NO;
if (mode == NSEventTrackingRunLoopMode) // temporary hack to
inTrackingLoop = YES; // regulate translation
else // of X motion events
inTrackingLoop = NO; // while not in a
// tracking loop
if ((event = [self _eventMatchingMask:mask dequeue:flag]))
if ((event = [self _eventMatchingMask: mask dequeue: flag]))
done = YES;
else
if (!expiration)
@ -861,26 +854,26 @@ BOOL done = NO;
NSDate *limitDate, *originalLimitDate;
NSRunLoop* currentLoop = [NSRunLoop currentRunLoop];
// Retain the limitDate so that it doesn't get released
// accidentally by runMode:beforeDate: if a timer which
// accidentally by runMode: beforeDate: if a timer which
// has this date as fire date gets released.
limitDate = [[currentLoop limitDateForMode:mode] retain];
limitDate = [[currentLoop limitDateForMode: mode] retain];
originalLimitDate = limitDate;
if ((event = [self _eventMatchingMask:mask dequeue:flag]))
if ((event = [self _eventMatchingMask: mask dequeue: flag]))
{
[limitDate release];
break;
}
if (limitDate)
limitDate = [expiration earlierDate:limitDate];
limitDate = [expiration earlierDate: limitDate];
else
limitDate = expiration;
[currentLoop runMode:mode beforeDate:limitDate];
[currentLoop runMode: mode beforeDate: limitDate];
[originalLimitDate release];
if ((event = [self _eventMatchingMask:mask dequeue:flag]))
if ((event = [self _eventMatchingMask: mask dequeue: flag]))
break;
}
// no need to unhide cursor
@ -901,7 +894,7 @@ BOOL done = NO;
return event;
}
- (void)postEvent:(NSEvent *)event atStart:(BOOL)flag
- (void) postEvent: (NSEvent *)event atStart: (BOOL)flag
{
if (!flag)
[event_queue addObject: event];
@ -1184,7 +1177,7 @@ BOOL done = NO;
j = [window_list count];
for (i = 0; i < j; ++i)
{
w = [window_list objectAtIndex:i];
w = [window_list objectAtIndex: i];
if ([w isMainWindow])
return w;
}
@ -1227,13 +1220,13 @@ BOOL done = NO;
return nil;
}
- (void)miniaturizeAll:sender
- (void) miniaturizeAll: sender
{
NSArray *window_list = [self windows];
unsigned i, count;
for (i = 0, count = [window_list count]; i < count; i++)
[[window_list objectAtIndex:i] miniaturize:sender];
[[window_list objectAtIndex: i] miniaturize: sender];
}
- (void) preventWindowOrdering
@ -1254,7 +1247,7 @@ BOOL done = NO;
windows_need_update = NO;
// notify that an update is
// imminent
[nc postNotificationName:NSApplicationWillUpdateNotification object: self];
[nc postNotificationName: NSApplicationWillUpdateNotification object: self];
for (i = 0, count = [window_list count]; i < count; i++)
{
@ -1263,7 +1256,7 @@ BOOL done = NO;
[win update]; // window is visible
}
// notify update did occur
[nc postNotificationName:NSApplicationDidUpdateNotification object:self];
[nc postNotificationName: NSApplicationDidUpdateNotification object: self];
}
- (NSArray*) windows
@ -1272,7 +1265,7 @@ BOOL done = NO;
return nil;
}
- (NSWindow *)windowWithWindowNumber:(int)windowNum
- (NSWindow *) windowWithWindowNumber: (int)windowNum
{
NSArray *window_list = [self windows];
unsigned i, j;
@ -1292,19 +1285,19 @@ BOOL done = NO;
//
// Showing Standard Panels
//
- (void)orderFrontColorPanel:sender
- (void) orderFrontColorPanel: sender
{
}
- (void)orderFrontDataLinkPanel:sender
- (void) orderFrontDataLinkPanel: sender
{
}
- (void)orderFrontHelpPanel:sender
- (void) orderFrontHelpPanel: sender
{
}
- (void)runPageLayout:sender
- (void) runPageLayout: sender
{
}
@ -1332,7 +1325,7 @@ BOOL done = NO;
windows_menu = nil; // this is the default
for (i = 0; i < j; ++i) // windows menu
{
mc = [mi objectAtIndex:i];
mc = [mi objectAtIndex: i];
if ([[mc stringValue] compare: @"Windows"] == NSOrderedSame)
{
windows_menu = mc; // Found it!
@ -1413,8 +1406,8 @@ BOOL done = NO;
/*
* Now we insert a menu item for the window in the correct order.
* Make special allowance for menu entries to 'arrangeInFront:'
* 'performMiniaturize:' and 'preformClose:'. If these exist the
* Make special allowance for menu entries to 'arrangeInFront: '
* 'performMiniaturize: ' and 'preformClose: '. If these exist the
* window entries should stay after the first one and before the
* other two.
*/
@ -1516,7 +1509,7 @@ BOOL done = NO;
}
/*
* Now use [-changeWindowsItem:title:filename:] to build the new menu.
* Now use [-changeWindowsItem: title: filename: ] to build the new menu.
*/
[main_menu setSubmenu: aMenu forItem: (id<NSMenuItem>)windows_menu];
while ((win = [windows lastObject]) != nil)
@ -1641,7 +1634,7 @@ BOOL done = NO;
return nil;
}
- (NSGraphicsContext *)context // return the current draw
- (NSGraphicsContext *) context // return the current draw
{ // context (drawing dest)
return [NSGraphicsContext currentContext];
}
@ -1678,10 +1671,10 @@ BOOL done = NO;
delegate = anObject;
#define SET_DELEGATE_NOTIFICATION(notif_name) \
if ([delegate respondsToSelector:@selector(application##notif_name:)]) \
[nc addObserver:delegate \
selector:@selector(application##notif_name:) \
name:NSApplication##notif_name##Notification object:self]
if ([delegate respondsToSelector: @selector(application##notif_name:)]) \
[nc addObserver: delegate \
selector: @selector(application##notif_name:) \
name: NSApplication##notif_name##Notification object: self]
SET_DELEGATE_NOTIFICATION(DidBecomeActive);
SET_DELEGATE_NOTIFICATION(DidFinishLaunching);
@ -1700,126 +1693,126 @@ BOOL done = NO;
//
// Implemented by the delegate
//
- (BOOL)application:sender openFileWithoutUI:(NSString *)filename
- (BOOL) application: sender openFileWithoutUI: (NSString *)filename
{
BOOL result = NO;
BOOL result = NO;
if ([delegate respondsToSelector:@selector(application:openFileWithoutUI:)])
result = [delegate application:sender openFileWithoutUI:filename];
if ([delegate respondsToSelector: @selector(application:openFileWithoutUI:)])
result = [delegate application: sender openFileWithoutUI: filename];
return result;
}
- (BOOL)application:(NSApplication *)app openFile:(NSString *)filename
- (BOOL) application: (NSApplication *)app openFile: (NSString *)filename
{
BOOL result = NO;
BOOL result = NO;
if ([delegate respondsToSelector:@selector(application:openFile:)])
result = [delegate application:app openFile:filename];
if ([delegate respondsToSelector: @selector(application:openFile:)])
result = [delegate application: app openFile: filename];
return result;
}
- (BOOL)application:(NSApplication *)app openTempFile:(NSString *)filename
- (BOOL) application: (NSApplication *)app openTempFile: (NSString *)filename
{
BOOL result = NO;
BOOL result = NO;
if ([delegate respondsToSelector:@selector(application:openTempFile:)])
result = [delegate application:app openTempFile:filename];
if ([delegate respondsToSelector: @selector(application:openTempFile:)])
result = [delegate application: app openTempFile: filename];
return result;
}
- (void)applicationDidBecomeActive:(NSNotification *)aNotification
- (void) applicationDidBecomeActive: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationDidBecomeActive:)])
[delegate applicationDidBecomeActive:aNotification];
if ([delegate respondsToSelector: @selector(applicationDidBecomeActive:)])
[delegate applicationDidBecomeActive: aNotification];
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
- (void) applicationDidFinishLaunching: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationDidFinishLaunching:)])
[delegate applicationDidFinishLaunching:aNotification];
if ([delegate respondsToSelector: @selector(applicationDidFinishLaunching:)])
[delegate applicationDidFinishLaunching: aNotification];
}
- (void)applicationDidHide:(NSNotification *)aNotification
- (void) applicationDidHide: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationDidHide:)])
[delegate applicationDidHide:aNotification];
if ([delegate respondsToSelector: @selector(applicationDidHide:)])
[delegate applicationDidHide: aNotification];
}
- (void)applicationDidResignActive:(NSNotification *)aNotification
- (void) applicationDidResignActive: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationDidResignActive:)])
[delegate applicationDidResignActive:aNotification];
if ([delegate respondsToSelector: @selector(applicationDidResignActive:)])
[delegate applicationDidResignActive: aNotification];
}
- (void)applicationDidUnhide:(NSNotification *)aNotification
- (void) applicationDidUnhide: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationDidUnhide:)])
[delegate applicationDidUnhide:aNotification];
if ([delegate respondsToSelector: @selector(applicationDidUnhide:)])
[delegate applicationDidUnhide: aNotification];
}
- (void)applicationDidUpdate:(NSNotification *)aNotification
- (void) applicationDidUpdate: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationDidUpdate:)])
[delegate applicationDidUpdate:aNotification];
if ([delegate respondsToSelector: @selector(applicationDidUpdate:)])
[delegate applicationDidUpdate: aNotification];
}
- (BOOL)applicationOpenUntitledFile:(NSApplication *)app
- (BOOL) applicationOpenUntitledFile: (NSApplication *)app
{
BOOL result = NO;
BOOL result = NO;
if ([delegate respondsToSelector:@selector(applicationOpenUntitledFile:)])
result = [delegate applicationOpenUntitledFile:app];
if ([delegate respondsToSelector: @selector(applicationOpenUntitledFile:)])
result = [delegate applicationOpenUntitledFile: app];
return result;
}
- (BOOL)applicationShouldTerminate:sender
- (BOOL) applicationShouldTerminate: sender
{
BOOL result = YES;
BOOL result = YES;
if ([delegate respondsToSelector:@selector(applicationShouldTerminate:)])
result = [delegate applicationShouldTerminate:sender];
if ([delegate respondsToSelector: @selector(applicationShouldTerminate:)])
result = [delegate applicationShouldTerminate: sender];
return result;
}
- (void)applicationWillBecomeActive:(NSNotification *)aNotification
- (void) applicationWillBecomeActive: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationWillBecomeActive:)])
[delegate applicationWillBecomeActive:aNotification];
if ([delegate respondsToSelector: @selector(applicationWillBecomeActive:)])
[delegate applicationWillBecomeActive: aNotification];
}
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
- (void) applicationWillFinishLaunching: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationWillFinishLaunching:)])
[delegate applicationWillFinishLaunching:aNotification];
if ([delegate respondsToSelector: @selector(applicationWillFinishLaunching:)])
[delegate applicationWillFinishLaunching: aNotification];
}
- (void)applicationWillHide:(NSNotification *)aNotification
- (void) applicationWillHide: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationWillHide:)])
[delegate applicationWillHide:aNotification];
if ([delegate respondsToSelector: @selector(applicationWillHide:)])
[delegate applicationWillHide: aNotification];
}
- (void)applicationWillResignActive:(NSNotification *)aNotification
- (void) applicationWillResignActive: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationWillResignActive:)])
[delegate applicationWillResignActive:aNotification];
if ([delegate respondsToSelector: @selector(applicationWillResignActive:)])
[delegate applicationWillResignActive: aNotification];
}
- (void)applicationWillUnhide:(NSNotification *)aNotification
- (void) applicationWillUnhide: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationWillUnhide:)])
[delegate applicationWillUnhide:aNotification];
if ([delegate respondsToSelector: @selector(applicationWillUnhide:)])
[delegate applicationWillUnhide: aNotification];
}
- (void)applicationWillUpdate:(NSNotification *)aNotification
- (void) applicationWillUpdate: (NSNotification *)aNotification
{
if ([delegate respondsToSelector:@selector(applicationWillUpdate:)])
[delegate applicationWillUpdate:aNotification];
if ([delegate respondsToSelector: @selector(applicationWillUpdate:)])
[delegate applicationWillUpdate: aNotification];
}
//
@ -1849,21 +1842,21 @@ BOOL result = YES;
return self;
}
+ (void)setNullEvent:(NSEvent *)e
+ (void) setNullEvent: (NSEvent *)e
{
ASSIGN(null_event, e);
}
+ (NSEvent *)getNullEvent;
+ (NSEvent *) getNullEvent;
{ // return the class
return null_event; // dummy event
}
- (void)_nextEvent // get next event
- (void) _nextEvent // get next event
{ // implemented in
} // backend
- (void)setupRunLoopInputSourcesForMode:(NSString*)mode
- (void) setupRunLoopInputSourcesForMode: (NSString*)mode
{ // implemented in
} // backend