Changeset 12504


Ignore:
Timestamp:
Jun 19, 2011, 3:52:54 AM (10 years ago)
Author:
livings124
Message:

#4241 Update dock badge count after removing download through web interface

Location:
trunk/macosx
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Badger.h

    r11756 r12504  
    2626#import <transmission.h>
    2727
     28@class Torrent;
     29
    2830@interface Badger : NSObject
    2931{
    3032    tr_session * fLib;
    3133   
    32     NSUInteger fCompleted;
     34    NSMutableSet * fHashes;
    3335}
    3436
     
    3638
    3739- (void) updateBadgeWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate;
    38 - (void) incrementCompleted;
     40- (void) addCompletedTorrent: (Torrent *) torrent;
     41- (void) removeTorrent: (Torrent *) torrent;
    3942- (void) clearCompleted;
    4043- (void) setQuitting;
  • trunk/macosx/Badger.m

    r12069 r12504  
    2525#import "Badger.h"
    2626#import "BadgeView.h"
     27#import "NSStringAdditions.h"
     28#import "Torrent.h"
    2729
    2830@implementation Badger
     
    3436        fLib = lib;
    3537       
    36         fCompleted = 0;
    37        
    3838        BadgeView * view = [[BadgeView alloc] initWithLib: lib];
    3939        [[NSApp dockTile] setContentView: view];
    4040        [view release];
     41       
     42        fHashes = [[NSMutableSet alloc] init];
    4143    }
    4244   
     
    4749{
    4850    [[NSNotificationCenter defaultCenter] removeObserver: self];
     51   
     52    [fHashes release];
    4953   
    5054    [super dealloc];
     
    6367}
    6468
    65 - (void) incrementCompleted
     69- (void) addCompletedTorrent: (Torrent *) torrent
    6670{
    67     fCompleted++;
    68     [[NSApp dockTile] setBadgeLabel: [NSString stringWithFormat: @"%d", fCompleted]];
     71    [fHashes addObject: [torrent hashString]];
     72    [[NSApp dockTile] setBadgeLabel: [NSString formattedUInteger: [fHashes count]]];
     73}
     74
     75- (void) removeTorrent: (Torrent *) torrent
     76{
     77    if ([fHashes count] > 0)
     78    {
     79        [fHashes removeObject: [torrent hashString]];
     80        if ([fHashes count] > 0)
     81            [[NSApp dockTile] setBadgeLabel: [NSString formattedUInteger: [fHashes count]]];
     82        else
     83            [[NSApp dockTile] setBadgeLabel: @""];
     84    }
    6985}
    7086
    7187- (void) clearCompleted
    7288{
    73     if (fCompleted != 0)
     89    if ([fHashes count] > 0)
    7490    {
    75         fCompleted = 0;
     91        [fHashes removeAllObjects];
    7692        [[NSApp dockTile] setBadgeLabel: @""];
    7793    }
  • trunk/macosx/Controller.m

    r12499 r12504  
    13421342        [fTableView removeCollapsedGroup: [torrent groupValue]];
    13431343       
     1344        //we can't assume the window is active - RPC removal, for example
     1345        [fBadger removeTorrent: torrent];
     1346       
    13441347        [torrent closeRemoveTorrent: deleteData];
    13451348    }
     
    17951798       
    17961799        if (![fWindow isMainWindow])
    1797             [fBadger incrementCompleted];
     1800            [fBadger addCompletedTorrent: torrent];
    17981801       
    17991802        //bounce download stack
  • trunk/macosx/InfoWindowController.m

    r12081 r12504  
    343343}
    344344
    345 - (void) swipeWithEvent:(NSEvent *) event
     345- (void) swipeWithEvent: (NSEvent *) event
    346346{
    347347    if ([event deltaX] < 0.0)
Note: See TracChangeset for help on using the changeset viewer.