Ticket #6042: CompleteLionDeadCode.diff
File CompleteLionDeadCode.diff, 41.2 KB (added by mattrajca, 7 years ago) |
---|
-
macosx/Controller.m
1474 1474 1475 1475 - (void) confirmRemoveTorrents: (NSArray *) torrents deleteData: (BOOL) deleteData 1476 1476 { 1477 NSMutableArray * selectedValues = nil;1478 if (![NSApp isOnLionOrBetter])1479 {1480 selectedValues = [NSMutableArray arrayWithArray: [fTableView selectedValues]];1481 [selectedValues removeObjectsInArray: torrents];1482 }1483 1484 1477 //miscellaneous 1485 1478 for (Torrent * torrent in torrents) 1486 1479 { … … 1523 1516 1524 1517 if ([indexes count] > 0) 1525 1518 { 1526 if ( [NSApp isOnLionOrBetter])1519 if (!beganUpdate) 1527 1520 { 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) 1541 1522 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; 1543 1531 } 1532 1533 [fTableView removeItemsAtIndexes: indexes inParent: parent withAnimation: NSTableViewAnimationSlideLeft]; 1534 1544 1535 [displayedTorrents removeObjectsAtIndexes: indexes]; 1545 1536 } 1546 1537 }; … … 1570 1561 [torrent closeRemoveTorrent: deleteData]; 1571 1562 } 1572 1563 1573 if (selectedValues)1574 [fTableView selectValues: selectedValues];1575 1576 1564 [self fullUpdateUI]; 1577 1565 } 1578 1566 … … 2226 2214 2227 2215 - (void) sortTorrents: (BOOL) includeQueueOrder 2228 2216 { 2229 const BOOL onLion = [NSApp isOnLionOrBetter];2230 2231 NSArray * selectedValues;2232 if (!onLion)2233 selectedValues = [fTableView selectedValues];2234 2235 2217 //actually sort 2236 2218 [self sortTorrentsCallUpdates: YES includeQueueOrder: includeQueueOrder]; 2237 2238 if (!onLion)2239 [fTableView selectValues: selectedValues];2240 2241 2219 [fTableView setNeedsDisplay: YES]; 2242 2220 } 2243 2221 … … 2306 2284 descriptors = [NSArray arrayWithObject: orderDescriptor]; 2307 2285 } 2308 2286 2309 BOOL beganTableUpdate = !callUpdates || ![NSApp isOnLionOrBetter];2287 BOOL beganTableUpdate = !callUpdates; 2310 2288 2311 2289 //actually sort 2312 2290 if ([fDefaults boolForKey: @"SortByGroup"]) … … 2319 2297 2320 2298 if (beganTableUpdate && callUpdates) 2321 2299 { 2322 if ([NSApp isOnLionOrBetter]) 2323 [fTableView endUpdates]; 2324 else 2325 [fTableView reloadData]; 2300 [fTableView endUpdates]; 2326 2301 } 2327 2302 } 2328 2303 … … 2348 2323 if (!*beganTableUpdate) 2349 2324 { 2350 2325 *beganTableUpdate = YES; 2351 if ([NSApp isOnLionOrBetter]) 2352 [fTableView beginUpdates]; 2326 [fTableView beginUpdates]; 2353 2327 } 2354 2328 2355 2329 [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]; 2358 2331 } 2359 2332 } 2360 2333 … … 2363 2336 2364 2337 - (void) applyFilter 2365 2338 { 2366 const BOOL onLion = [NSApp isOnLionOrBetter];2367 2368 NSArray * selectedValuesSL = nil;2369 if (!onLion)2370 selectedValuesSL = [fTableView selectedValues];2371 2372 2339 __block int32_t active = 0, downloading = 0, seeding = 0, paused = 0; 2373 2340 NSString * filterType = [fDefaults stringForKey: @"Filter"]; 2374 2341 BOOL filterActive = NO, filterDownload = NO, filterSeed = NO, filterPause = NO, filterStatus = YES; … … 2498 2465 } 2499 2466 2500 2467 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]; 2501 2475 2502 if (onLion)2503 {2504 //don't animate torrents when first launching2505 static dispatch_once_t onceToken;2506 dispatch_once(&onceToken, ^{2507 [[NSAnimationContext currentContext] setDuration: 0];2508 });2509 [NSAnimationContext beginGrouping];2510 }2511 2512 2476 //add/remove torrents (and rearrange for groups), one by one 2513 2477 if (!groupRows && !wasGroupRows) 2514 2478 { … … 2529 2493 if ([addIndexes count] > 0 || [removePreviousIndexes count] > 0) 2530 2494 { 2531 2495 beganUpdates = YES; 2532 if (onLion) 2533 [fTableView beginUpdates]; 2496 [fTableView beginUpdates]; 2534 2497 2535 2498 //remove torrents we didn't find 2536 2499 if ([removePreviousIndexes count] > 0) 2537 2500 { 2538 2501 [fDisplayedTorrents removeObjectsAtIndexes: removePreviousIndexes]; 2539 if (onLion) 2540 [fTableView removeItemsAtIndexes: removePreviousIndexes inParent: nil withAnimation: NSTableViewAnimationSlideDown]; 2502 [fTableView removeItemsAtIndexes: removePreviousIndexes inParent: nil withAnimation: NSTableViewAnimationSlideDown]; 2541 2503 } 2542 2504 2543 2505 //add new torrents … … 2553 2515 [addIndexes removeIndexes: newAddIndexes]; 2554 2516 2555 2517 [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]; 2558 2519 } 2559 2520 2560 2521 [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]; 2563 2523 } 2564 2524 } 2565 2525 } … … 2569 2529 2570 2530 #warning don't always do? 2571 2531 beganUpdates = YES; 2572 if (onLion) 2573 [fTableView beginUpdates]; 2532 [fTableView beginUpdates]; 2574 2533 2575 2534 NSMutableIndexSet * unusedAllTorrentsIndexes = [NSMutableIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [allTorrents count])]; 2576 2535 … … 2607 2566 newGroup = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease]; 2608 2567 [groupsByIndex setObject: newGroup forKey: [NSNumber numberWithInteger: groupValue]]; 2609 2568 [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]; 2616 2572 } 2617 2573 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 2618 2574 { … … 2623 2579 2624 2580 [[group torrents] removeObjectAtIndex: indexInGroup]; 2625 2581 [[newGroup torrents] addObject: torrent]; 2582 2583 [fTableView moveItemAtIndex: indexInGroup inParent: group toIndex: [[newGroup torrents] count]-1 inParent: newGroup]; 2626 2584 2627 if (onLion)2628 [fTableView moveItemAtIndex: indexInGroup inParent: group toIndex: [[newGroup torrents] count]-1 inParent: newGroup];2629 2630 2585 --indexInGroup; 2631 2586 } 2632 2587 … … 2638 2593 if ([removeIndexes count] > 0) 2639 2594 { 2640 2595 [[group torrents] removeObjectsAtIndexes: removeIndexes]; 2641 if (onLion) 2642 [fTableView removeItemsAtIndexes: removeIndexes inParent: group withAnimation: NSTableViewAnimationEffectFade]; 2596 [fTableView removeItemsAtIndexes: removeIndexes inParent: group withAnimation: NSTableViewAnimationEffectFade]; 2643 2597 } 2644 2598 } 2645 2599 … … 2653 2607 group = [[[TorrentGroup alloc] initWithGroup: groupValue] autorelease]; 2654 2608 [groupsByIndex setObject: group forKey: [NSNumber numberWithInteger: groupValue]]; 2655 2609 [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]; 2662 2613 } 2663 2614 2664 2615 [[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]; 2670 2619 } 2671 2620 2672 2621 //remove empty groups … … 2677 2626 if ([removeGroupIndexes count] > 0) 2678 2627 { 2679 2628 [fDisplayedTorrents removeObjectsAtIndexes: removeGroupIndexes]; 2680 if (onLion) 2681 [fTableView removeItemsAtIndexes: removeGroupIndexes inParent: nil withAnimation: NSTableViewAnimationEffectFade]; 2629 [fTableView removeItemsAtIndexes: removeGroupIndexes inParent: nil withAnimation: NSTableViewAnimationEffectFade]; 2682 2630 } 2683 2631 2684 2632 //now that all groups are there, sort them - don't insert on the fly in case groups were reordered in prefs … … 2697 2645 NSArray * selectedValues = [fTableView selectedValues]; 2698 2646 2699 2647 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]; 2702 2651 2703 if (onLion)2704 [fTableView removeItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationSlideDown];2705 2706 2652 if (groupRows) 2707 2653 { 2708 2654 //a map for quickly finding groups … … 2728 2674 } 2729 2675 else 2730 2676 [fDisplayedTorrents setArray: allTorrents]; 2677 2678 [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationEffectFade]; 2731 2679 2732 if (onLion)2733 [fTableView insertItemsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fDisplayedTorrents count])] inParent: nil withAnimation: NSTableViewAnimationEffectFade];2734 2735 2680 if (groupRows) 2736 2681 { 2737 2682 //actually expand group rows … … 2745 2690 2746 2691 //sort the torrents (won't sort the groups, though) 2747 2692 [self sortTorrentsCallUpdates: !beganUpdates includeQueueOrder: YES]; 2693 2694 if (beganUpdates) 2695 [fTableView endUpdates]; 2696 [fTableView setNeedsDisplay: YES]; 2748 2697 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 2776 2700 [self resetInfo]; //if group is already selected, but the torrents in it change 2777 2701 2778 2702 [self setBottomCountText: groupRows || filterStatus || filterGroup || searchStrings]; … … 2793 2717 2794 2718 - (IBAction) showGlobalPopover: (id) sender 2795 2719 { 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]; 2821 2733 } 2822 2734 2823 2735 //don't show multiple popovers when clicking the gear button repeatedly … … 3232 3144 NSPasteboard * pasteboard = [info draggingPasteboard]; 3233 3145 if ([[pasteboard types] containsObject: TORRENT_TABLE_VIEW_DATA_TYPE]) 3234 3146 { 3235 //remember selected rows3236 NSArray * selectedValues = nil;3237 if (![NSApp isOnLionOrBetter])3238 selectedValues = [fTableView selectedValues];3239 3240 3147 NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [pasteboard dataForType: TORRENT_TABLE_VIEW_DATA_TYPE]]; 3241 3148 3242 3149 //get the torrents to move … … 3284 3191 } 3285 3192 3286 3193 //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]; 3290 3195 3291 3196 NSUInteger insertDisplayIndex = topTorrent ? [groupTorrents indexOfObject: topTorrent] + 1 : 0; 3292 3197 … … 3310 3215 [newTorrents insertObject: torrent atIndex: insertDisplayIndex]; 3311 3216 [oldTorrents removeObjectAtIndex: oldIndex]; 3312 3217 } 3218 3219 [fTableView moveItemAtIndex: oldIndex inParent: oldParent toIndex: insertDisplayIndex inParent: item]; 3313 3220 3314 if (onLion)3315 [fTableView moveItemAtIndex: oldIndex inParent: oldParent toIndex: insertDisplayIndex inParent: item];3316 3317 3221 ++insertDisplayIndex; 3318 3222 } 3319 3320 if (onLion) 3321 [fTableView endUpdates]; 3223 3224 [fTableView endUpdates]; 3322 3225 } 3323 3226 3324 3227 [self applyFilter]; 3325 if (selectedValues)3326 [fTableView selectValues: selectedValues];3327 3228 } 3328 3229 3329 3230 return YES; … … 3453 3354 [fTableView setUsesAlternatingRowBackgroundColors: !makeSmall]; 3454 3355 3455 3356 [fTableView setRowHeight: makeSmall ? ROW_HEIGHT_SMALL : ROW_HEIGHT_REGULAR]; 3456 3457 if ([NSApp isOnLionOrBetter]) 3458 [fTableView beginUpdates]; 3357 3358 [fTableView beginUpdates]; 3459 3359 [fTableView noteHeightOfRowsWithIndexesChanged: [NSIndexSet indexSetWithIndexesInRange: NSMakeRange(0, [fTableView numberOfRows])]]; 3460 if ([NSApp isOnLionOrBetter]) 3461 [fTableView endUpdates]; 3360 [fTableView endUpdates]; 3462 3361 3463 3362 //resize for larger min height if not set to auto size 3464 3363 if (![fDefaults boolForKey: @"AutoSize"]) -
macosx/CreatorWindowController.m
140 140 141 141 - (void) awakeFromNib 142 142 { 143 if ([NSApp isOnLionOrBetter]) 144 [[self window] setRestorationClass: [self class]]; 143 [[self window] setRestorationClass: [self class]]; 145 144 146 145 NSString * name = [fPath lastPathComponent]; 147 146 … … 544 543 [fDefaults setBool: [fOpenCheck state] == NSOnState forKey: @"CreatorOpen"]; 545 544 fOpenWhenCreated = [fOpenCheck state] == NSOnState; //need this since the check box might not exist, and value in prefs might have changed from another creator window 546 545 [fDefaults setURL: [fLocation URLByDeletingLastPathComponent] forKey: @"CreatorLocationURL"]; 546 547 [[self window] setRestorable: NO]; 547 548 548 if ([NSApp isOnLionOrBetter])549 [[self window] setRestorable: NO];550 551 549 [[NSNotificationCenter defaultCenter] postNotificationName: @"BeginCreateTorrentFile" object: fLocation userInfo: nil]; 552 550 tr_makeMetaInfo(fInfo, [[fLocation path] UTF8String], trackerInfo, [fTrackers count], [[fCommentView string] UTF8String], [fPrivateCheck state] == NSOnState); 553 551 tr_free(trackerInfo); -
macosx/FileOutlineController.m
111 111 112 112 if ((!text && !fFilterText) || (text && fFilterText && [text isEqualToString: fFilterText])) 113 113 return; 114 115 [fOutline beginUpdates]; 114 116 115 const BOOL onLion = [NSApp isOnLionOrBetter];116 117 if (onLion)118 [fOutline beginUpdates];119 120 117 NSUInteger currentIndex = 0, totalCount = 0; 121 118 NSMutableArray * itemsToAdd = [NSMutableArray array]; 122 119 NSMutableIndexSet * itemsToAddIndexes = [NSMutableIndexSet indexSet]; … … 179 176 } 180 177 } 181 178 182 if (move && onLion)179 if (move) 183 180 [fOutline moveItemAtIndex: previousIndex inParent: parent toIndex: currentIndex inParent: nil]; 184 181 185 182 ++currentIndex; … … 194 191 { 195 192 const NSRange removeRange = NSMakeRange(currentIndex, [fFileList count]-currentIndex); 196 193 [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]; 199 195 } 200 196 201 197 //add new items 202 198 [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]; 205 202 206 if (onLion)207 [fOutline endUpdates];208 else209 [fOutline reloadData];210 211 203 [fFilterText release]; 212 204 fFilterText = [text retain]; 213 205 } -
macosx/GroupsPrefsController.m
120 120 if ([[pasteboard types] containsObject: GROUP_TABLE_VIEW_DATA_TYPE]) 121 121 { 122 122 NSIndexSet * indexes = [NSKeyedUnarchiver unarchiveObjectWithData: [pasteboard dataForType: GROUP_TABLE_VIEW_DATA_TYPE]]; 123 NSInteger oldRow = [indexes firstIndex] , selectedRow = [fTableView selectedRow];123 NSInteger oldRow = [indexes firstIndex]; 124 124 125 125 if (oldRow < newRow) 126 126 newRow--; 127 128 [fTableView beginUpdates]; 127 129 128 if ([NSApp isOnLionOrBetter])129 [fTableView beginUpdates];130 131 130 [[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]; 151 134 } 152 135 153 136 return YES; … … 163 146 switch ([[sender cell] tagForSegment: [sender selectedSegment]]) 164 147 { 165 148 case ADD_TAG: 166 if ([NSApp isOnLionOrBetter]) 167 [fTableView beginUpdates]; 149 [fTableView beginUpdates]; 168 150 169 151 [[GroupsController groups] addNewGroup]; 170 152 171 153 row = [fTableView numberOfRows]; 154 155 [fTableView insertRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp]; 156 [fTableView endUpdates]; 172 157 173 if ([NSApp isOnLionOrBetter])174 {175 [fTableView insertRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp];176 [fTableView endUpdates];177 }178 else179 [fTableView reloadData];180 181 158 [fTableView selectRowIndexes: [NSIndexSet indexSetWithIndex: row] byExtendingSelection: NO]; 182 159 [fTableView scrollRowToVisible: row]; 183 160 … … 188 165 case REMOVE_TAG: 189 166 row = [fTableView selectedRow]; 190 167 168 169 [fTableView beginUpdates]; 191 170 192 if ([NSApp isOnLionOrBetter])193 [fTableView beginUpdates];194 195 171 [[GroupsController groups] removeGroupWithRowIndex: row]; 172 173 [fTableView removeRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp]; 174 [fTableView endUpdates]; 196 175 197 if ([NSApp isOnLionOrBetter])198 {199 [fTableView removeRowsAtIndexes: [NSIndexSet indexSetWithIndex: row] withAnimation: NSTableViewAnimationSlideUp];200 [fTableView endUpdates];201 }202 else203 [fTableView reloadData];204 205 176 if ([fTableView numberOfRows] > 0) 206 177 { 207 178 if (row == [fTableView numberOfRows]) -
macosx/InfoTrackersViewController.m
116 116 117 117 [fTrackerTable setTrackers: fTrackers]; 118 118 119 if ( [NSApp isOnLionOrBetter] && (oldTrackers && [fTrackers isEqualToArray: oldTrackers]))119 if (oldTrackers && [fTrackers isEqualToArray: oldTrackers]) 120 120 [fTrackerTable setNeedsDisplay: YES]; 121 121 else 122 122 [fTrackerTable reloadData]; … … 399 399 return; 400 400 } 401 401 402 403 [fTrackerTable beginUpdates]; 402 404 403 if ([NSApp isOnLionOrBetter])404 [fTrackerTable beginUpdates];405 406 405 for (Torrent * torrent in removeIdentifiers) 407 406 [torrent removeTrackers: [removeIdentifiers objectForKey: torrent]]; 408 407 … … 411 410 fTrackers = [[NSMutableArray alloc] init]; 412 411 for (Torrent * torrent in fTorrents) 413 412 [fTrackers addObjectsFromArray: [torrent allTrackerStats]]; 413 414 [fTrackerTable removeRowsAtIndexes: removeIndexes withAnimation: NSTableViewAnimationSlideLeft]; 414 415 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]; 430 417 418 [fTrackerTable endUpdates]; 419 431 420 [[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateUI" object: nil]; //incase sort by tracker 432 421 } 433 422 -
macosx/MessageWindowController.m
57 57 NSWindow * window = [self window]; 58 58 [window setFrameAutosaveName: @"MessageWindowFrame"]; 59 59 [window setFrameUsingName: @"MessageWindowFrame"]; 60 [window setRestorationClass: [self class]]; 60 61 61 if ([NSApp isOnLionOrBetter])62 [window setRestorationClass: [self class]];63 64 62 [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(resizeColumn) 65 63 name: NSTableViewColumnDidResizeNotification object: fMessageTable]; 66 64 … … 380 378 [fLock lock]; 381 379 382 380 [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 391 385 [fDisplayedMessages removeAllObjects]; 386 387 [fMessageTable endUpdates]; 392 388 393 if (onLion)394 [fMessageTable endUpdates];395 else396 [fMessageTable reloadData];397 398 389 [fLock unlock]; 399 390 } 400 391 … … 469 460 }]; 470 461 471 462 NSArray * tempMessages = [[fMessages objectsAtIndexes: indexes] sortedArrayUsingDescriptors: [fMessageTable sortDescriptors]]; 463 464 [fMessageTable beginUpdates]; 472 465 473 const BOOL onLion = [NSApp isOnLionOrBetter];474 475 if (onLion)476 [fMessageTable beginUpdates];477 478 466 //figure out which rows were added/moved 479 467 NSUInteger currentIndex = 0, totalCount = 0; 480 468 NSMutableArray * itemsToAdd = [NSMutableArray array]; … … 493 481 if (previousIndex != currentIndex) 494 482 { 495 483 [fDisplayedMessages moveObjectAtIndex: previousIndex toIndex: currentIndex]; 496 if (onLion) 497 [fMessageTable moveRowAtIndex: previousIndex toIndex: currentIndex]; 484 [fMessageTable moveRowAtIndex: previousIndex toIndex: currentIndex]; 498 485 } 499 486 ++currentIndex; 500 487 } … … 507 494 { 508 495 const NSRange removeRange = NSMakeRange(currentIndex, [fDisplayedMessages count]-currentIndex); 509 496 [fDisplayedMessages removeObjectsInRange: removeRange]; 510 if (onLion) 511 [fMessageTable removeRowsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: removeRange] withAnimation: NSTableViewAnimationSlideDown]; 497 [fMessageTable removeRowsAtIndexes: [NSIndexSet indexSetWithIndexesInRange: removeRange] withAnimation: NSTableViewAnimationSlideDown]; 512 498 } 513 499 514 500 //add new items 515 501 [fDisplayedMessages insertObjects: itemsToAdd atIndexes: itemsToAddIndexes]; 516 if (onLion) 517 [fMessageTable insertRowsAtIndexes: itemsToAddIndexes withAnimation: NSTableViewAnimationSlideUp]; 502 [fMessageTable insertRowsAtIndexes: itemsToAddIndexes withAnimation: NSTableViewAnimationSlideUp]; 503 504 [fMessageTable endUpdates]; 518 505 519 if (onLion)520 [fMessageTable endUpdates];521 else522 {523 [fMessageTable reloadData];524 525 if ([fDisplayedMessages count] > 0)526 [fMessageTable deselectAll: self];527 }528 529 506 NSAssert2([fDisplayedMessages isEqualToArray: tempMessages], @"Inconsistency between message arrays! %@ %@", fDisplayedMessages, tempMessages); 530 507 } 531 508 -
macosx/NSApplicationAdditions.h
30 30 31 31 @interface NSApplication (NSApplicationAdditions) 32 32 33 - (BOOL) isOnLionOrBetter;34 33 - (BOOL) isOnMountainLionOrBetter; 35 34 - (BOOL) isOnYosemiteOrBetter; 36 35 -
macosx/NSApplicationAdditions.m
26 26 27 27 @implementation NSApplication (NSApplicationAdditions) 28 28 29 - (BOOL) isOnLionOrBetter30 {31 return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_6;32 }33 34 29 - (BOOL) isOnMountainLionOrBetter 35 30 { 36 31 return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7; -
macosx/PrefsController.m
166 166 - (void) awakeFromNib 167 167 { 168 168 fHasLoaded = YES; 169 170 [[self window] setRestorationClass: [self class]]; 169 171 170 if ([NSApp isOnLionOrBetter])171 [[self window] setRestorationClass: [self class]];172 173 172 NSToolbar * toolbar = [[NSToolbar alloc] initWithIdentifier: @"Preferences Toolbar"]; 174 173 [toolbar setDelegate: self]; 175 174 [toolbar setAllowsUserCustomization: NO]; -
macosx/StatsWindowController.m
66 66 fTimer = [[NSTimer scheduledTimerWithTimeInterval: UPDATE_SECONDS target: self selector: @selector(updateStats) userInfo: nil repeats: YES] retain]; 67 67 [[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSModalPanelRunLoopMode]; 68 68 [[NSRunLoop currentRunLoop] addTimer: fTimer forMode: NSEventTrackingRunLoopMode]; 69 70 [[self window] setRestorationClass: [self class]]; 69 71 70 if ([NSApp isOnLionOrBetter])71 [[self window] setRestorationClass: [self class]];72 73 72 [[self window] setTitle: NSLocalizedString(@"Statistics", "Stats window -> title")]; 74 73 75 74 //set label text -
macosx/StatusBarView.m
42 42 NSColor * darkColor = [NSColor colorWithCalibratedRed: 155.0/255.0 green: 155.0/255.0 blue: 155.0/255.0 alpha: 1.0]; 43 43 fGradient = [[NSGradient alloc] initWithStartingColor: lightColor endingColor: darkColor]; 44 44 45 if ([NSApp isOnLionOrBetter] &&![NSApp isOnYosemiteOrBetter])45 if (![NSApp isOnYosemiteOrBetter]) 46 46 { 47 47 CIFilter * randomFilter = [CIFilter filterWithName: @"CIRandomGenerator"]; 48 48 [randomFilter setDefaults]; … … 151 151 NSRectFillListWithColors(gridRects, colorRects, count); 152 152 153 153 if (fNoiseImage) { 154 NSAssert([NSApp isOnLionOrBetter], @"we have a noise image, but we're on 10.6"); //https://trac.transmissionbt.com/ticket/5053155 154 [fNoiseImage drawInRect: rect 156 155 fromRect: [self convertRectToBacking: rect] 157 156 operation: NSCompositeSourceOver -
macosx/TorrentTableView.h
43 43 44 44 IBOutlet NSMenu * fContextRow, * fContextNoRow; 45 45 46 NSInteger fMouseRow, fMouseControlRow, fMouseRevealRow, fMouseActionRow , fActionPushedRow;46 NSInteger fMouseRow, fMouseControlRow, fMouseRevealRow, fMouseActionRow; 47 47 NSArray * fSelectedValues; 48 48 49 49 IBOutlet NSMenu * fActionMenu, * fUploadMenu, * fDownloadMenu, * fRatioMenu, * fPriorityMenu; -
macosx/TorrentTableView.m
73 73 fMouseControlRow = -1; 74 74 fMouseRevealRow = -1; 75 75 fMouseActionRow = -1; 76 #warning we can get rid of the on 10.777 fActionPushedRow = -1;78 76 79 77 fActionPopoverShown = NO; 80 78 … … 169 167 [cell setControlHover: row == fMouseControlRow]; 170 168 [cell setRevealHover: row == fMouseRevealRow]; 171 169 [cell setActionHover: row == fMouseActionRow]; 172 [cell setActionPushed: row == fActionPushedRow];173 170 } 174 171 } 175 172 else … … 403 400 //avoid weird behavior when showing menu by doing this after mouse down 404 401 if (row != -1 && fMouseActionRow == row) 405 402 { 406 if (![NSApp isOnLionOrBetter])407 {408 fActionPushedRow = row;409 [self setNeedsDisplayInRect: [self rectOfRow: row]]; //ensure button is pushed down410 }411 412 403 #warning maybe make appear on mouse down 413 404 [self displayTorrentActionPopoverForEvent: event]; 414 415 if (![NSApp isOnLionOrBetter])416 {417 fActionPushedRow = -1;418 [self setNeedsDisplayInRect: [self rectOfRow: row]];419 }420 405 } 421 406 else if (!pushed && [event clickCount] == 2) //double click 422 407 { … … 548 533 NSURL * url; 549 534 if ((url = [NSURL URLFromPasteboard: [NSPasteboard generalPasteboard]])) 550 535 [fController openURL: [url absoluteString]]; 551 else if ([NSApp isOnLionOrBetter])536 else 552 537 { 553 538 NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil]; 554 539 if (items) … … 578 563 { 579 564 if ([[[NSPasteboard generalPasteboard] types] containsObject: NSURLPboardType]) 580 565 return YES; 581 582 if ([NSApp isOnLionOrBetter]) 566 567 NSArray * items = [[NSPasteboard generalPasteboard] readObjectsForClasses: [NSArray arrayWithObject: [NSString class]] options: nil]; 568 if (items) 583 569 { 584 NS Array * 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) 586 572 { 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; 595 577 } 596 578 } 597 598 579 580 return NO; 599 581 } 600 582 601 583 return YES; … … 623 605 return; 624 606 625 607 const NSRect rect = [fTorrentCell iconRectForBounds: [self rectOfRow: row]]; 608 609 if (fActionPopoverShown) 610 return; 626 611 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]; 665 626 } 666 627 667 628 //don't show multiple popovers when clicking the gear button repeatedly