Add suppression tick box to termination alert

This will disable the warning about multiple window and tabs.  Tiger
users can access this functionality by setting the user default
MMSuppressTerminationAlert to 1.
This commit is contained in:
Bjorn Winckler
2011-01-09 16:10:16 +01:00
parent 7ec523f4a8
commit 75ca477625
3 changed files with 15 additions and 1 deletions
+13 -1
View File
@@ -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];
}
}
+1
View File
@@ -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
+1
View File
@@ -44,6 +44,7 @@ NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior";
#ifdef INCLUDE_OLD_IM_CODE
NSString *MMUseInlineImKey = @"MMUseInlineIm";
#endif // INCLUDE_OLD_IM_CODE
NSString *MMSuppressTerminationAlertKey = @"MMSuppressTerminationAlert";