Changeset 142


Ignore:
Timestamp:
Mar 10, 2006, 9:57:01 PM (16 years ago)
Author:
titer
Message:

Fixing

Location:
branches/new_api/macosx
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • branches/new_api/macosx/Controller.m

    r141 r142  
    5555@implementation Controller
    5656
     57- (id) init
     58{
     59    fLib      = tr_init();
     60    fTorrents = [[NSMutableArray alloc] initWithCapacity: 10];
     61    return self;
     62}
     63
     64- (void) dealloc
     65{
     66    [fTorrents release];
     67    tr_close( fLib );
     68    [super dealloc];
     69}
     70
    5771- (void) awakeFromNib
    5872{
    5973    [fWindow setContentMinSize: NSMakeSize( 400, 120 )];
    60 
    61     fLib = tr_init();
    6274
    6375    [fPrefsController setPrefsWindow: fLib];
     
    253265        [torrent release];
    254266    }
    255     [fTorrents release];
    256 
    257     tr_close( fLib );
    258267}
    259268
     
    630639    (NSTableColumn *) tableColumn row: (int) rowIndex
    631640{
    632     return [fTorrents objectAtIndex: rowIndex];
     641    return nil;
     642}
     643
     644
     645- (void) tableView: (NSTableView *) t willDisplayCell: (id) cell
     646    forTableColumn: (NSTableColumn *) tableColumn row: (int) rowIndex
     647{
     648    [cell setTorrent: [fTorrents objectAtIndex: rowIndex]];
    633649}
    634650
  • branches/new_api/macosx/NameCell.h

    r141 r142  
    2525
    2626#import <Cocoa/Cocoa.h>
     27#import "Torrent.h"
    2728
    2829@interface NameCell : NSCell
    2930{
     31    Torrent * fTorrent;
    3032}
     33- (void) setTorrent: (Torrent *) torrent;
    3134@end
    3235
  • branches/new_api/macosx/NameCell.m

    r141 r142  
    2222
    2323#import "NameCell.h"
    24 #import "Torrent.h"
    2524#import "StringAdditions.h"
    2625#import "Utils.h"
     
    2827@implementation NameCell
    2928
     29- (void) setTorrent: (Torrent *) torrent
     30{
     31    fTorrent = torrent;
     32}
     33
    3034- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) view
    3135{
    32     Torrent * torrent = [self objectValue];
    33 
    3436    NSString * string;
    3537    NSPoint pen;
     
    4547
    4648    pen.x += 5; pen.y += 5;
    47     NSImage * icon = [torrent icon];
     49    NSImage * icon = [fTorrent icon];
    4850    [icon drawAtPoint: pen fromRect:
    4951        NSMakeRect( 0, 0, [icon size].width, [icon size].height )
     
    5961    pen.x += 37;
    6062    NSString * sizeString = [NSString stringWithFormat: @" (%@)",
    61         [NSString stringForFileSize: [torrent size]]];
    62     string = [[[torrent name] stringFittingInWidth: cellWidth -
     63        [NSString stringForFileSize: [fTorrent size]]];
     64    string = [[[fTorrent name] stringFittingInWidth: cellWidth -
    6365        72 - [sizeString sizeWithAttributes: attributes].width
    6466        withAttributes: attributes] stringByAppendingString: sizeString];
     
    6971
    7072    pen.x += 5; pen.y += 20;
    71     [[torrent statusString] drawAtPoint: pen withAttributes: attributes];
     73    [[fTorrent statusString] drawAtPoint: pen withAttributes: attributes];
    7274
    7375    pen.x += 0; pen.y += 15;
    74     string = [[torrent infoString] stringFittingInWidth:
     76    string = [[fTorrent infoString] stringFittingInWidth:
    7577        ( cellFrame.size.width - 77 ) withAttributes: attributes];
    7678    [string drawAtPoint: pen withAttributes: attributes];
  • branches/new_api/macosx/ProgressCell.h

    r141 r142  
    2525
    2626#import <Cocoa/Cocoa.h>
     27#import "Torrent.h"
    2728
    2829@interface ProgressCell : NSCell
    2930{
     31    Torrent * fTorrent;
    3032}
     33- (void) setTorrent: (Torrent *) torrent;
    3134@end
    3235
  • branches/new_api/macosx/ProgressCell.m

    r141 r142  
    8181      0x00ED00FF, 0x00F200FF, 0x00F400FF, 0x00B500FF };
    8282
     83- (void) setTorrent: (Torrent *) torrent
     84{
     85    fTorrent = torrent;
     86}
     87
    8388#if 0
    8489/***********************************************************************
  • branches/new_api/macosx/Torrent.h

    r141 r142  
    3333    BOOL           fResumeOnWake;
    3434
    35     NSImage      * fIcon;
    36     NSString    * fStatusString;
    37     NSString    * fInfoString;
     35    NSImage         * fIcon;
     36    NSMutableString * fStatusString;
     37    NSMutableString * fInfoString;
    3838}
    3939
  • branches/new_api/macosx/Torrent.m

    r141 r142  
    3838
    3939    fInfo = tr_torrentInfo( fHandle );
     40
    4041    NSString * fileType = ( fInfo->fileCount > 1 ) ?
    4142        NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension];
    4243    fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];
     44    [fIcon setFlipped: YES];
     45    [fIcon retain];
     46
     47    fStatusString = [[NSMutableString alloc] initWithCapacity: 50];
     48    fInfoString   = [[NSMutableString alloc] initWithCapacity: 50];
    4349
    4450    [self update];
     
    5157    {
    5258        tr_torrentClose( fLib, fHandle );
     59        [fIcon release];
     60        [fStatusString release];
     61        [fInfoString release];
    5362    }
    5463    [super dealloc];
     
    6978    fStat = tr_torrentStat( fHandle );
    7079
    71     fStatusString = @"";
    72     fInfoString   = @"";
     80    [fStatusString setString: @""];
     81    [fInfoString   setString: @""];
    7382
    7483    switch( fStat->status )
    7584    {
    7685        case TR_STATUS_PAUSE:
    77             fStatusString = [NSString stringWithFormat:
    78                 @"Paused (%.2f %%)", 100 * fStat->progress];
     86            [fStatusString appendFormat: @"Paused (%.2f %%)",
     87                100 * fStat->progress];
    7988            break;
    8089
    8190        case TR_STATUS_CHECK:
    82             fStatusString = [NSString stringWithFormat:
    83                 @"Checking existing files (%.2f %%)", 100 * fStat->progress];
     91            [fStatusString appendFormat:
     92                @"Checking existing files (%.2f %%)",
     93                100 * fStat->progress];
    8494            break;
    8595
     
    8797            if( fStat->eta < 0 )
    8898            {
    89                 fStatusString = [NSString stringWithFormat:
    90                     @"Finishing in --:--:-- (%.2f %%)", 100 * fStat->progress];
     99                [fStatusString appendFormat:
     100                    @"Finishing in --:--:-- (%.2f %%)",
     101                    100 * fStat->progress];
    91102            }
    92103            else
    93104            {
    94                 fStatusString = [NSString stringWithFormat:
     105                [fStatusString appendFormat:
    95106                    @"Finishing in %02d:%02d:%02d (%.2f %%)",
    96107                    fStat->eta / 3600, ( fStat->eta / 60 ) % 60,
    97108                    fStat->eta % 60, 100 * fStat->progress];
    98109            }
    99             fInfoString = [NSString stringWithFormat:
     110            [fInfoString appendFormat:
    100111                @"Downloading from %d of %d peer%s",
    101112                fStat->peersUploading, fStat->peersTotal,
     
    104115
    105116        case TR_STATUS_SEED:
    106             fStatusString  = [NSString stringWithFormat:
     117            [fStatusString appendFormat:
    107118                @"Seeding, uploading to %d of %d peer%s",
    108119                fStat->peersDownloading, fStat->peersTotal,
     
    111122
    112123        case TR_STATUS_STOPPING:
    113             fStatusString  = @"Stopping...";
     124            [fStatusString setString: @"Stopping..."];
    114125            break;
    115126    }
  • branches/new_api/macosx/TorrentTableView.h

    r34 r142  
    99    IBOutlet Controller  * fController;
    1010
    11     tr_stat_t            * fStat;
    1211    NSPoint                fClickPoint;
    1312   
     
    1615}
    1716
    18 - (void) updateUI: (tr_stat_t *) stat;
    19 
    2017@end
  • branches/new_api/macosx/TorrentTableView.m

    r141 r142  
    2626@implementation TorrentTableView
    2727
    28 - (void) updateUI: (tr_stat_t *) stat
    29 {
    30     fStat = stat;
    31     [self reloadData];
    32 }
    33 
    3428- (void) pauseOrResume: (int) row
    3529{
     30#if 0
    3631    if( fStat[row].status & TR_STATUS_PAUSE )
    3732    {
     
    4338        [fController stopTorrentWithIndex: row];
    4439    }                                                                   
     40#endif
    4541}
    4642
     
    153149    [super drawRect: r];
    154150
     151#if 0
    155152    for( i = 0; i < [self numberOfRows]; i++ )
    156153    {
     
    183180        [image compositeToPoint: point operation: NSCompositeSourceOver];
    184181    }
     182#endif
    185183}
    186184
Note: See TracChangeset for help on using the changeset viewer.