mirror of
https://github.com/macvim-dev/macvim.git
synced 2026-06-11 15:37:29 +02:00
Add menu item to toggle the plugin view drawer
The setting is remembered, so if the drawer was last toggled closed then it should not open again until toggled.
This commit is contained in:
committed by
Bjorn Winckler
parent
3245d2c6e4
commit
754d698c33
@@ -142,6 +142,9 @@ static int executeInLoginShell(NSString *path, NSArray *args);
|
||||
@"", MMLoginShellCommandKey,
|
||||
@"", MMLoginShellArgumentKey,
|
||||
[NSNumber numberWithBool:YES], MMDialogsTrackPwdKey,
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
[NSNumber numberWithBool:YES], MMShowLeftPlugInContainerKey,
|
||||
#endif
|
||||
nil];
|
||||
|
||||
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "MacVim.h"
|
||||
|
||||
|
||||
// NSUserDefaults keys
|
||||
@@ -39,6 +39,10 @@ extern NSString *MMLoginShellCommandKey;
|
||||
extern NSString *MMLoginShellArgumentKey;
|
||||
extern NSString *MMDialogsTrackPwdKey;
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
extern NSString *MMShowLeftPlugInContainerKey;
|
||||
#endif
|
||||
|
||||
// Enum for MMUntitledWindowKey
|
||||
enum {
|
||||
MMUntitledWindowNever = 0,
|
||||
|
||||
@@ -40,6 +40,9 @@ NSString *MMLoginShellCommandKey = @"MMLoginShellCommand";
|
||||
NSString *MMLoginShellArgumentKey = @"MMLoginShellArgument";
|
||||
NSString *MMDialogsTrackPwdKey = @"MMDialogsTrackPwd";
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
NSString *MMShowLeftPlugInContainerKey = @"MMShowLeftPlugInContainer";
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
+43
-4
@@ -22,7 +22,7 @@
|
||||
* Author: Matt Tolton
|
||||
*/
|
||||
|
||||
#import "MacVim.h"
|
||||
#import "Miscellaneous.h"
|
||||
|
||||
#ifdef MM_ENABLE_PLUGINS
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
NSSize contentSize = [drawer contentSize];
|
||||
|
||||
// XXX memory management for this
|
||||
MMPlugInViewContainer * containerView = [[MMPlugInViewContainer alloc]
|
||||
MMPlugInViewContainer *containerView = [[MMPlugInViewContainer alloc]
|
||||
initWithFrame:NSMakeRect(0, 0, contentSize.width, contentSize.height)];
|
||||
|
||||
[drawer setContentView:containerView];
|
||||
@@ -55,7 +55,15 @@
|
||||
[containerView release];
|
||||
|
||||
[drawer setParentWindow:[[vimController windowController] window]];
|
||||
}
|
||||
|
||||
- (void)toggleDrawer
|
||||
{
|
||||
[drawer toggle:nil];
|
||||
[[NSUserDefaults standardUserDefaults]
|
||||
setBool:[drawer state] == NSDrawerOpenState
|
||||
|| [drawer state] == NSDrawerOpeningState
|
||||
forKey:MMShowLeftPlugInContainerKey];
|
||||
}
|
||||
|
||||
- (void)initializeInstances
|
||||
@@ -117,8 +125,11 @@
|
||||
{
|
||||
//NSLog(@"%@ %s", [self className], _cmd);
|
||||
|
||||
// For now, just always open the drawer when adding a plugin view
|
||||
[drawer open];
|
||||
// Do this here so that the drawer is never opened automatically when there
|
||||
// are no plugin views.
|
||||
if ([[NSUserDefaults standardUserDefaults]
|
||||
boolForKey:MMShowLeftPlugInContainerKey] && [plugInViews count] == 0)
|
||||
[drawer open];
|
||||
|
||||
MMPlugInViewController *newView =
|
||||
[[MMPlugInViewController alloc] initWithView:view title:title];
|
||||
@@ -161,6 +172,34 @@ MMPlugInAppMediator *sharedAppMediator = nil;
|
||||
return sharedAppMediator;
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if ((self = [super init]) == nil) return nil;
|
||||
|
||||
NSString *title = NSLocalizedString(@"Toggle Left Drawer",
|
||||
@"Toggle Left Drawer menu title");
|
||||
NSMenuItem *item = [[[NSMenuItem alloc] initWithTitle:title
|
||||
action:@selector(toggleLeftDrawer:)
|
||||
keyEquivalent:@""] autorelease];
|
||||
[item setTarget:self];
|
||||
[self addPlugInMenuItem:item];
|
||||
[self addPlugInMenuItem:[NSMenuItem separatorItem]];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)toggleLeftDrawer:(id)sender
|
||||
{
|
||||
MMVimController *c = [[MMAppController sharedInstance] keyVimController];
|
||||
|
||||
[[c instanceMediator] toggleDrawer];
|
||||
}
|
||||
|
||||
- (BOOL)validateMenuItem:(NSMenuItem *)item
|
||||
{
|
||||
return [[MMAppController sharedInstance] keyVimController] != nil;
|
||||
}
|
||||
|
||||
- (void)addPlugInMenuItem:(NSMenuItem *)menuItem
|
||||
{
|
||||
NSAssert(menuItem, @"menuItem cannot be nil");
|
||||
|
||||
Reference in New Issue
Block a user