Add a window to the Mac interface to ask for a donation.

A lot of discussion has gone into the merits of such a feature, and as a result it has been designed to be as unobtrusive as possible. It will appear on second launch, and once a week after that. If the "don't ask again" check is checked, then it will never appear again. No matter what option is chosen, there will be no impact on any functionality of the program.
This commit is contained in:
Mitchell Livingston 2009-08-14 01:11:13 +00:00
parent e93c1280f7
commit effdd10a30
2 changed files with 41 additions and 0 deletions

View File

@ -144,6 +144,8 @@ typedef enum
#define TRAC_URL @"http://trac.transmissionbt.com/"
#define DONATE_URL @"http://www.transmissionbt.com/donate.php"
#define DONATE_NAG_TIME (60 * 60 * 24 * 7)
static void altSpeedToggledCallback(tr_session * handle UNUSED, tr_bool active, tr_bool byUser, void * controller)
{
NSDictionary * dict = [[NSDictionary alloc] initWithObjectsAndKeys: [[NSNumber alloc] initWithBool: active], @"Active",
@ -516,6 +518,43 @@ static void sleepCallback(void * controller, io_service_t y, natural_t messageTy
if ([fDefaults boolForKey: @"InfoVisible"])
[self showInfo: nil];
//shamelessly ask for donations
NSDate * lastDonateDate = [fDefaults objectForKey: @"DonateAskDate"];
if (YES ||( [fDefaults boolForKey: @"WarningDonate"] && (!lastDonateDate || [lastDonateDate timeIntervalSinceNow] < -1 * DONATE_NAG_TIME)))
{
if (lastDonateDate) //don't show on the first launch
{
NSAlert * alert = [[NSAlert alloc] init];
[alert setMessageText: NSLocalizedString(@"Support open-source indie software", "Donation beg -> title")];
NSString * donateMessage = [NSString stringWithFormat: @"%@\n\n%@",
NSLocalizedString(@"Transmission is a full-featured torrent application. 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];
[alert setAlertStyle: NSInformationalAlertStyle];
[alert addButtonWithTitle: [NSLocalizedString(@"Donate", "Donation beg -> button") stringByAppendingEllipsis]];
NSButton * noDonateButton = [alert addButtonWithTitle: NSLocalizedString(@"Nope", "Donation beg -> button")];
[noDonateButton setKeyEquivalent: @"\e"]; //escape key
[[alert suppressionButton] setTitle: NSLocalizedString(@"Don't bug me about this ever again.", "Donation beg -> button")];
[alert setShowsSuppressionButton: YES];
const NSInteger donateResult = [alert runModal];
if (donateResult == NSAlertFirstButtonReturn)
[self linkDonate: self];
if ([[alert suppressionButton] state] == NSOnState)
[fDefaults setBool: NO forKey: @"WarningDonate"];
[alert release];
}
[fDefaults setObject: [NSDate date] forKey: @"DonateAskDate"];
}
}
- (void) applicationDidFinishLaunching: (NSNotification *) notification

View File

@ -182,6 +182,8 @@
<false/>
<key>WarningCreatorBlankAddress</key>
<true/>
<key>WarningDonate</key>
<true/>
<key>WarningDuplicate</key>
<true/>
<key>WarningFolderDataSameName</key>