Changeset 5136


Ignore:
Timestamp:
Feb 27, 2008, 2:06:46 AM (14 years ago)
Author:
livings124
Message:

cleanup for last commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r5135 r5136  
    584584- (void) setTab: (id) sender
    585585{
     586    int oldTabTag = fCurrentTabTag;
     587    fCurrentTabTag = [fTabMatrix selectedTag];
     588    if (fCurrentTabTag == oldTabTag)
     589        return;
     590   
    586591    [self updateInfoStats];
    587592   
    588     //save old heights
    589     int oldTabTag = fCurrentTabTag;
    590     NSView * oldView = [self tabViewForTag: oldTabTag];
    591    
    592     BOOL oldCanResizeVertical;
    593     NSString * oldResizeSaveKey;
    594     switch (fCurrentTabTag)
    595     {
    596         case TAB_TRACKER_TAG:
    597             oldResizeSaveKey = @"InspectorContentHeightTracker";
    598             oldCanResizeVertical = YES;
    599             break;
    600         case TAB_PEERS_TAG:
    601             oldResizeSaveKey = @"InspectorContentHeightPeers";
    602             oldCanResizeVertical = YES;
    603             break;
    604         case TAB_FILES_TAG:
    605             oldResizeSaveKey = @"InspectorContentHeightFiles";
    606             oldCanResizeVertical = YES;
    607             break;
    608         default:
    609             oldCanResizeVertical = NO;
    610     }
    611    
     593    //take care of old view
    612594    float oldHeight = 0;
    613    
     595    NSString * oldResizeSaveKey = nil;
    614596    if (oldTabTag != INVALID)
     597    {
     598        //deselect old tab item
     599        [(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO];
     600       
     601        switch (oldTabTag)
     602        {
     603            case TAB_TRACKER_TAG:
     604                oldResizeSaveKey = @"InspectorContentHeightTracker";
     605                break;
     606            case TAB_PEERS_TAG:
     607                oldResizeSaveKey = @"InspectorContentHeightPeers";
     608                break;
     609            case TAB_FILES_TAG:
     610                oldResizeSaveKey = @"InspectorContentHeightFiles";
     611                break;
     612        }
     613       
     614        NSView * oldView = [self tabViewForTag: oldTabTag];
    615615        oldHeight = [oldView frame].size.height;
    616     if (oldCanResizeVertical)
    617         [[NSUserDefaults standardUserDefaults] setFloat: [oldView frame].size.height forKey: oldResizeSaveKey];
     616        if (oldResizeSaveKey)
     617            [[NSUserDefaults standardUserDefaults] setFloat: oldHeight forKey: oldResizeSaveKey];
     618       
     619        //get old view
     620        [oldView setHidden: YES];
     621        [oldView removeFromSuperview];
     622    }
    618623   
    619624    //set current tag
    620     BOOL canResizeVertical;
    621     NSString * resizeSaveKey;
    622     fCurrentTabTag = [fTabMatrix selectedTag];
     625    NSString * resizeSaveKey = nil;
    623626   
    624627    NSView * view;
     
    630633            identifier = TAB_INFO_IDENT;
    631634            title = NSLocalizedString(@"General Info", "Inspector -> title");
    632             canResizeVertical = NO;
    633635            break;
    634636        case TAB_ACTIVITY_TAG:
     
    636638            identifier = TAB_ACTIVITY_IDENT;
    637639            title = NSLocalizedString(@"Activity", "Inspector -> title");
    638             canResizeVertical = NO;
    639640           
    640641            [fPiecesView updateView: YES];
     
    644645            identifier = TAB_TRACKER_IDENT;
    645646            title = NSLocalizedString(@"Tracker", "Inspector -> title");
    646            
    647647            resizeSaveKey = @"InspectorContentHeightTracker";
    648             canResizeVertical = YES;
    649648            break;
    650649        case TAB_PEERS_TAG:
     
    652651            identifier = TAB_PEERS_IDENT;
    653652            title = NSLocalizedString(@"Peers", "Inspector -> title");
    654            
    655653            resizeSaveKey = @"InspectorContentHeightPeers";
    656             canResizeVertical = YES;
    657654            break;
    658655        case TAB_FILES_TAG:
     
    660657            identifier = TAB_FILES_IDENT;
    661658            title = NSLocalizedString(@"Files", "Inspector -> title");
    662            
    663659            resizeSaveKey = @"InspectorContentHeightFiles";
    664             canResizeVertical = YES;
    665660            break;
    666661        case TAB_OPTIONS_TAG:
     
    668663            identifier = TAB_OPTIONS_IDENT;
    669664            title = NSLocalizedString(@"Options", "Inspector -> title");
    670             canResizeVertical = NO;
    671665            break;
    672666        default:
    673667            return;
    674668    }
    675        
     669   
    676670    [[NSUserDefaults standardUserDefaults] setObject: identifier forKey: @"InspectorSelected"];
    677671   
    678672    NSWindow * window = [self window];
    679    
    680     /*if (fCurrentTabTag == oldTabTag)
    681         return;*/
    682    
    683     #warning move?
    684     if (oldTabTag != INVALID)
    685     {
    686         //deselect old tab item
    687         [(InfoTabButtonCell *)[fTabMatrix cellWithTag: oldTabTag] setSelectedTab: NO];
    688        
    689         //get old view
    690         [oldView setHidden: YES];
    691         [oldView removeFromSuperview];
    692     }
    693673   
    694674    [window setTitle: [NSString stringWithFormat: @"%@ - %@", title, NSLocalizedString(@"Torrent Inspector", "Inspector -> title")]];
     
    699679    NSRect windowRect = [window frame], viewRect = [view frame];
    700680   
    701     if (canResizeVertical)
     681    if (resizeSaveKey)
    702682    {
    703683        float height = [[NSUserDefaults standardUserDefaults] floatForKey: resizeSaveKey];
     
    710690    windowRect.size.height += difference;
    711691   
    712     if (canResizeVertical)
    713     {
    714         if (!oldCanResizeVertical)
     692    if (resizeSaveKey)
     693    {
     694        if (!oldResizeSaveKey)
    715695        {
    716696            [window setMinSize: NSMakeSize([window minSize].width, windowRect.size.height - viewRect.size.height + TAB_MIN_HEIGHT)];
Note: See TracChangeset for help on using the changeset viewer.