Remove NSApp isOnMountainLionOrBetter helper
This commit is contained in:
parent
fa504fb27f
commit
5e18ddbca8
|
@ -392,34 +392,23 @@ static void removeKeRangerRansomware()
|
|||
tr_variantDictAddBool(&settings, TR_KEY_utp_enabled, [fDefaults boolForKey: @"UTPGlobal"]);
|
||||
|
||||
|
||||
NSString * kbString, * mbString, * gbString, * tbString;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSByteCountFormatter * unitFormatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
[unitFormatter setIncludesCount: NO];
|
||||
[unitFormatter setAllowsNonnumericFormatting: NO];
|
||||
NSByteCountFormatter * unitFormatter = [[NSByteCountFormatter alloc] init];
|
||||
[unitFormatter setIncludesCount: NO];
|
||||
[unitFormatter setAllowsNonnumericFormatting: NO];
|
||||
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseKB];
|
||||
kbString = [unitFormatter stringFromByteCount: 17]; //use a random value to avoid possible pluralization issues with 1 or 0 (an example is if we use 1 for bytes, we'd get "byte" when we'd want "bytes" for the generic libtransmission value at least)
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseKB];
|
||||
NSString * kbString = [unitFormatter stringFromByteCount: 17]; //use a random value to avoid possible pluralization issues with 1 or 0 (an example is if we use 1 for bytes, we'd get "byte" when we'd want "bytes" for the generic libtransmission value at least)
|
||||
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseMB];
|
||||
mbString = [unitFormatter stringFromByteCount: 17];
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseMB];
|
||||
NSString * mbString = [unitFormatter stringFromByteCount: 17];
|
||||
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseGB];
|
||||
gbString = [unitFormatter stringFromByteCount: 17];
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseGB];
|
||||
NSString * gbString = [unitFormatter stringFromByteCount: 17];
|
||||
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseTB];
|
||||
tbString = [unitFormatter stringFromByteCount: 17];
|
||||
[unitFormatter setAllowedUnits: NSByteCountFormatterUseTB];
|
||||
NSString * tbString = [unitFormatter stringFromByteCount: 17];
|
||||
|
||||
[unitFormatter release];
|
||||
}
|
||||
else
|
||||
{
|
||||
kbString = NSLocalizedString(@"KB", "file/memory size - kilobytes");
|
||||
mbString = NSLocalizedString(@"MB", "file/memory size - megabytes");
|
||||
gbString = NSLocalizedString(@"GB", "file/memory size - gigabytes");
|
||||
tbString = NSLocalizedString(@"TB", "file/memory size - terabytes");
|
||||
}
|
||||
[unitFormatter release];
|
||||
|
||||
tr_formatter_size_init(1000, [kbString UTF8String],
|
||||
[mbString UTF8String],
|
||||
|
@ -598,14 +587,7 @@ static void removeKeRangerRansomware()
|
|||
|
||||
fBadger = [[Badger alloc] initWithLib: fLib];
|
||||
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
[[NSUserNotificationCenterMtLion defaultUserNotificationCenter] setDelegate: self];
|
||||
|
||||
// remove Share menu items
|
||||
if (![NSApp isOnMountainLionOrBetter]) {
|
||||
[[fShareMenuItem menu] removeItem:fShareMenuItem];
|
||||
[[fShareContextMenuItem menu] removeItem:fShareContextMenuItem];
|
||||
}
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] setDelegate: self];
|
||||
|
||||
//observe notifications
|
||||
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
||||
|
@ -683,12 +665,9 @@ static void removeKeRangerRansomware()
|
|||
forEventClass: kCoreEventClass andEventID: kAEOpenContents];
|
||||
|
||||
//if we were opened from a user notification, do the corresponding action
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSUserNotification * launchNotification = [[notification userInfo] objectForKey: NSApplicationLaunchUserNotificationKey];
|
||||
if (launchNotification)
|
||||
[self userNotificationCenter: nil didActivateNotification: launchNotification];
|
||||
}
|
||||
NSUserNotification * launchNotification = [[notification userInfo] objectForKey: NSApplicationLaunchUserNotificationKey];
|
||||
if (launchNotification)
|
||||
[self userNotificationCenter: nil didActivateNotification: launchNotification];
|
||||
|
||||
//auto importing
|
||||
[self checkAutoImportDirectory];
|
||||
|
@ -2109,23 +2088,20 @@ static void removeKeRangerRansomware()
|
|||
NSString * location = [torrent dataLocation];
|
||||
|
||||
NSString * notificationTitle = NSLocalizedString(@"Download Complete", "notification title");
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSUserNotification * notification = [[NSUserNotificationMtLion alloc] init];
|
||||
[notification setTitle: notificationTitle];
|
||||
[notification setInformativeText: [torrent name]];
|
||||
NSUserNotification * notification = [[NSUserNotification alloc] init];
|
||||
[notification setTitle: notificationTitle];
|
||||
[notification setInformativeText: [torrent name]];
|
||||
|
||||
[notification setHasActionButton: YES];
|
||||
[notification setActionButtonTitle: NSLocalizedString(@"Show", "notification button")];
|
||||
[notification setHasActionButton: YES];
|
||||
[notification setActionButtonTitle: NSLocalizedString(@"Show", "notification button")];
|
||||
|
||||
NSMutableDictionary * userInfo = [NSMutableDictionary dictionaryWithObject: [torrent hashString] forKey: @"Hash"];
|
||||
if (location)
|
||||
[userInfo setObject: location forKey: @"Location"];
|
||||
[notification setUserInfo: userInfo];
|
||||
NSMutableDictionary * userInfo = [NSMutableDictionary dictionaryWithObject: [torrent hashString] forKey: @"Hash"];
|
||||
if (location)
|
||||
[userInfo setObject: location forKey: @"Location"];
|
||||
[notification setUserInfo: userInfo];
|
||||
|
||||
[[NSUserNotificationCenterMtLion defaultUserNotificationCenter] deliverNotification: notification];
|
||||
[notification release];
|
||||
}
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification];
|
||||
[notification release];
|
||||
|
||||
NSMutableDictionary * clickContext = [NSMutableDictionary dictionaryWithObjectsAndKeys:
|
||||
GROWL_DOWNLOAD_COMPLETE, @"Type", nil];
|
||||
|
@ -2137,8 +2113,6 @@ static void removeKeRangerRansomware()
|
|||
description: [torrent name] notificationName: GROWL_DOWNLOAD_COMPLETE
|
||||
iconData: nil priority: 0 isSticky: NO clickContext: clickContext];
|
||||
|
||||
//NSLog(@"delegate: %@", [[NSUserNotificationCenterMtLion defaultUserNotificationCenter] delegate]);
|
||||
|
||||
if (![fWindow isMainWindow])
|
||||
[fBadger addCompletedTorrent: torrent];
|
||||
|
||||
|
@ -2173,23 +2147,20 @@ static void removeKeRangerRansomware()
|
|||
NSString * location = [torrent dataLocation];
|
||||
|
||||
NSString * notificationTitle = NSLocalizedString(@"Seeding Complete", "notification title");
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSUserNotification * notification = [[NSUserNotificationMtLion alloc] init];
|
||||
[notification setTitle: notificationTitle];
|
||||
[notification setInformativeText: [torrent name]];
|
||||
NSUserNotification * userNotification = [[NSUserNotification alloc] init];
|
||||
[userNotification setTitle: notificationTitle];
|
||||
[userNotification setInformativeText: [torrent name]];
|
||||
|
||||
[notification setHasActionButton: YES];
|
||||
[notification setActionButtonTitle: NSLocalizedString(@"Show", "notification button")];
|
||||
[userNotification setHasActionButton: YES];
|
||||
[userNotification setActionButtonTitle: NSLocalizedString(@"Show", "notification button")];
|
||||
|
||||
NSMutableDictionary * userInfo = [NSMutableDictionary dictionaryWithObject: [torrent hashString] forKey: @"Hash"];
|
||||
if (location)
|
||||
[userInfo setObject: location forKey: @"Location"];
|
||||
[notification setUserInfo: userInfo];
|
||||
NSMutableDictionary * userInfo = [NSMutableDictionary dictionaryWithObject: [torrent hashString] forKey: @"Hash"];
|
||||
if (location)
|
||||
[userInfo setObject: location forKey: @"Location"];
|
||||
[userNotification setUserInfo: userInfo];
|
||||
|
||||
[[NSUserNotificationCenterMtLion defaultUserNotificationCenter] deliverNotification: notification];
|
||||
[notification release];
|
||||
}
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: userNotification];
|
||||
[userNotification release];
|
||||
|
||||
NSMutableDictionary * clickContext = [NSMutableDictionary dictionaryWithObject: GROWL_SEEDING_COMPLETE forKey: @"Type"];
|
||||
|
||||
|
@ -2971,17 +2942,14 @@ static void removeKeRangerRansomware()
|
|||
[self openFiles: [NSArray arrayWithObject: fullFile] addType: ADD_AUTO forcePath: nil];
|
||||
|
||||
NSString * notificationTitle = NSLocalizedString(@"Torrent File Auto Added", "notification title");
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSUserNotification* notification = [[NSUserNotificationMtLion alloc] init];
|
||||
[notification setTitle: notificationTitle];
|
||||
[notification setInformativeText: file];
|
||||
NSUserNotification* notification = [[NSUserNotification alloc] init];
|
||||
[notification setTitle: notificationTitle];
|
||||
[notification setInformativeText: file];
|
||||
|
||||
[notification setHasActionButton: NO];
|
||||
[notification setHasActionButton: NO];
|
||||
|
||||
[[NSUserNotificationCenterMtLion defaultUserNotificationCenter] deliverNotification: notification];
|
||||
[notification release];
|
||||
}
|
||||
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification: notification];
|
||||
[notification release];
|
||||
|
||||
[GrowlApplicationBridge notifyWithTitle: notificationTitle
|
||||
description: file notificationName: GROWL_AUTO_ADD iconData: nil priority: 0 isSticky: NO
|
||||
|
@ -4013,30 +3981,20 @@ static void removeKeRangerRansomware()
|
|||
|
||||
- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar
|
||||
{
|
||||
NSMutableArray *items = [NSMutableArray arrayWithObjects:
|
||||
TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_OPEN_WEB, TOOLBAR_REMOVE,
|
||||
TOOLBAR_PAUSE_RESUME_SELECTED, TOOLBAR_PAUSE_RESUME_ALL,
|
||||
TOOLBAR_SHARE, TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO,
|
||||
NSToolbarSeparatorItemIdentifier,
|
||||
NSToolbarSpaceItemIdentifier,
|
||||
NSToolbarFlexibleSpaceItemIdentifier,
|
||||
NSToolbarCustomizeToolbarItemIdentifier, nil];
|
||||
if (![NSApp isOnMountainLionOrBetter]) {
|
||||
[items removeObject:TOOLBAR_SHARE];
|
||||
}
|
||||
return items;
|
||||
return @[ TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_OPEN_WEB, TOOLBAR_REMOVE,
|
||||
TOOLBAR_PAUSE_RESUME_SELECTED, TOOLBAR_PAUSE_RESUME_ALL,
|
||||
TOOLBAR_SHARE, TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO,
|
||||
NSToolbarSeparatorItemIdentifier,
|
||||
NSToolbarSpaceItemIdentifier,
|
||||
NSToolbarFlexibleSpaceItemIdentifier,
|
||||
NSToolbarCustomizeToolbarItemIdentifier ];
|
||||
}
|
||||
|
||||
- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
|
||||
{
|
||||
NSMutableArray *items = [NSMutableArray arrayWithObjects:
|
||||
TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_REMOVE, NSToolbarSpaceItemIdentifier,
|
||||
TOOLBAR_PAUSE_RESUME_ALL, NSToolbarFlexibleSpaceItemIdentifier,
|
||||
TOOLBAR_SHARE, TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO, nil];
|
||||
if (![NSApp isOnMountainLionOrBetter]) {
|
||||
[items removeObject:TOOLBAR_SHARE];
|
||||
}
|
||||
return items;
|
||||
return @[ TOOLBAR_CREATE, TOOLBAR_OPEN_FILE, TOOLBAR_REMOVE, NSToolbarSpaceItemIdentifier,
|
||||
TOOLBAR_PAUSE_RESUME_ALL, NSToolbarFlexibleSpaceItemIdentifier,
|
||||
TOOLBAR_SHARE, TOOLBAR_QUICKLOOK, TOOLBAR_FILTER, TOOLBAR_INFO ];
|
||||
}
|
||||
|
||||
- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
|
||||
|
|
|
@ -453,17 +453,10 @@ typedef enum
|
|||
[NSString stringWithFormat: NSLocalizedString(@"%@ total", "Inspector -> selected torrents"),
|
||||
[NSString stringForFileSize: size]]]];
|
||||
|
||||
NSString * byteString;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSByteCountFormatter * formatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
[formatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
byteString = [formatter stringFromByteCount: size];
|
||||
[formatter release];
|
||||
}
|
||||
else
|
||||
byteString = [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"), [NSString formattedUInteger: size]];
|
||||
[fBasicInfoField setToolTip: byteString];
|
||||
NSByteCountFormatter * formatter = [[NSByteCountFormatter alloc] init];
|
||||
[formatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
[fBasicInfoField setToolTip: [formatter stringFromByteCount: size]];
|
||||
[formatter release];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -512,17 +505,10 @@ typedef enum
|
|||
}
|
||||
[fBasicInfoField setStringValue: basicString];
|
||||
|
||||
NSString * byteString;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSByteCountFormatter * formatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
[formatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
byteString = [formatter stringFromByteCount: [torrent size]];
|
||||
[formatter release];
|
||||
}
|
||||
else
|
||||
byteString = [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "Inspector -> selected torrents"), [NSString formattedUInteger: [torrent size]]];
|
||||
[fBasicInfoField setToolTip: byteString];
|
||||
NSByteCountFormatter * formatter = [[NSByteCountFormatter alloc] init];
|
||||
[formatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
[fBasicInfoField setToolTip: [formatter stringFromByteCount: [torrent size]]];
|
||||
[formatter release];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -22,13 +22,8 @@
|
|||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#define NSByteCountFormatterMtLion NSClassFromString(@"NSByteCountFormatter")
|
||||
#define NSUserNotificationMtLion NSClassFromString(@"NSUserNotification")
|
||||
#define NSUserNotificationCenterMtLion NSClassFromString(@"NSUserNotificationCenter")
|
||||
|
||||
@interface NSApplication (NSApplicationAdditions)
|
||||
|
||||
- (BOOL) isOnMountainLionOrBetter;
|
||||
- (BOOL) isOnYosemiteOrBetter;
|
||||
|
||||
@end
|
||||
|
|
|
@ -24,11 +24,6 @@
|
|||
|
||||
@implementation NSApplication (NSApplicationAdditions)
|
||||
|
||||
- (BOOL) isOnMountainLionOrBetter
|
||||
{
|
||||
return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_7;
|
||||
}
|
||||
|
||||
- (BOOL) isOnYosemiteOrBetter
|
||||
{
|
||||
return floor(NSAppKitVersionNumber) > NSAppKitVersionNumber10_9;
|
||||
|
|
|
@ -46,67 +46,41 @@
|
|||
return [self stringByAppendingString: [NSString ellipsis]];
|
||||
}
|
||||
|
||||
#warning use localizedStringWithFormat: directly when 10.8-only
|
||||
#warning use localizedStringWithFormat: directly when 10.9-only and stringsdict translations are in place
|
||||
+ (NSString *) formattedUInteger: (NSUInteger) value
|
||||
{
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
return [NSString localizedStringWithFormat: @"%lu", value];
|
||||
else
|
||||
{
|
||||
static NSNumberFormatter * numberFormatter;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
numberFormatter = [[NSNumberFormatter alloc] init];
|
||||
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
|
||||
[numberFormatter setMaximumFractionDigits: 0];
|
||||
});
|
||||
|
||||
return [numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: value]];
|
||||
}
|
||||
return [NSString localizedStringWithFormat: @"%lu", value];
|
||||
}
|
||||
|
||||
#warning should we take long long instead?
|
||||
+ (NSString *) stringForFileSize: (uint64_t) size
|
||||
{
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
return [NSByteCountFormatterMtLion stringFromByteCount: size countStyle: NSByteCountFormatterCountStyleFile];
|
||||
else
|
||||
return [self stringForFileSizeLion: size showUnitUnless: nil unitsUsed: nil];
|
||||
return [NSByteCountFormatter stringFromByteCount: size countStyle: NSByteCountFormatterCountStyleFile];
|
||||
}
|
||||
|
||||
#warning should we take long long instead?
|
||||
+ (NSString *) stringForFilePartialSize: (uint64_t) partialSize fullSize: (uint64_t) fullSize
|
||||
{
|
||||
NSString * partialString, * fullString;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
NSByteCountFormatter * fileSizeFormatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
NSByteCountFormatter * fileSizeFormatter = [[NSByteCountFormatter alloc] init];
|
||||
|
||||
fullString = [fileSizeFormatter stringFromByteCount: fullSize];
|
||||
NSString * fullString = [fileSizeFormatter stringFromByteCount: fullSize];
|
||||
|
||||
//figure out the magniture of the two, since we can't rely on comparing the units because of localization and pluralization issues (for example, "1 byte of 2 bytes")
|
||||
BOOL partialUnitsSame;
|
||||
if (partialSize == 0)
|
||||
partialUnitsSame = YES; //we want to just show "0" when we have no partial data, so always set to the same units
|
||||
else
|
||||
{
|
||||
const unsigned int magnitudePartial = log(partialSize)/log(1000);
|
||||
const unsigned int magnitudeFull = fullSize < 1000 ? 0 : log(fullSize)/log(1000); //we have to catch 0 with a special case, so might as well avoid the math for all of magnitude 0
|
||||
partialUnitsSame = magnitudePartial == magnitudeFull;
|
||||
}
|
||||
|
||||
[fileSizeFormatter setIncludesUnit: !partialUnitsSame];
|
||||
partialString = [fileSizeFormatter stringFromByteCount: partialSize];
|
||||
|
||||
[fileSizeFormatter release];
|
||||
}
|
||||
//figure out the magniture of the two, since we can't rely on comparing the units because of localization and pluralization issues (for example, "1 byte of 2 bytes")
|
||||
BOOL partialUnitsSame;
|
||||
if (partialSize == 0)
|
||||
partialUnitsSame = YES; //we want to just show "0" when we have no partial data, so always set to the same units
|
||||
else
|
||||
{
|
||||
NSString * units;
|
||||
fullString = [self stringForFileSizeLion: fullSize showUnitUnless: nil unitsUsed: &units];
|
||||
partialString = [self stringForFileSizeLion: partialSize showUnitUnless: units unitsUsed: nil];
|
||||
const unsigned int magnitudePartial = log(partialSize)/log(1000);
|
||||
const unsigned int magnitudeFull = fullSize < 1000 ? 0 : log(fullSize)/log(1000); //we have to catch 0 with a special case, so might as well avoid the math for all of magnitude 0
|
||||
partialUnitsSame = magnitudePartial == magnitudeFull;
|
||||
}
|
||||
|
||||
[fileSizeFormatter setIncludesUnit: !partialUnitsSame];
|
||||
NSString * partialString = [fileSizeFormatter stringFromByteCount: partialSize];
|
||||
|
||||
[fileSizeFormatter release];
|
||||
|
||||
return [NSString stringWithFormat: NSLocalizedString(@"%@ of %@", "file size string"), partialString, fullString];
|
||||
}
|
||||
|
||||
|
|
|
@ -134,7 +134,7 @@
|
|||
}
|
||||
|
||||
//set built-in Growl
|
||||
[GrowlApplicationBridge setShouldUseBuiltInNotifications: ![NSApp isOnMountainLionOrBetter] && [fDefaults boolForKey: @"DisplayNotifications"]];
|
||||
[GrowlApplicationBridge setShouldUseBuiltInNotifications: NO];
|
||||
|
||||
[self setAutoUpdateToBeta: nil];
|
||||
}
|
||||
|
@ -1504,7 +1504,7 @@
|
|||
[fGrowlAppButton setTarget: self];
|
||||
[fGrowlAppButton setAction: @selector(openGrowlApp:)];
|
||||
}
|
||||
else if ([NSApp isOnMountainLionOrBetter])
|
||||
else
|
||||
{
|
||||
[fBuiltInGrowlButton setHidden: YES];
|
||||
[fGrowlAppButton setHidden: NO];
|
||||
|
@ -1516,13 +1516,6 @@
|
|||
[fGrowlAppButton setTarget: self];
|
||||
[fGrowlAppButton setAction: @selector(openNotificationSystemPrefs:)];
|
||||
}
|
||||
else
|
||||
{
|
||||
[fBuiltInGrowlButton setHidden: NO];
|
||||
[fGrowlAppButton setHidden: YES];
|
||||
|
||||
[fBuiltInGrowlButton setState: [fDefaults boolForKey: @"DisplayNotifications"]];
|
||||
}
|
||||
}
|
||||
|
||||
static NSString * getOSStatusDescription(OSStatus errorCode)
|
||||
|
|
|
@ -167,22 +167,18 @@ tr_session * fLib = NULL;
|
|||
tr_sessionGetCumulativeStats(fLib, &statsAll);
|
||||
tr_sessionGetStats(fLib, &statsSession);
|
||||
|
||||
NSByteCountFormatter * byteFormatter = nil;
|
||||
if ([NSApp isOnMountainLionOrBetter])
|
||||
{
|
||||
byteFormatter = [[NSByteCountFormatterMtLion alloc] init];
|
||||
[byteFormatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
}
|
||||
NSByteCountFormatter * byteFormatter = [[NSByteCountFormatter alloc] init];
|
||||
[byteFormatter setAllowedUnits: NSByteCountFormatterUseBytes];
|
||||
|
||||
[fUploadedField setStringValue: [NSString stringForFileSize: statsSession.uploadedBytes]];
|
||||
[fUploadedField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsSession.uploadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsSession.uploadedBytes]]];
|
||||
[fUploadedField setToolTip: [byteFormatter stringFromByteCount: statsSession.uploadedBytes]];
|
||||
[fUploadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString stringForFileSize: statsAll.uploadedBytes]]];
|
||||
[fUploadedAllField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsAll.uploadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsAll.uploadedBytes]]];
|
||||
[fUploadedAllField setToolTip: [byteFormatter stringFromByteCount: statsAll.uploadedBytes]];
|
||||
|
||||
[fDownloadedField setStringValue: [NSString stringForFileSize: statsSession.downloadedBytes]];
|
||||
[fDownloadedField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsSession.downloadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsSession.downloadedBytes]]];
|
||||
[fDownloadedField setToolTip: [byteFormatter stringFromByteCount: statsSession.downloadedBytes]];
|
||||
[fDownloadedAllField setStringValue: [NSString stringWithFormat: NSLocalizedString(@"%@ total", "stats total"), [NSString stringForFileSize: statsAll.downloadedBytes]]];
|
||||
[fDownloadedAllField setToolTip: [NSApp isOnMountainLionOrBetter] ? [byteFormatter stringFromByteCount: statsAll.downloadedBytes] : [NSString stringWithFormat: NSLocalizedString(@"%@ bytes", "stats -> bytes"), [NSString formattedUInteger: statsAll.downloadedBytes]]];
|
||||
[fDownloadedAllField setToolTip: [byteFormatter stringFromByteCount: statsAll.downloadedBytes]];
|
||||
|
||||
[byteFormatter release];
|
||||
|
||||
|
|
Loading…
Reference in New Issue