source: trunk/macosx/InfoWindowController.m @ 1034

Last change on this file since 1034 was 1034, checked in by livings124, 16 years ago

Partial use of bindings in prefs/action menu. This is still experimental and evolving, with the most obvious problem that entering an invalid value causes an annoying error sheet to appear.

  • Property svn:keywords set to Date Rev Author Id
File size: 21.6 KB
Line 
1/******************************************************************************
2 * $Id: InfoWindowController.m 1034 2006-10-27 19:14:04Z livings124 $
3 *
4 * Copyright (c) 2006 Transmission authors and contributors
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 *****************************************************************************/
24
25#import "InfoWindowController.h"
26#import "StringAdditions.h"
27
28#define RATIO_GLOBAL_TAG 0
29#define RATIO_NO_CHECK_TAG 1
30#define RATIO_CHECK_TAG 2
31
32#define MIN_WINDOW_WIDTH 300
33#define MAX_WINDOW_WIDTH 5000
34
35#define TAB_INFO_IDENT @"Info"
36#define TAB_ACTIVITY_IDENT @"Activity"
37#define TAB_PEERS_IDENT @"Peers"
38#define TAB_FILES_IDENT @"Files"
39#define TAB_OPTIONS_IDENT @"Options"
40
41//15 spacing at the bottom of each tab
42#define TAB_INFO_HEIGHT 182.0
43#define TAB_ACTIVITY_HEIGHT 109.0
44#define TAB_PEERS_HEIGHT 260.0
45#define TAB_FILES_HEIGHT 260.0
46#define TAB_OPTIONS_HEIGHT 83.0
47
48#define INVALID -99
49
50@interface InfoWindowController (Private)
51
52- (void) updateInfoActivity;
53- (void) updateInfoPeers;
54
55- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate;
56- (NSArray *) peerSortDescriptors;
57
58@end
59
60@implementation InfoWindowController
61
62- (id) initWithWindowNibName: (NSString *) name
63{
64    if ((self = [super initWithWindowNibName: name]))
65    {
66        fAppIcon = [[NSApp applicationIconImage] copy];
67        fDotGreen = [NSImage imageNamed: @"GreenDot.tiff"];
68        fDotRed = [NSImage imageNamed: @"RedDot.tiff"];
69        fCheckImage = [NSImage imageNamed: @"NSMenuCheckmark"];   
70    }
71    return self;
72}
73
74- (void) awakeFromNib
75{
76    fPeers = [[NSMutableArray alloc] initWithCapacity: 30];
77    fFiles = [[NSMutableArray alloc] initWithCapacity: 6];
78    [fFileTable setDoubleAction: @selector(revealFile:)];
79   
80    //window location and size
81    NSPanel * window = (NSPanel *)[self window];
82   
83    [window setBecomesKeyOnlyIfNeeded: YES];
84   
85    [window setFrameAutosaveName: @"InspectorWindowFrame"];
86    [window setFrameUsingName: @"InspectorWindowFrame"];
87   
88    //select tab
89    NSString * identifier = [[NSUserDefaults standardUserDefaults] stringForKey: @"InfoTab"];
90    if ([fTabView indexOfTabViewItemWithIdentifier: identifier] == NSNotFound)
91        identifier = TAB_INFO_IDENT;
92   
93    [fTabView selectTabViewItemWithIdentifier: identifier];
94    [self setWindowForTab: identifier animate: NO];
95   
96    //initially sort peer table by IP
97    if ([[fPeerTable sortDescriptors] count] == 0)
98        [fPeerTable setSortDescriptors: [NSArray arrayWithObject: [[fPeerTable tableColumnWithIdentifier: @"IP"]
99                                            sortDescriptorPrototype]]];
100   
101    [self updateInfoForTorrents: [NSArray array]];
102}
103
104- (void) dealloc
105{
106    [fTorrents release];
107    [fPeers release];
108    [fFiles release];
109
110    [fAppIcon release];
111    [super dealloc];
112}
113
114- (void) updateInfoForTorrents: (NSArray *) torrents
115{
116    if (fTorrents)
117        [fTorrents release];
118    fTorrents = [torrents retain];
119
120    int numberSelected = [fTorrents count];
121    if (numberSelected != 1)
122    {
123        if (numberSelected > 0)
124        {
125            [fNameField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d Torrents Selected", "Inspector -> above tabs -> selected torrents"), numberSelected]];
126       
127            uint64_t size = 0;
128            NSEnumerator * enumerator = [torrents objectEnumerator];
129            Torrent * torrent;
130            while ((torrent = [enumerator nextObject]))
131                size += [torrent size];
132           
133            [fSizeField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ Total", "Inspector -> above tabs -> total size (several torrents selected)"), [NSString stringForFileSize: size]]];
134        }
135        else
136        {
137            [fNameField setStringValue: NSLocalizedString(@"No Torrents Selected", "Inspector -> above tabs -> selected torrents")];
138            [fSizeField setStringValue: @""];
139   
140            [fDownloadedValidField setStringValue: @""];
141            [fDownloadedTotalField setStringValue: @""];
142            [fUploadedTotalField setStringValue: @""];
143        }
144       
145        [fImageView setImage: fAppIcon];
146       
147        [fNameField setToolTip: nil];
148
149        [fTrackerField setStringValue: @""];
150        [fTrackerField setToolTip: nil];
151        [fAnnounceField setStringValue: @""];
152        [fAnnounceField setToolTip: nil];
153        [fPieceSizeField setStringValue: @""];
154        [fPiecesField setStringValue: @""];
155        [fHashField setStringValue: @""];
156        [fHashField setToolTip: nil];
157       
158        [fTorrentLocationField setStringValue: @""];
159        [fTorrentLocationField setToolTip: nil];
160        [fDataLocationField setStringValue: @""];
161        [fDataLocationField setToolTip: nil];
162        [fDateStartedField setStringValue: @""];
163       
164        [fRevealDataButton setHidden: YES];
165        [fRevealTorrentButton setHidden: YES];
166       
167        //don't allow empty fields to be selected
168        [fTrackerField setSelectable: NO];
169        [fAnnounceField setSelectable: NO];
170        [fHashField setSelectable: NO];
171        [fTorrentLocationField setSelectable: NO];
172        [fDataLocationField setSelectable: NO];
173       
174        [fStateField setStringValue: @""];
175        [fRatioField setStringValue: @""];
176       
177        [fSeedersField setStringValue: @""];
178        [fLeechersField setStringValue: @""];
179        [fConnectedPeersField setStringValue: @""];
180        [fDownloadingFromField setStringValue: @""];
181        [fUploadingToField setStringValue: @""];
182        [fSwarmSpeedField setStringValue: @""];
183       
184        [fPeers removeAllObjects];
185        [fPeerTable reloadData];
186       
187        [fPiecesView setTorrent: nil];
188    }
189    else
190    {   
191        Torrent * torrent = [fTorrents objectAtIndex: 0];
192       
193        [fImageView setImage: [torrent icon]];
194       
195        NSString * name = [torrent name];
196        [fNameField setStringValue: name];
197        [fNameField setToolTip: name];
198        [fSizeField setStringValue: [NSString stringForFileSize: [torrent size]]];
199       
200        NSString * tracker = [torrent tracker],
201                * announce = [torrent announce],
202                * hashString = [torrent hashString];
203        [fTrackerField setStringValue: tracker];
204        [fTrackerField setToolTip: tracker];
205        [fAnnounceField setStringValue: announce];
206        [fAnnounceField setToolTip: announce];
207        [fPieceSizeField setStringValue: [NSString stringForFileSize: [torrent pieceSize]]];
208        [fPiecesField setIntValue: [torrent pieceCount]];
209        [fHashField setStringValue: hashString];
210        [fHashField setToolTip: hashString];
211       
212        [fTorrentLocationField setStringValue: [torrent torrentLocationString]];
213        [fTorrentLocationField setToolTip: [torrent torrentLocation]];
214        [fDataLocationField setStringValue: [[torrent dataLocation] stringByAbbreviatingWithTildeInPath]];
215        [fDataLocationField setToolTip: [torrent dataLocation]];
216        [fDateStartedField setObjectValue: [torrent date]];
217       
218        [fRevealDataButton setHidden: NO];
219        [fRevealTorrentButton setHidden: ![torrent publicTorrent]];
220       
221        //allow these fields to be selected
222        [fTrackerField setSelectable: YES];
223        [fAnnounceField setSelectable: YES];
224        [fHashField setSelectable: YES];
225        [fTorrentLocationField setSelectable: YES];
226        [fDataLocationField setSelectable: YES];
227       
228        [fPiecesView setTorrent: torrent];
229    }
230   
231    //update stats and settings
232    [self updateInfoStats];
233    [self updateInfoSettings];
234
235    //set file table
236    [fFiles removeAllObjects];
237   
238    if (numberSelected > 0)
239    {
240        Torrent * torrent;
241        NSEnumerator * enumerator = [fTorrents objectEnumerator];
242        while ((torrent = [enumerator nextObject]))
243            [fFiles addObjectsFromArray: [torrent fileList]];
244       
245        if ([fFiles count] > 1)
246            [fFileTableStatusField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> Files tab -> bottom text (number of files)"), [fFiles count]]];
247        else
248            [fFileTableStatusField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d file", "Inspector -> Files tab -> bottom text (number of files)"), [fFiles count]]];
249    }
250    else
251        [fFileTableStatusField setStringValue: NSLocalizedString(@"info not available", "Inspector -> Files tab -> bottom text (number of files)")];
252   
253    [fFileTable deselectAll: nil];
254    [fFileTable reloadData];
255}
256
257- (void) updateInfoStats
258{
259    if ([[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_ACTIVITY_IDENT])
260        [self updateInfoActivity];
261    else if ([[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_PEERS_IDENT])
262        [self updateInfoPeers];
263    else;
264}
265
266- (void) updateInfoActivity
267{
268    int numberSelected = [fTorrents count];
269    if (numberSelected == 0)
270        return;
271   
272    float downloadedValid = 0;
273    uint64_t downloadedTotal = 0, uploadedTotal = 0;
274    Torrent * torrent;
275    NSEnumerator * enumerator = [fTorrents objectEnumerator];
276    while ((torrent = [enumerator nextObject]))
277    {
278        downloadedValid += [torrent downloadedValid];
279        downloadedTotal += [torrent downloadedTotal];
280        uploadedTotal += [torrent uploadedTotal];
281    }
282
283    [fDownloadedValidField setStringValue: [NSString stringForFileSize: downloadedValid]];
284    [fDownloadedTotalField setStringValue: [NSString stringForFileSize: downloadedTotal]];
285    [fUploadedTotalField setStringValue: [NSString stringForFileSize: uploadedTotal]];
286   
287    if (numberSelected == 1)
288    {
289        torrent = [fTorrents objectAtIndex: 0];
290       
291        //append percentage to amount downloaded if 1 torrent
292        [fDownloadedValidField setStringValue: [[fDownloadedValidField stringValue]
293                                        stringByAppendingFormat: @" (%.2f%%)", 100.0 * [torrent progress]]];
294       
295        [fStateField setStringValue: [torrent stateString]];
296       
297        [fRatioField setStringValue: [NSString stringForRatioWithDownload: downloadedTotal upload: uploadedTotal]];
298       
299        [fSwarmSpeedField setStringValue: [torrent isActive] ? [NSString stringForSpeed: [torrent swarmSpeed]] : @""];
300       
301        [fPiecesView updateView: NO];
302    }
303}
304
305- (void) updateInfoPeers
306{
307    if ([fTorrents count] != 1)
308        return;
309    Torrent * torrent = [fTorrents objectAtIndex: 0];
310   
311    int seeders = [torrent seeders], leechers = [torrent leechers];
312    [fSeedersField setStringValue: seeders < 0 ? @"" : [NSString stringWithInt: seeders]];
313    [fLeechersField setStringValue: leechers < 0 ? @"" : [NSString stringWithInt: leechers]];
314   
315    BOOL active = [torrent isActive];
316    [fConnectedPeersField setStringValue: active ? [NSString stringWithFormat: NSLocalizedString(@"%d (%d incoming)", "Inspector -> Peers tab -> connected"),
317                                                    [torrent totalPeers], [torrent totalPeersIncoming]]: @""];
318    [fDownloadingFromField setStringValue: active ? [NSString stringWithInt: [torrent peersUploading]] : @""];
319    [fUploadingToField setStringValue: active ? [NSString stringWithInt: [torrent peersDownloading]] : @""];
320   
321    [fPeers setArray: [torrent peers]];
322    [fPeers sortUsingDescriptors: [self peerSortDescriptors]];
323   
324    [fPeerTable reloadData];
325}
326
327- (void) updateInfoSettings
328{
329    int numberSelected = [fTorrents count];
330
331    //set ratio settings
332    if (numberSelected > 0)
333    {
334        NSEnumerator * enumerator = [fTorrents objectEnumerator];
335        Torrent * torrent = [enumerator nextObject]; //first torrent
336       
337        int ratioSetting = [torrent stopRatioSetting];
338        float ratioLimit = [torrent ratioLimit];
339       
340        while ((ratioSetting != INVALID || ratioLimit != INVALID)
341                && (torrent = [enumerator nextObject]))
342        {
343            if (ratioSetting != INVALID && ratioSetting != [torrent stopRatioSetting])
344                ratioSetting = INVALID;
345           
346            if (ratioLimit != INVALID && ratioLimit != [torrent ratioLimit])
347                ratioLimit = INVALID;
348        }
349       
350        [fRatioMatrix setEnabled: YES];
351       
352        if (ratioSetting == RATIO_CHECK)
353        {
354            [fRatioMatrix selectCellWithTag: RATIO_CHECK_TAG];
355            [fRatioLimitField setEnabled: YES];
356        }
357        else
358        {
359            if (ratioSetting == RATIO_NO_CHECK)
360                [fRatioMatrix selectCellWithTag: RATIO_NO_CHECK_TAG];
361            else if (ratioSetting == RATIO_GLOBAL)
362                [fRatioMatrix selectCellWithTag: RATIO_GLOBAL_TAG];
363            else
364                [fRatioMatrix deselectAllCells];
365           
366            [fRatioLimitField setEnabled: NO];
367        }
368       
369        if (ratioLimit != INVALID)
370            [fRatioLimitField setFloatValue: ratioLimit];
371        else
372            [fRatioLimitField setStringValue: @""];
373    }
374    else
375    {
376        [fRatioMatrix deselectAllCells];
377        [fRatioMatrix setEnabled: NO];
378       
379        [fRatioLimitField setEnabled: NO];
380        [fRatioLimitField setStringValue: @""];
381    }
382   
383    [self updateInfoStats];
384}
385
386- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
387{
388    SEL action = [menuItem action];
389   
390    if (action == @selector(revealFile:))
391        return [fFileTable numberOfSelectedRows] > 0 &&
392            [[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_FILES_IDENT];
393       
394    return YES;
395}
396
397- (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
398{
399    NSRect windowRect = [window frame];
400    windowRect.size.width = [window minSize].width;   
401    return windowRect;
402}
403
404- (void) tabView: (NSTabView *) tabView didSelectTabViewItem: (NSTabViewItem *) tabViewItem
405{
406    NSString * identifier = [tabViewItem identifier];
407    [self setWindowForTab: identifier animate: YES];
408    [[NSUserDefaults standardUserDefaults] setObject: identifier forKey: @"InfoTab"];
409}
410
411- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate
412{
413    [self updateInfoStats];
414   
415    float height;
416    if ([identifier isEqualToString: TAB_ACTIVITY_IDENT])
417    {
418        height = TAB_ACTIVITY_HEIGHT;
419        [fPiecesView updateView: YES];
420    }
421    else if ([identifier isEqualToString: TAB_PEERS_IDENT])
422    {
423        height = TAB_PEERS_HEIGHT;
424    }
425    else if ([identifier isEqualToString: TAB_FILES_IDENT])
426        height = TAB_FILES_HEIGHT;
427    else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
428        height = TAB_OPTIONS_HEIGHT;
429    else
430        height = TAB_INFO_HEIGHT;
431   
432    NSWindow * window = [self window];
433    NSRect frame = [window frame];
434    NSView * view = [[fTabView selectedTabViewItem] view];
435   
436    float difference = height - [view frame].size.height;
437    frame.origin.y -= difference;
438    frame.size.height += difference;
439   
440    if (animate)
441    {
442        [view setHidden: YES];
443        [window setFrame: frame display: YES animate: YES];
444        [view setHidden: NO];
445    }
446    else
447        [window setFrame: frame display: YES];
448   
449    [window setMinSize: NSMakeSize(MIN_WINDOW_WIDTH, frame.size.height)];
450    [window setMaxSize: NSMakeSize(MAX_WINDOW_WIDTH, frame.size.height)];
451}
452
453- (void) setNextTab
454{
455    if ([fTabView indexOfTabViewItem: [fTabView selectedTabViewItem]] == [fTabView numberOfTabViewItems] - 1)
456        [fTabView selectFirstTabViewItem: nil];
457    else
458        [fTabView selectNextTabViewItem: nil];
459}
460
461- (void) setPreviousTab
462{
463    if ([fTabView indexOfTabViewItem: [fTabView selectedTabViewItem]] == 0)
464        [fTabView selectLastTabViewItem: nil];
465    else
466        [fTabView selectPreviousTabViewItem: nil];
467}
468
469- (int) numberOfRowsInTableView: (NSTableView *) tableView
470{
471    if (tableView == fPeerTable)
472        return [fPeers count];
473    else
474        return [fFiles count];
475}
476
477- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row
478{
479    NSString * ident = [column identifier];
480    if (tableView == fPeerTable)
481    {
482        NSDictionary * peer = [fPeers objectAtIndex: row];
483       
484        if ([ident isEqualToString: @"Connected"])
485            return [[peer objectForKey: @"Connected"] boolValue] ? fDotGreen : fDotRed;
486        else if ([ident isEqualToString: @"UL To"])
487            return [[peer objectForKey: @"UL To"] boolValue] ? fCheckImage : nil;
488        else if ([ident isEqualToString: @"DL From"])
489            return [[peer objectForKey: @"DL From"] boolValue] ? fCheckImage : nil;
490        else if ([ident isEqualToString: @"Client"])
491            return [peer objectForKey: @"Client"];
492        else
493            return [peer objectForKey: @"IP"];
494    }
495    else
496    {
497        NSDictionary * file = [fFiles objectAtIndex: row];
498        if ([ident isEqualToString: @"Icon"])
499            return [[NSWorkspace sharedWorkspace] iconForFileType: [[file objectForKey: @"Name"] pathExtension]];
500        else if ([ident isEqualToString: @"Size"])
501            return [NSString stringForFileSize: [[file objectForKey: @"Size"] unsignedLongLongValue]];
502        else
503            return [[file objectForKey: @"Name"] lastPathComponent];
504    }
505}
506
507- (void) tableView: (NSTableView *) tableView didClickTableColumn: (NSTableColumn *) tableColumn
508{
509    if (tableView == fPeerTable)
510    {
511        [fPeers sortUsingDescriptors: [self peerSortDescriptors]];
512        [tableView reloadData];
513    }
514}
515
516- (BOOL) tableView: (NSTableView *) tableView shouldSelectRow:(int) row
517{
518    return tableView != fPeerTable;
519}
520
521//only called on >= 10.4
522- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell
523        rect: (NSRectPointer) rect tableColumn: (NSTableColumn *) column
524        row: (int) row mouseLocation: (NSPoint) mouseLocation
525{
526    if (tableView == fFileTable)
527    {
528        NSDictionary * file = [fFiles objectAtIndex: row];
529        if ([[column identifier] isEqualToString: @"Size"])
530            return [[[file objectForKey: @"Size"] stringValue] stringByAppendingString: NSLocalizedString(@" bytes", "Inspector -> Files tab -> table row tooltip")];
531        else
532            return [file objectForKey: @"Name"];
533    }
534    else if (tableView == fPeerTable)
535    {
536        if ([[[fPeers objectAtIndex: row] objectForKey: @"Incoming"] boolValue])
537            return NSLocalizedString(@"From incoming connection", "Inspector -> Peers tab -> table row tooltip");
538        else
539            return NSLocalizedString(@"From outgoing connection", "Inspector -> Peers tab -> table row tooltip");
540    }
541    else
542        return nil;
543}
544
545- (NSArray *) peerSortDescriptors
546{
547    NSMutableArray * descriptors = [NSMutableArray array];
548   
549    NSArray * oldDescriptors = [fPeerTable sortDescriptors];
550    if ([oldDescriptors count] > 0)
551        [descriptors addObject: [oldDescriptors objectAtIndex: 0]];
552   
553    [descriptors addObject: [[fPeerTable tableColumnWithIdentifier: @"IP"] sortDescriptorPrototype]];
554   
555    return descriptors;
556}
557
558- (void) revealTorrentFile: (id) sender
559{
560    if ([fTorrents count] > 0)
561        [[fTorrents objectAtIndex: 0] revealPublicTorrent];
562}
563
564- (void) revealDataFile: (id) sender
565{
566    if ([fTorrents count] > 0)
567        [[fTorrents objectAtIndex: 0] revealData];
568}
569
570- (void) revealFile: (id) sender
571{
572    NSIndexSet * indexSet = [fFileTable selectedRowIndexes];
573    unsigned int i;
574    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
575        [[NSWorkspace sharedWorkspace] selectFile: [[fFiles objectAtIndex: i] objectForKey: @"Name"]
576                                        inFileViewerRootedAtPath: nil];
577}
578
579- (void) setRatioCheck: (id) sender
580{
581    int ratioSetting, tag = [[fRatioMatrix selectedCell] tag];
582    if (tag == RATIO_CHECK_TAG)
583        ratioSetting = RATIO_CHECK;
584    else if (tag == RATIO_NO_CHECK_TAG)
585        ratioSetting = RATIO_NO_CHECK;
586    else
587        ratioSetting = RATIO_GLOBAL;
588
589    Torrent * torrent;
590    NSEnumerator * enumerator = [fTorrents objectEnumerator];
591    while ((torrent = [enumerator nextObject]))
592        [torrent setStopRatioSetting: ratioSetting];
593   
594    [self setRatioLimit: fRatioLimitField];
595    [fRatioLimitField setEnabled: tag == RATIO_CHECK_TAG];
596}
597
598- (void) setRatioLimit: (id) sender
599{
600    Torrent * torrent;
601    NSEnumerator * enumerator = [fTorrents objectEnumerator];
602
603    float ratioLimit = [sender floatValue];
604    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]] || ratioLimit < 0)
605    {
606        NSBeep();
607        float ratioLimit = [[enumerator nextObject] ratioLimit]; //use first torrent
608        while ((torrent = [enumerator nextObject]))
609            if (ratioLimit != [torrent ratioLimit])
610            {
611                [sender setStringValue: @""];
612                return;
613            }
614       
615        [sender setFloatValue: ratioLimit];
616    }
617    else
618    {
619        while ((torrent = [enumerator nextObject]))
620            [torrent setRatioLimit: ratioLimit];
621    }
622}
623
624@end
Note: See TracBrowser for help on using the repository browser.