Skip to content

Commit c4e2cc7

Browse files
committed
Add pre-release software update channel support
Add a new option for the user to opt-in for getting pre-release software. When turned on, Sparkle will accept a new "prerelease" channel for updates. This feature only works in Sparkle 2, which means legacy binaries (10.9-10.12) which use Sparkle 1 won't get this. It's possible to implement this for Sparkle 1 but we would need to do so in a completely different (and more annoying) manner of using two separate appcast XML files and switch among them. Given the niche nature of legacy binaries, this is not worth doing. The setting is in the Advanced settings pane because the pre-release builds aren't guaranteed to be stable or well-tested, so we don't want users to turn it on unless they looked for it. For terminology, went back and forth on "beta", "preview", "pre-release", and eventually settled on "pre-release" builds which also lines up with GitHub Release's convention.
1 parent 3e453e2 commit c4e2cc7

File tree

8 files changed

+81
-19
lines changed

8 files changed

+81
-19
lines changed

src/MacVim/Base.lproj/Preferences.xib

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
<outlet property="generalPreferences" destination="115" id="143"/>
1616
<outlet property="inputPreferences" destination="Bnq-Nx-GJH" id="FES-rQ-Fpa"/>
1717
<outlet property="layoutPopUpButton" destination="427" id="596"/>
18+
<outlet property="sparklePrereleaseButton" destination="4Y5-mA-blQ" id="baN-Dn-dgO"/>
19+
<outlet property="sparklePrereleaseDesc" destination="ere-oJ-WLd" id="fTe-GS-5qR"/>
1820
<outlet property="sparkleUpdaterPane" destination="0hT-y8-Hge" id="e0L-sv-OCW"/>
1921
</connections>
2022
</customObject>
@@ -538,11 +540,22 @@
538540
<point key="canvasLocation" x="137.5" y="692"/>
539541
</customView>
540542
<customView id="620" userLabel="Advanced">
541-
<rect key="frame" x="0.0" y="0.0" width="483" height="264"/>
543+
<rect key="frame" x="0.0" y="0.0" width="483" height="367"/>
542544
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
543545
<subviews>
546+
<button id="4Y5-mA-blQ" userLabel="Pre-release channel">
547+
<rect key="frame" x="19" y="97" width="249" height="18"/>
548+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
549+
<buttonCell key="cell" type="check" title="Enable pre-release software updates" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="rTs-jS-K8M">
550+
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
551+
<font key="font" metaFont="system"/>
552+
</buttonCell>
553+
<connections>
554+
<binding destination="58" name="value" keyPath="values.MMUpdaterPrereleaseChannel" id="Kb1-yL-bmN"/>
555+
</connections>
556+
</button>
544557
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="826">
545-
<rect key="frame" x="17" y="116" width="449" height="56"/>
558+
<rect key="frame" x="18" y="218" width="449" height="56"/>
546559
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
547560
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="993">
548561
<font key="font" metaFont="smallSystem"/>
@@ -552,7 +565,7 @@
552565
</textFieldCell>
553566
</textField>
554567
<button id="817">
555-
<rect key="frame" x="18" y="174" width="133" height="18"/>
568+
<rect key="frame" x="19" y="276" width="133" height="18"/>
556569
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
557570
<buttonCell key="cell" type="check" title="Enable Quickstart" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="992">
558571
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -564,7 +577,7 @@
564577
</connections>
565578
</button>
566579
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="815">
567-
<rect key="frame" x="17" y="198" width="449" height="28"/>
580+
<rect key="frame" x="18" y="300" width="449" height="28"/>
568581
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
569582
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" title="(Deprecated) Deselect this option to use the legacy renderer, which is unsupported and will be removed in a future version." id="991">
570583
<font key="font" metaFont="smallSystem"/>
@@ -573,7 +586,7 @@
573586
</textFieldCell>
574587
</textField>
575588
<button id="782">
576-
<rect key="frame" x="18" y="228" width="174" height="18"/>
589+
<rect key="frame" x="19" y="330" width="174" height="18"/>
577590
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
578591
<buttonCell key="cell" type="check" title="Use Core Text renderer" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="990">
579592
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -585,7 +598,7 @@
585598
</connections>
586599
</button>
587600
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="1001">
588-
<rect key="frame" x="17" y="20" width="444" height="70"/>
601+
<rect key="frame" x="18" y="122" width="444" height="70"/>
589602
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
590603
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="1004">
591604
<font key="font" metaFont="smallSystem"/>
@@ -595,7 +608,7 @@
595608
</textFieldCell>
596609
</textField>
597610
<button id="1013">
598-
<rect key="frame" x="18" y="92" width="174" height="18"/>
611+
<rect key="frame" x="19" y="194" width="174" height="18"/>
599612
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
600613
<buttonCell key="cell" type="check" title="Draw marked text inline" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="1014">
601614
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
@@ -605,8 +618,18 @@
605618
<binding destination="58" name="value" keyPath="values.MMUseInlineIm" id="1016"/>
606619
</connections>
607620
</button>
621+
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="ere-oJ-WLd">
622+
<rect key="frame" x="19" y="20" width="449" height="70"/>
623+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
624+
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="Gdp-Ib-RGS">
625+
<font key="font" metaFont="smallSystem"/>
626+
<string key="title">Opt-in to the pre-release software update channel. Sofware updater will now also download early pre-release builds that will get new features faster, but will be less tested and occasionally have stability issues or incomplete features. Use this if you want to try out new features and help provide feedbacks early on, but don't use this if you need to rely on MacVim.</string>
627+
<color key="textColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
628+
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
629+
</textFieldCell>
630+
</textField>
608631
</subviews>
609-
<point key="canvasLocation" x="144" y="911"/>
632+
<point key="canvasLocation" x="143.5" y="962.5"/>
610633
</customView>
611634
</objects>
612635
</document>

