more string fiddling and minor badger changes

This commit is contained in:
Mitchell Livingston 2008-04-01 15:24:35 +00:00
parent 85c57c00cb
commit 9dc92d4d3b
5 changed files with 23 additions and 16 deletions

View File

@ -64,7 +64,7 @@
{
NSImage * quitBadge = [NSImage imageNamed: @"QuitBadge.png"];
[self badge: quitBadge string: NSLocalizedString(@"Quitting", "Dock Badger -> quit")
atHeight: (rect.size.height - [quitBadge size].height) * 0.5];
atHeight: (rect.size.height - [quitBadge size].height) * 0.5];
return;
}
@ -75,16 +75,19 @@
float downloadRate, uploadRate;
tr_torrentRates(fLib, &downloadRate, &uploadRate);
BOOL upload = checkUpload && uploadRate >= 0.1;
BOOL upload = checkUpload && uploadRate >= 0.1,
download = checkDownload && downloadRate >= 0.1;
float bottom = 0.0;
if (upload)
[self badge: [NSImage imageNamed: @"UploadBadge.png"] string: [NSString stringForSpeedAbbrev: uploadRate] atHeight: 0.0];
if (checkDownload && downloadRate >= 0.1)
{
//download rate above upload rate
float bottom = upload ? [[NSImage imageNamed: @"UploadBadge.png"] size].height + BETWEEN_PADDING : 0.0;
NSImage * uploadBadge = [NSImage imageNamed: @"UploadBadge.png"];
[self badge: uploadBadge string: [NSString stringForSpeedAbbrev: uploadRate] atHeight: bottom];
if (download)
bottom += [uploadBadge size].height + BETWEEN_PADDING; //download rate above upload rate
}
if (download)
[self badge: [NSImage imageNamed: @"DownloadBadge.png"] string: [NSString stringForSpeedAbbrev: downloadRate]
atHeight: bottom];
}
}
}
@ -108,7 +111,7 @@
[stringShadow release];
}
NSRect badgeRect = NSZeroRect;
NSRect badgeRect;
badgeRect.size = [badge size];
badgeRect.origin.y = height;
@ -117,7 +120,7 @@
//string is in center of image
NSSize stringSize = [string sizeWithAttributes: fAttributes];
NSRect stringRect = badgeRect;
NSRect stringRect;
stringRect.origin.x += (badgeRect.size.width - stringSize.width) * 0.5;
stringRect.origin.y += (badgeRect.size.height - stringSize.height) * 0.5 + 1.0; //adjust for shadow
stringRect.size = stringSize;

View File

@ -48,8 +48,6 @@
fLib = lib;
fCompleted = 0;
fCompletedBadged = 0;
fSpeedBadge = NO;
if ([NSApp isOnLeopardOrBetter])
{
@ -58,7 +56,11 @@
[view release];
}
else
{
fQuittingTiger = NO;
fSpeedBadge = NO;
fCompletedBadged = 0;
}
//change that just impacts the dock badge
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(updateBadge) name: @"DockBadgeChange" object: nil];

View File

@ -823,12 +823,14 @@ typedef enum
if ([[peer objectForKey: @"Encryption"] boolValue])
[components addObject: NSLocalizedString(@"Encrypted Connection", "Inspector -> Peers tab -> table row tooltip")];
NSString * portString;
int port;
if ((port = [[peer objectForKey: @"Port"] intValue]) > 0)
[components addObject: [NSString stringWithFormat:
NSLocalizedString(@"Port: %d", "Inspector -> Peers tab -> table row tooltip"), port]];
portString = [NSString stringWithFormat: @"%d", port];
else
[components addObject: NSLocalizedString(@"Port: N/A", "Inspector -> Peers tab -> table row tooltip")];
portString = NSLocalizedString(@"N/A", "Inspector -> Peers tab -> table row tooltip");
[components addObject: [NSString stringWithFormat: @"%@: %@", NSLocalizedString(@"Port",
"Inspector -> Peers tab -> table row tooltip"), portString]];
switch ([[peer objectForKey: @"From"] intValue])
{

View File

@ -254,6 +254,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
fFinishedPiecesDate = tab != NULL ? [[NSDate alloc] init] : nil;
}
#warning when queue and seeding options are folded into libt, no need to call this on all torrents - use tr_torrentGetStatus
- (void) update
{
//get previous status values before update
@ -986,7 +987,6 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
NSString * downloadString;
if (![self isComplete]) //only multifile possible
{
if ([fDefaults boolForKey: @"DisplayStatusProgressSelected"])
downloadString = [NSString stringWithFormat: NSLocalizedString(@"%@ selected", "Torrent -> progress string"),
[NSString stringForFileSize: [self haveTotal]]];
@ -1080,7 +1080,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
}
if (fStalled)
string = [NSLocalizedString(@"Stalled, ", "Torrent -> status string") stringByAppendingString: string];
string = [NSString stringWithFormat: @"%@, %@", NSLocalizedString(@"Stalled", "Torrent -> status string"), string];
}
//append even if error