From 9dc92d4d3b8e6887034ac3aa75cd14e73dc05153 Mon Sep 17 00:00:00 2001 From: Mitchell Livingston Date: Tue, 1 Apr 2008 15:24:35 +0000 Subject: [PATCH] more string fiddling and minor badger changes --- macosx/BadgeView.m | 21 ++++++++++++--------- macosx/Badger.m | 6 ++++-- macosx/English.lproj/Localizable.strings | Bin 56046 -> 55960 bytes macosx/InfoWindowController.m | 8 +++++--- macosx/Torrent.m | 4 ++-- 5 files changed, 23 insertions(+), 16 deletions(-) diff --git a/macosx/BadgeView.m b/macosx/BadgeView.m index 252449477..263d7856d 100644 --- a/macosx/BadgeView.m +++ b/macosx/BadgeView.m @@ -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; diff --git a/macosx/Badger.m b/macosx/Badger.m index 2689ab717..833a7460a 100644 --- a/macosx/Badger.m +++ b/macosx/Badger.m @@ -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]; diff --git a/macosx/English.lproj/Localizable.strings b/macosx/English.lproj/Localizable.strings index f29f82b6e8fe12dcc977f700c63a5cc394b6bd45..759cdc5109b0586789942e321a0e5f7bf98e7678 100644 GIT binary patch delta 110 zcmV-!0FnRhwF8*71F*Pflb{kJlWSlYFBX QllDw5lgcy{v)ZE+Hychdb^rhX delta 161 zcmbQSmHFLP<_$a2H;ZMgw5L0)H=ETh$A!85{>ed;-wfwGhJ wGejpF#Bfa3^R(L3sHG&Y1JtVo#I|5Mn4yFrks${NQyEeifO4B17l)ez02MYfTmS$7 diff --git a/macosx/InfoWindowController.m b/macosx/InfoWindowController.m index 1061e7067..a7c4096c8 100644 --- a/macosx/InfoWindowController.m +++ b/macosx/InfoWindowController.m @@ -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]) { diff --git a/macosx/Torrent.m b/macosx/Torrent.m index 4e717042f..01709bd56 100644 --- a/macosx/Torrent.m +++ b/macosx/Torrent.m @@ -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