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,6 +536,8 @@ 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
if ([fDefaults boolForKey: @"WarningDonate"])
{
tr_session_stats stats; tr_session_stats stats;
tr_sessionGetCumulativeStats(fLib, &stats); tr_sessionGetCumulativeStats(fLib, &stats);
const BOOL firstLaunch = stats.sessionCount <= 1; const BOOL firstLaunch = stats.sessionCount <= 1;
@ -543,7 +545,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
NSDate * lastDonateDate = [fDefaults objectForKey: @"DonateAskDate"]; NSDate * lastDonateDate = [fDefaults objectForKey: @"DonateAskDate"];
const BOOL timePassed = !lastDonateDate || (-1 * [lastDonateDate timeIntervalSinceNow]) >= DONATE_NAG_TIME; const BOOL timePassed = !lastDonateDate || (-1 * [lastDonateDate timeIntervalSinceNow]) >= DONATE_NAG_TIME;
if ([fDefaults boolForKey: @"WarningDonate"] && !firstLaunch && timePassed) if (!firstLaunch && timePassed)
{ {
NSAlert * alert = [[NSAlert alloc] init]; NSAlert * alert = [[NSAlert alloc] init];
[alert setMessageText: NSLocalizedString(@"Support open-source indie software", "Donation beg -> title")]; [alert setMessageText: NSLocalizedString(@"Support open-source indie software", "Donation beg -> title")];
@ -561,7 +563,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
NSButton * noDonateButton = [alert addButtonWithTitle: NSLocalizedString(@"Nope", "Donation beg -> button")]; NSButton * noDonateButton = [alert addButtonWithTitle: NSLocalizedString(@"Nope", "Donation beg -> button")];
[noDonateButton setKeyEquivalent: @"\e"]; //escape key [noDonateButton setKeyEquivalent: @"\e"]; //escape key
const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them a little time to try the app const BOOL allowNeverAgain = lastDonateDate != nil; //hide the "don't show again" check the first time - give them time to try the app
[alert setShowsSuppressionButton: allowNeverAgain]; [alert setShowsSuppressionButton: allowNeverAgain];
if (allowNeverAgain) if (allowNeverAgain)
[[alert suppressionButton] setTitle: NSLocalizedString(@"Don't bug me about this ever again.", "Donation beg -> button")]; [[alert suppressionButton] setTitle: NSLocalizedString(@"Don't bug me about this ever again.", "Donation beg -> button")];
@ -578,6 +580,7 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
[fDefaults setObject: [NSDate date] forKey: @"DonateAskDate"]; [fDefaults setObject: [NSDate date] forKey: @"DonateAskDate"];
} }
} }
}
- (BOOL) applicationShouldHandleReopen: (NSApplication *) app hasVisibleWindows: (BOOL) visibleWindows - (BOOL) applicationShouldHandleReopen: (NSApplication *) app hasVisibleWindows: (BOOL) visibleWindows
{ {