diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index dea6e81b05..2009c49099 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -222,6 +222,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef, #ifdef INCLUDE_OLD_IM_CODE [NSNumber numberWithBool:YES], MMUseInlineImKey, #endif // INCLUDE_OLD_IM_CODE + [NSNumber numberWithBool:NO], MMSuppressTerminationAlertKey, nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dict]; @@ -509,7 +510,8 @@ fsEventCallback(ConstFSEventStreamRef streamRef, reply = NSTerminateCancel; [alert release]; - } else { + } else if (![[NSUserDefaults standardUserDefaults] + boolForKey:MMSuppressTerminationAlertKey]) { // No unmodified buffers, but give a warning if there are multiple // windows and/or tabs open. int numWindows = [vimControllers count]; @@ -530,6 +532,9 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [alert setMessageText:NSLocalizedString( @"Are you sure you want to quit MacVim?", @"Quit dialog with no changed buffers, title")]; +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) + [alert setShowsSuppressionButton:YES]; +#endif NSString *info = nil; if (numWindows > 1) { @@ -559,6 +564,13 @@ fsEventCallback(ConstFSEventStreamRef streamRef, if ([alert runModal] != NSAlertFirstButtonReturn) reply = NSTerminateCancel; +#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5) + if ([[alert suppressionButton] state] == NSOnState) { + [[NSUserDefaults standardUserDefaults] + setBool:YES forKey:MMSuppressTerminationAlertKey]; + } +#endif + [alert release]; } } diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index 55d1fd6fdf..d1d82075d2 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -52,6 +52,7 @@ extern NSString *MMLastWindowClosedBehaviorKey; #ifdef INCLUDE_OLD_IM_CODE extern NSString *MMUseInlineImKey; #endif // INCLUDE_OLD_IM_CODE +extern NSString *MMSuppressTerminationAlertKey; // Enum for MMUntitledWindowKey diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index 781f84c760..e1222751c6 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -44,6 +44,7 @@ NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior"; #ifdef INCLUDE_OLD_IM_CODE NSString *MMUseInlineImKey = @"MMUseInlineIm"; #endif // INCLUDE_OLD_IM_CODE +NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert";