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

View File

@ -73,6 +73,7 @@
tmpPath = nil; tmpPath = nil;
vcsWrapper = nil; vcsWrapper = nil;
repeatVolta = 2; repeatVolta = 2;
brandNew = true;
[self setHasUndoManager:YES]; [self setHasUndoManager:YES];
undo = undo =
[[VLKeyValueUndo alloc] initWithOwner:self [[VLKeyValueUndo alloc] initWithOwner:self
@ -114,6 +115,8 @@
logWin = nil; logWin = nil;
else if (win == pdfWin) else if (win == pdfWin)
pdfWin = nil; pdfWin = nil;
else if (win == sheetWin)
sheetWin = nil;
[super removeWindowController:win]; [super removeWindowController:win];
} }
@ -223,6 +226,11 @@
return repeatVolta; return repeatVolta;
} }
- (bool) brandNew
{
return brandNew && ![self isDocumentEdited];
}
- (void) setRepeatVolta:(int)volta - (void) setRepeatVolta:(int)volta
{ {
repeatVolta = volta; repeatVolta = volta;
@ -305,6 +313,17 @@
- (BOOL)readFromFileWrapper:(NSFileWrapper *)wrapper ofType:(NSString *)typeName error:(NSError **)outError - (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"]) { if ([typeName isEqual:@"VLNativeType"]) {
return [self readFromXMLFileWrapper:wrapper error:outError]; return [self readFromXMLFileWrapper:wrapper error:outError];
} else { } else {