mirror of
https://github.com/gnustep/apps-gorm.git
synced 2025-02-24 12:01:16 +00:00
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:
parent
14666a0bed
commit
15d8b973ba
5 changed files with 93 additions and 103 deletions
|
@ -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>
|
Sat Jan 15 04:35:59 2000 Nicola Pero <n.pero@mi.flashnet.it>
|
||||||
|
|
||||||
* GormObjectEditor.m ([GormObjectEditor -activate]),
|
* GormObjectEditor.m ([GormObjectEditor -activate]),
|
||||||
|
|
77
Gorm.m
77
Gorm.m
|
@ -153,7 +153,6 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
RELEASE(infoPanel);
|
RELEASE(infoPanel);
|
||||||
RELEASE(inspectorsManager);
|
RELEASE(inspectorsManager);
|
||||||
RELEASE(palettesManager);
|
RELEASE(palettesManager);
|
||||||
RELEASE(hiddenDuringTest);
|
|
||||||
RELEASE(documents);
|
RELEASE(documents);
|
||||||
RELEASE(classManager);
|
RELEASE(classManager);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
@ -267,8 +266,8 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
|
NSUserDefaults *defs;
|
||||||
NSEnumerator *e;
|
NSEnumerator *e;
|
||||||
NSWindow *w;
|
|
||||||
id val;
|
id val;
|
||||||
|
|
||||||
[nc postNotificationName: IBWillEndTestingInterfaceNotification
|
[nc postNotificationName: IBWillEndTestingInterfaceNotification
|
||||||
|
@ -288,15 +287,14 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
}
|
}
|
||||||
DESTROY(testContainer);
|
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;
|
isTesting = NO;
|
||||||
|
|
||||||
|
@ -313,7 +311,6 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
- (void) finishLaunching
|
- (void) finishLaunching
|
||||||
{
|
{
|
||||||
NSMenu *aMenu;
|
NSMenu *aMenu;
|
||||||
NSMenu *mainMenu;
|
|
||||||
NSMenu *modulesMenu;
|
NSMenu *modulesMenu;
|
||||||
NSMenu *windowsMenu;
|
NSMenu *windowsMenu;
|
||||||
NSMenuItem *menuItem;
|
NSMenuItem *menuItem;
|
||||||
|
@ -556,7 +553,6 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
targetImage = [[NSImage alloc] initWithContentsOfFile: path];
|
targetImage = [[NSImage alloc] initWithContentsOfFile: path];
|
||||||
|
|
||||||
documents = [NSMutableArray new];
|
documents = [NSMutableArray new];
|
||||||
hiddenDuringTest = [NSMutableArray new];
|
|
||||||
[nc addObserver: self
|
[nc addObserver: self
|
||||||
selector: @selector(handleNotification:)
|
selector: @selector(handleNotification:)
|
||||||
name: IBSelectionChangedNotification
|
name: IBSelectionChangedNotification
|
||||||
|
@ -824,37 +820,29 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
NSUserDefaults *defs;
|
||||||
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
|
||||||
GormDocument *a = (GormDocument*)[self activeDocument];
|
GormDocument *a = (GormDocument*)[self activeDocument];
|
||||||
NSEnumerator *e;
|
|
||||||
NSWindow *w;
|
|
||||||
NSData *d;
|
NSData *d;
|
||||||
|
|
||||||
|
[a beginArchiving];
|
||||||
|
d = [NSArchiver archivedDataWithRootObject: a];
|
||||||
|
[a endArchiving];
|
||||||
|
|
||||||
[nc postNotificationName: IBWillBeginTestingInterfaceNotification
|
[nc postNotificationName: IBWillBeginTestingInterfaceNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
|
||||||
isTesting = YES;
|
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)
|
if ([selectionOwner conformsToProtocol: @protocol(IBEditors)] == YES)
|
||||||
{
|
{
|
||||||
[(id<IBEditors>)selectionOwner makeSelectionVisible: NO];
|
[(id<IBEditors>)selectionOwner makeSelectionVisible: NO];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
defs = [NSUserDefaults standardUserDefaults];
|
||||||
|
menuLocations = [[defs objectForKey: @"NSMenuLocations"] copy];
|
||||||
|
[defs removeObjectForKey: @"NSMenuLocations"];
|
||||||
|
|
||||||
testContainer = [NSUnarchiver unarchiveObjectWithData: d];
|
testContainer = [NSUnarchiver unarchiveObjectWithData: d];
|
||||||
if (testContainer != nil)
|
if (testContainer != nil)
|
||||||
{
|
{
|
||||||
|
@ -862,6 +850,39 @@ NSString *GormLinkPboardType = @"GormLinkPboardType";
|
||||||
RETAIN(testContainer);
|
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
|
[nc postNotificationName: IBDidBeginTestingInterfaceNotification
|
||||||
object: self];
|
object: self];
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,12 @@
|
||||||
NSMatrix *selectionView;
|
NSMatrix *selectionView;
|
||||||
NSScrollView *scrollView;
|
NSScrollView *scrollView;
|
||||||
id objectsView;
|
id objectsView;
|
||||||
BOOL hiddenDuringTest;
|
|
||||||
BOOL hasSetDefaults;
|
BOOL hasSetDefaults;
|
||||||
BOOL isActive;
|
BOOL isActive;
|
||||||
NSMenu *savedMenu;
|
NSMenu *savedMenu;
|
||||||
NSMenuItem *quitItem; /* Replaced during test */
|
NSMenuItem *quitItem; /* Replaced during test */
|
||||||
NSMutableArray *savedEditors;
|
NSMutableArray *savedEditors;
|
||||||
|
NSMutableArray *hidden;
|
||||||
}
|
}
|
||||||
- (void) addConnector: (id<IBConnectors>)aConnector;
|
- (void) addConnector: (id<IBConnectors>)aConnector;
|
||||||
- (NSArray*) allConnectors;
|
- (NSArray*) allConnectors;
|
||||||
|
|
|
@ -378,6 +378,7 @@ static NSImage *classesImage = nil;
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
[[NSNotificationCenter defaultCenter] removeObserver: self];
|
||||||
[window setDelegate: nil];
|
[window setDelegate: nil];
|
||||||
[window performClose: self];
|
[window performClose: self];
|
||||||
|
RELEASE(hidden);
|
||||||
RELEASE(window);
|
RELEASE(window);
|
||||||
RELEASE(filesOwner);
|
RELEASE(filesOwner);
|
||||||
RELEASE(firstResponder);
|
RELEASE(firstResponder);
|
||||||
|
@ -637,96 +638,57 @@ static NSImage *classesImage = nil;
|
||||||
{
|
{
|
||||||
if ([window isVisible] == YES)
|
if ([window isVisible] == YES)
|
||||||
{
|
{
|
||||||
hiddenDuringTest = YES;
|
[hidden addObject: window];
|
||||||
[window setExcludedFromWindowsMenu: YES];
|
[window setExcludedFromWindowsMenu: YES];
|
||||||
[window orderOut: self];
|
[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)
|
if ([(id<IB>)NSApp activeDocument] == self)
|
||||||
{
|
{
|
||||||
NSWindow *keyWindow = nil;
|
NSEnumerator *enumerator;
|
||||||
NSMenu *testMenu = nil;
|
id obj;
|
||||||
NSMenuItem *item;
|
|
||||||
NSArray *links;
|
|
||||||
NSEnumerator *e;
|
|
||||||
NSNibConnector *con;
|
|
||||||
|
|
||||||
[connections makeObjectsPerform: @selector(establishConnection)];
|
enumerator = [nameTable objectEnumerator];
|
||||||
/*
|
while ((obj = [enumerator nextObject]) != nil)
|
||||||
* Get links for all the top-level objects
|
|
||||||
*/
|
|
||||||
links = [self connectorsForDestination: filesOwner
|
|
||||||
ofClass: [NSNibConnector class]];
|
|
||||||
e = [links objectEnumerator];
|
|
||||||
while ((con = [e nextObject]) != nil)
|
|
||||||
{
|
{
|
||||||
id obj = [con source];
|
|
||||||
|
|
||||||
if ([obj isKindOfClass: [NSMenu class]] == YES)
|
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)
|
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)
|
else if ([name isEqual: IBWillEndTestingInterfaceNotification] == YES)
|
||||||
{
|
{
|
||||||
if (hiddenDuringTest == YES)
|
if ([hidden count] > 0)
|
||||||
{
|
{
|
||||||
hiddenDuringTest = NO;
|
NSEnumerator *enumerator;
|
||||||
/*
|
id obj;
|
||||||
* 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"];
|
|
||||||
|
|
||||||
[testMenu removeItem: item];
|
enumerator = [hidden objectEnumerator];
|
||||||
if (quitItem != nil)
|
while ((obj = [enumerator nextObject]) != nil)
|
||||||
{
|
{
|
||||||
[testMenu addItem: quitItem];
|
if ([obj isKindOfClass: [NSMenu class]] == YES)
|
||||||
DESTROY(quitItem);
|
{
|
||||||
|
[obj display];
|
||||||
}
|
}
|
||||||
/*
|
else if ([obj isKindOfClass: [NSWindow class]] == YES)
|
||||||
* restore the main menu.
|
{
|
||||||
*/
|
[obj orderFront: self];
|
||||||
[NSApp setMainMenu: savedMenu];
|
|
||||||
DESTROY(savedMenu);
|
|
||||||
}
|
}
|
||||||
[window orderFront: self];
|
}
|
||||||
|
[hidden removeAllObjects];
|
||||||
[window setExcludedFromWindowsMenu: NO];
|
[window setExcludedFromWindowsMenu: NO];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -861,6 +823,7 @@ static NSImage *classesImage = nil;
|
||||||
fontManager = [GormFontManager new];
|
fontManager = [GormFontManager new];
|
||||||
[self setName: @"NSFont" forObject: fontManager];
|
[self setName: @"NSFont" forObject: fontManager];
|
||||||
|
|
||||||
|
hidden = [NSMutableArray new];
|
||||||
/*
|
/*
|
||||||
* Watch to see when we are starting/ending testing.
|
* Watch to see when we are starting/ending testing.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -31,8 +31,9 @@ extern NSString *GormLinkPboardType;
|
||||||
NSMutableArray *documents;
|
NSMutableArray *documents;
|
||||||
BOOL isConnecting;
|
BOOL isConnecting;
|
||||||
BOOL isTesting;
|
BOOL isTesting;
|
||||||
NSMutableArray *hiddenDuringTest;
|
|
||||||
id testContainer;
|
id testContainer;
|
||||||
|
NSMenu *mainMenu;
|
||||||
|
NSDictionary *menuLocations;
|
||||||
NSImage *linkImage;
|
NSImage *linkImage;
|
||||||
NSImage *sourceImage;
|
NSImage *sourceImage;
|
||||||
NSImage *targetImage;
|
NSImage *targetImage;
|
||||||
|
|
Loading…
Reference in a new issue