a little cleanup

This commit is contained in:
Mitchell Livingston 2009-08-19 00:38:53 +00:00
parent 27c38171cb
commit 8f87d72461
1 changed files with 40 additions and 37 deletions

View File

@ -536,46 +536,49 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
[[BonjourController defaultController] startWithPort: [fDefaults integerForKey: @"RPCPort"]]; [[BonjourController defaultController] startWithPort: [fDefaults integerForKey: @"RPCPort"]];
//shamelessly ask for donations //shamelessly ask for donations
tr_session_stats stats; if ([fDefaults boolForKey: @"WarningDonate"])
tr_sessionGetCumulativeStats(fLib, &stats);
const BOOL firstLaunch = stats.sessionCount <= 1;
NSDate * lastDonateDate = [fDefaults objectForKey: @"DonateAskDate"];
const BOOL timePassed = !lastDonateDate || (-1 * [lastDonateDate timeIntervalSinceNow]) >= DONATE_NAG_TIME;
if ([fDefaults boolForKey: @"WarningDonate"] && !firstLaunch && timePassed)
{ {
NSAlert * alert = [[NSAlert alloc] init]; tr_session_stats stats;
[alert setMessageText: NSLocalizedString(@"Support open-source indie software", "Donation beg -> title")]; tr_sessionGetCumulativeStats(fLib, &stats);
const BOOL firstLaunch = stats.sessionCount <= 1;
NSString * donateMessage = [NSString stringWithFormat: @"%@\n\n%@", NSDate * lastDonateDate = [fDefaults objectForKey: @"DonateAskDate"];
NSLocalizedString(@"Transmission is a full-featured torrent application." const BOOL timePassed = !lastDonateDate || (-1 * [lastDonateDate timeIntervalSinceNow]) >= DONATE_NAG_TIME;
" A lot of time and effort have gone into development, coding, and refinement."
" If you enjoy using it, please consider showing your love with a donation.", "Donation beg -> message"),
NSLocalizedString(@"Donate or not, there will be no difference to your torrenting experience.", "Donation beg -> message")];
[alert setInformativeText: donateMessage]; if (!firstLaunch && timePassed)
[alert setAlertStyle: NSInformationalAlertStyle]; {
NSAlert * alert = [[NSAlert alloc] init];
[alert addButtonWithTitle: [NSLocalizedString(@"Donate", "Donation beg -> button") stringByAppendingEllipsis]]; [alert setMessageText: NSLocalizedString(@"Support open-source indie software", "Donation beg -> title")];
NSButton * noDonateButton = [alert addButtonWithTitle: NSLocalizedString(@"Nope", "Donation beg -> button")];
[noDonateButton setKeyEquivalent: @"\e"]; //escape key NSString * donateMessage = [NSString stringWithFormat: @"%@\n\n%@",
NSLocalizedString(@"Transmission is a full-featured torrent application."
const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them a little time to try the app " A lot of time and effort have gone into development, coding, and refinement."
[alert setShowsSuppressionButton: allowNeverAgain]; " If you enjoy using it, please consider showing your love with a donation.", "Donation beg -> message"),
if (allowNeverAgain) NSLocalizedString(@"Donate or not, there will be no difference to your torrenting experience.", "Donation beg -> message")];
[[alert suppressionButton] setTitle: NSLocalizedString(@"Don't bug me about this ever again.", "Donation beg -> button")];
[alert setInformativeText: donateMessage];
const NSInteger donateResult = [alert runModal]; [alert setAlertStyle: NSInformationalAlertStyle];
if (donateResult == NSAlertFirstButtonReturn)
[self linkDonate: self]; [alert addButtonWithTitle: [NSLocalizedString(@"Donate", "Donation beg -> button") stringByAppendingEllipsis]];
NSButton * noDonateButton = [alert addButtonWithTitle: NSLocalizedString(@"Nope", "Donation beg -> button")];
if (allowNeverAgain) [noDonateButton setKeyEquivalent: @"\e"]; //escape key
[fDefaults setBool: ([[alert suppressionButton] state] != NSOnState) forKey: @"WarningDonate"];
const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them time to try the app
[alert release]; [alert setShowsSuppressionButton: allowNeverAgain];
if (allowNeverAgain)
[fDefaults setObject: [NSDate date] forKey: @"DonateAskDate"]; [[alert suppressionButton] setTitle: NSLocalizedString(@"Don't bug me about this ever again.", "Donation beg -> button")];
const NSInteger donateResult = [alert runModal];
if (donateResult == NSAlertFirstButtonReturn)
[self linkDonate: self];
if (allowNeverAgain)
[fDefaults setBool: ([[alert suppressionButton] state] != NSOnState) forKey: @"WarningDonate"];
[alert release];
[fDefaults setObject: [NSDate date] forKey: @"DonateAskDate"];
}
} }
} }