src/MacVim/MMAppController.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#import "MMVimController.h"
4343
#import "MMVimView.h"
4444
#import "MMWindowController.h"
45-
#import "MMSparkle2Delegate.h"
4645
#import "MMTextView.h"
4746
#import "Miscellaneous.h"
4847
#import <unistd.h>
@@ -51,6 +50,7 @@
5150
#import <Carbon/Carbon.h>
5251

5352
#if !DISABLE_SPARKLE
53+
#import "MMSparkle2Delegate.h"
5454
#import "Sparkle.framework/Headers/Sparkle.h"
5555
#endif
5656

@@ -261,6 +261,7 @@ + (void)initialize
261261
[NSNumber numberWithBool:NO], MMSmoothResizeKey,
262262
[NSNumber numberWithBool:NO], MMCmdLineAlignBottomKey,
263263
[NSNumber numberWithBool:YES], MMAllowForceClickLookUpKey,
264+
[NSNumber numberWithBool:NO], MMUpdaterPrereleaseChannelKey,
264265
nil];
265266

266267
[[NSUserDefaults standardUserDefaults] registerDefaults:dict];

src/MacVim/MMPreferenceController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424

2525
// Input pane
2626
IBOutlet NSButton *allowForceClickLookUpButton;
27+
28+
// Advanced pane
29+
IBOutlet NSView *sparklePrereleaseButton;
30+
IBOutlet NSView *sparklePrereleaseDesc;
2731
}
2832

2933
// General pane

