mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-29 21:27:40 +00:00
Fix application termination behavior by sending a message to the
document controller to let the user review any unsaved changes in its managed documents before asking the application delegate whether its okay to terminate the application. This matches Cocoa's documented and implemented behavior. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@31957 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
18806fd515
commit
3da944c1dd
2 changed files with 30 additions and 20 deletions
|
@ -3432,8 +3432,22 @@ struct _DelegateWrapper
|
|||
*/
|
||||
- (void) terminate: (id)sender
|
||||
{
|
||||
NSApplicationTerminateReply termination = NSTerminateNow;
|
||||
NSDocumentController *sdc;
|
||||
NSApplicationTerminateReply termination;
|
||||
|
||||
/* First ask the shared document controller to save any unsaved changes */
|
||||
sdc = [NSDocumentController sharedDocumentController];
|
||||
if ([[sdc documentClassNames] count] > 0)
|
||||
{
|
||||
if ([sdc reviewUnsavedDocumentsWithAlertTitle: _(@"Quit")
|
||||
cancellable: YES] == NO)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Now ask the application delegate whether its okay to terminate */
|
||||
termination = NSTerminateNow;
|
||||
if ([_delegate respondsToSelector: @selector(applicationShouldTerminate:)])
|
||||
{
|
||||
/* The old API has applicationShouldTerminate: return a BOOL,
|
||||
|
@ -3447,28 +3461,9 @@ struct _DelegateWrapper
|
|||
*/
|
||||
termination = ([_delegate applicationShouldTerminate: self] & 0xff);
|
||||
}
|
||||
else
|
||||
{
|
||||
NSDocumentController *sdc;
|
||||
|
||||
sdc = [NSDocumentController sharedDocumentController];
|
||||
if ([[sdc documentClassNames] count] > 0)
|
||||
{
|
||||
if ([sdc reviewUnsavedDocumentsWithAlertTitle: _(@"Quit")
|
||||
cancellable: YES] == YES)
|
||||
{
|
||||
termination = NSTerminateNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
termination = NSTerminateCancel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (termination == NSTerminateNow)
|
||||
{
|
||||
GSRemoveIcon(_app_icon_window);
|
||||
[self replyToApplicationShouldTerminate: YES];
|
||||
}
|
||||
/*
|
||||
|
@ -3492,6 +3487,7 @@ struct _DelegateWrapper
|
|||
|
||||
_app_is_running = NO;
|
||||
|
||||
GSRemoveIcon(_app_icon_window);
|
||||
[[self windows] makeObjectsPerformSelector: @selector(close)];
|
||||
[NSCursor setHiddenUntilMouseMoves: NO];
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue