mirror of
https://github.com/transmission/transmission
synced 2025-03-03 10:15:45 +00:00
have the Badger keep track of the completed count rather than Controller
This commit is contained in:
parent
81a6d96d6e
commit
4567bc0b3f
4 changed files with 35 additions and 22 deletions
|
@ -34,12 +34,15 @@
|
|||
|
||||
NSImage * fDockIcon, * fBadge, * fUploadBadge, * fDownloadBadge;
|
||||
NSDictionary * fAttributes;
|
||||
int fCompleted;
|
||||
int fCompleted, fCompletedBadged;
|
||||
BOOL fSpeedBadge;
|
||||
}
|
||||
|
||||
- (id) initWithLib: (tr_handle_t *) lib;
|
||||
- (void) updateBadgeWithCompleted: (int) completed;
|
||||
|
||||
- (void) updateBadge;
|
||||
- (void) incrementCompleted;
|
||||
- (void) clearCompleted;
|
||||
- (void) clearBadge;
|
||||
|
||||
@end
|
||||
|
|
|
@ -58,6 +58,7 @@
|
|||
[stringShadow release];
|
||||
|
||||
fCompleted = 0;
|
||||
fCompletedBadged = 0;
|
||||
fSpeedBadge = NO;
|
||||
}
|
||||
|
||||
|
@ -71,18 +72,18 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) updateBadgeWithCompleted: (int) completed
|
||||
- (void) updateBadge
|
||||
{
|
||||
//set completed badge to top right
|
||||
BOOL baseChange;
|
||||
if (baseChange = (fCompleted != completed))
|
||||
if (baseChange = (fCompleted != fCompletedBadged))
|
||||
{
|
||||
fCompleted = completed;
|
||||
fCompletedBadged = fCompleted;
|
||||
|
||||
[fDockIcon release];
|
||||
fDockIcon = [[NSImage imageNamed: @"NSApplicationIcon"] copy];
|
||||
|
||||
if (completed > 0)
|
||||
if (fCompleted > 0)
|
||||
{
|
||||
NSRect badgeRect;
|
||||
NSSize iconSize = [fDockIcon size];
|
||||
|
@ -101,7 +102,7 @@
|
|||
badgeRect.origin.y += badgeBottomExtra;
|
||||
|
||||
//place badge text
|
||||
[self badgeString: [NSString stringWithInt: completed] forRect: badgeRect];
|
||||
[self badgeString: [NSString stringWithInt: fCompleted] forRect: badgeRect];
|
||||
|
||||
[fDockIcon unlockFocus];
|
||||
}
|
||||
|
@ -182,10 +183,26 @@
|
|||
}
|
||||
}
|
||||
|
||||
- (void) incrementCompleted
|
||||
{
|
||||
fCompleted++;
|
||||
[self updateBadge];
|
||||
}
|
||||
|
||||
- (void) clearCompleted
|
||||
{
|
||||
if (fCompleted != 0)
|
||||
{
|
||||
fCompleted = 0;
|
||||
[self updateBadge];
|
||||
}
|
||||
}
|
||||
|
||||
- (void) clearBadge
|
||||
{
|
||||
[NSApp setApplicationIconImage: [NSImage imageNamed: @"NSApplicationIcon"]];
|
||||
fCompleted = 0;
|
||||
fCompletedBadged = 0;
|
||||
[NSApp setApplicationIconImage: [NSImage imageNamed: @"NSApplicationIcon"]];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
@interface Controller : NSObject <GrowlApplicationBridgeDelegate>
|
||||
{
|
||||
tr_handle_t * fLib;
|
||||
int fCompleted;
|
||||
|
||||
NSMutableArray * fTorrents, * fDisplayedTorrents;
|
||||
|
||||
|
@ -200,7 +199,7 @@
|
|||
|
||||
- (void) doNothing: (id) sender; //needed for menu items that use bindings with no associated action
|
||||
|
||||
- (void) resetDockBadge: (NSNotification *) notification;
|
||||
- (void) updateDockBadge: (NSNotification *) notification;
|
||||
|
||||
- (void) setWindowSizeToFit;
|
||||
- (NSRect) sizedWindowFrame;
|
||||
|
|
|
@ -394,11 +394,10 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
name: @"UpdateQueue" object: nil];
|
||||
|
||||
//change that just impacts the dock badge
|
||||
[nc addObserver: self selector: @selector(resetDockBadge:)
|
||||
[nc addObserver: self selector: @selector(updateDockBadge:)
|
||||
name: @"DockBadgeChange" object: nil];
|
||||
|
||||
//timer to update the interface every second
|
||||
fCompleted = 0;
|
||||
[self updateUI];
|
||||
fTimer = [NSTimer scheduledTimerWithTimeInterval: UPDATE_UI_SECONDS target: self
|
||||
selector: @selector(updateUI) userInfo: nil repeats: YES];
|
||||
|
@ -1326,7 +1325,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
[fInfoController updateInfoStats];
|
||||
|
||||
//badge dock
|
||||
[fBadger updateBadgeWithCompleted: fCompleted];
|
||||
[fBadger updateBadge];
|
||||
}
|
||||
|
||||
- (void) updateTorrentsInQueue
|
||||
|
@ -1423,7 +1422,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
|
||||
|
||||
if (![fWindow isKeyWindow])
|
||||
fCompleted++;
|
||||
[fBadger incrementCompleted];
|
||||
|
||||
if ([fDefaults boolForKey: @"QueueSeed"])
|
||||
{
|
||||
|
@ -2886,9 +2885,9 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
return fDockMenu;
|
||||
}
|
||||
|
||||
- (void) resetDockBadge: (NSNotification *) notification
|
||||
- (void) updateDockBadge: (NSNotification *) notification
|
||||
{
|
||||
[fBadger updateBadgeWithCompleted: fCompleted];
|
||||
[fBadger updateBadge];
|
||||
}
|
||||
|
||||
- (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
|
||||
|
@ -2924,12 +2923,7 @@ static void sleepCallBack(void * controller, io_service_t y, natural_t messageTy
|
|||
|
||||
- (void) windowDidBecomeKey: (NSNotification *) notification
|
||||
{
|
||||
//reset dock badge for completed
|
||||
if (fCompleted > 0)
|
||||
{
|
||||
fCompleted = 0;
|
||||
[self resetDockBadge: nil];
|
||||
}
|
||||
[fBadger clearCompleted];
|
||||
}
|
||||
|
||||
- (NSSize) windowWillResize: (NSWindow *) sender toSize: (NSSize) proposedFrameSize
|
||||
|
|
Loading…
Reference in a new issue