Changeset 761


Ignore:
Timestamp:
Aug 13, 2006, 3:46:02 PM (17 years ago)
Author:
livings124
Message:

Basic peer info in info window...more to come.

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Transmission.xcodeproj/project.pbxproj

    r754 r761  
    8282                A2173E1C0A33C1B300B0D8AB /* ActionButtonPressed.png in Resources */ = {isa = PBXBuildFile; fileRef = A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */; };
    8383                A21DFF100A292B2B007C5F76 /* Transfers.png in Resources */ = {isa = PBXBuildFile; fileRef = A21DFF0F0A292B2B007C5F76 /* Transfers.png */; };
     84                A221DA890A8F7E7E0011E98E /* InfoTableView.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = A221DA870A8F7E7E0011E98E /* InfoTableView.h */; };
     85                A221DA8A0A8F7E7E0011E98E /* InfoTableView.m in Sources */ = {isa = PBXBuildFile; fileRef = A221DA880A8F7E7E0011E98E /* InfoTableView.m */; };
    8486                A2305A800A3DC9E400AB2D77 /* ProgressBarWhite.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */; };
    8587                A2305A810A3DC9E400AB2D77 /* ProgressBarBlue.png in Resources */ = {isa = PBXBuildFile; fileRef = A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */; };
     
    159161                                A261F1E40A69A1B10002815A /* Growl.framework in CopyFiles */,
    160162                                A24F19210A3A796800C9C145 /* Sparkle.framework in CopyFiles */,
     163                                A221DA890A8F7E7E0011E98E /* InfoTableView.h in CopyFiles */,
    161164                        );
    162165                        runOnlyForDeploymentPostprocessing = 0;
     
    256259                4DCCBB3C09C3D71100D3CABF /* TorrentCell.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = TorrentCell.m; path = macosx/TorrentCell.m; sourceTree = "<group>"; };
    257260                4DCCBB3D09C3D71100D3CABF /* TorrentCell.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = TorrentCell.h; path = macosx/TorrentCell.h; sourceTree = "<group>"; };
    258                 4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
     261                4DDBB71909E16BAE00284745 /* transmissioncli */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = transmissioncli; sourceTree = BUILT_PRODUCTS_DIR; };
    259262                4DDBB71B09E16BF100284745 /* transmissioncli.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = transmissioncli.c; path = cli/transmissioncli.c; sourceTree = "<group>"; };
    260263                4DDFDD20099A5D8E00189D81 /* DownloadBadge.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = DownloadBadge.png; path = macosx/Images/DownloadBadge.png; sourceTree = "<group>"; };
     
    285288                A2173E1B0A33C1B300B0D8AB /* ActionButtonPressed.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ActionButtonPressed.png; path = macosx/Images/ActionButtonPressed.png; sourceTree = "<group>"; };
    286289                A21DFF0F0A292B2B007C5F76 /* Transfers.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Transfers.png; path = macosx/Images/Transfers.png; sourceTree = "<group>"; };
     290                A221DA870A8F7E7E0011E98E /* InfoTableView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = InfoTableView.h; path = macosx/InfoTableView.h; sourceTree = "<group>"; };
     291                A221DA880A8F7E7E0011E98E /* InfoTableView.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; name = InfoTableView.m; path = macosx/InfoTableView.m; sourceTree = "<group>"; };
    287292                A2305A7C0A3DC9E400AB2D77 /* ProgressBarWhite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarWhite.png; path = macosx/Images/ProgressBarWhite.png; sourceTree = "<group>"; };
    288293                A2305A7D0A3DC9E400AB2D77 /* ProgressBarBlue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ProgressBarBlue.png; path = macosx/Images/ProgressBarBlue.png; sourceTree = "<group>"; };
     
    399404                                A2710E740A86796000CE4F7D /* PrefsWindow.h */,
    400405                                A2710E750A86796000CE4F7D /* PrefsWindow.m */,
     406                                A221DA870A8F7E7E0011E98E /* InfoTableView.h */,
     407                                A221DA880A8F7E7E0011E98E /* InfoTableView.m */,
    401408                        );
    402409                        name = Sources;
     
    813820                                A27ABC240A6ADE410020EC71 /* ImageBackgroundView.m in Sources */,
    814821                                A2710E770A86796000CE4F7D /* PrefsWindow.m in Sources */,
     822                                A221DA8A0A8F7E7E0011E98E /* InfoTableView.m in Sources */,
    815823                        );
    816824                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/macosx/English.lproj/InfoWindow.nib/classes.nib

    r535 r761  
    55            LANGUAGE = ObjC;
    66            OUTLETS = {fContextMenu = NSMenu; };
    7             SUPERCLASS = NSTableView;
     7            SUPERCLASS = InfoTableView;
    88        },
    99        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
     10        {CLASS = InfoTableView; LANGUAGE = ObjC; SUPERCLASS = NSTableView; },
    1011        {
    1112            ACTIONS = {
     
    3031                fLeechersField = NSTextField;
    3132                fNameField = NSTextField;
     33                fPeerTable = NSTableView;
    3234                fPieceSizeField = NSTextField;
    3335                fPiecesField = NSTextField;
  • trunk/macosx/FileTableView.h

    r376 r761  
    2424
    2525#import <Cocoa/Cocoa.h>
     26#import "InfoTableView.h"
    2627
    27 @interface FileTableView : NSTableView
     28@interface FileTableView : InfoTableView
    2829{
    2930    IBOutlet NSMenu * fContextMenu;
  • trunk/macosx/FileTableView.m

    r421 r761  
    2727@implementation FileTableView
    2828
    29 - (void) mouseDown: (NSEvent *) event
    30 {
    31     [[self window] makeKeyWindow];
    32     [super mouseDown: event];
    33 }
    34 
    3529- (NSMenu *) menuForEvent: (NSEvent *) e
    3630{
  • trunk/macosx/InfoWindowController.h

    r569 r761  
    2525#import <Cocoa/Cocoa.h>
    2626#import "Torrent.h"
     27#import <transmission.h>
    2728
    2829@interface InfoWindowController : NSWindowController
    2930{
    3031    NSArray * fTorrents;
    31     NSMutableArray * fFiles;
     32    NSMutableArray * fPeers, * fFiles;
    3233    NSImage * fAppIcon;
    3334   
     
    4647                        * fConnectedPeersField, * fDownloadingFromField, * fUploadingToField;
    4748
    48     IBOutlet NSTableView * fFileTable;
     49    IBOutlet NSTableView * fPeerTable, * fFileTable;
    4950   
    5051    IBOutlet NSMatrix * fRatioMatrix;
  • trunk/macosx/InfoWindowController.m

    r746 r761  
    3535#define TAB_INFO_IDENT @"Info"
    3636#define TAB_ACTIVITY_IDENT @"Activity"
     37#define TAB_PEERS_IDENT @"Peers"
    3738#define TAB_OPTIONS_IDENT @"Options"
    3839#define TAB_FILES_IDENT @"Files"
     
    4142#define TAB_INFO_HEIGHT 182.0
    4243#define TAB_ACTIVITY_HEIGHT 214.0
     44#define TAB_PEERS_HEIGHT 250.0
    4345#define TAB_OPTIONS_HEIGHT 116.0
    4446#define TAB_FILES_HEIGHT 250.0
     
    5759   
    5860    fTorrents = [[NSArray alloc] init];
     61    fPeers = [[NSMutableArray alloc] initWithCapacity: 6];
    5962    fFiles = [[NSMutableArray alloc] initWithCapacity: 6];
    6063    [fFileTable setDoubleAction: @selector(revealFile:)];
     
    6871    [window setFrameUsingName: @"InspectorWindowFrame"];
    6972   
     73    //select tab
    7074    NSString * identifier = [[NSUserDefaults standardUserDefaults] stringForKey: @"InfoTab"];
     75    if ([fTabView indexOfTabViewItemWithIdentifier: identifier] == NSNotFound)
     76        identifier = TAB_INFO_IDENT;
     77   
    7178    [fTabView selectTabViewItemWithIdentifier: identifier];
    7279    [self setWindowForTab: identifier animate: NO];
     
    7885{
    7986    [fTorrents release];
     87    [fPeers release];
    8088    [fFiles release];
    8189
     
    253261        }
    254262    }
     263   
     264    //set peers table
     265    if (numberSelected == 1)
     266    {
     267        [fPeers setArray: [[fTorrents objectAtIndex: 0] peers]];
     268        [fPeers sortUsingDescriptors: [fPeerTable sortDescriptors]];
     269    }
     270    else
     271        [fPeers removeAllObjects];
     272   
     273    [fPeerTable deselectAll: nil];
     274    [fPeerTable reloadData];
    255275}
    256276
     
    365385    if ([identifier isEqualToString: TAB_ACTIVITY_IDENT])
    366386        height = TAB_ACTIVITY_HEIGHT;
     387    else if ([identifier isEqualToString: TAB_PEERS_IDENT])
     388        height = TAB_PEERS_HEIGHT;
    367389    else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
    368390        height = TAB_OPTIONS_HEIGHT;
     
    411433- (int) numberOfRowsInTableView: (NSTableView *) tableView
    412434{
    413     return [fFiles count];
    414 }
    415 
    416 - (id) tableView: (NSTableView *) tableView objectValueForTableColumn:
    417                     (NSTableColumn *) column row: (int) row
    418 {
    419     NSString * file = [fFiles objectAtIndex: row];
    420     if ([[column identifier] isEqualToString: @"Icon"])
    421         return [[NSWorkspace sharedWorkspace] iconForFileType: [file pathExtension]];
    422     else
    423         return [file lastPathComponent];
     435    if (tableView == fPeerTable)
     436        return [fTorrents count] == 1 ? [[fTorrents objectAtIndex: 0] totalPeers] : 0;
     437    else if (tableView == fFileTable)
     438        return [fFiles count];
     439    else
     440        return 0;
     441}
     442
     443- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row
     444{
     445    NSString * ident = [column identifier];
     446    if (tableView == fPeerTable)
     447    {
     448        NSDictionary * peer = [fPeers objectAtIndex: row];
     449       
     450        if ([ident isEqualToString: @"UL To"])
     451            return [[peer objectForKey: @"UL To"] boolValue] ? @"Y" : @"";
     452        else if ([ident isEqualToString: @"DL From"])
     453            return [[peer objectForKey: @"DL From"] boolValue] ? @"Y" : @"";
     454        else
     455            return [peer objectForKey: @"Client"];
     456    }
     457    else
     458    {
     459        NSString * file = [fFiles objectAtIndex: row];
     460        if ([ident isEqualToString: @"Icon"])
     461            return [[NSWorkspace sharedWorkspace] iconForFileType: [file pathExtension]];
     462        else
     463            return [file lastPathComponent];
     464    }
     465}
     466
     467- (void) tableView: (NSTableView *) tableView didClickTableColumn: (NSTableColumn *) tableColumn
     468{
     469    if (tableView == fPeerTable)
     470    {
     471        [fPeers sortUsingDescriptors: [tableView sortDescriptors]];
     472        [tableView reloadData];
     473    }
    424474}
    425475
     
    429479        row: (int) row mouseLocation: (NSPoint) mouseLocation
    430480{
    431     return [fFiles objectAtIndex: row];
     481    return tableView == fFileTable ? [fFiles objectAtIndex: row] : nil;
    432482}
    433483
  • trunk/macosx/Torrent.h

    r692 r761  
    115115- (BOOL)    justFinished;
    116116
     117- (NSArray *) peers;
     118
    117119- (NSString *) progressString;
    118120- (NSString *) statusString;
  • trunk/macosx/Torrent.m

    r729 r761  
    516516}
    517517
     518- (NSArray *) peers
     519{
     520    tr_peer_t * peer;
     521    int totalPeers = [self totalPeers], i;
     522   
     523    NSMutableArray * peers = [NSMutableArray arrayWithCapacity: totalPeers];
     524    for (i = 0; i < totalPeers; i++)
     525    {
     526        peer = tr_getPeer(fHandle, i);
     527        [peers addObject: [NSDictionary dictionaryWithObjectsAndKeys:
     528            [NSString stringWithCString: (char *) tr_clientForId(tr_peerId(peer)) encoding: NSUTF8StringEncoding],
     529                @"Client",
     530            [NSNumber numberWithBool: tr_peerIsDownloading(peer)], @"UL To",
     531            [NSNumber numberWithBool: tr_peerIsUploading(peer)], @"DL From", nil]];
     532    }
     533   
     534    return peers;
     535}
     536
    518537- (NSString *) progressString
    519538{
Note: See TracChangeset for help on using the changeset viewer.