]> granicus.if.org Git - transmission/commitdiff
Add a window to the Mac interface to ask for a donation.
authorMitchell Livingston <livings124@transmissionbt.com>
Fri, 14 Aug 2009 01:11:13 +0000 (01:11 +0000)
committerMitchell Livingston <livings124@transmissionbt.com>
Fri, 14 Aug 2009 01:11:13 +0000 (01:11 +0000)
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.

macosx/Controller.m
macosx/Defaults.plist

index 7e766175a51e31aedad19f0dc06a0f3e41cbd4e0..2eb5284ccec5f82f818f9b1c00fb60826b9a903d 100644 (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
index 40427a28370b6f4eeefc784a1c9ae507fb226c4a..4c3d3cb1d6ef5ae197a675cffd06e5ad151f6d02 100644 (file)
        <false/>
        <key>WarningCreatorBlankAddress</key>
        <true/>
+       <key>WarningDonate</key>
+       <true/>
        <key>WarningDuplicate</key>
        <true/>
        <key>WarningFolderDataSameName</key>