Changeset 9842


Ignore:
Timestamp:
Dec 31, 2009, 3:19:54 AM (12 years ago)
Author:
livings124
Message:

some more insignificant changes I have sitting around locally

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r9839 r9842  
    11261126        const uint64_t b = isSeed ? tor->info.files[i].length : fileBytesCompleted( tor, i );
    11271127        walk->bytesCompleted = b;
    1128         walk->progress = tor->info.files[i].length > 0.0 ? ( (float)b / tor->info.files[i].length ) : 1.0;
     1128        walk->progress = tor->info.files[i].length > 0 ? ( (float)b / tor->info.files[i].length ) : 1.0;
    11291129    }
    11301130
  • trunk/macosx/AboutWindowController.m

    r9812 r9842  
    4848   
    4949    //size license button
    50     const CGFloat oldButtonWidth = [fLicenseButton frame].size.width;
     50    const CGFloat oldButtonWidth = NSWidth([fLicenseButton frame]);
    5151   
    5252    [fLicenseButton setTitle: NSLocalizedString(@"License", "About window -> license button")];
  • trunk/macosx/FileNameCell.m

    r9828 r9842  
    3030#import "NSStringAdditions.h"
    3131
    32 #define PADDING_HORIZONAL 2.0f
    33 #define IMAGE_FOLDER_SIZE 16.0f
    34 #define IMAGE_ICON_SIZE 32.0f
    35 #define PADDING_BETWEEN_IMAGE_AND_TITLE 4.0f
    36 #define PADDING_ABOVE_TITLE_FILE 2.0f
    37 #define PADDING_BELOW_STATUS_FILE 2.0f
    38 #define PADDING_BETWEEN_NAME_AND_FOLDER_STATUS 4.0f
     32#define PADDING_HORIZONAL 2.0
     33#define IMAGE_FOLDER_SIZE 16.0
     34#define IMAGE_ICON_SIZE 32.0
     35#define PADDING_BETWEEN_IMAGE_AND_TITLE 4.0
     36#define PADDING_ABOVE_TITLE_FILE 2.0
     37#define PADDING_BELOW_STATUS_FILE 2.0
     38#define PADDING_BETWEEN_NAME_AND_FOLDER_STATUS 4.0
    3939
    4040@interface FileNameCell (Private)
     
    5858       
    5959        fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    60                             [NSFont messageFontOfSize: 12.0f], NSFontAttributeName,
     60                            [NSFont messageFontOfSize: 12.0], NSFontAttributeName,
    6161                            paragraphStyle, NSParagraphStyleAttributeName, nil];
    6262       
    6363        fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
    64                                 [NSFont messageFontOfSize: 9.0f], NSFontAttributeName,
     64                                [NSFont messageFontOfSize: 9.0], NSFontAttributeName,
    6565                                paragraphStyle, NSParagraphStyleAttributeName, nil];
    6666       
     
    101101   
    102102    const CGFloat IMAGE_SIZE = [(FileListNode *)[self objectValue] isFolder] ? IMAGE_FOLDER_SIZE : IMAGE_ICON_SIZE;
    103     result.origin.y += (result.size.height - IMAGE_SIZE) * 0.5f;
     103    result.origin.y += (result.size.height - IMAGE_SIZE) * 0.5;
    104104    result.size = NSMakeSize(IMAGE_SIZE, IMAGE_SIZE);
    105105   
     
    151151- (NSRect) rectForTitleWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
    152152{
    153     NSSize titleSize = [string size];
    154    
    155     NSRect result = bounds;
    156    
    157     if (![(FileListNode *)[self objectValue] isFolder])
    158     {
    159         result.origin.x += PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
    160         result.origin.y += PADDING_ABOVE_TITLE_FILE;
    161     }
    162     else
    163     {
    164         result.origin.x += PADDING_HORIZONAL + IMAGE_FOLDER_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
    165         result.origin.y += (result.size.height - titleSize.height) * 0.5f;
    166     }
    167     result.size = titleSize;
    168     result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL);
    169    
    170     return result;
    171 }
    172 
    173 - (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds;
    174 {
    175     NSSize statusSize = [string size];
     153    const NSSize titleSize = [string size];
    176154   
    177155    NSRect result;
    178156    if (![(FileListNode *)[self objectValue] isFolder])
    179157    {
    180         result.origin.x = bounds.origin.x + PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
     158        result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
     159        result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE_FILE;
     160    }
     161    else
     162    {
     163        result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + IMAGE_FOLDER_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
     164        result.origin.y = NSMidY(bounds) - titleSize.height * 0.5;
     165    }
     166    result.size.height = titleSize.height;
     167    result.size.width = MIN(titleSize.width, NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONAL);
     168   
     169    return result;
     170}
     171
     172- (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds;
     173{
     174    const NSSize statusSize = [string size];
     175   
     176    NSRect result;
     177    if (![(FileListNode *)[self objectValue] isFolder])
     178    {
     179        result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
    181180        result.origin.y = NSMaxY(bounds) - PADDING_BELOW_STATUS_FILE - statusSize.height;
    182181    }
     
    184183    {
    185184        result.origin.x = NSMaxX(titleRect) + PADDING_BETWEEN_NAME_AND_FOLDER_STATUS;
    186         result.origin.y = NSMaxY(titleRect) - statusSize.height - 1.0f;
    187     }
    188        
    189     result.size = statusSize;
    190     result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL);
     185        result.origin.y = NSMaxY(titleRect) - statusSize.height - 1.0;
     186    }
     187       
     188    result.size.height = statusSize.height;
     189    result.size.width = NSMaxX(bounds) - NSMaxX(result) - PADDING_HORIZONAL;
    191190   
    192191    return result;
     
    204203    FileListNode * node = (FileListNode *)[self objectValue];
    205204   
    206     CGFloat progress = [torrent fileProgress: node];
    207     NSString * percentString = progress == 1.0f ? @"100%" : [NSString localizedStringWithFormat: @"%.2f%%", progress * 100.0f];
    208    
     205    const CGFloat progress = [torrent fileProgress: node];
     206    NSString * percentString = progress == 1.0 ? @"100%" : [NSString localizedStringWithFormat: @"%.2f%%", progress * 100.0];
    209207   
    210208    NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@",
  • trunk/macosx/FileOutlineController.m

    r9561 r9842  
    162162{
    163163    if ([[tableColumn identifier] isEqualToString: @"Check"])
    164         return [NSNumber numberWithInt: [fTorrent checkForFiles: [(FileListNode *)item indexes]]];
     164        return [NSNumber numberWithInteger: [fTorrent checkForFiles: [(FileListNode *)item indexes]]];
    165165    else
    166166        return item;
  • trunk/macosx/FilterButton.m

    r9491 r9842  
    3131    if ((self = [super initWithCoder: coder]))
    3232    {
    33         fCount = NSUIntegerMax;
     33        fCount = NSNotFound;
    3434    }
    3535    return self;
  • trunk/macosx/NSStringAdditions.m

    r9732 r9842  
    123123+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max
    124124{
     125    NSAssert(max > 0, @"Cannot generate a time string with no fields");
     126   
    125127    NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: MIN(max, 4)];
    126128    NSUInteger remaining = seconds; //causes problems for some users when it's a uint64_t
    127129   
    128     if (max > 0 && seconds >= (24 * 60 * 60))
     130    if (seconds >= (24 * 60 * 60))
    129131    {
    130132        const NSUInteger days = remaining / (24 * 60 * 60);
  • trunk/macosx/Torrent.m

    r9822 r9842  
    12521252- (void) checkGroupValueForRemoval: (NSNotification *) notification
    12531253{
    1254     if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Index"] intValue] == fGroupValue)
     1254    if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Index"] integerValue] == fGroupValue)
    12551255        fGroupValue = -1;
    12561256}
     
    16151615            tr_file * file = &fInfo->files[i];
    16161616           
    1617             NSMutableArray * pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
     1617            NSString * fullPath = [NSString stringWithUTF8String: file->name];
     1618            NSMutableArray * pathComponents = [[NSMutableArray alloc] initWithArray: [fullPath pathComponents]];
     1619            NSAssert1([pathComponents count] >= 2, @"Not enough components in path %@", fullPath);
     1620           
    16181621            NSString * path = [pathComponents objectAtIndex: 0];
    16191622            NSString * name = [pathComponents objectAtIndex: 1];
    1620             [pathComponents removeObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, 2)]];
    16211623           
    1622             if ([pathComponents count] > 0)
     1624            if ([pathComponents count] > 2)
    16231625            {
     1626                [pathComponents removeObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, 2)]];
     1627               
    16241628                //determine if folder node already exists
    16251629                FileListNode * node;
Note: See TracChangeset for help on using the changeset viewer.