src/MacVim/MMPreferenceController.m

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,35 @@ @implementation MMPreferenceController
1717
- (void)windowDidLoad
1818
{
1919
#if DISABLE_SPARKLE
20-
// If Sparkle is disabled in config, we don't want to show the preference pane
21-
// which could be confusing as it won't do anything.
22-
// After hiding the Sparkle subview, shorten the height of the General pane
23-
// and move its other subviews down.
24-
[sparkleUpdaterPane setHidden:YES];
25-
CGFloat sparkleHeight = NSHeight(sparkleUpdaterPane.frame);
26-
NSRect frame = generalPreferences.frame;
27-
frame.size.height -= sparkleHeight;
28-
generalPreferences.frame = frame;
20+
{
21+
// If Sparkle is disabled in config, we don't want to show the preference pane
22+
// which could be confusing as it won't do anything.
23+
// After hiding the Sparkle subview, shorten the height of the General pane
24+
// and move its other subviews down.
25+
[sparkleUpdaterPane setHidden:YES];
26+
CGFloat sparkleHeight = NSHeight(sparkleUpdaterPane.frame);
27+
NSRect frame = generalPreferences.frame;
28+
frame.size.height -= sparkleHeight;
29+
generalPreferences.frame = frame;
30+
}
31+
#endif
32+
33+
#if DISABLE_SPARKLE || USE_SPARKLE_1
34+
{
35+
// Also hide the pre-release update channel pane, if we disabled Sparkle, or
36+
// we are using Sparkle 1 still (since it doesn't support this feature).
37+
[sparklePrereleaseButton setHidden:YES];
38+
CGFloat sparkleHeight = NSHeight(sparklePrereleaseButton.frame);
39+
NSRect frame = advancedPreferences.frame;
40+
frame.size.height -= sparkleHeight;
41+
advancedPreferences.frame = frame;
42+
43+
[sparklePrereleaseDesc setHidden:YES];
44+
sparkleHeight = NSHeight(sparklePrereleaseDesc.frame);
45+
frame = advancedPreferences.frame;
46+
frame.size.height -= sparkleHeight;
47+
advancedPreferences.frame = frame;
48+
}
2949
#endif
3050
[super windowDidLoad];
3151

src/MacVim/MMSparkle2Delegate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
@interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate>;
1212

1313
// SPUUpdaterDelegate
14-
// Don't implement anything for now.
14+
- (nonnull NSSet<NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater;
1515

1616
// SPUStandardUserDriverDelegate
1717
// No need to implement anything for now. Default behaviors work fine.

src/MacVim/MMSparkle2Delegate.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,22 @@
88

99
#import "MMSparkle2Delegate.h"
1010

11+
#import "Miscellaneous.h"
12+
1113
#import <Foundation/Foundation.h>
1214

1315
@implementation MMSparkle2Delegate;
1416

17+
/// If the user has opted in, return the pre-release channel to Sparkle so pre-
18+
/// release builds will be available for update as well.
19+
- (nonnull NSSet<NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater
20+
{
21+
if ([[NSUserDefaults standardUserDefaults] boolForKey:MMUpdaterPrereleaseChannelKey]) {
22+
return [NSSet<NSString *> setWithObject:@"prerelease"];
23+
}
24+
return [NSSet<NSString *> set];
25+
}
26+
1527
@end;
1628

1729
#endif

src/MacVim/Miscellaneous.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ extern NSString *MMNonNativeFullScreenSafeAreaBehaviorKey;
6262
extern NSString *MMSmoothResizeKey;
6363
extern NSString *MMCmdLineAlignBottomKey;
6464
extern NSString *MMAllowForceClickLookUpKey;
65+
extern NSString *MMUpdaterPrereleaseChannelKey;
6566

6667

6768
// Enum for MMUntitledWindowKey

src/MacVim/Miscellaneous.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
NSString *MMSmoothResizeKey = @"MMSmoothResize";
5959
NSString *MMCmdLineAlignBottomKey = @"MMCmdLineAlignBottom";
6060
NSString *MMAllowForceClickLookUpKey = @"MMAllowForceClickLookUp";
61+
NSString *MMUpdaterPrereleaseChannelKey = @"MMUpdaterPrereleaseChannel";
6162

6263

6364
@implementation NSIndexSet (MMExtras)

0 commit comments

Comments
 (0)