Ignore:
Timestamp:
Oct 6, 2011, 12:30:40 AM (10 years ago)
Author:
livings124
Message:

We now require Mac OS X 10.6 or later. Make that change and all the nice little adjustments that go with it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/Controller.m

    r12925 r12940  
    160160{
    161161    //make sure another Transmission.app isn't running already
    162     BOOL othersRunning = NO;
    163    
    164     if ([NSApp isOnSnowLeopardOrBetter])
    165     {
    166         NSArray * apps = [NSRunningApplicationSL runningApplicationsWithBundleIdentifier: [[NSBundle mainBundle] bundleIdentifier]];
    167         othersRunning = [apps count] > 1;
    168     }
    169     else
    170     {
    171         NSString * bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
    172         const int processIdentifier = [[NSProcessInfo processInfo] processIdentifier];
    173 
    174         for (NSDictionary * dic in [[NSWorkspace sharedWorkspace] launchedApplications])
    175         {
    176             if ([[dic objectForKey: @"NSApplicationBundleIdentifier"] isEqualToString: bundleIdentifier]
    177                     && [[dic objectForKey: @"NSApplicationProcessIdentifier"] intValue] != processIdentifier)
    178                 othersRunning = YES;
    179         }
    180     }
    181    
    182     if (othersRunning)
     162    NSArray * apps = [NSRunningApplication runningApplicationsWithBundleIdentifier: [[NSBundle mainBundle] bundleIdentifier]];
     163    if ([apps count] > 1)
    183164    {
    184165        NSAlert * alert = [[NSAlert alloc] init];
     
    324305        tr_bencDictAddBool(&settings, TR_PREFS_KEY_UTP_ENABLED, [fDefaults boolForKey: @"UTPGlobal"]);
    325306       
    326         tr_formatter_size_init([NSApp isOnSnowLeopardOrBetter] ? 1000 : 1024,
    327                                     [NSLocalizedString(@"KB", "File size - kilobytes") UTF8String],
    328                                     [NSLocalizedString(@"MB", "File size - megabytes") UTF8String],
    329                                     [NSLocalizedString(@"GB", "File size - gigabytes") UTF8String],
    330                                     [NSLocalizedString(@"TB", "File size - terabytes") UTF8String]);
    331 
    332         tr_formatter_speed_init([NSApp isOnSnowLeopardOrBetter] ? 1000 : 1024,
    333                                     [NSLocalizedString(@"KB/s", "Transfer speed (kilobytes per second)") UTF8String],
    334                                     [NSLocalizedString(@"MB/s", "Transfer speed (megabytes per second)") UTF8String],
    335                                     [NSLocalizedString(@"GB/s", "Transfer speed (gigabytes per second)") UTF8String],
    336                                     [NSLocalizedString(@"TB/s", "Transfer speed (terabytes per second)") UTF8String]); //why not?
    337 
    338         tr_formatter_mem_init(1024, [NSLocalizedString(@"KB", "Memory size - kilobytes") UTF8String],
     307        tr_formatter_size_init(1000, [NSLocalizedString(@"KB", "File size - kilobytes") UTF8String],
     308                                        [NSLocalizedString(@"MB", "File size - megabytes") UTF8String],
     309                                        [NSLocalizedString(@"GB", "File size - gigabytes") UTF8String],
     310                                        [NSLocalizedString(@"TB", "File size - terabytes") UTF8String]);
     311
     312        tr_formatter_speed_init(1000, [NSLocalizedString(@"KB/s", "Transfer speed (kilobytes per second)") UTF8String],
     313                                        [NSLocalizedString(@"MB/s", "Transfer speed (megabytes per second)") UTF8String],
     314                                        [NSLocalizedString(@"GB/s", "Transfer speed (gigabytes per second)") UTF8String],
     315                                        [NSLocalizedString(@"TB/s", "Transfer speed (terabytes per second)") UTF8String]); //why not?
     316
     317        tr_formatter_mem_init(1000, [NSLocalizedString(@"KB", "Memory size - kilobytes") UTF8String],
    339318                                    [NSLocalizedString(@"MB", "Memory size - megabytes") UTF8String],
    340319                                    [NSLocalizedString(@"GB", "Memory size - gigabytes") UTF8String],
     
    682661    [fDefaults setBool: [[fInfoController window] isVisible] forKey: @"InfoVisible"];
    683662   
    684     const BOOL quickLookOpen = [NSApp isOnSnowLeopardOrBetter] && [QLPreviewPanelSL sharedPreviewPanelExists]
    685                                 && [[QLPreviewPanelSL sharedPreviewPanel] isVisible];
    686     if (quickLookOpen)
    687         [[QLPreviewPanelSL sharedPreviewPanel] updateController];
     663    if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible])
     664        [[QLPreviewPanel sharedPreviewPanel] updateController];
    688665   
    689666    for (NSWindow * window in [NSApp windows])
     
    15451522   
    15461523    NSPasteboard * pb = [NSPasteboard generalPasteboard];
    1547     if ([NSApp isOnSnowLeopardOrBetter])
    1548     {
    1549         [pb clearContents];
    1550         [pb writeObjects: [NSArray arrayWithObject: text]];
    1551     }
    1552     else
    1553     {
    1554         [pb declareTypes: [NSArray arrayWithObject: NSStringPboardType] owner: nil];
    1555         [pb setString: text forType: NSStringPboardType];
    1556     }
     1524    [pb clearContents];
     1525    [pb writeObjects: [NSArray arrayWithObject: text]];
    15571526}
    15581527
     
    15601529{
    15611530    NSArray * selected = [fTableView selectedTorrents];
    1562     if ([NSApp isOnSnowLeopardOrBetter])
    1563     {
    1564         NSMutableArray * paths = [NSMutableArray arrayWithCapacity: [selected count]];
    1565         for (Torrent * torrent in selected)
    1566         {
    1567             NSString * location = [torrent dataLocation];
    1568             if (location)
    1569                 [paths addObject: [NSURL fileURLWithPath: location]];
    1570         }
    1571        
    1572         if ([paths count] > 0)
    1573             [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: paths];
    1574     }
    1575     else
    1576     {
    1577         for (Torrent * torrent in selected)
    1578         {
    1579             NSString * location = [torrent dataLocation];
    1580             if (location)
    1581                 [[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
    1582         }
    1583     }
     1531    NSMutableArray * paths = [NSMutableArray arrayWithCapacity: [selected count]];
     1532    for (Torrent * torrent in selected)
     1533    {
     1534        NSString * location = [torrent dataLocation];
     1535        if (location)
     1536            [paths addObject: [NSURL fileURLWithPath: location]];
     1537    }
     1538   
     1539    if ([paths count] > 0)
     1540        [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: paths];
    15841541}
    15851542
     
    16291586        [[fInfoController window] orderFront: nil];
    16301587       
    1631         if ([fInfoController canQuickLook]
    1632             && [QLPreviewPanelSL sharedPreviewPanelExists] && [[QLPreviewPanelSL sharedPreviewPanel] isVisible])
    1633             [[QLPreviewPanelSL sharedPreviewPanel] reloadData];
    1634        
     1588        if ([fInfoController canQuickLook] && [QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible])
     1589            [[QLPreviewPanel sharedPreviewPanel] reloadData];
    16351590    }
    16361591   
     
    16421597    [fInfoController setInfoForTorrents: [fTableView selectedTorrents]];
    16431598   
    1644     if ([NSApp isOnSnowLeopardOrBetter] && [QLPreviewPanelSL sharedPreviewPanelExists]
    1645         && [[QLPreviewPanelSL sharedPreviewPanel] isVisible])
    1646         [[QLPreviewPanelSL sharedPreviewPanel] reloadData];
     1599    if ([QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible])
     1600        [[QLPreviewPanel sharedPreviewPanel] reloadData];
    16471601}
    16481602
     
    19011855       
    19021856        NSArray * descriptors;
    1903         NSSortDescriptor * nameDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"name" ascending: asc
    1904                                                 selector: @selector(compareFinder:)] autorelease];
     1857        NSSortDescriptor * nameDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"name" ascending: asc selector: @selector(localizedStandardCompare:)];
    19051858       
    19061859        if ([sortType isEqualToString: SORT_STATE])
    19071860        {
    1908             NSSortDescriptor * stateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"stateSortKey" ascending: !asc] autorelease],
    1909                             * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"progress" ascending: !asc] autorelease],
    1910                             * ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"ratio" ascending: !asc] autorelease];
     1861            NSSortDescriptor * stateDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"stateSortKey" ascending: !asc],
     1862                            * progressDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"progress" ascending: !asc],
     1863                            * ratioDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"ratio" ascending: !asc];
    19111864           
    19121865            descriptors = [[NSArray alloc] initWithObjects: stateDescriptor, progressDescriptor, ratioDescriptor,
     
    19151868        else if ([sortType isEqualToString: SORT_PROGRESS])
    19161869        {
    1917             NSSortDescriptor * progressDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"progress" ascending: asc] autorelease],
    1918                             * ratioProgressDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"progressStopRatio"
    1919                                                             ascending: asc] autorelease],
    1920                             * ratioDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"ratio" ascending: asc] autorelease];
     1870            NSSortDescriptor * progressDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"progress" ascending: asc],
     1871                            * ratioProgressDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"progressStopRatio" ascending: asc],
     1872                            * ratioDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"ratio" ascending: asc];
    19211873           
    19221874            descriptors = [[NSArray alloc] initWithObjects: progressDescriptor, ratioProgressDescriptor, ratioDescriptor,
     
    19251877        else if ([sortType isEqualToString: SORT_TRACKER])
    19261878        {
    1927             NSSortDescriptor * trackerDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"trackerSortKey" ascending: asc
    1928                                                     selector: @selector(localizedCaseInsensitiveCompare:)] autorelease];
     1879            NSSortDescriptor * trackerDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"trackerSortKey" ascending: asc selector: @selector(localizedCaseInsensitiveCompare:)];
    19291880           
    19301881            descriptors = [[NSArray alloc] initWithObjects: trackerDescriptor, nameDescriptor, nil];
     
    19321883        else if ([sortType isEqualToString: SORT_ACTIVITY])
    19331884        {
    1934             NSSortDescriptor * rateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"totalRate" ascending: !asc] autorelease];
    1935             NSSortDescriptor * activityDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateActivityOrAdd" ascending: !asc]
    1936                                                         autorelease];
     1885            NSSortDescriptor * rateDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"totalRate" ascending: !asc];
     1886            NSSortDescriptor * activityDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"dateActivityOrAdd" ascending: !asc];
    19371887           
    19381888            descriptors = [[NSArray alloc] initWithObjects: rateDescriptor, activityDescriptor, nameDescriptor, nil];
     
    19401890        else if ([sortType isEqualToString: SORT_DATE])
    19411891        {
    1942             NSSortDescriptor * dateDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"dateAdded" ascending: asc] autorelease];
     1892            NSSortDescriptor * dateDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"dateAdded" ascending: asc];
    19431893           
    19441894            descriptors = [[NSArray alloc] initWithObjects: dateDescriptor, nameDescriptor, nil];
     
    19461896        else if ([sortType isEqualToString: SORT_SIZE])
    19471897        {
    1948             NSSortDescriptor * sizeDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"size" ascending: asc] autorelease];
     1898            NSSortDescriptor * sizeDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"size" ascending: asc];
    19491899           
    19501900            descriptors = [[NSArray alloc] initWithObjects: sizeDescriptor, nameDescriptor, nil];
     
    21072057        [fDisplayedTorrents removeAllObjects];
    21082058       
    2109         NSSortDescriptor * groupDescriptor = [[[NSSortDescriptor alloc] initWithKey: @"groupOrderValue" ascending: YES] autorelease];
     2059        NSSortDescriptor * groupDescriptor = [NSSortDescriptor sortDescriptorWithKey: @"groupOrderValue" ascending: YES];
    21102060        [allTorrents sortUsingDescriptors: [NSArray arrayWithObject: groupDescriptor]];
    21112061       
     
    22032153        location.y += NSHeight(rect) + 5.0;
    22042154       
    2205         if ([NSApp isOnSnowLeopardOrBetter])
    2206             [fActionMenu popUpMenuPositioningItem: nil atLocation: location inView: sender];
    2207         else
    2208         {
    2209             NSEvent * newEvent = [NSEvent mouseEventWithType: NSLeftMouseDown location: location
    2210                                                modifierFlags: NSLeftMouseDownMask timestamp: GetCurrentEventTime() windowNumber: [fWindow windowNumber]
    2211                                                      context: nil eventNumber: 1 clickCount: 1 pressure: 1];
    2212              
    2213             [NSMenu popUpContextMenu: fActionMenu withEvent: newEvent forView: sender];
    2214         }
     2155        [fActionMenu popUpMenuPositioningItem: nil atLocation: location inView: sender];
    22152156    }
    22162157}
     
    30843025}
    30853026
    3086 #warning change from id to QLPreviewPanel
    3087 - (BOOL) acceptsPreviewPanelControl: (id) panel
     3027- (BOOL) acceptsPreviewPanelControl: (QLPreviewPanel *) panel
    30883028{
    30893029    return !fQuitting;
    30903030}
    30913031
    3092 - (void) beginPreviewPanelControl: (id) panel
     3032- (void) beginPreviewPanelControl: (QLPreviewPanel *) panel
    30933033{
    30943034    fPreviewPanel = [panel retain];
     
    30973037}
    30983038
    3099 - (void) endPreviewPanelControl: (id) panel
     3039- (void) endPreviewPanelControl: (QLPreviewPanel *) panel
    31003040{
    31013041    [fPreviewPanel release];
     
    31153055}
    31163056
    3117 - (NSInteger) numberOfPreviewItemsInPreviewPanel: (id) panel
     3057- (NSInteger) numberOfPreviewItemsInPreviewPanel: (QLPreviewPanel *) panel
    31183058{
    31193059    if ([fInfoController canQuickLook])
     
    31233063}
    31243064
    3125 - (id /*<QLPreviewItem>*/) previewPanel: (id) panel previewItemAtIndex: (NSInteger) index
     3065- (id <QLPreviewItem>) previewPanel: (QLPreviewPanel *) panel previewItemAtIndex: (NSInteger) index
    31263066{
    31273067    if ([fInfoController canQuickLook])
     
    31313071}
    31323072
    3133 - (BOOL) previewPanel: (id) panel handleEvent: (NSEvent *) event
     3073- (BOOL) previewPanel: (QLPreviewPanel *) panel handleEvent: (NSEvent *) event
    31343074{
    31353075    /*if ([event type] == NSKeyDown)
     
    31423082}
    31433083
    3144 - (NSRect) previewPanel: (id) panel sourceFrameOnScreenForPreviewItem: (id /*<QLPreviewItem>*/) item
     3084- (NSRect) previewPanel: (QLPreviewPanel *) panel sourceFrameOnScreenForPreviewItem: (id <QLPreviewItem>) item
    31453085{
    31463086    if ([fInfoController canQuickLook])
     
    34853425    if ([ident isEqualToString: TOOLBAR_QUICKLOOK])
    34863426    {
    3487         [(NSButton *)[toolbarItem view] setState: [NSApp isOnSnowLeopardOrBetter] && [QLPreviewPanelSL sharedPreviewPanelExists]
    3488                                                     && [[QLPreviewPanelSL sharedPreviewPanel] isVisible]];
    3489         return [NSApp isOnSnowLeopardOrBetter];
     3427        [(NSButton *)[toolbarItem view] setState: [QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible]];
     3428        return YES;
    34903429    }
    34913430
     
    38473786    if (action == @selector(toggleQuickLook:))
    38483787    {
    3849         const BOOL visible = [NSApp isOnSnowLeopardOrBetter] && [QLPreviewPanelSL sharedPreviewPanelExists]
    3850                                 && [[QLPreviewPanelSL sharedPreviewPanel] isVisible];
     3788        const BOOL visible =[QLPreviewPanel sharedPreviewPanelExists] && [[QLPreviewPanel sharedPreviewPanel] isVisible];
    38513789        //text consistent with Finder
    38523790        NSString * title = !visible ? NSLocalizedString(@"Quick Look", "View menu -> Quick Look")
     
    38543792        [menuItem setTitle: title];
    38553793       
    3856         return [NSApp isOnSnowLeopardOrBetter];
     3794        return YES;
    38573795    }
    38583796   
     
    39613899        [scrollView setHasVerticalScroller: YES];
    39623900       
    3963         //hack to ensure scrollbars don't disappear after resizing
    3964         if (![NSApp isOnSnowLeopardOrBetter])
    3965         {
    3966             [scrollView setAutohidesScrollers: NO];
    3967             [scrollView setAutohidesScrollers: YES];
    3968         }
    3969        
    39703901        [self setWindowMinMaxToCurrent];
    39713902    }
     
    40453976- (void) toggleQuickLook: (id) sender
    40463977{
    4047     if (![NSApp isOnSnowLeopardOrBetter])
    4048         return;
    4049    
    4050     if ([[QLPreviewPanelSL sharedPreviewPanel] isVisible])
    4051         [[QLPreviewPanelSL sharedPreviewPanel] orderOut: nil];
     3978    if ([[QLPreviewPanel sharedPreviewPanel] isVisible])
     3979        [[QLPreviewPanel sharedPreviewPanel] orderOut: nil];
    40523980    else
    4053         [[QLPreviewPanelSL sharedPreviewPanel] makeKeyAndOrderFront: nil];
     3981        [[QLPreviewPanel sharedPreviewPanel] makeKeyAndOrderFront: nil];
    40543982}
    40553983
     
    40964024            && (location = [clickContext objectForKey: @"Location"]))
    40974025    {
    4098         if ([NSApp isOnSnowLeopardOrBetter])
    4099         {
    4100             NSURL * file = [NSURL fileURLWithPath: location];
    4101             [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
    4102         }
    4103         else
    4104             [[NSWorkspace sharedWorkspace] selectFile: location inFileViewerRootedAtPath: nil];
     4026        NSURL * file = [NSURL fileURLWithPath: location];
     4027        [[NSWorkspace sharedWorkspace] activateFileViewerSelectingURLs: [NSArray arrayWithObject: file]];
    41054028    }
    41064029}
     
    42574180    NSArray * selectedValues = [fTableView selectedValues];
    42584181   
    4259     NSSortDescriptor * descriptor = [[NSSortDescriptor alloc] initWithKey: @"queuePosition" ascending: YES];
     4182    NSSortDescriptor * descriptor = [NSSortDescriptor sortDescriptorWithKey: @"queuePosition" ascending: YES];
    42604183    NSArray * descriptors = [NSArray arrayWithObject: descriptor];
    4261     [descriptor release];
    42624184   
    42634185    [fTorrents sortUsingDescriptors: descriptors];
Note: See TracChangeset for help on using the changeset viewer.