Skip to content

Commit

Permalink
Merge pull request #1332 from ychin/sparkle-2
Browse files Browse the repository at this point in the history
Upgrade to Sparkle 2
  • Loading branch information
ychin authored Nov 2, 2022
2 parents 88dc6f7 + a48a6e5 commit d311aae
Show file tree
Hide file tree
Showing 406 changed files with 13,911 additions and 4,905 deletions.
17 changes: 17 additions & 0 deletions .github/workflows/ci-macvim.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,20 @@ jobs:
- name: Set up legacy build
if: matrix.legacy
run: |
# Set the correct build env vars to target the correct architectures and min OS targets.
echo "MACOSX_DEPLOYMENT_TARGET=$MACOSX_DEPLOYMENT_TARGET_LEGACY" >> $GITHUB_ENV
echo "MACVIM_ARCHS=$MACVIM_ARCHS_LEGACY" >> $GITHUB_ENV
- name: Set up Sparkle 1
if: matrix.legacy || !matrix.publish
run: |
# Use Sparkle 1 because Sparkle 2 requires newer OS version than our legacy build.
# Later, we pass the --enable-sparkle_1 flag to configure to set the corresponding ifdef.
#
# We also do this for non-publish builds, because those are usually run on older versions
# of Xcode, and they cannot handle the Sparkle 2 framework as it's built using newer Xcode.
ln -fhs Sparkle_1.framework src/MacVim/Sparkle.framework
# Set up, install, and cache gettext library for localization.
#
# Instead of using the default binary installed by Homebrew, need to build our own because gettext is statically
Expand Down Expand Up @@ -161,6 +172,12 @@ jobs:
else
CONFOPT+=(
--with-macarchs=x86_64
--disable-sparkle # Disable Sparkle for testing that this flag builds and works
)
fi
if ${{ matrix.legacy == true }}; then
CONFOPT+=(
--enable-sparkle_1
)
fi
echo "CONFOPT: ${CONFOPT[@]}"
Expand Down
1 change: 1 addition & 0 deletions runtime/doc/gui_mac.txt
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -5454,6 +5454,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
Original file line number Diff line number Diff line change
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>
10 changes: 10 additions & 0 deletions src/MacVim/MMAppController.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
@class MMVimController;

#if !DISABLE_SPARKLE
#if USE_SPARKLE_1
@class SUUpdater;
#else
@class SPUStandardUpdaterController;
@class MMSparkle2Delegate;
#endif
#endif


Expand Down Expand Up @@ -46,7 +51,12 @@
int processingFlag;

#if !DISABLE_SPARKLE
#if USE_SPARKLE_1
SUUpdater *updater;
#else
SPUStandardUpdaterController *updater;
MMSparkle2Delegate *sparkle2delegate; ///< Sparkle 2 delegate which allows us to customize the updater's behavior.
#endif
#endif

FSEventStreamRef fsEventStream;
Expand Down
15 changes: 14 additions & 1 deletion src/MacVim/MMAppController.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,16 @@
#import "MMWindowController.h"
#import "MMTextView.h"
#import "Miscellaneous.h"
#import "Sparkle.framework/Headers/Sparkle.h"
#import <unistd.h>
#import <CoreServices/CoreServices.h>
// Need Carbon for TIS...() functions
#import <Carbon/Carbon.h>

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


#define MM_HANDLE_XCODE_MOD_EVENT 0

Expand Down Expand Up @@ -257,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 Expand Up @@ -312,7 +317,12 @@ - (id)init
#if !DISABLE_SPARKLE
// Sparkle is enabled (this is the default). Initialize it. It will
// automatically check for update.
#if USE_SPARKLE_1
updater = [[SUUpdater alloc] init];
#else
sparkle2delegate = [[MMSparkle2Delegate alloc] init];
updater = [[SPUStandardUpdaterController alloc] initWithUpdaterDelegate:sparkle2delegate userDriverDelegate:sparkle2delegate];
#endif
#endif

return self;
Expand All @@ -334,6 +344,9 @@ - (void)dealloc
[appMenuItemTemplate release]; appMenuItemTemplate = nil;
#if !DISABLE_SPARKLE
[updater release]; updater = nil;
#if !USE_SPARKLE_1
[sparkle2delegate release]; sparkle2delegate = nil;
#endif
#endif

[super dealloc];
Expand Down
4 changes: 4 additions & 0 deletions src/MacVim/MMPreferenceController.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
21 changes: 21 additions & 0 deletions src/MacVim/MMSparkle2Delegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//
// MMSparkle2Delegate.h
//
// Delegate class to interface with Sparkle 2
//

#if !DISABLE_SPARKLE && !USE_SPARKLE_1

#import "Sparkle.framework/Headers/Sparkle.h"

