source: trunk/macosx/InfoWindowController.m @ 1053

Last change on this file since 1053 was 1053, checked in by livings124, 15 years ago

update inspector when torrent location changes

  • Property svn:keywords set to Date Rev Author Id
File size: 21.7 KB
Line 
1/******************************************************************************
2 * $Id: InfoWindowController.m 1053 2006-11-04 08:32:29Z 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       
215        [fDateStartedField setObjectValue: [torrent date]];
216       
217        [fRevealDataButton setHidden: NO];
218        [fRevealTorrentButton setHidden: ![torrent publicTorrent]];
219       
220        //allow these fields to be selected
221        [fTrackerField setSelectable: YES];
222        [fAnnounceField setSelectable: YES];
223        [fHashField setSelectable: YES];
224        [fTorrentLocationField setSelectable: YES];
225        [fDataLocationField setSelectable: YES];
226       
227        [fPiecesView setTorrent: torrent];
228    }
229   
230    //update stats and settings
231    [self updateInfoStats];
232    [self updateInfoSettings];
233
234    //set file table
235    [fFiles removeAllObjects];
236   
237    if (numberSelected > 0)
238    {
239        Torrent * torrent;
240        NSEnumerator * enumerator = [fTorrents objectEnumerator];
241        while ((torrent = [enumerator nextObject]))
242            [fFiles addObjectsFromArray: [torrent fileList]];
243       
244        if ([fFiles count] > 1)
245            [fFileTableStatusField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d files", "Inspector -> Files tab -> bottom text (number of files)"), [fFiles count]]];
246        else
247            [fFileTableStatusField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%d file", "Inspector -> Files tab -> bottom text (number of files)"), [fFiles count]]];
248    }
249    else
250        [fFileTableStatusField setStringValue: NSLocalizedString(@"info not available", "Inspector -> Files tab -> bottom text (number of files)")];
251   
252    [fFileTable deselectAll: nil];
253    [fFileTable reloadData];
254}
255
256- (void) updateInfoStats
257{
258    if ([[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_ACTIVITY_IDENT])
259        [self updateInfoActivity];
260    else if ([[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_PEERS_IDENT])
261        [self updateInfoPeers];
262    else;
263}
264
265- (void) updateInfoActivity
266{
267    int numberSelected = [fTorrents count];
268    if (numberSelected == 0)
269        return;
270   
271    float downloadedValid = 0;
272    uint64_t downloadedTotal = 0, uploadedTotal = 0;
273    Torrent * torrent;
274    NSEnumerator * enumerator = [fTorrents objectEnumerator];
275    while ((torrent = [enumerator nextObject]))
276    {
277        downloadedValid += [torrent downloadedValid];
278        downloadedTotal += [torrent downloadedTotal];
279        uploadedTotal += [torrent uploadedTotal];
280    }
281
282    [fDownloadedValidField setStringValue: [NSString stringForFileSize: downloadedValid]];
283    [fDownloadedTotalField setStringValue: [NSString stringForFileSize: downloadedTotal]];
284    [fUploadedTotalField setStringValue: [NSString stringForFileSize: uploadedTotal]];
285   
286    if (numberSelected == 1)
287    {
288        torrent = [fTorrents objectAtIndex: 0];
289       
290        //append percentage to amount downloaded if 1 torrent
291        [fDownloadedValidField setStringValue: [[fDownloadedValidField stringValue]
292                                        stringByAppendingFormat: @" (%.2f%%)", 100.0 * [torrent progress]]];
293       
294        [fStateField setStringValue: [torrent stateString]];
295       
296        [fRatioField setStringValue: [NSString stringForRatioWithDownload: downloadedTotal upload: uploadedTotal]];
297       
298        [fSwarmSpeedField setStringValue: [torrent isActive] ? [NSString stringForSpeed: [torrent swarmSpeed]] : @""];
299       
300        [fPiecesView updateView: NO];
301    }
302}
303
304- (void) updateInfoPeers
305{
306    if ([fTorrents count] != 1)
307        return;
308    Torrent * torrent = [fTorrents objectAtIndex: 0];
309   
310    int seeders = [torrent seeders], leechers = [torrent leechers];
311    [fSeedersField setStringValue: seeders < 0 ? @"" : [NSString stringWithInt: seeders]];
312    [fLeechersField setStringValue: leechers < 0 ? @"" : [NSString stringWithInt: leechers]];
313   
314    BOOL active = [torrent isActive];
315    [fConnectedPeersField setStringValue: active ? [NSString stringWithFormat: NSLocalizedString(@"%d (%d incoming)", "Inspector -> Peers tab -> connected"),
316                                                    [torrent totalPeers], [torrent totalPeersIncoming]]: @""];
317    [fDownloadingFromField setStringValue: active ? [NSString stringWithInt: [torrent peersUploading]] : @""];
318    [fUploadingToField setStringValue: active ? [NSString stringWithInt: [torrent peersDownloading]] : @""];
319   
320    [fPeers setArray: [torrent peers]];
321    [fPeers sortUsingDescriptors: [self peerSortDescriptors]];
322   
323    [fPeerTable reloadData];
324}
325
326- (void) updateInfoSettings
327{
328    int numberSelected = [fTorrents count];
329
330    if (numberSelected > 0)
331    {
332        Torrent * torrent;
333       
334        if (numberSelected == 1)
335        {
336            torrent = [fTorrents objectAtIndex: 0];
337            [fDataLocationField setStringValue: [[torrent dataLocation] stringByAbbreviatingWithTildeInPath]];
338            [fDataLocationField setToolTip: [torrent dataLocation]];
339        }
340       
341        //set ratio settings
342        NSEnumerator * enumerator = [fTorrents objectEnumerator];
343        torrent = [enumerator nextObject]; //first torrent
344       
345        int ratioSetting = [torrent stopRatioSetting];
346        float ratioLimit = [torrent ratioLimit];
347       
348        while ((ratioSetting != INVALID || ratioLimit != INVALID)
349                && (torrent = [enumerator nextObject]))
350        {
351            if (ratioSetting != INVALID && ratioSetting != [torrent stopRatioSetting])
352                ratioSetting = INVALID;
353           
354            if (ratioLimit != INVALID && ratioLimit != [torrent ratioLimit])
355                ratioLimit = INVALID;
356        }
357       
358        [fRatioMatrix setEnabled: YES];
359       
360        if (ratioSetting == RATIO_CHECK)
361        {
362            [fRatioMatrix selectCellWithTag: RATIO_CHECK_TAG];
363            [fRatioLimitField setEnabled: YES];
364        }
365        else
366        {
367            if (ratioSetting == RATIO_NO_CHECK)
368                [fRatioMatrix selectCellWithTag: RATIO_NO_CHECK_TAG];
369            else if (ratioSetting == RATIO_GLOBAL)
370                [fRatioMatrix selectCellWithTag: RATIO_GLOBAL_TAG];
371            else
372                [fRatioMatrix deselectAllCells];
373           
374            [fRatioLimitField setEnabled: NO];
375        }
376       
377        if (ratioLimit != INVALID)
378            [fRatioLimitField setFloatValue: ratioLimit];
379        else
380            [fRatioLimitField setStringValue: @""];
381    }
382    else
383    {
384        [fRatioMatrix deselectAllCells];
385        [fRatioMatrix setEnabled: NO];
386       
387        [fRatioLimitField setEnabled: NO];
388        [fRatioLimitField setStringValue: @""];
389    }
390   
391    [self updateInfoStats];
392}
393
394- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
395{
396    SEL action = [menuItem action];
397   
398    if (action == @selector(revealFile:))
399        return [fFileTable numberOfSelectedRows] > 0 &&
400            [[[fTabView selectedTabViewItem] identifier] isEqualToString: TAB_FILES_IDENT];
401       
402    return YES;
403}
404
405- (NSRect) windowWillUseStandardFrame: (NSWindow *) window defaultFrame: (NSRect) defaultFrame
406{
407    NSRect windowRect = [window frame];
408    windowRect.size.width = [window minSize].width;   
409    return windowRect;
410}
411
412- (void) tabView: (NSTabView *) tabView didSelectTabViewItem: (NSTabViewItem *) tabViewItem
413{
414    NSString * identifier = [tabViewItem identifier];
415    [self setWindowForTab: identifier animate: YES];
416    [[NSUserDefaults standardUserDefaults] setObject: identifier forKey: @"InfoTab"];
417}
418
419- (void) setWindowForTab: (NSString *) identifier animate: (BOOL) animate
420{
421    [self updateInfoStats];
422   
423    float height;
424    if ([identifier isEqualToString: TAB_ACTIVITY_IDENT])
425    {
426        height = TAB_ACTIVITY_HEIGHT;
427        [fPiecesView updateView: YES];
428    }
429    else if ([identifier isEqualToString: TAB_PEERS_IDENT])
430    {
431        height = TAB_PEERS_HEIGHT;
432    }
433    else if ([identifier isEqualToString: TAB_FILES_IDENT])
434        height = TAB_FILES_HEIGHT;
435    else if ([identifier isEqualToString: TAB_OPTIONS_IDENT])
436        height = TAB_OPTIONS_HEIGHT;
437    else
438        height = TAB_INFO_HEIGHT;
439   
440    NSWindow * window = [self window];
441    NSRect frame = [window frame];
442    NSView * view = [[fTabView selectedTabViewItem] view];
443   
444    float difference = height - [view frame].size.height;
445    frame.origin.y -= difference;
446    frame.size.height += difference;
447   
448    if (animate)
449    {
450        [view setHidden: YES];
451        [window setFrame: frame display: YES animate: YES];
452        [view setHidden: NO];
453    }
454    else
455        [window setFrame: frame display: YES];
456   
457    [window setMinSize: NSMakeSize(MIN_WINDOW_WIDTH, frame.size.height)];
458    [window setMaxSize: NSMakeSize(MAX_WINDOW_WIDTH, frame.size.height)];
459}
460
461- (void) setNextTab
462{
463    if ([fTabView indexOfTabViewItem: [fTabView selectedTabViewItem]] == [fTabView numberOfTabViewItems] - 1)
464        [fTabView selectFirstTabViewItem: nil];
465    else
466        [fTabView selectNextTabViewItem: nil];
467}
468
469- (void) setPreviousTab
470{
471    if ([fTabView indexOfTabViewItem: [fTabView selectedTabViewItem]] == 0)
472        [fTabView selectLastTabViewItem: nil];
473    else
474        [fTabView selectPreviousTabViewItem: nil];
475}
476
477- (int) numberOfRowsInTableView: (NSTableView *) tableView
478{
479    if (tableView == fPeerTable)
480        return [fPeers count];
481    else
482        return [fFiles count];
483}
484
485- (id) tableView: (NSTableView *) tableView objectValueForTableColumn: (NSTableColumn *) column row: (int) row
486{
487    NSString * ident = [column identifier];
488    if (tableView == fPeerTable)
489    {
490        NSDictionary * peer = [fPeers objectAtIndex: row];
491       
492        if ([ident isEqualToString: @"Connected"])
493            return [[peer objectForKey: @"Connected"] boolValue] ? fDotGreen : fDotRed;
494        else if ([ident isEqualToString: @"UL To"])
495            return [[peer objectForKey: @"UL To"] boolValue] ? fCheckImage : nil;
496        else if ([ident isEqualToString: @"DL From"])
497            return [[peer objectForKey: @"DL From"] boolValue] ? fCheckImage : nil;
498        else if ([ident isEqualToString: @"Client"])
499            return [peer objectForKey: @"Client"];
500        else
501            return [peer objectForKey: @"IP"];
502    }
503    else
504    {
505        NSDictionary * file = [fFiles objectAtIndex: row];
506        if ([ident isEqualToString: @"Icon"])
507            return [[NSWorkspace sharedWorkspace] iconForFileType: [[file objectForKey: @"Name"] pathExtension]];
508        else if ([ident isEqualToString: @"Size"])
509            return [NSString stringForFileSize: [[file objectForKey: @"Size"] unsignedLongLongValue]];
510        else
511            return [[file objectForKey: @"Name"] lastPathComponent];
512    }
513}
514
515- (void) tableView: (NSTableView *) tableView didClickTableColumn: (NSTableColumn *) tableColumn
516{
517    if (tableView == fPeerTable)
518    {
519        [fPeers sortUsingDescriptors: [self peerSortDescriptors]];
520        [tableView reloadData];
521    }
522}
523
524- (BOOL) tableView: (NSTableView *) tableView shouldSelectRow:(int) row
525{
526    return tableView != fPeerTable;
527}
528
529- (NSString *) tableView: (NSTableView *) tableView toolTipForCell: (NSCell *) cell
530        rect: (NSRectPointer) rect tableColumn: (NSTableColumn *) column
531        row: (int) row mouseLocation: (NSPoint) mouseLocation
532{
533    if (tableView == fFileTable)
534    {
535        NSDictionary * file = [fFiles objectAtIndex: row];
536        if ([[column identifier] isEqualToString: @"Size"])
537            return [[[file objectForKey: @"Size"] stringValue] stringByAppendingString: NSLocalizedString(@" bytes", "Inspector -> Files tab -> table row tooltip")];
538        else
539            return [file objectForKey: @"Name"];
540    }
541    else if (tableView == fPeerTable)
542    {
543        if ([[[fPeers objectAtIndex: row] objectForKey: @"Incoming"] boolValue])
544            return NSLocalizedString(@"From incoming connection", "Inspector -> Peers tab -> table row tooltip");
545        else
546            return NSLocalizedString(@"From outgoing connection", "Inspector -> Peers tab -> table row tooltip");
547    }
548    else
549        return nil;
550}
551
552- (NSArray *) peerSortDescriptors
553{
554    NSMutableArray * descriptors = [NSMutableArray array];
555   
556    NSArray * oldDescriptors = [fPeerTable sortDescriptors];
557    if ([oldDescriptors count] > 0)
558        [descriptors addObject: [oldDescriptors objectAtIndex: 0]];
559   
560    [descriptors addObject: [[fPeerTable tableColumnWithIdentifier: @"IP"] sortDescriptorPrototype]];
561   
562    return descriptors;
563}
564
565- (void) revealTorrentFile: (id) sender
566{
567    if ([fTorrents count] > 0)
568        [[fTorrents objectAtIndex: 0] revealPublicTorrent];
569}
570
571- (void) revealDataFile: (id) sender
572{
573    if ([fTorrents count] > 0)
574        [[fTorrents objectAtIndex: 0] revealData];
575}
576
577- (void) revealFile: (id) sender
578{
579    NSIndexSet * indexSet = [fFileTable selectedRowIndexes];
580    unsigned int i;
581    for (i = [indexSet firstIndex]; i != NSNotFound; i = [indexSet indexGreaterThanIndex: i])
582        [[NSWorkspace sharedWorkspace] selectFile: [[fFiles objectAtIndex: i] objectForKey: @"Name"]
583                                        inFileViewerRootedAtPath: nil];
584}
585
586- (void) setRatioCheck: (id) sender
587{
588    int ratioSetting, tag = [[fRatioMatrix selectedCell] tag];
589    if (tag == RATIO_CHECK_TAG)
590        ratioSetting = RATIO_CHECK;
591    else if (tag == RATIO_NO_CHECK_TAG)
592        ratioSetting = RATIO_NO_CHECK;
593    else
594        ratioSetting = RATIO_GLOBAL;
595
596    Torrent * torrent;
597    NSEnumerator * enumerator = [fTorrents objectEnumerator];
598    while ((torrent = [enumerator nextObject]))
599        [torrent setStopRatioSetting: ratioSetting];
600   
601    [self setRatioLimit: fRatioLimitField];
602    [fRatioLimitField setEnabled: tag == RATIO_CHECK_TAG];
603}
604
605- (void) setRatioLimit: (id) sender
606{
607    Torrent * torrent;
608    NSEnumerator * enumerator = [fTorrents objectEnumerator];
609
610    float ratioLimit = [sender floatValue];
611    if (![[sender stringValue] isEqualToString: [NSString stringWithFormat: @"%.2f", ratioLimit]] || ratioLimit < 0)
612    {
613        NSBeep();
614        float ratioLimit = [[enumerator nextObject] ratioLimit]; //use first torrent
615        while ((torrent = [enumerator nextObject]))
616            if (ratioLimit != [torrent ratioLimit])
617            {
618                [sender setStringValue: @""];
619                return;
620            }
621       
622        [sender setFloatValue: ratioLimit];
623    }
624    else
625    {
626        while ((torrent = [enumerator nextObject]))
627            [torrent setRatioLimit: ratioLimit];
628    }
629}
630
631@end
Note: See TracBrowser for help on using the repository browser.