Skip to content

Commit

Permalink
Add pre-release software update channel support
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ychin committed Nov 1, 2022
1 parent 3e453e2 commit 0667ce7
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 19 deletions.
1 change: 1 addition & 0 deletions runtime/doc/gui_mac.txt
Expand Up @@ -305,6 +305,7 @@ KEY VALUE ~
*MMUseMouseTime* use mousetime to detect multiple clicks [bool]
*MMVerticalSplit* files open in vertical splits [bool]
*MMZoomBoth* zoom button maximizes both directions [bool]
*MMUpdaterPrereleaseChannel* opt-in to pre-release software update [bool]

As an example, if you have more than one mouse button and would wish to free
up Ctrl-click so you can bind it to something else, then the appropriate
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/tags
Expand Up @@ -5447,6 +5447,7 @@ MMTextInsetTop gui_mac.txt /*MMTextInsetTop*
MMTexturedWindow gui_mac.txt /*MMTexturedWindow*
MMTitlebarAppearsTransparent gui_mac.txt /*MMTitlebarAppearsTransparent*
MMTranslateCtrlClick gui_mac.txt /*MMTranslateCtrlClick*
MMUpdaterPrereleaseChannel gui_mac.txt /*MMUpdaterPrereleaseChannel*
MMUseMouseTime gui_mac.txt /*MMUseMouseTime*
MMVerticalSplit gui_mac.txt /*MMVerticalSplit*
MMZoomBoth gui_mac.txt /*MMZoomBoth*
Expand Down
39 changes: 31 additions & 8 deletions src/MacVim/Base.lproj/Preferences.xib
Expand Up @@ -15,6 +15,8 @@
<outlet property="generalPreferences" destination="115" id="143"/>
<outlet property="inputPreferences" destination="Bnq-Nx-GJH" id="FES-rQ-Fpa"/>
<outlet property="layoutPopUpButton" destination="427" id="596"/>
<outlet property="sparklePrereleaseButton" destination="4Y5-mA-blQ" id="baN-Dn-dgO"/>
<outlet property="sparklePrereleaseDesc" destination="ere-oJ-WLd" id="fTe-GS-5qR"/>
<outlet property="sparkleUpdaterPane" destination="0hT-y8-Hge" id="e0L-sv-OCW"/>
</connections>
</customObject>
Expand Down Expand Up @@ -538,11 +540,22 @@
<point key="canvasLocation" x="137.5" y="692"/>
</customView>
<customView id="620" userLabel="Advanced">
<rect key="frame" x="0.0" y="0.0" width="483" height="264"/>
<rect key="frame" x="0.0" y="0.0" width="483" height="367"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<subviews>
<button id="4Y5-mA-blQ" userLabel="Pre-release channel">
<rect key="frame" x="19" y="97" width="249" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Enable pre-release software updates" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="rTs-jS-K8M">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
<font key="font" metaFont="system"/>
</buttonCell>
<connections>
<binding destination="58" name="value" keyPath="values.MMUpdaterPrereleaseChannel" id="Kb1-yL-bmN"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="826">
<rect key="frame" x="17" y="116" width="449" height="56"/>
<rect key="frame" x="18" y="218" width="449" height="56"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="993">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -552,7 +565,7 @@
</textFieldCell>
</textField>
<button id="817">
<rect key="frame" x="18" y="174" width="133" height="18"/>
<rect key="frame" x="19" y="276" width="133" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Enable Quickstart" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="992">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -564,7 +577,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="815">
<rect key="frame" x="17" y="198" width="449" height="28"/>
<rect key="frame" x="18" y="300" width="449" height="28"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<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">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -573,7 +586,7 @@
</textFieldCell>
</textField>
<button id="782">
<rect key="frame" x="18" y="228" width="174" height="18"/>
<rect key="frame" x="19" y="330" width="174" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Use Core Text renderer" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="990">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -585,7 +598,7 @@
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="1001">
<rect key="frame" x="17" y="20" width="444" height="70"/>
<rect key="frame" x="18" y="122" width="444" height="70"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="1004">
<font key="font" metaFont="smallSystem"/>
Expand All @@ -595,7 +608,7 @@
</textFieldCell>
</textField>
<button id="1013">
<rect key="frame" x="18" y="92" width="174" height="18"/>
<rect key="frame" x="19" y="194" width="174" height="18"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<buttonCell key="cell" type="check" title="Draw marked text inline" bezelStyle="regularSquare" imagePosition="left" alignment="left" inset="2" id="1014">
<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
Expand All @@ -605,8 +618,18 @@
<binding destination="58" name="value" keyPath="values.MMUseInlineIm" id="1016"/>
</connections>
</button>
<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" id="ere-oJ-WLd">
<rect key="frame" x="19" y="20" width="449" height="70"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="Gdp-Ib-RGS">
<font key="font" metaFont="smallSystem"/>
<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>
<color key="textColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
</subviews>
<point key="canvasLocation" x="144" y="911"/>
<point key="canvasLocation" x="143.5" y="962.5"/>
</customView>
</objects>
</document>
3 changes: 2 additions & 1 deletion src/MacVim/MMAppController.m
Expand Up @@ -42,7 +42,6 @@
#import "MMVimController.h"
#import "MMVimView.h"
#import "MMWindowController.h"
#import "MMSparkle2Delegate.h"
#import "MMTextView.h"
#import "Miscellaneous.h"
#import <unistd.h>
Expand All @@ -51,6 +50,7 @@
#import <Carbon/Carbon.h>

#if !DISABLE_SPARKLE
#import "MMSparkle2Delegate.h"
#import "Sparkle.framework/Headers/Sparkle.h"
#endif

Expand Down Expand Up @@ -261,6 +261,7 @@ + (void)initialize
[NSNumber numberWithBool:NO], MMSmoothResizeKey,
[NSNumber numberWithBool:NO], MMCmdLineAlignBottomKey,
[NSNumber numberWithBool:YES], MMAllowForceClickLookUpKey,
[NSNumber numberWithBool:NO], MMUpdaterPrereleaseChannelKey,
nil];

[[NSUserDefaults standardUserDefaults] registerDefaults:dict];
Expand Down
4 changes: 4 additions & 0 deletions src/MacVim/MMPreferenceController.h
Expand Up @@ -24,6 +24,10 @@

// Input pane
IBOutlet NSButton *allowForceClickLookUpButton;

// Advanced pane
IBOutlet NSView *sparklePrereleaseButton;
IBOutlet NSView *sparklePrereleaseDesc;
}

// General pane
Expand Down
38 changes: 29 additions & 9 deletions src/MacVim/MMPreferenceController.m
Expand Up @@ -17,15 +17,35 @@ @implementation MMPreferenceController
- (void)windowDidLoad
{
#if DISABLE_SPARKLE
// If Sparkle is disabled in config, we don't want to show the preference pane
// which could be confusing as it won't do anything.
// After hiding the Sparkle subview, shorten the height of the General pane
// and move its other subviews down.
[sparkleUpdaterPane setHidden:YES];
CGFloat sparkleHeight = NSHeight(sparkleUpdaterPane.frame);
NSRect frame = generalPreferences.frame;
frame.size.height -= sparkleHeight;
generalPreferences.frame = frame;
{
// If Sparkle is disabled in config, we don't want to show the preference pane
// which could be confusing as it won't do anything.
// After hiding the Sparkle subview, shorten the height of the General pane
// and move its other subviews down.
[sparkleUpdaterPane setHidden:YES];
CGFloat sparkleHeight = NSHeight(sparkleUpdaterPane.frame);
NSRect frame = generalPreferences.frame;
frame.size.height -= sparkleHeight;
generalPreferences.frame = frame;
}
#endif

#if DISABLE_SPARKLE || USE_SPARKLE_1
{
// Also hide the pre-release update channel pane, if we disabled Sparkle, or
// we are using Sparkle 1 still (since it doesn't support this feature).
[sparklePrereleaseButton setHidden:YES];
CGFloat sparkleHeight = NSHeight(sparklePrereleaseButton.frame);
NSRect frame = advancedPreferences.frame;
frame.size.height -= sparkleHeight;
advancedPreferences.frame = frame;

[sparklePrereleaseDesc setHidden:YES];
sparkleHeight = NSHeight(sparklePrereleaseDesc.frame);
frame = advancedPreferences.frame;
frame.size.height -= sparkleHeight;
advancedPreferences.frame = frame;
}
#endif
[super windowDidLoad];

Expand Down
2 changes: 1 addition & 1 deletion src/MacVim/MMSparkle2Delegate.h
Expand Up @@ -11,7 +11,7 @@
@interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate>;

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

// SPUStandardUserDriverDelegate
// No need to implement anything for now. Default behaviors work fine.
Expand Down
12 changes: 12 additions & 0 deletions src/MacVim/MMSparkle2Delegate.m
Expand Up @@ -8,10 +8,22 @@

#import "MMSparkle2Delegate.h"

#import "Miscellaneous.h"

#import <Foundation/Foundation.h>

@implementation MMSparkle2Delegate;

/// If the user has opted in, return the pre-release channel to Sparkle so pre-
/// release builds will be available for update as well.
- (nonnull NSSet<NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater
{
if ([[NSUserDefaults standardUserDefaults] boolForKey:MMUpdaterPrereleaseChannelKey]) {
return [NSSet<NSString *> setWithObject:@"prerelease"];
}
return [NSSet<NSString *> set];
}

@end;

#endif
1 change: 1 addition & 0 deletions src/MacVim/Miscellaneous.h
Expand Up @@ -62,6 +62,7 @@ extern NSString *MMNonNativeFullScreenSafeAreaBehaviorKey;
extern NSString *MMSmoothResizeKey;
extern NSString *MMCmdLineAlignBottomKey;
extern NSString *MMAllowForceClickLookUpKey;
extern NSString *MMUpdaterPrereleaseChannelKey;


// Enum for MMUntitledWindowKey
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/Miscellaneous.m
Expand Up @@ -58,6 +58,7 @@
NSString *MMSmoothResizeKey = @"MMSmoothResize";
NSString *MMCmdLineAlignBottomKey = @"MMCmdLineAlignBottom";
NSString *MMAllowForceClickLookUpKey = @"MMAllowForceClickLookUp";
NSString *MMUpdaterPrereleaseChannelKey = @"MMUpdaterPrereleaseChannel";


@implementation NSIndexSet (MMExtras)
Expand Down

0 comments on commit 0667ce7

Please sign in to comment.