Move alert panel for archive upgrade to delegate

This commit is contained in:
Gregory John Casamento 2023-07-18 13:44:44 -04:00
parent f78f1e5425
commit c39c54d62d
4 changed files with 28 additions and 11 deletions

View file

@ -150,6 +150,19 @@
}
// Gorm specific methods...
- (BOOL) shouldUpgradeOlderArchive
{
NSInteger retval = NSRunAlertPanel(_(@"Compatibility Warning"),
_(@"Saving will update this gorm to the latest version \n"
@"which may not be compatible with some previous versions \n"
@"of GNUstep."),
_(@"Save"),
_(@"Don't Save"), nil, nil);
return (retval == NSAlertDefaultReturn);
}
- (BOOL) isInTool
{
return NO;

View file

@ -3344,27 +3344,24 @@ static void _real_close(GormDocument *self,
id<GormWrapperBuilder> builder = [[GormWrapperBuilderFactory sharedWrapperBuilderFactory]
wrapperBuilderForType: type];
NSFileWrapper *result = nil;
id delegate = [NSApp delegate];
/*
* Warn the user, if we are about to upgrade the package.
*/
if(isOlderArchive && [filePrefsManager isLatest])
{
NSInteger retval = NSRunAlertPanel(_(@"Compatibility Warning"),
_(@"Saving will update this gorm to the latest version \n"
@"which may not be compatible with some previous versions \n"
@"of GNUstep."),
_(@"Save"),
_(@"Don't Save"), nil, nil);
if (retval != NSAlertDefaultReturn)
{
return nil;
}
else
BOOL result = [delegate shouldUpgradeOlderArchive];
if (result == YES)
{
// we're saving anyway... set to new value.
isOlderArchive = NO;
}
else
{
return nil;
}
}
/*

View file

@ -54,6 +54,7 @@
// Check if we are in the app or the tool
- (BOOL) isInTool;
- (BOOL) shouldUpgradeOlderArchive;
@end

View file

@ -35,6 +35,12 @@
return YES;
}
- (BOOL) shouldUpgradeOlderArchive
{
NSLog(@"Upgrading archive to latest version of .gorm format");
return YES;
}
- (NSDictionary *) parseArguments
{
GormDocumentController *dc = [GormDocumentController sharedDocumentController];