Add option to hide MacVim when last window closes

This commit is contained in:
Bjorn Winckler
2008-08-23 22:01:30 +02:00
parent 0b896e4f59
commit 27c683092d
4 changed files with 19 additions and 7 deletions
Binary file not shown.
+10 -3
View File
@@ -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];
}
}
+8 -2
View File
@@ -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,
};
+1 -2
View File
@@ -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";