Changeset 421


Ignore:
Timestamp:
Jun 21, 2006, 2:07:56 PM (16 years ago)
Author:
livings124
Message:

A lot of cleanup; remove cantfindaname once and for all.

Location:
trunk/macosx
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r419 r421  
    4646#define GROWL_PATH  @"/Library/PreferencePanes/Growl.prefPane/Contents/Resources/GrowlHelperApp.app"
    4747
    48 static void sleepCallBack( void * controller, io_service_t y,
    49         natural_t messageType, void * messageArgument )
     48static void sleepCallBack(void * controller, io_service_t y,
     49        natural_t messageType, void * messageArgument)
    5050{
    5151    Controller * c = controller;
     
    135135        [NSArray arrayWithObject: NSFilenamesPboardType]];
    136136
    137     //Register for sleep notifications
     137    //register for sleep notifications
    138138    IONotificationPortRef notify;
    139     io_object_t anIterator;
    140     if (fRootPort = IORegisterForSystemPower(self, & notify,
    141                                 sleepCallBack, & anIterator))
    142     {
    143         CFRunLoopAddSource( CFRunLoopGetCurrent(),
    144                             IONotificationPortGetRunLoopSource( notify ),
    145                             kCFRunLoopCommonModes );
     139    io_object_t iterator;
     140    if (fRootPort = IORegisterForSystemPower(self, & notify, sleepCallBack, & iterator))
     141    {
     142        CFRunLoopAddSource(CFRunLoopGetCurrent(), IONotificationPortGetRunLoopSource(notify),
     143                            kCFRunLoopCommonModes);
    146144    }
    147145    else
     
    260258                    @"There are %d active transfers. Do you really want to quit?", active];
    261259
    262             NSBeginAlertSheet(@"Confirm Quit",
    263                                 @"Quit", @"Cancel", nil,
    264                                 fWindow, self,
     260            NSBeginAlertSheet(@"Confirm Quit", @"Quit", @"Cancel", nil, fWindow, self,
    265261                                @selector(quitSheetDidEnd:returnCode:contextInfo:),
    266262                                nil, nil, message);
     
    317313}
    318314
    319 - (void) folderChoiceClosed: (NSOpenPanel *) s returnCode: (int) code
     315- (void) folderChoiceClosed: (NSOpenPanel *) openPanel returnCode: (int) code
    320316    contextInfo: (Torrent *) torrent
    321317{
    322318    if (code == NSOKButton)
    323319    {
    324         [torrent setDownloadFolder: [[s filenames] objectAtIndex: 0]];
     320        [torrent setDownloadFolder: [[openPanel filenames] objectAtIndex: 0]];
    325321        if ([fDefaults boolForKey: @"AutoStartDownload"])
    326322            [torrent start];
     
    423419- (void) open: (NSArray *) files
    424420{
    425     [self performSelectorOnMainThread: @selector(cantFindAName:)
    426                 withObject: files waitUntilDone: NO];
     421    [self performSelectorOnMainThread: @selector(openFromSheet:) withObject: files waitUntilDone: NO];
    427422}
    428423
     
    470465    unsigned int i;
    471466    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    472     {
    473         torrent = [fTorrents objectAtIndex: i];
    474         [torrent start];
    475     }
     467        [[fTorrents objectAtIndex: i] start];
    476468   
    477469    [self updateUI: nil];
     
    492484- (void) stopTorrentWithIndex: (NSIndexSet *) indexSet
    493485{
     486    unsigned int i;
    494487    Torrent * torrent;
    495     unsigned int i;
    496488    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    497489    {
     
    521513            torrents, @"Torrents",
    522514            [NSNumber numberWithBool: deleteData], @"DeleteData",
    523             [NSNumber numberWithBool: deleteTorrent], @"DeleteTorrent",
    524             nil];
     515            [NSNumber numberWithBool: deleteTorrent], @"DeleteTorrent", nil];
    525516
    526517        NSString * title, * message;
     
    551542        NSBeginAlertSheet(title,
    552543            @"Remove", @"Cancel", nil, fWindow, self,
    553             @selector(removeSheetDidEnd:returnCode:contextInfo:),
    554             nil, dict, message);
     544            @selector(removeSheetDidEnd:returnCode:contextInfo:), nil, dict, message);
    555545    }
    556546    else
     
    723713    NSEnumerator * enumerator = [fTorrents objectEnumerator];
    724714    Torrent * torrent;
    725     while( ( torrent = [enumerator nextObject] ) )
     715    while ((torrent = [enumerator nextObject]))
    726716    {
    727717        [torrent update];
    728718
    729         if( [torrent justFinished] )
     719        if ([torrent justFinished])
    730720        {
    731             /* Notifications */
     721            //notifications
    732722            [self notifyGrowl: [torrent name]];
    733             if( ![fWindow isKeyWindow] )
     723            if (![fWindow isKeyWindow])
    734724                fCompleted++;
    735725        }
     
    741731        [fTableView reloadData];
    742732   
    743     //Update the global DL/UL rates
     733    //update the global DL/UL rates
    744734    float downloadRate, uploadRate;
    745735    tr_torrentRates(fLib, & downloadRate, & uploadRate);
     
    11271117        Torrent * torrent;
    11281118        NSEnumerator * enumerator = [fTorrents objectEnumerator];
    1129         while( ( torrent = [enumerator nextObject] ) )
    1130             if( [torrent isActive] )
     1119        while ((torrent = [enumerator nextObject]))
     1120            if ([torrent isActive])
    11311121                return YES;
    11321122        return NO;
     
    11381128        Torrent * torrent;
    11391129        NSEnumerator * enumerator = [fTorrents objectEnumerator];
    1140         while( ( torrent = [enumerator nextObject] ) )
    1141             if( [torrent isPaused] )
     1130        while ((torrent = [enumerator nextObject]))
     1131            if ([torrent isPaused])
    11421132                return YES;
    11431133        return NO;
     
    11521142       
    11531143        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    1154         {
    1155             torrent = [fTorrents objectAtIndex: i];
    1156             if ([torrent isActive])
     1144            if ([[fTorrents objectAtIndex: i] isActive])
    11571145                return YES;
    1158         }
    11591146        return NO;
    11601147    }
     
    11631150    if ([ident isEqualToString: TOOLBAR_RESUME_SELECTED])
    11641151    {
    1165         Torrent * torrent;
    11661152        NSIndexSet * indexSet = [fTableView selectedRowIndexes];
    11671153        unsigned int i;
    11681154       
    11691155        for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
    1170         {
    1171             torrent = [fTorrents objectAtIndex: i];
    1172             if ([torrent isPaused])
     1156            if ([[fTorrents objectAtIndex: i] isPaused])
    11731157                return YES;
    1174         }
    11751158        return NO;
    11761159    }
     
    12151198        Torrent * torrent;
    12161199        NSEnumerator * enumerator = [fTorrents objectEnumerator];
    1217         while( ( torrent = [enumerator nextObject] ) )
    1218             if( [torrent isPaused] )
     1200        while ((torrent = [enumerator nextObject]))
     1201            if ([torrent isPaused])
    12191202                return YES;
    12201203        return NO;
     
    12261209        Torrent * torrent;
    12271210        NSEnumerator * enumerator = [fTorrents objectEnumerator];
    1228         while( ( torrent = [enumerator nextObject] ) )
    1229             if( [torrent isActive] )
     1211        while ((torrent = [enumerator nextObject]))
     1212            if ([torrent isActive])
    12301213                return YES;
    12311214        return NO;
     
    12421225    {
    12431226        BOOL active = NO,
    1244             canDelete = !(action == @selector(removeDeleteTorrent:)
    1245                             || action == @selector(removeDeleteBoth:));
     1227            canDelete = action != @selector(removeDeleteTorrent:) && action != @selector(removeDeleteBoth:);
    12461228        Torrent * torrent;
    12471229        NSIndexSet * indexSet = [fTableView selectedRowIndexes];
     
    12751257        {
    12761258            if ([title hasSuffix: ellipsis])
    1277                 [menuItem setTitle: [title substringToIndex:
    1278                             [title rangeOfString: ellipsis].location]];
     1259                [menuItem setTitle: [title substringToIndex: [title rangeOfString: ellipsis].location]];
    12791260        }
    12801261       
     
    14411422    NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
    14421423    NSDictionary * error;
    1443     if (![appleScript executeAndReturnError: &error])
     1424    if (![appleScript executeAndReturnError: & error])
    14441425        NSLog(@"Growl notify failed");
    14451426    [appleScript release];
     
    14651446    NSAppleScript * appleScript = [[NSAppleScript alloc] initWithSource: growlScript];
    14661447    NSDictionary * error;
    1467     if (![appleScript executeAndReturnError: &error])
     1448    if (![appleScript executeAndReturnError: & error])
    14681449        NSLog(@"Growl registration failed");
    14691450    [appleScript release];
  • trunk/macosx/FileTableView.m

    r376 r421  
    4040    {
    4141        if (![self isRowSelected: row])
    42             [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]
    43                 byExtendingSelection: NO];
     42            [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
    4443    }
    4544    else
  • trunk/macosx/PrefsController.m

    r394 r421  
    2626#import "StringAdditions.h"
    2727
    28 #define MIN_PORT            1
    29 #define MAX_PORT            65535
     28#define MIN_PORT    1
     29#define MAX_PORT    65535
    3030
    3131#define DOWNLOAD_FOLDER     0
     
    3333#define DOWNLOAD_ASK        3
    3434
    35 #define UPDATE_DAILY        0
    36 #define UPDATE_WEEKLY       1
    37 #define UPDATE_NEVER        2
     35#define UPDATE_DAILY    0
     36#define UPDATE_WEEKLY   1
     37#define UPDATE_NEVER    2
    3838
    3939#define TOOLBAR_GENERAL     @"General"
     
    4949- (void) setPrefView: (NSView *) view;
    5050
    51 - (void) folderSheetClosed: (NSOpenPanel *) s returnCode: (int) code
    52                                 contextInfo: (void *) info;
     51- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info;
    5352- (void) updatePopUp;
    5453
     
    8685   
    8786    //set download folder
    88     NSString * downloadChoice  = [fDefaults stringForKey: @"DownloadChoice"];
     87    NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
    8988    fDownloadFolder = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
    9089    [fDownloadFolder retain];
     
    101100    int bindPort = [fDefaults integerForKey: @"BindPort"];
    102101    [fPortField setIntValue: bindPort];
    103     fHandle = handle;
    104     tr_setBindPort( fHandle, bindPort );
     102    tr_setBindPort(fHandle, bindPort);
    105103   
    106104    //checks for old version upload speed of -1
     
    119117    [fUploadField setEnabled: checkUpload];
    120118   
    121     tr_setUploadLimit( fHandle, checkUpload ? uploadLimit : -1 );
     119    tr_setUploadLimit(fHandle, checkUpload ? uploadLimit : -1);
    122120
    123121        //set download limit
     
    129127    [fDownloadField setEnabled: checkDownload];
    130128   
    131     tr_setDownloadLimit( fHandle, checkDownload ? downloadLimit : -1 );
     129    tr_setDownloadLimit(fHandle, checkDownload ? downloadLimit : -1);
    132130   
    133131    //set ratio limit
     
    254252
    255253    int limit = [sender intValue];
    256     if (![[sender stringValue] isEqualToString:
    257             [NSString stringWithFormat: @"%d", limit]]
     254    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%d", limit]]
    258255            || limit < 0)
    259256    {
     
    264261    else
    265262    {
    266         if( sender == fUploadField )
    267             tr_setUploadLimit( fHandle,
    268                 ( [fUploadCheck state] == NSOffState ) ? -1 : limit );
     263        if (sender == fUploadField)
     264            tr_setUploadLimit(fHandle, [fUploadCheck state] == NSOffState ? -1 : limit);
    269265        else
    270             tr_setDownloadLimit( fHandle,
    271                 ( [fDownloadCheck state] == NSOffState ) ? -1 : limit );
     266            tr_setDownloadLimit(fHandle, [fDownloadCheck state] == NSOffState ? -1 : limit);
    272267       
    273268        [fDefaults setInteger: limit forKey: key];
     
    278273                                    [NSNumber numberWithInt: limit], @"Limit",
    279274                                    type, @"Type", nil];
    280     [[NSNotificationCenter defaultCenter] postNotificationName:
    281                             @"LimitGlobalChange" object: dict];
     275    [[NSNotificationCenter defaultCenter] postNotificationName: @"LimitGlobalChange" object: dict];
    282276}
    283277
     
    306300- (void) setLimitEnabled: (BOOL) enable type: (NSString *) type
    307301{
    308     NSButton * check = [type isEqualToString: @"Upload"]
    309                         ? fUploadCheck : fDownloadCheck;
     302    NSButton * check = [type isEqualToString: @"Upload"] ? fUploadCheck : fDownloadCheck;
    310303    [check setState: enable ? NSOnState : NSOffState];
    311304    [self setLimitCheck: check];
     
    332325{
    333326    float ratioLimit = [sender floatValue];
    334     if (![[sender stringValue] isEqualToString:
    335             [NSString stringWithFormat: @"%.2f", ratioLimit]]
     327    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]]
    336328            || ratioLimit < 0)
    337329    {
     
    346338                                    [NSNumber numberWithBool: [fRatioCheck state]], @"Enable",
    347339                                    [NSNumber numberWithFloat: ratioLimit], @"Ratio", nil];
    348     [[NSNotificationCenter defaultCenter] postNotificationName:
    349                                 @"RatioGlobalChange" object: dict];
     340    [[NSNotificationCenter defaultCenter] postNotificationName: @"RatioGlobalChange" object: dict];
    350341}
    351342
     
    443434{
    444435    //Download folder
    445     switch( [fFolderPopUp indexOfSelectedItem] )
     436    switch ([fFolderPopUp indexOfSelectedItem])
    446437    {
    447438        case DOWNLOAD_FOLDER:
     
    466457    NSOpenPanel * panel = [NSOpenPanel openPanel];
    467458
    468     [panel setPrompt:                  @"Select"];
    469     [panel setAllowsMultipleSelection:        NO];
    470     [panel setCanChooseFiles:                 NO];
    471     [panel setCanChooseDirectories:          YES];
     459    [panel setPrompt: @"Select"];
     460    [panel setAllowsMultipleSelection: NO];
     461    [panel setCanChooseFiles: NO];
     462    [panel setCanChooseDirectories: YES];
    472463
    473464    [panel beginSheetForDirectory: nil file: nil types: nil
     
    513504}
    514505
    515 - (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code
    516     contextInfo: (void *) info
     506- (void) folderSheetClosed: (NSOpenPanel *) openPanel returnCode: (int) code contextInfo: (void *) info
    517507{
    518508   if (code == NSOKButton)
     
    532522       //reset if cancelled
    533523       NSString * downloadChoice = [fDefaults stringForKey: @"DownloadChoice"];
    534        if( [downloadChoice isEqualToString: @"Constant"] )
    535        {
     524       if ([downloadChoice isEqualToString: @"Constant"])
    536525           [fFolderPopUp selectItemAtIndex: DOWNLOAD_FOLDER];
    537        }
    538        else if( [downloadChoice isEqualToString: @"Torrent"] )
    539        {
     526       else if ([downloadChoice isEqualToString: @"Torrent"])
    540527           [fFolderPopUp selectItemAtIndex: DOWNLOAD_TORRENT];
    541        }
    542528       else
    543        {
    544529           [fFolderPopUp selectItemAtIndex: DOWNLOAD_ASK];
    545        }
    546530   }
    547531}
  • trunk/macosx/StringAdditions.m

    r357 r421  
    6969    if (size < 10240)
    7070        /* 1.00 to 9.99 XB */
    71         value = [NSString stringWithFormat: @"%lld.%02lld",
    72                     size / 1024, ( size % 1024 ) * 100 / 1024];
     71        value = [NSString stringWithFormat: @"%lld.%02lld", size / 1024, ( size % 1024 ) * 100 / 1024];
    7372    else if (size < 102400)
    7473        /* 10.0 to 99.9 XB */
    75         value = [NSString stringWithFormat: @"%lld.%lld",
    76                     size / 1024, ( size % 1024 ) * 10 / 1024];
     74        value = [NSString stringWithFormat: @"%lld.%lld", size / 1024, ( size % 1024 ) * 10 / 1024];
    7775    else
    7876        /* 100+ XB */
     
    8482+ (NSString *) stringForSpeed: (float) speed
    8583{
    86     return [[self stringForSpeedAbbrev: speed]
    87         stringByAppendingString: @"B/s"];
     84    return [[self stringForSpeedAbbrev: speed] stringByAppendingString: @"B/s"];
    8885}
    8986
  • trunk/macosx/Torrent.h

    r418 r421  
    101101
    102102- (float)   progress;
     103- (int)     eta;
     104
    103105- (BOOL)    isActive;
    104106- (BOOL)    isSeeding;
  • trunk/macosx/Torrent.m

    r419 r421  
    4242- (id) initWithPath: (NSString *) path lib: (tr_handle_t *) lib
    4343{
    44     self = [self initWithHash: nil path: path lib: lib
    45             privateTorrent: nil publicTorrent: nil
     44    self = [self initWithHash: nil path: path lib: lib privateTorrent: nil publicTorrent: nil
    4645            date: nil stopRatioSetting: nil ratioLimit: nil];
    4746   
     
    6867        NSString * downloadFolder;
    6968        if (!(downloadFolder = [history objectForKey: @"DownloadFolder"]))
    70             downloadFolder = [[fDefaults stringForKey: @"DownloadFolder"]
    71                                 stringByExpandingTildeInPath];
     69            downloadFolder = [[fDefaults stringForKey: @"DownloadFolder"] stringByExpandingTildeInPath];
    7270        [self setDownloadFolder: downloadFolder];
    7371
     
    10199- (void) dealloc
    102100{
    103     if( fHandle )
    104     {
    105         tr_torrentClose( fLib, fHandle );
     101    if (fHandle)
     102    {
     103        tr_torrentClose(fLib, fHandle);
    106104       
    107105        if (fPublicTorrentLocation)
     
    119117- (void) setDownloadFolder: (NSString *) path
    120118{
    121     tr_torrentSetFolder( fHandle, [path UTF8String] );
     119    tr_torrentSetFolder(fHandle, [path UTF8String]);
    122120}
    123121
    124122- (NSString *) downloadFolder
    125123{
    126     return [NSString stringWithUTF8String: tr_torrentGetFolder( fHandle )];
     124    return [NSString stringWithUTF8String: tr_torrentGetFolder(fHandle)];
    127125}
    128126
    129127- (void) getAvailability: (int8_t *) tab size: (int) size
    130128{
    131     tr_torrentAvailability( fHandle, tab, size );
     129    tr_torrentAvailability(fHandle, tab, size);
    132130}
    133131
    134132- (void) update
    135133{
    136     fStat = tr_torrentStat( fHandle );
    137    
    138     if ([self isSeeding]
    139         && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
     134    fStat = tr_torrentStat(fHandle);
     135   
     136    if ([self isSeeding] && ((fStopRatioSetting == RATIO_CHECK && [self ratio] >= fRatioLimit)
    140137            || (fStopRatioSetting == RATIO_GLOBAL && [fDefaults boolForKey: @"RatioCheck"]
    141138            && [self ratio] >= [fDefaults floatForKey: @"RatioLimit"])))
     
    145142        fFinishedSeeding = YES;
    146143       
    147         fStat = tr_torrentStat( fHandle );
     144        fStat = tr_torrentStat(fHandle);
    148145       
    149146        [[NSNotificationCenter defaultCenter] postNotificationName: @"TorrentRatioChanged" object: self];
     
    159156                [NSString stringForRatioWithDownload: [self downloadedTotal] upload: [self uploadedTotal]]];
    160157
    161     switch( fStat->status )
     158    switch (fStat->status)
    162159    {
    163160        case TR_STATUS_PAUSE:
     
    172169            [fStatusString setString: @""];
    173170            [fStatusString appendFormat:
    174                 @"Downloading from %d of %d peer%s",
    175                 [self peersUploading], [self totalPeers],
     171                @"Downloading from %d of %d peer%s", [self peersUploading], [self totalPeers],
    176172                ([self totalPeers] == 1) ? "" : "s"];
    177173           
    178             int eta = fStat->eta;
     174            int eta = [self eta];
    179175            if (eta < 0)
    180176                [fProgressString appendString: @" - remaining time unknown"];
     
    223219- (void) start
    224220{
    225     if( fStat->status & TR_STATUS_INACTIVE )
    226     {
    227         tr_torrentStart( fHandle );
     221    if (![self isActive])
     222    {
     223        tr_torrentStart(fHandle);
    228224        fFinishedSeeding = NO;
    229225    }
     
    232228- (void) stop
    233229{
    234     if( fStat->status & TR_STATUS_ACTIVE )
    235     {
    236         tr_torrentStop( fHandle );
    237     }
     230    if ([self isActive])
     231        tr_torrentStop(fHandle);
    238232}
    239233
     
    246240- (void) sleep
    247241{
    248     if( ( fResumeOnWake = ( fStat->status & TR_STATUS_ACTIVE ) ) )
    249     {
     242    if ((fResumeOnWake = [self isActive]))
    250243        [self stop];
    251     }
    252244}
    253245
    254246- (void) wakeUp
    255247{
    256     if( fResumeOnWake )
    257     {
     248    if (fResumeOnWake)
    258249        [self start];
    259     }
    260250}
    261251
     
    289279- (void) reveal
    290280{
    291     [[NSWorkspace sharedWorkspace] selectFile: [self dataLocation]
    292         inFileViewerRootedAtPath: nil];
     281    [[NSWorkspace sharedWorkspace] selectFile: [self dataLocation] inFileViewerRootedAtPath: nil];
    293282}
    294283
     
    326315- (NSString *) tracker
    327316{
    328     return [NSString stringWithFormat: @"%s:%d",
    329             fInfo->trackerAddress, fInfo->trackerPort];
     317    return [NSString stringWithFormat: @"%s:%d", fInfo->trackerAddress, fInfo->trackerPort];
    330318}
    331319
     
    415403}
    416404
     405- (int) eta
     406{
     407    return fStat->eta;
     408}
     409
    417410- (BOOL) isActive
    418411{
    419     return ( fStat->status & TR_STATUS_ACTIVE );
     412    return fStat->status & TR_STATUS_ACTIVE;
    420413}
    421414
    422415- (BOOL) isSeeding
    423416{
    424     return ( fStat->status == TR_STATUS_SEED );
     417    return fStat->status == TR_STATUS_SEED;
    425418}
    426419
    427420- (BOOL) isPaused
    428421{
    429     return ( fStat->status == TR_STATUS_PAUSE );
     422    return fStat->status == TR_STATUS_PAUSE;
    430423}
    431424
    432425- (BOOL) justFinished
    433426{
    434     return tr_getFinished( fHandle );
     427    return tr_getFinished(fHandle);
    435428}
    436429
     
    514507- (NSNumber *) stateSortKey
    515508{
    516     if (fStat->status & TR_STATUS_INACTIVE)
     509    if (![self isActive])
    517510        return [NSNumber numberWithInt: 0];
    518     else if (fStat->status == TR_STATUS_SEED)
     511    else if ([self isSeeding])
    519512        return [NSNumber numberWithInt: 1];
    520513    else
     
    572565    fFinishedSeeding = NO;
    573566   
    574     NSString * fileType = fInfo->multifile ?
    575         NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension];
     567    NSString * fileType = fInfo->multifile ? NSFileTypeForHFSTypeCode('fldr') : [[self name] pathExtension];
    576568    fIcon = [[NSWorkspace sharedWorkspace] iconForFileType: fileType];
    577569    [fIcon retain];
  • trunk/macosx/TorrentTableView.m

    r419 r421  
    7171}
    7272
    73 - (void) mouseDown: (NSEvent *) e
    74 {
    75     fClickPoint = [self convertPoint: [e locationInWindow] fromView: nil];
    76     int row = [self rowAtPoint: fClickPoint];
    77 
    78     if( [e modifierFlags] & NSAlternateKeyMask )
     73- (void) mouseDown: (NSEvent *) event
     74{
     75    fClickPoint = [self convertPoint: [event locationInWindow] fromView: nil];
     76
     77    if ([event modifierFlags] & NSAlternateKeyMask)
    7978    {
    8079        [fController advancedChanged: self];
    81         fClickPoint = NSMakePoint( 0, 0 );
    82     }
    83     else if( ![self pointInPauseRect: fClickPoint] &&
    84              ![self pointInRevealRect: fClickPoint] )
    85         [super mouseDown: e];
     80        fClickPoint = NSZeroPoint;
     81    }
     82    else if (![self pointInPauseRect: fClickPoint] && ![self pointInRevealRect: fClickPoint])
     83        [super mouseDown: event];
    8684    else;
    8785
     
    8987}
    9088
    91 - (void) mouseUp: (NSEvent *) e
    92 {
    93     NSPoint point;
    94     int row;
    95     bool sameRow;
    96     Torrent * torrent;
    97 
    98     point = [self convertPoint: [e locationInWindow] fromView: nil];
    99     row   = [self rowAtPoint: point];
    100     sameRow = row == [self rowAtPoint: fClickPoint];
    101    
    102     if( sameRow && [self pointInPauseRect: point]
    103             && [self pointInPauseRect: fClickPoint] )
    104     {
    105         torrent = [fTorrents objectAtIndex: row];
    106 
    107                 if( [torrent isPaused] )
     89- (void) mouseUp: (NSEvent *) event
     90{
     91    NSPoint point = [self convertPoint: [event locationInWindow] fromView: nil];
     92    int row = [self rowAtPoint: point];
     93    BOOL sameRow = row == [self rowAtPoint: fClickPoint];
     94   
     95    if (sameRow && [self pointInPauseRect: point] && [self pointInPauseRect: fClickPoint])
     96    {
     97        Torrent * torrent = [fTorrents objectAtIndex: row];
     98
     99                if ([torrent isPaused])
    108100                        [fController resumeTorrentWithIndex: [NSIndexSet indexSetWithIndex: row]];
    109                 else if( [torrent isActive] )
     101                else if ([torrent isActive])
    110102                        [fController stopTorrentWithIndex: [NSIndexSet indexSetWithIndex: row]];
    111103                else;
    112104    }
    113     else if( sameRow && [self pointInRevealRect: point]
    114                 && [self pointInRevealRect: fClickPoint] )
     105    else if (sameRow && [self pointInRevealRect: point] && [self pointInRevealRect: fClickPoint])
    115106        [[fTorrents objectAtIndex: row] reveal];
    116         else if ([e clickCount] == 2)
     107        else if ([event clickCount] == 2)
    117108    {
    118109        if ([self pointInIconRect: point])
     
    123114    else;
    124115   
    125         [super mouseUp: e];
    126 
    127     fClickPoint = NSMakePoint( 0, 0 );
     116        [super mouseUp: event];
     117
     118    fClickPoint = NSZeroPoint;
    128119    [self display];
    129120}
    130121
    131 - (NSMenu *) menuForEvent: (NSEvent *) e
    132 {
    133     int row = [self rowAtPoint: [self convertPoint: [e locationInWindow] fromView: nil]];
     122- (NSMenu *) menuForEvent: (NSEvent *) event
     123{
     124    int row = [self rowAtPoint: [self convertPoint: [event locationInWindow] fromView: nil]];
    134125   
    135126    if (row >= 0)
    136127    {
    137128        if (![self isRowSelected: row])
    138             [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row]
    139                 byExtendingSelection: NO];
     129            [self selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
    140130               
    141131        return fContextRow;
     
    150140- (void) drawRect: (NSRect) r
    151141{
    152     unsigned i;
    153142    NSRect rect;
     143    Torrent * torrent;
    154144    NSImage * image;
    155     Torrent * torrent;
    156145
    157146    [super drawRect: r];
    158147
    159     for( i = 0; i < [fTorrents count]; i++ )
     148    int i;
     149    for (i = 0; i < [fTorrents count]; i++)
    160150    {
    161151        torrent = [fTorrents objectAtIndex: i];
     
    172162        {
    173163            [image setFlipped: YES];
    174             [image drawAtPoint: rect.origin fromRect:
    175                 NSMakeRect(0, 0, BUTTON_WIDTH, BUTTON_WIDTH) operation:
    176                 NSCompositeSourceOver fraction: 1.0];
     164            [image drawAtPoint: rect.origin fromRect: NSMakeRect(0, 0, BUTTON_WIDTH, BUTTON_WIDTH)
     165                operation: NSCompositeSourceOver fraction: 1.0];
    177166        }
    178167
     
    180169        image = NSPointInRect(fClickPoint, rect) ? fRevealOnIcon : fRevealOffIcon;
    181170        [image setFlipped: YES];
    182         [image drawAtPoint: rect.origin fromRect:
    183             NSMakeRect(0, 0, BUTTON_WIDTH, BUTTON_WIDTH) operation:
    184             NSCompositeSourceOver fraction: 1.0];
     171        [image drawAtPoint: rect.origin fromRect: NSMakeRect(0, 0, BUTTON_WIDTH, BUTTON_WIDTH)
     172            operation: NSCompositeSourceOver fraction: 1.0];
    185173    }
    186174}
     
    192180- (NSRect) pauseRectForRow: (int) row
    193181{
    194     NSRect cellRect = [self frameOfCellAtColumn:
    195                 [self columnWithIdentifier: @"Torrent"] row: row];
     182    NSRect cellRect = [self frameOfCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: row];
    196183               
    197184    return NSMakeRect(cellRect.origin.x + cellRect.size.width
     
    202189- (NSRect) revealRectForRow: (int) row
    203190{
    204     NSRect cellRect = [self frameOfCellAtColumn:
    205                 [self columnWithIdentifier: @"Torrent"] row: row];
    206    
    207     return NSMakeRect(cellRect.origin.x + cellRect.size.width
    208                         - AREA_CENTER + DISTANCE_FROM_CENTER,
     191    NSRect cellRect = [self frameOfCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: row];
     192   
     193    return NSMakeRect(cellRect.origin.x + cellRect.size.width - AREA_CENTER + DISTANCE_FROM_CENTER,
    209194                        cellRect.origin.y + BUTTON_TO_TOP, BUTTON_WIDTH, BUTTON_WIDTH);
    210195}
     
    216201        return NO;
    217202   
    218     NSRect cellRect = [self frameOfCellAtColumn:
    219                 [self columnWithIdentifier: @"Torrent"] row: row];
     203    NSRect cellRect = [self frameOfCellAtColumn: [self columnWithIdentifier: @"Torrent"] row: row];
    220204    NSSize iconSize = [[[fTorrents objectAtIndex: row] iconFlipped] size];
    221205   
    222206    NSRect iconRect = NSMakeRect(cellRect.origin.x + 3.0, cellRect.origin.y
    223                         + (cellRect.size.height - iconSize.height) * 0.5,
    224                         iconSize.width, iconSize.height);
     207            + (cellRect.size.height - iconSize.height) * 0.5, iconSize.width, iconSize.height);
    225208   
    226209    return NSPointInRect(point, iconRect);
Note: See TracChangeset for help on using the changeset viewer.