@interface MMSparkle2Delegate : NSObject <SPUUpdaterDelegate, SPUStandardUserDriverDelegate>;

// SPUUpdaterDelegate
- (nonnull NSSet<NSString *> *)allowedChannelsForUpdater:(nonnull SPUUpdater *)updater;

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

@end

#endif
29 changes: 29 additions & 0 deletions src/MacVim/MMSparkle2Delegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// MMSparkle2Delegate.m
//
// This file contains code to interface with Sparkle 2 and customize it.
//

#if !DISABLE_SPARKLE && !USE_SPARKLE_1

#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
6 changes: 6 additions & 0 deletions src/MacVim/MacVim.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
907FF7512521BCE200BADACB /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 907FF74F2521BCE200BADACB /* MainMenu.xib */; };
907FF7542521BDA600BADACB /* Preferences.xib in Resources */ = {isa = PBXBuildFile; fileRef = 907FF7522521BDA600BADACB /* Preferences.xib */; };
907FF7572521BDC300BADACB /* FindAndReplace.xib in Resources */ = {isa = PBXBuildFile; fileRef = 907FF7552521BDC200BADACB /* FindAndReplace.xib */; };
90A33BEA28D563DF003A2E2F /* MMSparkle2Delegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 90A33BE928D563DF003A2E2F /* MMSparkle2Delegate.m */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -414,6 +415,8 @@
90922ABC221D42F700F1E1F4 /* MMBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MMBackend.h; sourceTree = "<group>"; };
90922ABD221D42F700F1E1F4 /* gui_macvim.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = gui_macvim.m; sourceTree = "<group>"; };
90922ABE221D42F700F1E1F4 /* MMBackend.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MMBackend.m; sourceTree = "<group>"; };
90A33BE928D563DF003A2E2F /* MMSparkle2Delegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MMSparkle2Delegate.m; sourceTree = "<group>"; };
90A33BEC28D56423003A2E2F /* MMSparkle2Delegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MMSparkle2Delegate.h; sourceTree = "<group>"; };
90F84F1E2521F2270000268B /* ko */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ko; path = ko.lproj/MainMenu.strings; sourceTree = "<group>"; };
90F84F232521F6480000268B /* ca */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ca; path = ca.lproj/MainMenu.strings; sourceTree = "<group>"; };
90F84F242521F6590000268B /* cs */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = cs; path = cs.lproj/MainMenu.strings; sourceTree = "<group>"; };
Expand Down Expand Up @@ -502,6 +505,8 @@
1D1474960C56703C0038FA2B /* MacVim.m */,
32CA4F630368D1EE00C91783 /* MacVim_Prefix.pch */,
29B97316FDCFA39411CA2CEA /* main.m */,
90A33BE928D563DF003A2E2F /* MMSparkle2Delegate.m */,
90A33BEC28D56423003A2E2F /* MMSparkle2Delegate.h */,
);
name = "MacVim Source";
sourceTree = "<group>";
Expand Down Expand Up @@ -1089,6 +1094,7 @@
1D1474B60C56796D0038FA2B /* MMVimController.m in Sources */,
1D1474BC0C567A910038FA2B /* MMWindowController.m in Sources */,
1D09AB420C6A4D520045497E /* MMTypesetter.m in Sources */,
90A33BEA28D563DF003A2E2F /* MMSparkle2Delegate.m in Sources */,
1DD66ECE0C803D3600EBDAB3 /* MMApplication.m in Sources */,
1D80FBD40CBBD3B700102A1C /* MMFullScreenWindow.m in Sources */,
1D80FBD60CBBD3B700102A1C /* MMVimView.m in Sources */,
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/Miscellaneous.h
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
NSString *MMSmoothResizeKey = @"MMSmoothResize";
NSString *MMCmdLineAlignBottomKey = @"MMCmdLineAlignBottom";
NSString *MMAllowForceClickLookUpKey = @"MMAllowForceClickLookUp";
NSString *MMUpdaterPrereleaseChannelKey = @"MMUpdaterPrereleaseChannel";


@implementation NSIndexSet (MMExtras)
Expand Down
1 change: 1 addition & 0 deletions src/MacVim/Sparkle.framework
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/MacVim/Sparkle_2.framework/Autoupdate
1 change: 1 addition & 0 deletions src/MacVim/Sparkle_2.framework/Headers
1 change: 1 addition & 0 deletions src/MacVim/Sparkle_2.framework/Modules
1 change: 1 addition & 0 deletions src/MacVim/Sparkle_2.framework/PrivateHeaders
1 change: 1 addition & 0 deletions src/MacVim/Sparkle_2.framework/Resources
Loading

0 comments on commit d311aae

Please sign in to comment.