Changeset 6002


Ignore:
Timestamp:
Jun 2, 2008, 7:17:04 PM (14 years ago)
Author:
livings124
Message:

pluralize the "remove tracker" dialogue appropriately; merge more of the remove code

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/InfoWindowController.m

    r6001 r6002  
    14531453    NSMutableIndexSet * indexes = [[[fTrackerTable selectedRowIndexes] mutableCopy] autorelease];
    14541454   
    1455    
    1456     NSUInteger i = 0;
     1455    //get all rows to remove and determine if any built-in trackers are being remove
     1456    NSUInteger i = 0, numberBuiltIn = 0;
    14571457    while (i < [fTrackers count])
    14581458    {
     1459        BOOL builtIn = i != 0 || [[fTrackers objectAtIndex: i] intValue] != 0;
     1460       
    14591461        //if a group is selected, remove all trackers in the group
    14601462        if ([indexes containsIndex: i])
    14611463        {
    14621464            for (i = i+1; i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]]; i++)
     1465            {
    14631466                [indexes addIndex: i];
     1467                if (builtIn)
     1468                    numberBuiltIn++;
     1469            }
    14641470        }
    14651471        //remove empty groups
     
    14691475            NSUInteger j;
    14701476            for (j = i+1; j < [fTrackers count] && ![[fTrackers objectAtIndex: j] isKindOfClass: [NSNumber class]]; j++)
     1477            {
    14711478                if (![indexes containsIndex: j])
    1472                 {
    14731479                    allSelected = NO;
    1474                     break;
    1475                 }
     1480                else if (builtIn)
     1481                    numberBuiltIn++;
     1482                else;
     1483            }
    14761484           
    14771485            if (allSelected)
    14781486                [indexes addIndex: i];
     1487           
    14791488            i = j;
    1480            
    1481             //get to next group
    1482             while (i < [fTrackers count] && ![[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
    1483                 i++;
    14841489        }
    14851490    }
     
    14931498    Torrent * torrent = [fTorrents objectAtIndex: 0];
    14941499   
    1495     //determine if removing trackers not built-in to the torrent
    1496     if ([[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveBuiltInTracker"])
    1497     {
    1498         BOOL allBuiltIn = ![torrent hasAddedTrackers];
    1499         if (!allBuiltIn)
    1500         {
    1501             for (i=1; i < [fTrackers count]; i++)
    1502                 if ([[fTrackers objectAtIndex: i] isKindOfClass: [NSNumber class]])
    1503                     break;
    1504         }
    1505        
    1506         if (allBuiltIn || [indexes indexGreaterThanOrEqualToIndex: i] != NSNotFound)
    1507         {
    1508             #warning pluralize?
    1509             NSAlert * alert = [[NSAlert alloc] init];
    1510             [alert setMessageText: NSLocalizedString(@"Are you sure you want to remove built-in trackers?",
    1511                                     "Remove built-in tracker alert -> title")];
     1500    //determine if removing trackers built into the torrent
     1501    if (numberBuiltIn > 0 && [[NSUserDefaults standardUserDefaults] boolForKey: @"WarningRemoveBuiltInTracker"])
     1502    {
     1503        #warning pluralize?
     1504        NSAlert * alert = [[NSAlert alloc] init];
     1505       
     1506        if (numberBuiltIn > 1)
     1507        {
     1508            [alert setMessageText: [NSString stringWithFormat:
     1509                                    NSLocalizedString(@"Are you sure you want to remove %d built-in trackers?",
     1510                                    "Remove built-in tracker alert -> title"), numberBuiltIn]];
    15121511            [alert setInformativeText: NSLocalizedString(@"These tracker addresses are part of the torrent file."
    15131512                " Once removed, Transmission will no longer attempt to contact them.", "Remove built-in tracker alert -> message")];
    1514             [alert addButtonWithTitle: NSLocalizedString(@"Remove", "Remove built-in tracker alert -> button")];
    1515             [alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Remove built-in tracker alert -> button")];
    1516            
    1517             BOOL onLeopard = [NSApp isOnLeopardOrBetter];
    1518             if (onLeopard)
    1519                 [alert setShowsSuppressionButton: YES];
    1520             else
    1521                 [alert addButtonWithTitle: NSLocalizedString(@"Don't Alert Again", "Remove built-in tracker alert -> button")];
    1522 
    1523             NSInteger result = [alert runModal];
    1524             if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn))
    1525                 [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningRemoveBuiltInTracker"];
    1526             [alert release];
    1527            
    1528             if (result != NSAlertFirstButtonReturn)
    1529                 return;
    1530         }
     1513        }
     1514        else
     1515        {
     1516            [alert setMessageText: NSLocalizedString(@"Are you sure you want to remove a built-in tracker?",
     1517                                    "Remove built-in tracker alert -> title")];
     1518            [alert setInformativeText: NSLocalizedString(@"The tracker address is part of the torrent file."
     1519                " Once removed, Transmission will no longer attempt to contact it.", "Remove built-in tracker alert -> message")];
     1520        }
     1521       
     1522        [alert addButtonWithTitle: NSLocalizedString(@"Remove", "Remove built-in tracker alert -> button")];
     1523        [alert addButtonWithTitle: NSLocalizedString(@"Cancel", "Remove built-in tracker alert -> button")];
     1524       
     1525        BOOL onLeopard = [NSApp isOnLeopardOrBetter];
     1526        if (onLeopard)
     1527            [alert setShowsSuppressionButton: YES];
     1528        else
     1529            [alert addButtonWithTitle: NSLocalizedString(@"Don't Alert Again", "Remove built-in tracker alert -> button")];
     1530
     1531        NSInteger result = [alert runModal];
     1532        if ((onLeopard ? [[alert suppressionButton] state] == NSOnState : result == NSAlertThirdButtonReturn))
     1533            [[NSUserDefaults standardUserDefaults] setBool: NO forKey: @"WarningRemoveBuiltInTracker"];
     1534        [alert release];
     1535       
     1536        if (result != NSAlertFirstButtonReturn)
     1537            return;
    15311538    }
    15321539   
Note: See TracChangeset for help on using the changeset viewer.