From ba332e64c29622e0b69412cb2fea639182ac1d1c Mon Sep 17 00:00:00 2001 From: avenjamin Date: Wed, 30 Jun 2010 16:34:03 +0000 Subject: Add option to toggle the tab bar visibility. - Only applies when one tab is present. - Saves last used state to preferences. --- Source/SPWindowController.m | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'Source/SPWindowController.m') diff --git a/Source/SPWindowController.m b/Source/SPWindowController.m index 0cfe9e8e..5cd98870 100644 --- a/Source/SPWindowController.m +++ b/Source/SPWindowController.m @@ -53,7 +53,7 @@ // Set up the tab bar [tabBar setStyleNamed:@"SequelPro"]; [tabBar setCanCloseOnlyTab:NO]; - [tabBar setHideForSingleTab:YES]; + [tabBar setHideForSingleTab:![[NSUserDefaults standardUserDefaults] boolForKey:SPAlwaysShowWindowTabBar]]; [tabBar setShowAddTabButton:YES]; [tabBar setSizeCellsToFit:NO]; [tabBar setCellMinWidth:100]; @@ -259,6 +259,17 @@ } +/** + * Toggle Tab Bar Visibility + */ + +- (IBAction)toggleTabBarShown:(id)sender +{ + [tabBar setHideForSingleTab:![tabBar isTabBarHidden]]; + [[NSUserDefaults standardUserDefaults] setBool:![tabBar hideForSingleTab] forKey:SPAlwaysShowWindowTabBar]; +} + + /** * Menu validation */ @@ -273,6 +284,12 @@ return ([tabView numberOfTabViewItems] != 1); } + // Show/hide Tab bar + if ([menuItem action] == @selector(toggleTabBarShown:)) { + [menuItem setTitle:(![tabBar isTabBarHidden] ? NSLocalizedString(@"Hide Tab Bar", @"hide tab bar") : NSLocalizedString(@"Show Tab Bar", @"show tab bar"))]; + return [[tabBar cells] count] <= 1; + } + // See if the front document blocks validation of this item if (![selectedTableDocument validateMenuItem:menuItem]) return NO; -- cgit v1.2.3