~ubuntu-branches/ubuntu/jaunty/transmission/jaunty-updates

« back to all changes in this revision

Viewing changes to macosx/BadgeView.m

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2008-11-28 15:33:48 UTC
  • mfrom: (1.1.19 upstream)
  • Revision ID: james.westby@ubuntu.com-20081128153348-it70trfnxiroblmc
Tags: 1.40-0ubuntu1
* New upstream release (LP: #302672)
  - Tracker communication uses fewer resources
  - More accurate bandwidth limits
  - Reduce disk fragmentation by preallocating files (LP: #287726)
  - Stability, security and performance improvements to the RPC /
    Web UI server (closes LP: #290423)
  - Support compression when serving Web UI and RPC responses
  - Simplify the RPC whitelist
  - Fix bug that prevented handshakes with encrypted BitComet peers
  - Fix 1.3x bug that could re-download some data unnecessarily
    (LP: #295040)
  - Option to automatically update the blocklist weekly
  - Added off-hour bandwidth scheduling
  - Simplify file/priority selection in the details dialog
  - Fix a couple of crashes
  - New / updated translations
  - Don't inhibit hibernation by default (LP: #292929)
  - Use "close" animation when sending to notification area (LP: #130811)
  - Fix resize problems (LP: #269872)
  - Support "--version" option when launching from command line
    (LP: #292011)
  - Correctly parse announce URLs that have leading or trailing
    spaces (LP: #262411)
  - Display an error when "Open Torrent" fails (LP: #281463)
* Dropped 10_fix_crasher_from_upstream.dpatch: Fix is in this
  upstream release.
* debian/control: Don't just build-depend on libcurl-dev, which is
  a virtual package.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: BadgeView.m 5740 2008-05-02 13:08:23Z livings124 $
 
2
 * $Id: BadgeView.m 7077 2008-11-08 22:13:00Z livings124 $
3
3
 *
4
4
 * Copyright (c) 2007-2008 Transmission authors and contributors
5
5
 *
25
25
#import "BadgeView.h"
26
26
#import "NSStringAdditions.h"
27
27
 
28
 
#define BETWEEN_PADDING 2.0
 
28
#define BETWEEN_PADDING 2.0f
29
29
 
30
30
@interface BadgeView (Private)
31
31
 
32
 
- (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (float) height adjustForQuit: (BOOL) quit;
 
32
- (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (CGFloat) height adjustForQuit: (BOOL) quit;
33
33
 
34
34
@end
35
35
 
54
54
    [super dealloc];
55
55
}
56
56
 
57
 
- (BOOL) setRatesWithDownload: (float) downloadRate upload: (float) uploadRate
 
57
- (BOOL) setRatesWithDownload: (CGFloat) downloadRate upload: (CGFloat) uploadRate
58
58
{
59
59
    //only needs update if the badges were displayed or are displayed now
60
 
    BOOL needsUpdate = fDownloadRate != downloadRate || fUploadRate != uploadRate;
61
 
    if (needsUpdate)
62
 
    {
63
 
        fDownloadRate = downloadRate;
64
 
        fUploadRate = uploadRate;
65
 
    }
 
60
    if (fDownloadRate == downloadRate && fUploadRate == uploadRate)
 
61
        return NO;
66
62
    
67
 
    return needsUpdate;
 
63
    fDownloadRate = downloadRate;
 
64
    fUploadRate = uploadRate;
 
65
    return YES;
68
66
}
69
67
 
70
68
- (void) setQuitting
80
78
    {
81
79
        NSImage * quitBadge = [NSImage imageNamed: @"QuitBadge.png"];
82
80
        [self badge: quitBadge string: NSLocalizedString(@"Quitting", "Dock Badger -> quit")
83
 
                atHeight: (rect.size.height - [quitBadge size].height) * 0.5 adjustForQuit: YES];
 
81
                atHeight: (rect.size.height - [quitBadge size].height) * 0.5f adjustForQuit: YES];
84
82
        return;
85
83
    }
86
84
    
87
 
    BOOL upload = fUploadRate >= 0.1,
88
 
        download = fDownloadRate >= 0.1;
89
 
    float bottom = 0.0;
 
85
    BOOL upload = fUploadRate >= 0.1f,
 
86
        download = fDownloadRate >= 0.1f;
 
87
    CGFloat bottom = 0.0f;
90
88
    if (upload)
91
89
    {
92
90
        NSImage * uploadBadge = [NSImage imageNamed: @"UploadBadge.png"];
104
102
@implementation BadgeView (Private)
105
103
 
106
104
//dock icon must have locked focus
107
 
- (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (float) height adjustForQuit: (BOOL) quit
 
105
- (void) badge: (NSImage *) badge string: (NSString *) string atHeight: (CGFloat) height adjustForQuit: (BOOL) quit
108
106
{
109
107
    if (!fAttributes)
110
108
    {
111
109
        NSShadow * stringShadow = [[NSShadow alloc] init];
112
 
        [stringShadow setShadowOffset: NSMakeSize(2.0, -2.0)];
113
 
        [stringShadow setShadowBlurRadius: 4.0];
 
110
        [stringShadow setShadowOffset: NSMakeSize(2.0f, -2.0f)];
 
111
        [stringShadow setShadowBlurRadius: 4.0f];
114
112
        
115
113
        fAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:
116
114
            [NSColor whiteColor], NSForegroundColorAttributeName,
117
 
            [NSFont boldSystemFontOfSize: 26.0], NSFontAttributeName, stringShadow, NSShadowAttributeName, nil];
 
115
            [NSFont boldSystemFontOfSize: 26.0f], NSFontAttributeName, stringShadow, NSShadowAttributeName, nil];
118
116
        
119
117
        [stringShadow release];
120
118
    }
123
121
    badgeRect.size = [badge size];
124
122
    badgeRect.origin.y = height;
125
123
    
126
 
    [badge drawInRect: badgeRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
 
124
    [badge drawInRect: badgeRect fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0f];
127
125
    
128
126
    //string is in center of image
129
127
    NSSize stringSize = [string sizeWithAttributes: fAttributes];
130
128
    
131
129
    NSRect stringRect = badgeRect;
132
 
    stringRect.origin.x += (badgeRect.size.width - stringSize.width) * 0.5;
133
 
    stringRect.origin.y += (badgeRect.size.height - stringSize.height) * 0.5 + (quit ? 2.0 : 1.0); //adjust for shadow, extra for quit
 
130
    stringRect.origin.x += (badgeRect.size.width - stringSize.width) * 0.5f;
 
131
    stringRect.origin.y += (badgeRect.size.height - stringSize.height) * 0.5f + (quit ? 2.0f : 1.0f); //adjust for shadow, extra for quit
134
132
    stringRect.size = stringSize;
135
133
    
136
134
    [string drawInRect: stringRect withAttributes: fAttributes];