Begin work on tab position options

This commit is contained in:
anthony 2021-03-03 19:39:24 +00:00
parent 9036df44ae
commit 96d0311ad3
4 changed files with 27 additions and 3 deletions

View File

@ -451,12 +451,14 @@ static id newTabTarget;
-(void)updateTabsVisibility {
BOOL hideTabs = [tabs count] < 2 && ![[Preferences defaultPreferences]
alwaysShowTabs];
TabLocation location = [[Preferences defaultPreferences] tabLocation];
NSRect rect = [tabView frame];
rect.size.height = [[self window] frame].size.height - TOP_CONTENT_HEIGHT;
if (hideTabs) {
[tabView setTabViewType: NSNoTabsNoBorder];
} else {
[tabView setTabViewType: NSTopTabsBezelBorder];
[tabView setTabViewType: location == TabLocationTop ? NSTopTabsBezelBorder
: NSBottomTabsBezelBorder];
}
[tabView setFrame: rect];
// Work around a graphical glitch where the tab view doesn't properly readjust itself
@ -466,7 +468,7 @@ static id newTabTarget;
-(void)onPreferencesUpdated: (id)sender {
id dict = [sender object];
PreferenceType type = (PreferenceType)[[dict objectForKey: @"type"] integerValue];
if (type == PreferenceTypeAlwaysShowTabs) {
if (type == PreferenceTypeAlwaysShowTabs || type == PreferenceTypeTabLocation) {
[self updateTabsVisibility];
}
}

View File

@ -17,7 +17,8 @@ typedef NS_ENUM(NSInteger, TabLocation) {
// Certain preferences will notify that they have been updated using this key.
#define PreferencesUpdatedNotificationName @"PreferencesUpdatedNotification"
typedef NS_ENUM(NSInteger, PreferenceType) {
PreferenceTypeAlwaysShowTabs = 0
PreferenceTypeAlwaysShowTabs = 0,
PreferenceTypeTabLocation
};
@interface Preferences: NSObject {
@ -51,5 +52,8 @@ typedef NS_ENUM(NSInteger, PreferenceType) {
-(BOOL)blankNewTabs;
-(void)setBlankNewTabs: (BOOL)value;
-(TabLocation)tabLocation;
-(void)setTabLocation: (TabLocation)value;
+(Preferences*)defaultPreferences;
@end

View File

@ -11,6 +11,7 @@
#define KEY_SWITCH_TAB_IMMEDIATELY @"switch_tab_immediately"
#define KEY_BLANK_NEW_TABS @"blank_new_tabs"
#define KEY_ALWAYS_SHOW_TABS @"always_show_tabs"
#define KEY_TAB_LOCATION @"tab_location"
@interface Preferences (Private)
@ -143,6 +144,19 @@
[defaults setBool: value forKey: KEY_BLANK_NEW_TABS];
}
-(TabLocation)tabLocation {
if ([defaults objectForKey: KEY_TAB_LOCATION] != nil) {
return (TabLocation)[defaults integerForKey: KEY_TAB_LOCATION];
} else {
return TabLocationTop;
}
}
-(void)setTabLocation: (TabLocation)value {
[defaults setInteger: (NSInteger)value forKey: KEY_TAB_LOCATION];
[self notifyPreferenceUpdated: PreferenceTypeTabLocation];
}
+(Preferences*)defaultPreferences {
static Preferences *prefs;
if (prefs == nil) {

View File

@ -205,6 +205,8 @@
? NSOnState : NSOffState];
[bankNewTabsButton setState: [[Preferences defaultPreferences] blankNewTabs] ?
NSOnState : NSOffState];
TabLocation location = [[Preferences defaultPreferences] tabLocation];
[tabPositionButton selectItemAtIndex: (NSInteger)location];
}
-(void)didPickDeveloperViews: (id)sender {
@ -213,6 +215,8 @@
-(void)didPickTabPosition: (id)sender {
NSLog(@"didPickTabPosition");
TabLocation location = (TabLocation)[sender indexOfItem: [sender selectedItem]];
[[Preferences defaultPreferences] setTabLocation: location];
}
-(void)didPressAlwaysShowTabBar: (id)sender {