diff options
author | avenjamin <avenjamin@gmail.com> | 2010-06-30 16:34:03 +0000 |
---|---|---|
committer | avenjamin <avenjamin@gmail.com> | 2010-06-30 16:34:03 +0000 |
commit | ba332e64c29622e0b69412cb2fea639182ac1d1c (patch) | |
tree | 23d990c97bc1c70fe4a26450b2ea0b579ddbe919 /Source | |
parent | 92b97ba3f3ee634e101483f5129f25b4f8230117 (diff) | |
download | sequelpro-ba332e64c29622e0b69412cb2fea639182ac1d1c.tar.gz sequelpro-ba332e64c29622e0b69412cb2fea639182ac1d1c.tar.bz2 sequelpro-ba332e64c29622e0b69412cb2fea639182ac1d1c.zip |
Add option to toggle the tab bar visibility.
- Only applies when one tab is present.
- Saves last used state to preferences.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/SPConstants.h | 1 | ||||
-rw-r--r-- | Source/SPConstants.m | 1 | ||||
-rw-r--r-- | Source/SPWindowController.h | 3 | ||||
-rw-r--r-- | Source/SPWindowController.m | 19 |
4 files changed, 22 insertions, 2 deletions
diff --git a/Source/SPConstants.h b/Source/SPConstants.h index e6932900..a7a10fc2 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -286,6 +286,7 @@ extern NSString *SPProcessListEnableAutoRefresh; extern NSString *SPProcessListAutoRrefreshInterval; extern NSString *SPFavoritesSortedBy; extern NSString *SPFavoritesSortedInReverse; +extern NSString *SPAlwaysShowWindowTabBar; // Hidden Prefs extern NSString *SPPrintWarningRowLimit; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index 5580cbe7..bd02875f 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -134,6 +134,7 @@ NSString *SPProcessListEnableAutoRefresh = @"ProcessListEnableAutoRefres NSString *SPProcessListAutoRrefreshInterval = @"ProcessListAutoRrefreshInterval"; NSString *SPFavoritesSortedBy = @"FavoritesSortedBy"; NSString *SPFavoritesSortedInReverse = @"FavoritesSortedInReverse"; +NSString *SPAlwaysShowWindowTabBar = @"WindowAlwaysShowTabBar"; // Hidden Prefs NSString *SPPrintWarningRowLimit = @"PrintWarningRowLimit"; diff --git a/Source/SPWindowController.h b/Source/SPWindowController.h index 33d6df49..828c6cda 100644 --- a/Source/SPWindowController.h +++ b/Source/SPWindowController.h @@ -29,7 +29,7 @@ { IBOutlet PSMTabBarControl *tabBar; IBOutlet NSTabView *tabView; - + NSMenuItem *closeWindowMenuItem; NSMenuItem *closeTabMenuItem; @@ -46,6 +46,7 @@ - (IBAction)closeTab:(id)sender; - (IBAction)selectNextDocumentTab:(id)sender; - (IBAction)selectPreviousDocumentTab:(id)sender; +- (IBAction)toggleTabBarShown:(id)sender; - (NSArray *)documents; - (void)selectTabAtIndex:(NSInteger)index; - (void)setHideForSingleTab:(BOOL)hide; 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]; @@ -260,6 +260,17 @@ } /** + * Toggle Tab Bar Visibility + */ + +- (IBAction)toggleTabBarShown:(id)sender +{ + [tabBar setHideForSingleTab:![tabBar isTabBarHidden]]; + [[NSUserDefaults standardUserDefaults] setBool:![tabBar hideForSingleTab] forKey:SPAlwaysShowWindowTabBar]; +} + + +/** * Menu validation */ - (BOOL) validateMenuItem:(NSMenuItem *)menuItem @@ -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; |