Ticket #6042: CompleteLionDeadCode.diff

File CompleteLionDeadCode.diff, 41.2 KB (added by mattrajca, 7 years ago)
  • macosx/Controller.m

     
    14741474
    14751475- (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData
    14761476{
    1477     NSMutableArray * selectedValues = nil;
    1478     if (![NSApp isOnLionOrBetter])
    1479     {
    1480         selectedValues = [NSMutableArray arrayWithArray: [fTableView selectedValues]];
    1481         [selectedValues removeObjectsInArray: torrents];
    1482     }
    1483    
    14841477    //miscellaneous
    14851478    for (Torrent * torrent in torrents)
    14861479    {
     
    15231516       
    15241517        if ([indexes count] > 0)
    15251518        {
    1526             if ([NSApp isOnLionOrBetter])
     1519            if (!beganUpdate)
    15271520            {
    1528                 if (!beganUpdate)
    1529                 {
    1530                     [NSAnimationContext beginGrouping]; //this has to be before we set the completion handler (#4874)
    1531                    
    1532                     //we can't closeRemoveTorrent: until it's no longer in the GUI at all
    1533                     [[NSAnimationContext currentContext] setCompletionHandler: ^{
    1534                         for (Torrent * torrent in torrents)
    1535                             [torrent closeRemoveTorrent: deleteData];
    1536                     }];
    1537                    
    1538                     [fTableView beginUpdates];
    1539                     beganUpdate = YES;
    1540                 }
     1521                [NSAnimationContext beginGrouping]; //this has to be before we set the completion handler (#4874)
    15411522               
    1542                 [fTableView removeItemsAtIndexes: indexes inParent: parent withAnimation: NSTableViewAnimationSlideLeft];
     1523                //we can't closeRemoveTorrent: until it's no longer in the GUI at all
     1524                [[NSAnimationContext currentContext] setCompletionHandler: ^{
     1525                    for (Torrent * torrent in torrents)
     1526                        [torrent closeRemoveTorrent: deleteData];
     1527                }];
     1528               
     1529                [fTableView beginUpdates];
     1530                beganUpdate = YES;
    15431531            }
     1532           
     1533            [fTableView removeItemsAtIndexes: indexes inParent: parent withAnimation: NSTableViewAnimationSlideLeft];
     1534
    15441535            [displayedTorrents removeObjectsAtIndexes: indexes];
    15451536        }
    15461537    };
     
    15701561            [torrent closeRemoveTorrent: deleteData];
    15711562    }
    15721563   
    1573     if (selectedValues)
    1574         [fTableView selectValues: selectedValues];
    1575    
    15761564    [self fullUpdateUI];
    15771565}
    15781566
     
    22262214
    22272215- (void) sortTorrents: (BOOL) includeQueueOrder
    22282216{
    2229     const BOOL onLion = [NSApp isOnLionOrBetter];
    2230    
    2231     NSArray * selectedValues;
    2232     if (!onLion)
    2233         selectedValues = [fTableView selectedValues];
    2234    
    22352217    //actually sort
    22362218    [self sortTorrentsCallUpdates: YES includeQueueOrder: includeQueueOrder];
    2237    
    2238     if (!onLion)
    2239         [fTableView selectValues: selectedValues];
    2240    
    22412219    [fTableView setNeedsDisplay: YES];
    22422220}
    22432221
     
    23062284        descriptors = [NSArray arrayWithObject: orderDescriptor];
    23072285    }
    23082286   
    2309     BOOL beganTableUpdate = !callUpdates || ![NSApp isOnLionOrBetter];
     2287    BOOL beganTableUpdate = !callUpdates;
    23102288   
    23112289    //actually sort
    23122290    if ([fDefaults boolForKey: @"SortByGroup"])
     
    23192297   
    23202298    if (beganTableUpdate && callUpdates)
    23212299    {
    2322         if ([NSApp isOnLionOrBetter])
    2323             [fTableView endUpdates];
    2324         else
    2325             [fTableView reloadData];
     2300        [fTableView endUpdates];
    23262301    }
    23272302}
    23282303
     
    23482323            if (!*beganTableUpdate)
    23492324            {
    23502325                *beganTableUpdate = YES;
    2351                 if ([NSApp isOnLionOrBetter])
    2352                     [fTableView beginUpdates];
     2326                [fTableView beginUpdates];
    23532327            }
    23542328           
    23552329            [rearrangeArray moveObjectAtIndex: currentIndex toIndex: insertIndex];
    2356             if ([NSApp isOnLionOrBetter])
    2357                 [fTableView moveItemAtIndex: currentIndex inParent: parent toIndex: insertIndex inParent: parent];
     2330            [fTableView moveItemAtIndex: currentIndex inParent: parent toIndex: insertIndex inParent: parent];
    23582331        }
    23592332    }
    23602333   
     
    23632336
    23642337- (void) applyFilter
    23652338{
    2366     const BOOL onLion = [NSApp isOnLionOrBetter];
    2367    
    2368     NSArray * selectedValuesSL = nil;
    2369     if (!onLion)
    2370         selectedValuesSL = [fTableView selectedValues];
    2371    
    23722339    __block int32_t active = 0, downloading = 0, seeding = 0, paused = 0;
    23732340    NSString * filterType = [fDefaults stringForKey: @"Filter"];
    23742341    BOOL filterActive = NO, filterDownload = NO, filterSeed = NO, filterPause = NO, filterStatus = YES;
     
    24982465    }
    24992466   
    25002467    BOOL beganUpdates = NO;
     2468
     2469    //don't animate torrents when first launching
     2470    static dispatch_once_t onceToken;
     2471    dispatch_once(&onceToken, ^{
     2472        [[NSAnimationContext currentContext] setDuration: 0];
     2473    });
     2474    [NSAnimationContext beginGrouping];
    25012475   
    2502     if (onLion)
    2503     {
    2504         //don't animate torrents when first launching
    2505         static dispatch_once_t onceToken;
    2506         dispatch_once(&onceToken, ^{
    2507             [[NSAnimationContext currentContext] setDuration: 0];
    2508         });
    2509         [NSAnimationContext beginGrouping];
    2510     }
    2511    
    25122476    //add/remove torrents (and rearrange for groups), one by one
    25132477    if (!groupRows && !wasGroupRows)
    25142478    {
     
    25292493        if ([addIndexes count] > 0 || [removePreviousIndexes count] > 0)
    25302494        {
    25312495            beganUpdates = YES;
    2532             if (onLion)
    2533                 [fTableView beginUpdates];
     2496            [fTableView beginUpdates];
    25342497           
    25352498            //remove torrents we didn't find
    25362499            if ([removePreviousIndexes count] > 0)
    25372500            {
    25382501                [fDisplayedTorrents removeObjectsAtIndexes: removePreviousIndexes];
    2539                 if (onLion)
    2540                     [fTableView removeItemsAtIndexes: removePreviousIndexes inParent: nil withAnimation: NSTableViewAnimationSlideDown];
     2502                [fTableView removeItemsAtIndexes: removePreviousIndexes inParent: nil withAnimation: NSTableViewAnimationSlideDown];
    25412503            }
    25422504           
    25432505            //add new torrents
     
    25532515                    [addIndexes removeIndexes: newAddIndexes];
    25542516                   
    25552517                    [fDisplayedTorrents addObjectsFromArray: [allTorrents objectsAtIndexes: newAddIndexes]];
    2556                     if (onLion)
    2557                         [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange([fDisplayedTorrents count] - [newAddIndexes count], [newAddIndexes count])] inParent: nil withAnimation: NSTableViewAnimationSlideLeft];
     2518                    [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange([fDisplayedTorrents count] - [newAddIndexes count], [newAddIndexes count])] inParent: nil withAnimation: NSTableViewAnimationSlideLeft];
    25582519                }
    25592520               
    25602521                [fDisplayedTorrents addObjectsFromArray: [allTorrents objectsAtIndexes: addIndexes]];
    2561                 if (onLion)
    2562                     [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange([fDisplayedTorrents count] - [addIndexes count], [addIndexes count])] inParent: nil withAnimation: NSTableViewAnimationSlideDown];
     2522                [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange([fDisplayedTorrents count] - [addIndexes count], [addIndexes count])] inParent: nil withAnimation: NSTableViewAnimationSlideDown];
    25632523            }
    25642524        }
    25652525    }
     
    25692529       
    25702530        #warning don't always do?
    25712531        beganUpdates = YES;
    2572         if (onLion)
    2573             [fTableView beginUpdates];
     2532        [fTableView beginUpdates];
    25742533       
    25752534        NSMutableIndexSet * unusedAllTorrentsIndexes = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [allTorrents count])];
    25762535       
     
    26072566                            newGroup = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
    26082567                            [groupsByIndex setObject: newGroup forKey: [NSNumber numberWithInteger: groupValue]];
    26092568                            [fDisplayedTorrents addObject: newGroup];
    2610                            
    2611                             if (onLion)
    2612                             {
    2613                                 [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndex: [fDisplayedTorrents count]-1] inParent: nil withAnimation: NSTableViewAnimationEffectFade];
    2614                                 [fTableView isGroupCollapsed: groupValue] ? [fTableView collapseItem: newGroup] : [fTableView expandItem: newGroup];
    2615                             }
     2569
     2570                            [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndex: [fDisplayedTorrents count]-1] inParent: nil withAnimation: NSTableViewAnimationEffectFade];
     2571                            [fTableView isGroupCollapsed: groupValue] ? [fTableView collapseItem: newGroup] : [fTableView expandItem: newGroup];
    26162572                        }
    26172573                        else //if we haven't processed the other group yet, we have to make sure we don't flag it for removal the next time
    26182574                        {
     
    26232579                       
    26242580                        [[group torrents] removeObjectAtIndex: indexInGroup];
    26252581                        [[newGroup torrents] addObject: torrent];
     2582
     2583                        [fTableView moveItemAtIndex: indexInGroup inParent: group toIndex: [[newGroup torrents] count]-1 inParent: newGroup];
    26262584                       
    2627                         if (onLion)
    2628                             [fTableView moveItemAtIndex: indexInGroup inParent: group toIndex: [[newGroup torrents] count]-1 inParent: newGroup];
    2629                        
    26302585                        --indexInGroup;
    26312586                    }
    26322587                   
     
    26382593            if ([removeIndexes count] > 0)
    26392594            {
    26402595                [[group torrents] removeObjectsAtIndexes: removeIndexes];
    2641                 if (onLion)
    2642                     [fTableView removeItemsAtIndexes: removeIndexes inParent: group withAnimation: NSTableViewAnimationEffectFade];
     2596                [fTableView removeItemsAtIndexes: removeIndexes inParent: group withAnimation: NSTableViewAnimationEffectFade];
    26432597            }
    26442598        }
    26452599       
     
    26532607                group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease];
    26542608                [groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]];
    26552609                [fDisplayedTorrents addObject: group];
    2656                
    2657                 if (onLion)
    2658                 {
    2659                     [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndex: [fDisplayedTorrents count]-1] inParent: nil withAnimation: NSTableViewAnimationEffectFade];
    2660                     [fTableView isGroupCollapsed: groupValue] ? [fTableView collapseItem: group] : [fTableView expandItem: group];
    2661                 }
     2610
     2611                [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndex: [fDisplayedTorrents count]-1] inParent: nil withAnimation: NSTableViewAnimationEffectFade];
     2612                [fTableView isGroupCollapsed: groupValue] ? [fTableView collapseItem: group] : [fTableView expandItem: group];
    26622613            }
    26632614           
    26642615            [[group torrents] addObject: torrent];
    2665             if (onLion)
    2666             {
    2667                 const BOOL newTorrent = fAddingTransfers && [fAddingTransfers containsObject: torrent];
    2668                 [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndex: [[group torrents] count]-1] inParent: group withAnimation: newTorrent ? NSTableViewAnimationSlideLeft : NSTableViewAnimationSlideDown];
    2669             }
     2616
     2617            const BOOL newTorrent = fAddingTransfers && [fAddingTransfers containsObject: torrent];
     2618            [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndex: [[group torrents] count]-1] inParent: group withAnimation: newTorrent ? NSTableViewAnimationSlideLeft : NSTableViewAnimationSlideDown];
    26702619        }
    26712620       
    26722621        //remove empty groups
     
    26772626        if ([removeGroupIndexes count] > 0)
    26782627        {
    26792628            [fDisplayedTorrents removeObjectsAtIndexes: removeGroupIndexes];
    2680             if (onLion)
    2681                 [fTableView removeItemsAtIndexes: removeGroupIndexes inParent: nil withAnimation: NSTableViewAnimationEffectFade];
     2629            [fTableView removeItemsAtIndexes: removeGroupIndexes inParent: nil withAnimation: NSTableViewAnimationEffectFade];
    26822630        }
    26832631       
    26842632        //now that all groups are there, sort them - don't insert on the fly in case groups were reordered in prefs
     
    26972645        NSArray * selectedValues = [fTableView selectedValues];
    26982646       
    26992647        beganUpdates = YES;
    2700         if (onLion)
    2701             [fTableView beginUpdates];
     2648        [fTableView beginUpdates];
     2649
     2650        [fTableView removeItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationSlideDown];
    27022651       
    2703         if (onLion)
    2704             [fTableView removeItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationSlideDown];
    2705        
    27062652        if (groupRows)
    27072653        {
    27082654            //a map for quickly finding groups
     
    27282674        }
    27292675        else
    27302676            [fDisplayedTorrents setArray: allTorrents];
     2677
     2678        [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationEffectFade];
    27312679       
    2732         if (onLion)
    2733             [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationEffectFade];
    2734        
    27352680        if (groupRows)
    27362681        {
    27372682            //actually expand group rows
     
    27452690   
    27462691    //sort the torrents (won't sort the groups, though)
    27472692    [self sortTorrentsCallUpdates: !beganUpdates includeQueueOrder: YES];
     2693
     2694    if (beganUpdates)
     2695        [fTableView endUpdates];
     2696    [fTableView setNeedsDisplay: YES];
    27482697   
    2749     if (onLion)
    2750     {
    2751         if (beganUpdates)
    2752             [fTableView endUpdates];
    2753         [fTableView setNeedsDisplay: YES];
    2754        
    2755         [NSAnimationContext endGrouping];
    2756     }
    2757     else
    2758     {
    2759         [fTableView reloadData];
    2760        
    2761         if (groupRows)
    2762         {
    2763             for (TorrentGroup * group in fDisplayedTorrents)
    2764             {
    2765                 if ([fTableView isGroupCollapsed: [group groupIndex]])
    2766                     [fTableView collapseItem: group];
    2767                 else
    2768                     [fTableView expandItem: group];
    2769             }
    2770         }
    2771     }
    2772    
    2773     if (!onLion)
    2774         [fTableView selectValues: selectedValuesSL];
    2775    
     2698    [NSAnimationContext endGrouping];
     2699
    27762700    [self resetInfo]; //if group is already selected, but the torrents in it change
    27772701   
    27782702    [self setBottomCountText: groupRows || filterStatus || filterGroup || searchStrings];
     
    27932717
    27942718- (IBAction) showGlobalPopover: (id) sender
    27952719{
    2796     if ([NSApp isOnLionOrBetter])
    2797     {
    2798         if (fGlobalPopoverShown)
    2799             return;
    2800        
    2801         NSPopover * popover = [[NSPopoverLion alloc] init];
    2802         [popover setBehavior: NSPopoverBehaviorTransient];
    2803         GlobalOptionsPopoverViewController * viewController = [[GlobalOptionsPopoverViewController alloc] initWithHandle: fLib];
    2804         [popover setContentViewController: viewController];
    2805         [popover setDelegate: self];
    2806        
    2807         [popover showRelativeToRect: [sender frame] ofView: sender preferredEdge: NSMaxYEdge];
    2808        
    2809         [viewController release];
    2810         [popover release];
    2811     }
    2812     else
    2813     {
    2814         //place menu below button
    2815         NSRect rect = [sender frame];
    2816         NSPoint location = rect.origin;
    2817         location.y += NSHeight(rect) + 5.0;
    2818        
    2819         [fActionMenu popUpMenuPositioningItem: nil atLocation: location inView: sender];
    2820     }
     2720    if (fGlobalPopoverShown)
     2721        return;
     2722   
     2723    NSPopover * popover = [[NSPopoverLion alloc] init];
     2724    [popover setBehavior: NSPopoverBehaviorTransient];
     2725    GlobalOptionsPopoverViewController * viewController = [[GlobalOptionsPopoverViewController alloc] initWithHandle: fLib];
     2726    [popover setContentViewController: viewController];
     2727    [popover setDelegate: self];
     2728   
     2729    [popover showRelativeToRect: [sender frame] ofView: sender preferredEdge: NSMaxYEdge];
     2730   
     2731    [viewController release];
     2732    [popover release];
    28212733}
    28222734
    28232735//don't show multiple popovers when clicking the gear button repeatedly
     
    32323144    NSPasteboard * pasteboard = [info draggingPasteboard];
    32333145    if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE])
    32343146    {
    3235         //remember selected rows
    3236         NSArray * selectedValues = nil;
    3237         if (![NSApp isOnLionOrBetter])
    3238             selectedValues = [fTableView selectedValues];
    3239    
    32403147        NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [pasteboard dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]];
    32413148       
    32423149        //get the torrents to move
     
    32843191            }
    32853192           
    32863193            //do the drag animation here so that the dragged torrents are the ones that are animated as moving, and not the torrents around them
    3287             const BOOL onLion = [NSApp isOnLionOrBetter];
    3288             if (onLion)
    3289                 [fTableView beginUpdates];
     3194            [fTableView beginUpdates];
    32903195           
    32913196            NSUInteger insertDisplayIndex = topTorrent ? [groupTorrents indexOfObject: topTorrent] + 1 : 0;
    32923197           
     
    33103215                    [newTorrents insertObject: torrent atIndex: insertDisplayIndex];
    33113216                    [oldTorrents removeObjectAtIndex: oldIndex];
    33123217                }
     3218
     3219                [fTableView moveItemAtIndex: oldIndex inParent: oldParent toIndex: insertDisplayIndex inParent: item];
    33133220               
    3314                 if (onLion)
    3315                     [fTableView moveItemAtIndex: oldIndex inParent: oldParent toIndex: insertDisplayIndex inParent: item];
    3316                
    33173221                ++insertDisplayIndex;
    33183222            }
    3319            
    3320             if (onLion)
    3321                 [fTableView endUpdates];
     3223
     3224            [fTableView endUpdates];
    33223225        }
    33233226       
    33243227        [self applyFilter];
    3325         if (selectedValues)
    3326             [fTableView selectValues: selectedValues];
    33273228    }
    33283229   
    33293230    return YES;
     
    34533354    [fTableView setUsesAlternatingRowBackgroundColors: !makeSmall];
    34543355   
    34553356    [fTableView setRowHeight: makeSmall ? ROW_HEIGHT_SMALL : ROW_HEIGHT_REGULAR];
    3456    
    3457     if ([NSApp isOnLionOrBetter])
    3458         [fTableView beginUpdates];
     3357
     3358    [fTableView beginUpdates];
    34593359    [fTableView noteHeightOfRowsWithIndexesChanged: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTableView numberOfRows])]];
    3460     if ([NSApp isOnLionOrBetter])
    3461         [fTableView endUpdates];
     3360    [fTableView endUpdates];
    34623361   
    34633362    //resize for larger min height if not set to auto size
    34643363    if (![fDefaults boolForKey: @"AutoSize"])
  • macosx/CreatorWindowController.m

     
    140140
    141141- (void) awakeFromNib
    142142{
    143     if ([NSApp isOnLionOrBetter])
    144         [[self window] setRestorationClass: [self class]];
     143    [[self window] setRestorationClass: [self class]];
    145144   
    146145    NSString * name = [fPath lastPathComponent];
    147146   
     
    544543    [fDefaults setBool: [fOpenCheck state] == NSOnState forKey: @"CreatorOpen"];
    545544    fOpenWhenCreated = [fOpenCheck state] == NSOnState; //need this since the check box might not exist, and value in prefs might have changed from another creator window
    546545    [fDefaults setURL: [fLocation URLByDeletingLastPathComponent] forKey: @"CreatorLocationURL"];
     546
     547    [[self window] setRestorable: NO];
    547548   
    548     if ([NSApp isOnLionOrBetter])
    549         [[self window] setRestorable: NO];
    550    
    551549    [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil];
    552550    tr_makeMetaInfo(fInfo, [[fLocation path] UTF8String], trackerInfo, [fTrackers count], [[fCommentView string] UTF8String], [fPrivateCheck state] == NSOnState);
    553551    tr_free(trackerInfo);
  • macosx/FileOutlineController.m

     
    111111   
    112112    if ((!text && !fFilterText) || (text && fFilterText && [text isEqualToString: fFilterText]))
    113113        return;
     114
     115    [fOutline beginUpdates];
    114116   
    115     const BOOL onLion = [NSApp isOnLionOrBetter];
    116    
    117     if (onLion)
    118         [fOutline beginUpdates];
    119    
    120117    NSUInteger currentIndex = 0, totalCount = 0;
    121118    NSMutableArray * itemsToAdd = [NSMutableArray array];
    122119    NSMutableIndexSet * itemsToAddIndexes = [NSMutableIndexSet indexSet];
     
    179176                    }
    180177                }
    181178               
    182                 if (move && onLion)
     179                if (move)
    183180                    [fOutline moveItemAtIndex: previousIndex inParent: parent toIndex: currentIndex inParent: nil];
    184181               
    185182                ++currentIndex;
     
    194191    {
    195192        const NSRange removeRange = NSMakeRange(currentIndex, [fFileList count]-currentIndex);
    196193        [fFileList removeObjectsInRange: removeRange];
    197         if (onLion)
    198             [fOutline removeItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: removeRange] inParent: nil withAnimation: NSTableViewAnimationSlideDown];
     194        [fOutline removeItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: removeRange] inParent: nil withAnimation: NSTableViewAnimationSlideDown];
    199195    }
    200196   
    201197    //add new items
    202198    [fFileList insertObjects: itemsToAdd atIndexes: itemsToAddIndexes];
    203     if (onLion)
    204         [fOutline insertItemsAtIndexes: itemsToAddIndexes inParent: nil withAnimation: NSTableViewAnimationSlideUp];
     199    [fOutline insertItemsAtIndexes: itemsToAddIndexes inParent: nil withAnimation: NSTableViewAnimationSlideUp];
     200
     201    [fOutline endUpdates];
    205202   
    206     if (onLion)
    207         [fOutline endUpdates];
    208     else
    209         [fOutline reloadData];
    210    
    211203    [fFilterText release];
    212204    fFilterText = [text retain];
    213205}
  • macosx/GroupsPrefsController.m

     
    120120    if ([[pasteboard types] containsObject: GROUP_TABLE_VIEW_DATA_TYPE])
    121121    {
    122122        NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [pasteboard dataForType: GROUP_TABLE_VIEW_DATA_TYPE]];
    123         NSInteger oldRow = [indexes firstIndex], selectedRow = [fTableView selectedRow];
     123        NSInteger oldRow = [indexes firstIndex];
    124124       
    125125        if (oldRow < newRow)
    126126            newRow--;
     127
     128        [fTableView beginUpdates];
    127129       
    128         if ([NSApp isOnLionOrBetter])
    129             [fTableView beginUpdates];
    130        
    131130        [[GroupsController groups] moveGroupAtRow: oldRow toRow: newRow];
    132        
    133         if ([NSApp isOnLionOrBetter])
    134         {
    135             [fTableView moveRowAtIndex: oldRow toIndex: newRow];
    136             [fTableView endUpdates];
    137         }
    138         else
    139         {
    140             if (selectedRow == oldRow)
    141                 selectedRow = newRow;
    142             else if (selectedRow > oldRow && selectedRow <= newRow)
    143                 selectedRow--;
    144             else if (selectedRow < oldRow && selectedRow >= newRow)
    145                 selectedRow++;
    146             else;
    147            
    148             [fTableView selectRowIndexes: [NSIndexSet indexSetWithIndex: selectedRow] byExtendingSelection: NO];
    149             [fTableView reloadData];
    150         }
     131
     132        [fTableView moveRowAtIndex: oldRow toIndex: newRow];
     133        [fTableView endUpdates];
    151134    }
    152135   
    153136    return YES;
     
    163146    switch ([[sender cell] tagForSegment: [sender selectedSegment]])
    164147    {
    165148        case ADD_TAG:
    166             if ([NSApp isOnLionOrBetter])
    167                 [fTableView beginUpdates];
     149            [fTableView beginUpdates];
    168150           
    169151            [[GroupsController groups] addNewGroup];
    170152           
    171153            row = [fTableView numberOfRows];
     154
     155            [fTableView insertRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp];
     156            [fTableView endUpdates];
    172157           
    173             if ([NSApp isOnLionOrBetter])
    174             {
    175                 [fTableView insertRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp];
    176                 [fTableView endUpdates];
    177             }
    178             else
    179                 [fTableView reloadData];
    180            
    181158            [fTableView selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO];
    182159            [fTableView scrollRowToVisible: row];
    183160           
     
    188165        case REMOVE_TAG:
    189166            row = [fTableView selectedRow];
    190167           
     168
     169            [fTableView beginUpdates];
    191170           
    192             if ([NSApp isOnLionOrBetter])
    193                 [fTableView beginUpdates];
    194            
    195171            [[GroupsController groups] removeGroupWithRowIndex: row];           
     172
     173            [fTableView removeRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp];
     174            [fTableView endUpdates];
    196175           
    197             if ([NSApp isOnLionOrBetter])
    198             {
    199                 [fTableView removeRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp];
    200                 [fTableView endUpdates];
    201             }
    202             else
    203                 [fTableView reloadData];
    204            
    205176            if ([fTableView numberOfRows] > 0)
    206177            {
    207178                if (row == [fTableView numberOfRows])
  • macosx/InfoTrackersViewController.m

     
    116116       
    117117        [fTrackerTable setTrackers: fTrackers];
    118118       
    119         if ([NSApp isOnLionOrBetter] && (oldTrackers && [fTrackers isEqualToArray: oldTrackers]))
     119        if (oldTrackers && [fTrackers isEqualToArray: oldTrackers])
    120120            [fTrackerTable setNeedsDisplay: YES];
    121121        else
    122122            [fTrackerTable reloadData];
     
    399399            return;
    400400    }
    401401   
     402
     403    [fTrackerTable beginUpdates];
    402404   
    403     if ([NSApp isOnLionOrBetter])
    404         [fTrackerTable beginUpdates];
    405    
    406405    for (Torrent * torrent in removeIdentifiers)
    407406        [torrent removeTrackers: [removeIdentifiers objectForKey: torrent]];
    408407   
     
    411410    fTrackers = [[NSMutableArray alloc] init];
    412411    for (Torrent * torrent in fTorrents)
    413412        [fTrackers addObjectsFromArray: [torrent allTrackerStats]];
     413
     414    [fTrackerTable removeRowsAtIndexes: removeIndexes withAnimation: NSTableViewAnimationSlideLeft];
    414415   
    415     if ([NSApp isOnLionOrBetter])
    416     {
    417         [fTrackerTable removeRowsAtIndexes: removeIndexes withAnimation: NSTableViewAnimationSlideLeft];
    418        
    419         [fTrackerTable setTrackers: fTrackers];
    420        
    421         [fTrackerTable endUpdates];
    422     }
    423     else
    424     {
    425         [fTrackerTable setTrackers: fTrackers];
    426        
    427         [fTrackerTable reloadData];
    428         [fTrackerTable deselectAll: self];
    429     }
     416    [fTrackerTable setTrackers: fTrackers];
    430417   
     418    [fTrackerTable endUpdates];
     419   
    431420    [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: nil]; //incase sort by tracker
    432421}
    433422
  • macosx/MessageWindowController.m

     
    5757    NSWindow * window = [self window];
    5858    [window setFrameAutosaveName: @"MessageWindowFrame"];
    5959    [window setFrameUsingName: @"MessageWindowFrame"];
     60    [window setRestorationClass: [self class]];
    6061   
    61     if ([NSApp isOnLionOrBetter])
    62         [window setRestorationClass: [self class]];
    63    
    6462    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resizeColumn)
    6563        name: NSTableViewColumnDidResizeNotification object: fMessageTable];
    6664   
     
    380378    [fLock lock];
    381379   
    382380    [fMessages removeAllObjects];
    383    
    384     const BOOL onLion = [NSApp isOnLionOrBetter];
    385    
    386     if (onLion)
    387         [fMessageTable beginUpdates];
    388    
    389     if (onLion)
    390         [fMessageTable removeRowsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedMessages count])] withAnimation: NSTableViewAnimationSlideLeft];
     381
     382    [fMessageTable beginUpdates];
     383    [fMessageTable removeRowsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedMessages count])] withAnimation: NSTableViewAnimationSlideLeft];
     384
    391385    [fDisplayedMessages removeAllObjects];
     386
     387    [fMessageTable endUpdates];
    392388   
    393     if (onLion)
    394         [fMessageTable endUpdates];
    395     else
    396         [fMessageTable reloadData];
    397    
    398389    [fLock unlock];
    399390}
    400391
     
    469460    }];
    470461   
    471462    NSArray * tempMessages = [[fMessages objectsAtIndexes: indexes] sortedArrayUsingDescriptors: [fMessageTable sortDescriptors]];
     463
     464    [fMessageTable beginUpdates];
    472465   
    473     const BOOL onLion = [NSApp isOnLionOrBetter];
    474    
    475     if (onLion)
    476         [fMessageTable beginUpdates];
    477    
    478466    //figure out which rows were added/moved
    479467    NSUInteger currentIndex = 0, totalCount = 0;
    480468    NSMutableArray * itemsToAdd = [NSMutableArray array];
     
    493481            if (previousIndex != currentIndex)
    494482            {
    495483                [fDisplayedMessages moveObjectAtIndex: previousIndex toIndex: currentIndex];
    496                 if (onLion)
    497                     [fMessageTable moveRowAtIndex: previousIndex toIndex: currentIndex];
     484                [fMessageTable moveRowAtIndex: previousIndex toIndex: currentIndex];
    498485            }
    499486            ++currentIndex;
    500487        }
     
    507494    {
    508495        const NSRange removeRange = NSMakeRange(currentIndex, [fDisplayedMessages count]-currentIndex);
    509496        [fDisplayedMessages removeObjectsInRange: removeRange];
    510         if (onLion)
    511             [fMessageTable removeRowsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: removeRange] withAnimation: NSTableViewAnimationSlideDown];
     497        [fMessageTable removeRowsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: removeRange] withAnimation: NSTableViewAnimationSlideDown];
    512498    }
    513499   
    514500    //add new items
    515501    [fDisplayedMessages insertObjects: itemsToAdd atIndexes: itemsToAddIndexes];
    516     if (onLion)
    517         [fMessageTable insertRowsAtIndexes: itemsToAddIndexes withAnimation: NSTableViewAnimationSlideUp];
     502    [fMessageTable insertRowsAtIndexes: itemsToAddIndexes withAnimation: NSTableViewAnimationSlideUp];
     503
     504    [fMessageTable endUpdates];
    518505   
    519     if (onLion)
    520         [fMessageTable endUpdates];
    521     else
    522     {
    523         [fMessageTable reloadData];
    524        
    525         if ([fDisplayedMessages count] > 0)
    526             [fMessageTable deselectAll: self];
    527     }
    528    
    529506    NSAssert2([fDisplayedMessages isEqualToArray: tempMessages], @"Inconsistency between message arrays! %@ %@", fDisplayedMessages, tempMessages);
    530507}
    531508
  • macosx/NSApplicationAdditions.h

     
    3030
    3131@interface NSApplication (NSApplicationAdditions)
    3232
    33 - (BOOL) isOnLionOrBetter;
    3433- (BOOL) isOnMountainLionOrBetter;
    3534- (BOOL) isOnYosemiteOrBetter;
    3635
  • macosx/NSApplicationAdditions.m

     
    2626
    2727@implementation NSApplication (NSApplicationAdditions)
    2828
    29 - (BOOL) isOnLionOrBetter
    30 {
    31         return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;
    32 }
    33 
    3429- (BOOL) isOnMountainLionOrBetter
    3530{
    3631    return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7;
  • macosx/PrefsController.m

     
    166166- (void) awakeFromNib
    167167{
    168168    fHasLoaded = YES;
     169
     170    [[self window] setRestorationClass: [self class]];
    169171   
    170     if ([NSApp isOnLionOrBetter])
    171         [[self window] setRestorationClass: [self class]];
    172    
    173172    NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"];
    174173    [toolbar setDelegate: self];
    175174    [toolbar setAllowsUserCustomization: NO];
  • macosx/StatsWindowController.m

     
    6666    fTimer = [[NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self selector: @selector(updateStats) userInfo: nil repeats: YES] retain];
    6767    [[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSModalPanelRunLoopMode];
    6868    [[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSEventTrackingRunLoopMode];
     69
     70    [[self window] setRestorationClass: [self class]];
    6971   
    70     if ([NSApp isOnLionOrBetter])
    71         [[self window] setRestorationClass: [self class]];
    72    
    7372    [[self window] setTitle: NSLocalizedString(@"Statistics", "Stats window -> title")];
    7473   
    7574    //set label text
  • macosx/StatusBarView.m

     
    4242        NSColor * darkColor = [NSColor colorWithCalibratedRed: 155.0/255.0 green: 155.0/255.0 blue: 155.0/255.0 alpha: 1.0];
    4343        fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor];
    4444       
    45         if([NSApp isOnLionOrBetter] && ![NSApp isOnYosemiteOrBetter])
     45        if (![NSApp isOnYosemiteOrBetter])
    4646        {
    4747            CIFilter * randomFilter = [CIFilter filterWithName: @"CIRandomGenerator"];
    4848            [randomFilter setDefaults];
     
    151151        NSRectFillListWithColors(gridRects, colorRects, count);
    152152       
    153153        if (fNoiseImage) {
    154             NSAssert([NSApp isOnLionOrBetter], @"we have a noise image, but we're on 10.6"); //https://trac.transmissionbt.com/ticket/5053
    155154            [fNoiseImage drawInRect: rect
    156155                           fromRect: [self convertRectToBacking: rect]
    157156                          operation: NSCompositeSourceOver
  • macosx/TorrentTableView.h

     
    4343   
    4444    IBOutlet NSMenu * fContextRow, * fContextNoRow;
    4545   
    46     NSInteger fMouseRow, fMouseControlRow, fMouseRevealRow, fMouseActionRow, fActionPushedRow;
     46    NSInteger fMouseRow, fMouseControlRow, fMouseRevealRow, fMouseActionRow;
    4747    NSArray * fSelectedValues;
    4848   
    4949    IBOutlet NSMenu * fActionMenu, * fUploadMenu, * fDownloadMenu, * fRatioMenu, * fPriorityMenu;
  • macosx/TorrentTableView.m

     
    7373        fMouseControlRow = -1;
    7474        fMouseRevealRow = -1;
    7575        fMouseActionRow = -1;
    76         #warning we can get rid of the on 10.7
    77         fActionPushedRow = -1;
    7876       
    7977        fActionPopoverShown = NO;
    8078       
     
    169167            [cell setControlHover: row == fMouseControlRow];
    170168            [cell setRevealHover: row == fMouseRevealRow];
    171169            [cell setActionHover: row == fMouseActionRow];
    172             [cell setActionPushed: row == fActionPushedRow];
    173170        }
    174171    }
    175172    else
     
    403400    //avoid weird behavior when showing menu by doing this after mouse down
    404401    if (row != -1 && fMouseActionRow == row)
    405402    {
    406         if (![NSApp isOnLionOrBetter])
    407         {
    408             fActionPushedRow = row;
    409             [self setNeedsDisplayInRect: [self rectOfRow: row]]; //ensure button is pushed down
    410         }
    411        
    412403        #warning maybe make appear on mouse down
    413404        [self displayTorrentActionPopoverForEvent: event];
    414        
    415         if (![NSApp isOnLionOrBetter])
    416         {
    417             fActionPushedRow = -1;
    418             [self setNeedsDisplayInRect: [self rectOfRow: row]];
    419         }
    420405    }
    421406    else if (!pushed && [event clickCount] == 2) //double click
    422407    {
     
    548533    NSURL * url;
    549534    if ((url = [NSURL URLFromPasteboard: [NSPasteboard generalPasteboard]]))
    550535        [fController openURL: [url absoluteString]];
    551     else if ([NSApp isOnLionOrBetter])
     536    else
    552537    {
    553538        NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil];
    554539        if (items)
     
    578563    {
    579564        if ([[[NSPasteboard generalPasteboard] types] containsObject: NSURLPboardType])
    580565            return YES;
    581        
    582         if ([NSApp isOnLionOrBetter])
     566
     567        NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil];
     568        if (items)
    583569        {
    584             NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil];
    585             if (items)
     570            NSDataDetector * detector = [NSDataDetectorLion dataDetectorWithTypes: NSTextCheckingTypeLink error: nil];
     571            for (NSString * pbItem in items)
    586572            {
    587                 NSDataDetector * detector = [NSDataDetectorLion dataDetectorWithTypes: NSTextCheckingTypeLink error: nil];
    588                 for (NSString * pbItem in items)
    589                 {
    590                     pbItem = [pbItem stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
    591                     if (([pbItem rangeOfString: @"magnet:" options: (NSAnchoredSearch | NSCaseInsensitiveSearch)].location != NSNotFound)
    592                         || [detector firstMatchInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])])
    593                         return YES;
    594                 }
     573                pbItem = [pbItem stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceAndNewlineCharacterSet]];
     574                if (([pbItem rangeOfString: @"magnet:" options: (NSAnchoredSearch | NSCaseInsensitiveSearch)].location != NSNotFound)
     575                    || [detector firstMatchInString: pbItem options: 0 range: NSMakeRange(0, [pbItem length])])
     576                    return YES;
    595577            }
    596578        }
    597        
    598         return NO;
     579   
     580    return NO;
    599581    }
    600582   
    601583    return YES;
     
    623605        return;
    624606   
    625607    const NSRect rect = [fTorrentCell iconRectForBounds: [self rectOfRow: row]];
     608
     609    if (fActionPopoverShown)
     610        return;
    626611   
    627     if ([NSApp isOnLionOrBetter])
    628     {
    629         if (fActionPopoverShown)
    630             return;
    631        
    632         Torrent * torrent = [self itemAtRow: row];
    633        
    634         NSPopover * popover = [[NSPopoverLion alloc] init];
    635         [popover setBehavior: NSPopoverBehaviorTransient];
    636         InfoOptionsViewController * infoViewController = [[InfoOptionsViewController alloc] init];
    637         [popover setContentViewController: infoViewController];
    638         [popover setDelegate: self];
    639        
    640         [popover showRelativeToRect: rect ofView: self preferredEdge: NSMaxYEdge];
    641         [infoViewController setInfoForTorrents: [NSArray arrayWithObject: torrent]];
    642         [infoViewController updateInfo];
    643        
    644         [infoViewController release];
    645         [popover release];
    646     }
    647     else
    648     {
    649         //update file action menu
    650         fMenuTorrent = [[self itemAtRow: row] retain];
    651        
    652         //update global limit check
    653         [fGlobalLimitItem setState: [fMenuTorrent usesGlobalSpeedLimit] ? NSOnState : NSOffState];
    654        
    655         //place menu below button
    656         NSPoint location = rect.origin;
    657         location.y += NSHeight(rect) + 5.0;
    658        
    659         location = [self convertPoint: location toView: self];
    660         [fActionMenu popUpMenuPositioningItem: nil atLocation: location inView: self];
    661        
    662         [fMenuTorrent release];
    663         fMenuTorrent = nil;
    664     }
     612    Torrent * torrent = [self itemAtRow: row];
     613   
     614    NSPopover * popover = [[NSPopoverLion alloc] init];
     615    [popover setBehavior: NSPopoverBehaviorTransient];
     616    InfoOptionsViewController * infoViewController = [[InfoOptionsViewController alloc] init];
     617    [popover setContentViewController: infoViewController];
     618    [popover setDelegate: self];
     619   
     620    [popover showRelativeToRect: rect ofView: self preferredEdge: NSMaxYEdge];
     621    [infoViewController setInfoForTorrents: [NSArray arrayWithObject: torrent]];
     622    [infoViewController updateInfo];
     623   
     624    [infoViewController release];
     625    [popover release];
    665626}
    666627
    667628//don't show multiple popovers when clicking the gear button repeatedly