1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-24 00:34:04 +00:00

Remember selected inspector tab.

This commit is contained in:
Mitchell Livingston 2006-06-22 00:10:37 +00:00
parent 5ab5baa008
commit e179fc6e40
2 changed files with 32 additions and 17 deletions

View file

@ -28,6 +28,8 @@
<integer>100</integer>
<key>History</key>
<array/>
<key>InfoTab</key>
<string>Info</string>
<key>InfoVisible</key>
<false/>
<key>Move</key>

View file

@ -43,6 +43,12 @@
#define TAB_OPTIONS_HEIGHT 82.0
#define TAB_FILES_HEIGHT 250.0
@interface InfoWindowController (Private)
- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
@end
@implementation InfoWindowController
- (void) awakeFromNib
@ -60,14 +66,9 @@
[window setFrameAutosaveName: @"InspectorWindowFrame"];
[window setFrameUsingName: @"InspectorWindowFrame"];
NSRect frame = [window frame];
float difference = TAB_INFO_HEIGHT - [[[fTabView selectedTabViewItem] view] frame].size.height;
frame.origin.y -= difference;
frame.size.height += difference;
[window setFrame: frame display: YES];
[window setMinSize: NSMakeSize(MIN_WINDOW_WIDTH, frame.size.height)];
[window setMaxSize: NSMakeSize(MAX_WINDOW_WIDTH, frame.size.height)];
NSString * identifier = [[NSUserDefaults standardUserDefaults] stringForKey: @"InfoTab"];
[fTabView selectTabViewItemWithIdentifier: identifier];
[self setWindowForTab: identifier animate: NO];
}
- (void) dealloc
@ -319,29 +320,41 @@
}
- (void) tabView: (NSTabView *) tabView didSelectTabViewItem: (NSTabViewItem *) tabViewItem
{
NSString * identifier = [tabViewItem identifier];
[self setWindowForTab: identifier animate: YES];
[[NSUserDefaults standardUserDefaults] setObject: identifier forKey: @"InfoTab"];
}
- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate
{
NSWindow * window = [self window];
NSRect frame = [window frame];
float height;
NSString * identifier = [tabViewItem identifier];
if ([identifier isEqualToString: TAB_INFO_IDENT])
height = TAB_INFO_HEIGHT;
else if ([identifier isEqualToString: TAB_ACTIVITY_IDENT])
if ([identifier isEqualToString: TAB_ACTIVITY_IDENT])
height = TAB_ACTIVITY_HEIGHT;
else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
height = TAB_OPTIONS_HEIGHT;
else
else if ([identifier isEqualToString: TAB_FILES_IDENT])
height = TAB_FILES_HEIGHT;
else
height = TAB_INFO_HEIGHT;
NSView * view = [tabViewItem view];
NSView * view = [[fTabView selectedTabViewItem] view];
float difference = height - [view frame].size.height;
frame.origin.y -= difference;
frame.size.height += difference;
[view setHidden: YES];
[window setFrame: frame display: YES animate: YES];
[view setHidden: NO];
if (animate)
{
[view setHidden: YES];
[window setFrame: frame display: YES animate: YES];
[view setHidden: NO];
}
else
[window setFrame: frame display: YES];
[window setMinSize: NSMakeSize(MIN_WINDOW_WIDTH, frame.size.height)];
[window setMaxSize: NSMakeSize(MAX_WINDOW_WIDTH, frame.size.height)];