Close virgin windows on open

This commit is contained in:
Matthias Neeracher 2007-01-21 11:34:40 +00:00
parent c0dc4686bb
commit 1f60eb1a44
2 changed files with 21 additions and 0 deletions

View File

@ -27,6 +27,7 @@
NSString * tmpPath;
NSFileWrapper * vcsWrapper;
int repeatVolta;
bool brandNew;
VLSheetWindow * sheetWin;
VLLogWindow * logWin;
@ -39,6 +40,7 @@
- (NSNumber *) songTime;
- (NSNumber *) songDivisions;
- (int) repeatVolta;
- (bool) brandNew;
- (void) setKey:(int)key transpose:(BOOL)transpose;
- (void) setTimeNum:(int)num denom:(int)denom;

View File

@ -73,6 +73,7 @@
tmpPath = nil;
vcsWrapper = nil;
repeatVolta = 2;
brandNew = true;
[self setHasUndoManager:YES];
undo =
[[VLKeyValueUndo alloc] initWithOwner:self
@ -114,6 +115,8 @@
logWin = nil;
else if (win == pdfWin)
pdfWin = nil;
else if (win == sheetWin)
sheetWin = nil;
[super removeWindowController:win];
}
@ -223,6 +226,11 @@
return repeatVolta;
}
- (bool) brandNew
{
return brandNew && ![self isDocumentEdited];
}
- (void) setRepeatVolta:(int)volta
{
repeatVolta = volta;
@ -305,6 +313,17 @@
- (BOOL)readFromFileWrapper:(NSFileWrapper *)wrapper ofType:(NSString *)typeName error:(NSError **)outError
{
brandNew = false;
//
// On opening a document, close all unchanged empty documents
//
NSEnumerator * docs = [[[NSDocumentController sharedDocumentController]
documents] objectEnumerator];
while (VLDocument * doc = [docs nextObject])
if ([doc brandNew])
[[doc windowControllers]
makeObjectsPerformSelector:@selector(close)];
if ([typeName isEqual:@"VLNativeType"]) {
return [self readFromXMLFileWrapper:wrapper error:outError];
} else {