diff --git a/src/MacVim/MMVimController.h b/src/MacVim/MMVimController.h index 7246e68460..07421b0448 100644 --- a/src/MacVim/MMVimController.h +++ b/src/MacVim/MMVimController.h @@ -27,8 +27,11 @@ id backendProxy; NSMenu *mainMenu; NSMutableArray *popupMenuItems; + + // TODO: Move all toolbar code to window controller? NSToolbar *toolbar; NSMutableDictionary *toolbarItemDict; + int pid; NSString *serverName; NSDictionary *vimState; diff --git a/src/MacVim/MMWindowController.h b/src/MacVim/MMWindowController.h index 707fc5c3ed..f2af4319d9 100644 --- a/src/MacVim/MMWindowController.h +++ b/src/MacVim/MMWindowController.h @@ -42,6 +42,7 @@ int userCols; NSPoint userTopLeft; NSPoint defaultTopLeft; + NSToolbar *toolbar; } - (id)initWithVimController:(MMVimController *)controller; diff --git a/src/MacVim/MMWindowController.m b/src/MacVim/MMWindowController.m index a9f620fe16..309e8f07c3 100644 --- a/src/MacVim/MMWindowController.m +++ b/src/MacVim/MMWindowController.m @@ -203,6 +203,7 @@ [decoratedWindow release]; decoratedWindow = nil; [windowAutosaveKey release]; windowAutosaveKey = nil; [vimView release]; vimView = nil; + [toolbar release]; toolbar = nil; [super dealloc]; } @@ -389,9 +390,14 @@ [fullscreenWindow setRepresentedFilename:filename]; } -- (void)setToolbar:(NSToolbar *)toolbar +- (void)setToolbar:(NSToolbar *)theToolbar { - // The full-screen window has no toolbar. + if (theToolbar != toolbar) { + [toolbar release]; + toolbar = [theToolbar retain]; + } + + // NOTE: Toolbar must be set here or it won't work to show it later. [decoratedWindow setToolbar:toolbar]; // HACK! Redirect the pill button so that we can ask Vim to hide the @@ -530,10 +536,9 @@ // Showing the tabline may result in the tabline separator being hidden or // shown; this does not apply to full-screen mode. if (!on) { - NSToolbar *toolbar = [decoratedWindow toolbar]; if (([decoratedWindow styleMask] & NSTexturedBackgroundWindowMask) == 0) { - [self hideTablineSeparator:![toolbar isVisible]]; + [self hideTablineSeparator:![decoratedWindow toolbar]]; } else { [self hideTablineSeparator:NO]; } @@ -549,7 +554,6 @@ - (void)showToolbar:(BOOL)on size:(int)size mode:(int)mode { - NSToolbar *toolbar = [decoratedWindow toolbar]; if (!toolbar) return; [toolbar setSizeMode:size]; @@ -1350,12 +1354,11 @@ - (void)updateToolbar { - NSToolbar *toolbar = [decoratedWindow toolbar]; if (nil == toolbar || 0 == updateToolbarFlag) return; // Positive flag shows toolbar, negative hides it. BOOL on = updateToolbarFlag > 0 ? YES : NO; - [toolbar setVisible:on]; + [decoratedWindow setToolbar:(on ? toolbar : nil)]; if (([decoratedWindow styleMask] & NSTexturedBackgroundWindowMask) == 0) { if (!on) { @@ -1421,4 +1424,3 @@ @end // MMWindowController (Private) -