~sense/ubuntu/lucid/transmission/fix-497882

« back to all changes in this revision

Viewing changes to macosx/FileNameCell.m

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Klimonda
  • Date: 2009-12-08 10:49:11 UTC
  • mfrom: (1.1.29 upstream) (2.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20091208104911-06gio45n2nla3vpg
Tags: 1.80~b1-0ubuntu1
* New upstream release (LP: #460620), rebased on debian unstable
  remaining changes:
  - debian/control:
    + Added replaces & provides clutch (now included as part of transmission).
      Can be removed in lucid+1
    + Added quilt, liblaunchpad-integration-dev and lsb-release to Build-Depends
  - debian/rules:
    + create a po template during package build.
  - debian/patches/01_lpi.patch:
    + integrate transmission with launchpad
  - debian/patches/20_add_x-ubuntu-gettext-domain.diff:
    + add x-ubuntu-gettext-domain to .desktop file.
  - debian/transmission-daemon.default:
    - remove --auth from OPTIONS
* Fixes bugs:
  - tray menu shows wrong status for "main window" when started minimized
    (LP: #451415)
* Refreshed patches:
  - dont_build_libevent.patch
  - 99_autoreconf.patch
* Removed patches:
  - 21_onPortTested.diff, 23_tr_torrentNext.diff and
    24_tr_torrentDeleteLocalData_do_move.diff
* debian/patches/21_fix_inhibition.patch:
  - The right value for suspend inhibition is 4
* debian/control:
  - Build-Depend on libgconf2-dev to enable magnet link registration and on
    libcanberra-gtk-dev for notification sound.
* debian/watch:
  - make it detect beta versions, to be removed after 1.80 is released.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: FileNameCell.m 7659 2009-01-10 23:37:37Z livings124 $
 
2
 * $Id: FileNameCell.m 9320 2009-10-18 03:02:10Z livings124 $
3
3
 * 
4
4
 * Copyright (c) 2007-2009 Transmission authors and contributors
5
5
 *
26
26
#import "FileOutlineView.h"
27
27
#import "Torrent.h"
28
28
#import "FileListNode.h"
 
29
#import "NSApplicationAdditions.h"
29
30
#import "NSStringAdditions.h"
30
31
 
31
32
#define PADDING_HORIZONAL 2.0f
41
42
- (NSRect) rectForTitleWithString: (NSAttributedString *) string inBounds: (NSRect) bounds;
42
43
- (NSRect) rectForStatusWithString: (NSAttributedString *) string withTitleRect: (NSRect) titleRect inBounds: (NSRect) bounds;
43
44
 
44
 
- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color;
45
 
- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color;
 
45
- (NSAttributedString *) attributedTitle;
 
46
- (NSAttributedString *) attributedStatus;
46
47
 
47
48
@end
48
49
 
97
98
    if ([node isFolder])
98
99
    {
99
100
        if (!fFolderImage)
100
 
        {
101
101
            fFolderImage = [[[NSWorkspace sharedWorkspace] iconForFileType: NSFileTypeForHFSTypeCode('fldr')] copy];
102
 
            [fFolderImage setFlipped: YES];
103
 
        }
104
102
        image = fFolderImage;
105
103
    }
106
104
    else
124
122
 
125
123
- (NSRect) titleRectForBounds: (NSRect) bounds
126
124
{
127
 
    return [self rectForTitleWithString: [self attributedTitleWithColor: nil] inBounds: bounds];
 
125
    return [self rectForTitleWithString: [self attributedTitle] inBounds: bounds];
128
126
}
129
127
 
130
128
- (NSRect) statusRectForBounds: (NSRect) bounds
131
129
{
132
 
    return [self rectForStatusWithString: [self attributedStatusWithColor: nil]
 
130
    return [self rectForStatusWithString: [self attributedStatus]
133
131
            withTitleRect: [(FileListNode *)[self objectValue] isFolder] ? [self titleRectForBounds: bounds] : NSZeroRect
134
132
            inBounds: bounds];
135
133
}
137
135
- (void) drawWithFrame: (NSRect) cellFrame inView: (NSView *) controlView
138
136
{
139
137
    //icon
140
 
    [[self image] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
 
138
    if ([NSApp isOnSnowLeopardOrBetter])
 
139
        [[self image] drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0
 
140
            respectFlipped: YES hints: nil];
 
141
    else
 
142
    {
 
143
        NSImage * image = [self image];
 
144
        [image setFlipped: YES];
 
145
        [image drawInRect: [self imageRectForBounds: cellFrame] fromRect: NSZeroRect operation: NSCompositeSourceOver fraction: 1.0];
 
146
    }
141
147
    
142
148
    NSColor * titleColor, * statusColor;
143
149
    if ([self backgroundStyle] == NSBackgroundStyleDark)
150
156
        statusColor = [NSColor darkGrayColor];
151
157
    }
152
158
    
 
159
    [fTitleAttributes setObject: titleColor forKey: NSForegroundColorAttributeName];
 
160
    [fStatusAttributes setObject: statusColor forKey: NSForegroundColorAttributeName];
 
161
    
153
162
    //title
154
 
    NSAttributedString * titleString = [self attributedTitleWithColor: titleColor];
 
163
    NSAttributedString * titleString = [self attributedTitle];
155
164
    NSRect titleRect = [self rectForTitleWithString: titleString inBounds: cellFrame];
156
165
    [titleString drawInRect: titleRect];
157
166
    
158
167
    //status
159
 
    NSAttributedString * statusString = [self attributedStatusWithColor: statusColor];
 
168
    NSAttributedString * statusString = [self attributedStatus];
160
169
    NSRect statusRect = [self rectForStatusWithString: statusString withTitleRect: titleRect inBounds: cellFrame];
161
170
    [statusString drawInRect: statusRect];
162
171
}
209
218
    return result;
210
219
}
211
220
 
212
 
- (NSAttributedString *) attributedTitleWithColor: (NSColor *) color
 
221
- (NSAttributedString *) attributedTitle
213
222
{
214
 
    if (color)
215
 
        [fTitleAttributes setObject: color forKey: NSForegroundColorAttributeName];
216
 
        
217
223
    NSString * title = [(FileListNode *)[self objectValue] name];
218
224
    return [[[NSAttributedString alloc] initWithString: title attributes: fTitleAttributes] autorelease];
219
225
}
220
226
 
221
 
- (NSAttributedString *) attributedStatusWithColor: (NSColor *) color
 
227
- (NSAttributedString *) attributedStatus
222
228
{
223
 
    if (color)
224
 
        [fStatusAttributes setObject: color forKey: NSForegroundColorAttributeName];
225
 
    
226
229
    Torrent * torrent = [(FileOutlineView *)[self controlView] torrent];
227
230
    FileListNode * node = (FileListNode *)[self objectValue];
228
231
    
230
233
    NSString * percentString = progress == 1.0f ? @"100%" : [NSString localizedStringWithFormat: @"%.2f%%", progress * 100.0f];
231
234
    
232
235
    
233
 
    NSString * status = [NSString localizedStringWithFormat: NSLocalizedString(@"%@ of %@",
 
236
    NSString * status = [NSString stringWithFormat: NSLocalizedString(@"%@ of %@",
234
237
                            "Inspector -> Files tab -> file status string"), percentString, [NSString stringForFileSize: [node size]]];
235
238
    
236
239
    return [[[NSAttributedString alloc] initWithString: status attributes: fStatusAttributes] autorelease];