1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

if on Leopard use the built in badging for the number of completed downloads

This commit is contained in:
Mitchell Livingston 2007-10-29 04:31:44 +00:00
parent a0a9c8b2aa
commit 2c3dc63569
2 changed files with 15 additions and 4 deletions

View file

@ -28,8 +28,9 @@
@interface Badger : NSObject @interface Badger : NSObject
{ {
tr_handle * fLib; tr_handle * fLib;
NSImage * fDockIcon, * fBadge, * fUploadBadge, * fDownloadBadge; NSImage * fDockIcon, * fBadge, * fUploadBadge, * fDownloadBadge;
NSDictionary * fAttributes; NSDictionary * fAttributes;
int fCompleted, fCompletedBadged; int fCompleted, fCompletedBadged;
BOOL fSpeedBadge; BOOL fSpeedBadge;

View file

@ -23,6 +23,7 @@
*****************************************************************************/ *****************************************************************************/
#import "Badger.h" #import "Badger.h"
#import "NSApplicationAdditions.h"
#import "NSStringAdditions.h" #import "NSStringAdditions.h"
#define COMPLETED_BOTTOM_PADDING 5.0 #define COMPLETED_BOTTOM_PADDING 5.0
@ -62,7 +63,7 @@
- (void) updateBadge - (void) updateBadge
{ {
//set completed badge to top right //set completed badge to top right
BOOL completedChange = fCompleted != fCompletedBadged; BOOL completedChange = [NSApp isOnLeopardOrBetter] && fCompleted != fCompletedBadged;
if (completedChange) if (completedChange)
{ {
fCompletedBadged = fCompleted; fCompletedBadged = fCompleted;
@ -183,7 +184,11 @@
- (void) incrementCompleted - (void) incrementCompleted
{ {
fCompleted++; fCompleted++;
[self updateBadge];
if ([NSApp isOnLeopardOrBetter])
[[NSApp dockTile] setBadgeLabel: [NSString stringWithFormat: @"%d", fCompleted]];
else
[self updateBadge];
} }
- (void) clearCompleted - (void) clearCompleted
@ -191,7 +196,10 @@
if (fCompleted != 0) if (fCompleted != 0)
{ {
fCompleted = 0; fCompleted = 0;
[self updateBadge]; if ([NSApp isOnLeopardOrBetter])
[[NSApp dockTile] setBadgeLabel: @""];
else
[self updateBadge];
} }
} }
@ -201,6 +209,8 @@
fCompletedBadged = 0; fCompletedBadged = 0;
fSpeedBadge = NO; fSpeedBadge = NO;
[NSApp setApplicationIconImage: [NSImage imageNamed: @"NSApplicationIcon"]]; [NSApp setApplicationIconImage: [NSImage imageNamed: @"NSApplicationIcon"]];
if ([NSApp isOnLeopardOrBetter])
[[NSApp dockTile] setBadgeLabel: @""];
} }
@end @end