A few testing fixes.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/apps/gorm/trunk@5917 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 2000-02-03 17:04:37 +00:00
parent 14666a0bed
commit 15d8b973ba
5 changed files with 93 additions and 103 deletions

View file

@ -1,3 +1,8 @@
Thu Feb 3 16:16:59 2000 Richard Frith-Macdonald <richard@brainstorm.co.uk>
* Gorm.m: tidied start/end testing.
* GormDocument.m: ditto
Sat Jan 15 04:35:59 2000 Nicola Pero <n.pero@mi.flashnet.it>
* GormObjectEditor.m ([GormObjectEditor -activate]),

77
Gorm.m
View file

@ -153,7 +153,6 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
RELEASE(infoPanel);
RELEASE(inspectorsManager);
RELEASE(palettesManager);
RELEASE(hiddenDuringTest);
RELEASE(documents);
RELEASE(classManager);
[super dealloc];
@ -267,8 +266,8 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
else
{
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
NSUserDefaults *defs;
NSEnumerator *e;
NSWindow *w;
id val;
[nc postNotificationName: IBWillEndTestingInterfaceNotification
@ -288,15 +287,14 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
}
DESTROY(testContainer);
/*
* Restore old windows.
*/
e = [hiddenDuringTest objectEnumerator];
while ((w = [e nextObject]) != nil)
{
[w orderFront: self];
NSAutoreleasePool *p = [NSAutoreleasePool new];
defs = [NSUserDefaults standardUserDefaults];
[defs setObject: menuLocations forKey: @"NSMenuLocations"];
DESTROY(menuLocations);
[p release];
}
[hiddenDuringTest removeAllObjects];
[self setMainMenu: mainMenu];
isTesting = NO;
@ -313,7 +311,6 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
- (void) finishLaunching
{
NSMenu *aMenu;
NSMenu *mainMenu;
NSMenu *modulesMenu;
NSMenu *windowsMenu;
NSMenuItem *menuItem;
@ -556,7 +553,6 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
targetImage = [[NSImage alloc] initWithContentsOfFile: path];
documents = [NSMutableArray new];
hiddenDuringTest = [NSMutableArray new];
[nc addObserver: self
selector: @selector(handleNotification:)
name: IBSelectionChangedNotification
@ -824,37 +820,29 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
}
else
{
NSUserDefaults *defs;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
GormDocument *a = (GormDocument*)[self activeDocument];
NSEnumerator *e;
NSWindow *w;
NSData *d;
[a beginArchiving];
d = [NSArchiver archivedDataWithRootObject: a];
[a endArchiving];
[nc postNotificationName: IBWillBeginTestingInterfaceNotification
object: self];
isTesting = YES;
[a beginArchiving];
d = [NSArchiver archivedDataWithRootObject: a];
[a endArchiving];
e = [[self windows] objectEnumerator];
while ((w = [e nextObject]) != nil)
{
if ([w isVisible] == YES
&& [w isKindOfClass: [NSMenuWindow class]] == NO)
{
[hiddenDuringTest addObject: w];
[w orderOut: self];
}
}
if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES)
{
[(id<IBEditors>)selectionOwner makeSelectionVisible: NO];
}
defs = [NSUserDefaults standardUserDefaults];
menuLocations = [[defs objectForKey: @"NSMenuLocations"] copy];
[defs removeObjectForKey: @"NSMenuLocations"];
testContainer = [NSUnarchiver unarchiveObjectWithData: d];
if (testContainer != nil)
{
@ -862,6 +850,39 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
RETAIN(testContainer);
}
/*
* If the NIB didn't have a main menu, create one,
* otherwise, ensure that 'quit' ends testing mode.
*/
if ([self mainMenu] == mainMenu)
{
NSMenu *testMenu;
testMenu = [[NSMenu alloc] initWithTitle: @"Test"];
[testMenu addItemWithTitle: @"Quit"
action: @selector(endTesting:)
keyEquivalent: @"q"];
[self setMainMenu: testMenu];
RELEASE(testMenu);
}
else
{
NSMenu *testMenu = [self mainMenu];
NSMenuItem *item;
item = [testMenu itemWithTitle: @"Quit"];
if (item != nil)
{
[item setAction: @selector(endTesting:)];
}
else
{
[testMenu addItemWithTitle: @"Quit"
action: @selector(endTesting:)
keyEquivalent: @"q"];
}
}
[nc postNotificationName: IBDidBeginTestingInterfaceNotification
object: self];

View file

@ -30,12 +30,12 @@
NSMatrix *selectionView;
NSScrollView *scrollView;
id objectsView;
BOOL hiddenDuringTest;
BOOL hasSetDefaults;
BOOL isActive;
NSMenu *savedMenu;
NSMenuItem *quitItem; /* Replaced during test */
NSMutableArray *savedEditors;
NSMutableArray *hidden;
}
- (void) addConnector: (id<IBConnectors>)aConnector;
- (NSArray*) allConnectors;

View file

@ -378,6 +378,7 @@ static NSImage *classesImage = nil;
[[NSNotificationCenter defaultCenter] removeObserver: self];
[window setDelegate: nil];
[window performClose: self];
RELEASE(hidden);
RELEASE(window);
RELEASE(filesOwner);
RELEASE(firstResponder);
@ -637,96 +638,57 @@ static NSImage *classesImage = nil;
{
if ([window isVisible] == YES)
{
hiddenDuringTest = YES;
[hidden addObject: window];
[window setExcludedFromWindowsMenu: YES];
[window orderOut: self];
/*
* If this is the active document, we must replace the main menu with
* our own version using a modified 'Quit' item (to end testing).
* and we should try to make one of our windows key.
*/
}
if ([(id<IB>)NSApp activeDocument] == self)
{
NSWindow *keyWindow = nil;
NSMenu *testMenu = nil;
NSMenuItem *item;
NSArray *links;
NSEnumerator *e;
NSNibConnector *con;
NSEnumerator *enumerator;
id obj;
[connections makeObjectsPerform: @selector(establishConnection)];
/*
* Get links for all the top-level objects
*/
links = [self connectorsForDestination: filesOwner
ofClass: [NSNibConnector class]];
e = [links objectEnumerator];
while ((con = [e nextObject]) != nil)
enumerator = [nameTable objectEnumerator];
while ((obj = [enumerator nextObject]) != nil)
{
id obj = [con source];
if ([obj isKindOfClass: [NSMenu class]] == YES)
{
testMenu = obj;
if ([[obj window] isVisible] == YES)
{
[hidden addObject: obj];
[obj close];
}
}
else if ([obj isKindOfClass: [NSWindow class]] == YES)
{
if (keyWindow == nil || [keyWindow isVisible] == NO)
if ([obj isVisible] == YES)
{
keyWindow = obj;
[hidden addObject: obj];
[obj orderOut: self];
}
}
}
if (testMenu == nil)
{
testMenu = [[NSMenu alloc] initWithTitle: @"Test"];
AUTORELEASE(testMenu);
}
item = [testMenu itemWithTitle: @"Quit"];
if (item != nil)
{
quitItem = RETAIN(item);
[testMenu removeItem: item];
}
[testMenu addItemWithTitle: @"Quit"
action: @selector(endTesting:)
keyEquivalent: @"q"];
savedMenu = RETAIN([NSApp mainMenu]);
[NSApp setMainMenu: testMenu];
[keyWindow makeKeyAndOrderFront: self];
RELEASE(testMenu);
}
}
}
else if ([name isEqual: IBWillEndTestingInterfaceNotification] == YES)
{
if (hiddenDuringTest == YES)
if ([hidden count] > 0)
{
hiddenDuringTest = NO;
/*
* If this is the active document, we must restore the main menu
* and restore the 'Quit' menu item (which was used to end testing)
* to its original value.
*/
if ([(id<IB>)NSApp activeDocument] == self)
{
NSMenu *testMenu = [NSApp mainMenu];
NSMenuItem *item = [testMenu itemWithTitle: @"Quit"];
NSEnumerator *enumerator;
id obj;
[testMenu removeItem: item];
if (quitItem != nil)
enumerator = [hidden objectEnumerator];
while ((obj = [enumerator nextObject]) != nil)
{
[testMenu addItem: quitItem];
DESTROY(quitItem);
if ([obj isKindOfClass: [NSMenu class]] == YES)
{
[obj display];
}
/*
* restore the main menu.
*/
[NSApp setMainMenu: savedMenu];
DESTROY(savedMenu);
else if ([obj isKindOfClass: [NSWindow class]] == YES)
{
[obj orderFront: self];
}
[window orderFront: self];
}
[hidden removeAllObjects];
[window setExcludedFromWindowsMenu: NO];
}
}
@ -861,6 +823,7 @@ static NSImage *classesImage = nil;
fontManager = [GormFontManager new];
[self setName: @"NSFont" forObject: fontManager];
hidden = [NSMutableArray new];
/*
* Watch to see when we are starting/ending testing.
*/

View file

@ -31,8 +31,9 @@ extern NSString *GormLinkPboardType;
NSMutableArray *documents;
BOOL isConnecting;
BOOL isTesting;
NSMutableArray *hiddenDuringTest;
id testContainer;
NSMenu *mainMenu;
NSDictionary *menuLocations;
NSImage *linkImage;
NSImage *sourceImage;
NSImage *targetImage;