mirror of
https://github.com/transmission/transmission
synced 2025-03-04 10:38:13 +00:00
some more insignificant changes I have sitting around locally
This commit is contained in:
parent
6529a78c9b
commit
f2bbae3fd8
7 changed files with 40 additions and 36 deletions
|
@ -1125,7 +1125,7 @@ tr_torrentFiles( const tr_torrent * tor,
|
|||
for( i=0; i<n; ++i, ++walk ) {
|
||||
const uint64_t b = isSeed ? tor->info.files[i].length : fileBytesCompleted( tor, i );
|
||||
walk->bytesCompleted = b;
|
||||
walk->progress = tor->info.files[i].length > 0.0 ? ( (float)b / tor->info.files[i].length ) : 1.0;
|
||||
walk->progress = tor->info.files[i].length > 0 ? ( (float)b / tor->info.files[i].length ) : 1.0;
|
||||
}
|
||||
|
||||
if( fileCount )
|
||||
|
|
|
@ -47,7 +47,7 @@ AboutWindowController * fAboutBoxInstance = nil;
|
|||
[[NSBundle mainBundle] pathForResource: @"Credits" ofType: @"rtf"] documentAttributes: nil] autorelease]];
|
||||
|
||||
//size license button
|
||||
const CGFloat oldButtonWidth = [fLicenseButton frame].size.width;
|
||||
const CGFloat oldButtonWidth = NSWidth([fLicenseButton frame]);
|
||||
|
||||
[fLicenseButton setTitle: NSLocalizedString(@"License", "About window -> license button")];
|
||||
[fLicenseButton sizeToFit];
|
||||
|
|
|
@ -29,13 +29,13 @@
|
|||
#import "NSApplicationAdditions.h"
|
||||
#import "NSStringAdditions.h"
|
||||
|
||||
#define PADDING_HORIZONAL 2.0f
|
||||
#define IMAGE_FOLDER_SIZE 16.0f
|
||||
#define IMAGE_ICON_SIZE 32.0f
|
||||
#define PADDING_BETWEEN_IMAGE_AND_TITLE 4.0f
|
||||
#define PADDING_ABOVE_TITLE_FILE 2.0f
|
||||
#define PADDING_BELOW_STATUS_FILE 2.0f
|
||||
#define PADDING_BETWEEN_NAME_AND_FOLDER_STATUS 4.0f
|
||||
#define PADDING_HORIZONAL 2.0
|
||||
#define IMAGE_FOLDER_SIZE 16.0
|
||||
#define IMAGE_ICON_SIZE 32.0
|
||||
#define PADDING_BETWEEN_IMAGE_AND_TITLE 4.0
|
||||
#define PADDING_ABOVE_TITLE_FILE 2.0
|
||||
#define PADDING_BELOW_STATUS_FILE 2.0
|
||||
#define PADDING_BETWEEN_NAME_AND_FOLDER_STATUS 4.0
|
||||
|
||||
@interface FileNameCell (Private)
|
||||
|
||||
|
@ -57,11 +57,11 @@
|
|||
[paragraphStyle setLineBreakMode: NSLineBreakByTruncatingTail];
|
||||
|
||||
fTitleAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSFont messageFontOfSize: 12.0f], NSFontAttributeName,
|
||||
[NSFont messageFontOfSize: 12.0], NSFontAttributeName,
|
||||
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
|
||||
fStatusAttributes = [[NSMutableDictionary alloc] initWithObjectsAndKeys:
|
||||
[NSFont messageFontOfSize: 9.0f], NSFontAttributeName,
|
||||
[NSFont messageFontOfSize: 9.0], NSFontAttributeName,
|
||||
paragraphStyle, NSParagraphStyleAttributeName, nil];
|
||||
|
||||
[paragraphStyle release];
|
||||
|
@ -100,7 +100,7 @@
|
|||
result.origin.x += PADDING_HORIZONAL;
|
||||
|
||||
const CGFloat IMAGE_SIZE = [(FileListNode *)[self objectValue] isFolder] ? IMAGE_FOLDER_SIZE : IMAGE_ICON_SIZE;
|
||||
result.origin.y += (result.size.height - IMAGE_SIZE) * 0.5f;
|
||||
result.origin.y += (result.size.height - IMAGE_SIZE) * 0.5;
|
||||
result.size = NSMakeSize(IMAGE_SIZE, IMAGE_SIZE);
|
||||
|
||||
return result;
|
||||
|
@ -150,44 +150,43 @@
|
|||
|
||||
- (NSRect) rectForTitleWithString: (NSAttributedString *) string inBounds: (NSRect) bounds
|
||||
{
|
||||
NSSize titleSize = [string size];
|
||||
|
||||
NSRect result = bounds;
|
||||
const NSSize titleSize = [string size];
|
||||
|
||||
NSRect result;
|
||||
if (![(FileListNode *)[self objectValue] isFolder])
|
||||
{
|
||||
result.origin.x += PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||
result.origin.y += PADDING_ABOVE_TITLE_FILE;
|
||||
result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||
result.origin.y = NSMinY(bounds) + PADDING_ABOVE_TITLE_FILE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.origin.x += PADDING_HORIZONAL + IMAGE_FOLDER_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||
result.origin.y += (result.size.height - titleSize.height) * 0.5f;
|
||||
result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + IMAGE_FOLDER_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||
result.origin.y = NSMidY(bounds) - titleSize.height * 0.5;
|
||||
}
|
||||
result.size = titleSize;
|
||||
result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL);
|
||||
result.size.height = titleSize.height;
|
||||
result.size.width = MIN(titleSize.width, NSMaxX(bounds) - NSMinX(result) - PADDING_HORIZONAL);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
- (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds;
|
||||
{
|
||||
NSSize statusSize = [string size];
|
||||
const NSSize statusSize = [string size];
|
||||
|
||||
NSRect result;
|
||||
if (![(FileListNode *)[self objectValue] isFolder])
|
||||
{
|
||||
result.origin.x = bounds.origin.x + PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||
result.origin.x = NSMinX(bounds) + PADDING_HORIZONAL + IMAGE_ICON_SIZE + PADDING_BETWEEN_IMAGE_AND_TITLE;
|
||||
result.origin.y = NSMaxY(bounds) - PADDING_BELOW_STATUS_FILE - statusSize.height;
|
||||
}
|
||||
else
|
||||
{
|
||||
result.origin.x = NSMaxX(titleRect) + PADDING_BETWEEN_NAME_AND_FOLDER_STATUS;
|
||||
result.origin.y = NSMaxY(titleRect) - statusSize.height - 1.0f;
|
||||
result.origin.y = NSMaxY(titleRect) - statusSize.height - 1.0;
|
||||
}
|
||||
|
||||
result.size = statusSize;
|
||||
result.size.width = MIN(result.size.width, NSMaxX(bounds) - result.origin.x - PADDING_HORIZONAL);
|
||||
result.size.height = statusSize.height;
|
||||
result.size.width = NSMaxX(bounds) - NSMaxX(result) - PADDING_HORIZONAL;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -203,9 +202,8 @@
|
|||
Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
|
||||
FileListNode * node = (FileListNode *)[self objectValue];
|
||||
|
||||
CGFloat progress = [torrent fileProgress: node];
|
||||
NSString * percentString = progress == 1.0f ? @"100%" : [NSString localizedStringWithFormat: @"%.2f%%", progress * 100.0f];
|
||||
|
||||
const CGFloat progress = [torrent fileProgress: node];
|
||||
NSString * percentString = progress == 1.0 ? @"100%" : [NSString localizedStringWithFormat: @"%.2f%%", progress * 100.0];
|
||||
|
||||
NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@",
|
||||
"Inspector -> Files tab -> file status string"), percentString, [NSString stringForFileSize: [node size]]];
|
||||
|
|
|
@ -161,7 +161,7 @@ typedef enum
|
|||
- (id) outlineView: (NSOutlineView *) outlineView objectValueForTableColumn: (NSTableColumn *) tableColumn byItem: (id) item
|
||||
{
|
||||
if ([[tableColumn identifier] isEqualToString: @"Check"])
|
||||
return [NSNumber numberWithInt: [fTorrent checkForFiles: [(FileListNode *)item indexes]]];
|
||||
return [NSNumber numberWithInteger: [fTorrent checkForFiles: [(FileListNode *)item indexes]]];
|
||||
else
|
||||
return item;
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
{
|
||||
if ((self = [super initWithCoder: coder]))
|
||||
{
|
||||
fCount = NSUIntegerMax;
|
||||
fCount = NSNotFound;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
|
@ -122,10 +122,12 @@
|
|||
|
||||
+ (NSString *) timeString: (uint64_t) seconds showSeconds: (BOOL) showSeconds maxFields: (NSUInteger) max
|
||||
{
|
||||
NSAssert(max > 0, @"Cannot generate a time string with no fields");
|
||||
|
||||
NSMutableArray * timeArray = [NSMutableArray arrayWithCapacity: MIN(max, 4)];
|
||||
NSUInteger remaining = seconds; //causes problems for some users when it's a uint64_t
|
||||
|
||||
if (max > 0 && seconds >= (24 * 60 * 60))
|
||||
if (seconds >= (24 * 60 * 60))
|
||||
{
|
||||
const NSUInteger days = remaining / (24 * 60 * 60);
|
||||
if (days == 1)
|
||||
|
|
|
@ -1251,7 +1251,7 @@ int trashDataFile(const char * filename)
|
|||
|
||||
- (void) checkGroupValueForRemoval: (NSNotification *) notification
|
||||
{
|
||||
if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Index"] intValue] == fGroupValue)
|
||||
if (fGroupValue != -1 && [[[notification userInfo] objectForKey: @"Index"] integerValue] == fGroupValue)
|
||||
fGroupValue = -1;
|
||||
}
|
||||
|
||||
|
@ -1614,13 +1614,17 @@ int trashDataFile(const char * filename)
|
|||
{
|
||||
tr_file * file = &fInfo->files[i];
|
||||
|
||||
NSMutableArray * pathComponents = [[[NSString stringWithUTF8String: file->name] pathComponents] mutableCopy];
|
||||
NSString * fullPath = [NSString stringWithUTF8String: file->name];
|
||||
NSMutableArray * pathComponents = [[NSMutableArray alloc] initWithArray: [fullPath pathComponents]];
|
||||
NSAssert1([pathComponents count] >= 2, @"Not enough components in path %@", fullPath);
|
||||
|
||||
NSString * path = [pathComponents objectAtIndex: 0];
|
||||
NSString * name = [pathComponents objectAtIndex: 1];
|
||||
[pathComponents removeObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, 2)]];
|
||||
|
||||
if ([pathComponents count] > 0)
|
||||
if ([pathComponents count] > 2)
|
||||
{
|
||||
[pathComponents removeObjectsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, 2)]];
|
||||
|
||||
//determine if folder node already exists
|
||||
FileListNode * node;
|
||||
for (node in fileList)
|
||||
|
|
Loading…
Add table
Reference in a new issue