diff --git a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib index 2729ceab3b..d6c412543a 100644 Binary files a/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib and b/src/MacVim/English.lproj/Preferences.nib/keyedobjects.nib differ diff --git a/src/MacVim/MMAppController.m b/src/MacVim/MMAppController.m index b0fb405d91..a481811768 100644 --- a/src/MacVim/MMAppController.m +++ b/src/MacVim/MMAppController.m @@ -161,7 +161,6 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [NSNumber numberWithInt:1], MMTextInsetRightKey, [NSNumber numberWithInt:1], MMTextInsetTopKey, [NSNumber numberWithInt:1], MMTextInsetBottomKey, - [NSNumber numberWithBool:NO], MMTerminateAfterLastWindowClosedKey, @"MMTypesetter", MMTypesetterKey, [NSNumber numberWithFloat:1], MMCellWidthMultiplierKey, [NSNumber numberWithFloat:-1], MMBaselineOffsetKey, @@ -183,6 +182,7 @@ fsEventCallback(ConstFSEventStreamRef streamRef, [NSNumber numberWithInt:3], MMOpenLayoutKey, [NSNumber numberWithBool:NO], MMVerticalSplitKey, [NSNumber numberWithInt:0], MMPreloadCacheSizeKey, + [NSNumber numberWithInt:0], MMLastWindowClosedBehaviorKey, nil]; [[NSUserDefaults standardUserDefaults] registerDefaults:dict]; @@ -537,8 +537,9 @@ fsEventCallback(ConstFSEventStreamRef streamRef, - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender { - return [[NSUserDefaults standardUserDefaults] - boolForKey:MMTerminateAfterLastWindowClosedKey]; + return (MMTerminateWhenLastWindowClosed == + [[NSUserDefaults standardUserDefaults] + integerForKey:MMLastWindowClosedBehaviorKey]); } - (NSApplicationTerminateReply)applicationShouldTerminate: @@ -731,6 +732,12 @@ fsEventCallback(ConstFSEventStreamRef streamRef, // The last editor window just closed so restore the main menu back to // its default state (which is defined in MainMenu.nib). [self setMainMenu:defaultMainMenu]; + + BOOL hide = (MMHideWhenLastWindowClosed == + [[NSUserDefaults standardUserDefaults] + integerForKey:MMLastWindowClosedBehaviorKey]); + if (hide) + [NSApp hide:self]; } } diff --git a/src/MacVim/Miscellaneous.h b/src/MacVim/Miscellaneous.h index 6b8df3553a..23c3ebe206 100644 --- a/src/MacVim/Miscellaneous.h +++ b/src/MacVim/Miscellaneous.h @@ -30,7 +30,6 @@ extern NSString *MMTextInsetLeftKey; extern NSString *MMTextInsetRightKey; extern NSString *MMTextInsetTopKey; extern NSString *MMTextInsetBottomKey; -extern NSString *MMTerminateAfterLastWindowClosedKey; extern NSString *MMTypesetterKey; extern NSString *MMCellWidthMultiplierKey; extern NSString *MMBaselineOffsetKey; @@ -53,6 +52,7 @@ extern NSString *MMShowLeftPlugInContainerKey; extern NSString *MMOpenLayoutKey; extern NSString *MMVerticalSplitKey; extern NSString *MMPreloadCacheSizeKey; +extern NSString *MMLastWindowClosedBehaviorKey; // Enum for MMUntitledWindowKey @@ -63,7 +63,6 @@ enum { MMUntitledWindowAlways = 3 }; - // Enum for MMOpenLayoutKey (first 4 must match WIN_* defines in main.c) enum { MMLayoutArglist = 0, @@ -73,6 +72,13 @@ enum { MMLayoutWindows = 4, }; +// Enum for MMLastWindowClosedBehaviorKey +enum { + MMDoNothingWhenLastWindowClosed = 0, + MMHideWhenLastWindowClosed = 1, + MMTerminateWhenLastWindowClosed = 2, +}; + diff --git a/src/MacVim/Miscellaneous.m b/src/MacVim/Miscellaneous.m index 95782b8d48..15259d48d7 100644 --- a/src/MacVim/Miscellaneous.m +++ b/src/MacVim/Miscellaneous.m @@ -21,8 +21,6 @@ NSString *MMTextInsetLeftKey = @"MMTextInsetLeft"; NSString *MMTextInsetRightKey = @"MMTextInsetRight"; NSString *MMTextInsetTopKey = @"MMTextInsetTop"; NSString *MMTextInsetBottomKey = @"MMTextInsetBottom"; -NSString *MMTerminateAfterLastWindowClosedKey - = @"MMTerminateAfterLastWindowClosed"; NSString *MMTypesetterKey = @"MMTypesetter"; NSString *MMCellWidthMultiplierKey = @"MMCellWidthMultiplier"; NSString *MMBaselineOffsetKey = @"MMBaselineOffset"; @@ -45,6 +43,7 @@ NSString *MMShowLeftPlugInContainerKey = @"MMShowLeftPlugInContainer"; NSString *MMOpenLayoutKey = @"MMOpenLayout"; NSString *MMVerticalSplitKey = @"MMVerticalSplit"; NSString *MMPreloadCacheSizeKey = @"MMPreloadCacheSize"; +NSString *MMLastWindowClosedBehaviorKey = @"MMLastWindowClosedBehavior";