Changeset 841


Ignore:
Timestamp:
Sep 3, 2006, 4:16:35 PM (15 years ago)
Author:
livings124
Message:

Only update peer table when it's visible

Location:
trunk/macosx
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r809 r841  
    4848@interface InfoWindowController (Private)
    4949
     50- (void) reloadPeerTable;
    5051- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
    5152- (NSArray *) peerSortDescriptors;
     
    268269        BOOL active = [torrent isActive];
    269270       
    270         [fConnectedPeersField setStringValue: active ? [NSString
    271                 stringWithInt: [torrent totalPeers]] : @""];
    272         [fDownloadingFromField setStringValue: active ? [NSString
    273                 stringWithInt: [torrent peersUploading]] : @""];
    274         [fUploadingToField setStringValue: active ? [NSString
    275                 stringWithInt: [torrent peersDownloading]] : @""];
     271        [fConnectedPeersField setStringValue: active ? [NSString stringWithInt: [torrent totalPeers]] : @""];
     272        [fDownloadingFromField setStringValue: active ? [NSString stringWithInt: [torrent peersUploading]] : @""];
     273        [fUploadingToField setStringValue: active ? [NSString stringWithInt: [torrent peersDownloading]] : @""];
    276274       
    277275        [fRatioField setStringValue: [NSString stringForRatioWithDownload: downloadedTotal upload: uploadedTotal]];
     
    279277        [fSwarmSpeedField setStringValue: [torrent isActive] ? [NSString stringForSpeed: [torrent swarmSpeed]] : @""];
    280278       
    281         //set peers table
    282         [fPeers setArray: [torrent peers]];
    283         [fPeers sortUsingDescriptors: [self peerSortDescriptors]];
    284    
    285         [fPeerTable reloadData];
    286         [fPeerTableStatusField setStringValue: [NSString stringWithFormat: @"%d of %d connected",
    287                                                 [torrent totalPeers], [fPeers count]]];
     279        //set peers table if visible
     280        if ([[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_PEERS_IDENT])
     281            [self reloadPeerTable];
    288282    }
    289283}
     
    369363}
    370364
     365//requires a non-empty torrent array
     366- (void) reloadPeerTable
     367{
     368    Torrent * torrent = [fTorrents objectAtIndex: 0];
     369   
     370    [fPeers setArray: [torrent peers]];
     371    [fPeers sortUsingDescriptors: [self peerSortDescriptors]];
     372   
     373    [fPeerTable reloadData];
     374    [fPeerTableStatusField setStringValue: [NSString stringWithFormat: @"%d of %d connected",
     375                                            [torrent totalPeers], [fPeers count]]];
     376}
     377
    371378- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
    372379{
     
    400407        height = TAB_ACTIVITY_HEIGHT;
    401408    else if ([identifier isEqualToString: TAB_PEERS_IDENT])
     409    {
    402410        height = TAB_PEERS_HEIGHT;
     411       
     412        if ([fTorrents count] == 1)
     413            [self reloadPeerTable]; //initial update of peer table
     414    }
    403415    else if ([identifier isEqualToString: TAB_FILES_IDENT])
    404416        height = TAB_FILES_HEIGHT;
  • trunk/macosx/MessageWindowController.m

    r840 r841  
    3939    if ((self = [super initWithWindowNibName: name]))
    4040    {
    41         NSMutableParagraphStyle * paragraph = [[NSMutableParagraphStyle defaultParagraphStyle] mutableCopy];
     41        NSMutableParagraphStyle * paragraph = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    4242        [paragraph setHeadIndent: 20.0];
    4343       
     
    8888{
    8989    tr_msg_list_t * messages, * currentMessage;
    90     if (!(messages = tr_getQueuedMessages()))
     90    if ((messages = tr_getQueuedMessages()) == NULL)
    9191        return;
    9292   
Note: See TracChangeset for help on using the changeset viewer.