Skip to content

Commit 675cd65

Browse files
committed
Make Sparkle updater an optional component of MacVim
MacVim by default uses Sparkle to update itself. It checks a URL that tells it whether there's a new binary release, and if one exists, it will download it and patches MacVim. However, there are certain situations where this is not wanted (e.g. when MacVim is bundled as part of a package management system), and previously there was no way to disable Sparkle. Make Sparkle optional by implementing a new configure argument: `./configure --disable-sparkle`, which will set a compile-time ifdef. Instead of instantiating the updater in MainMenu.nib as suggested by Sparkle's documentation, just instantiate it manually in code, and also disable the "Check for updates" menu item and updater-related preference pane items to make sure these settings don't confuse users when they are running a Sparkle-disabled build. Sparkle.framework is currently still bundled when it's disabled, because there doesn't seem to be an easy way to configure the copy build phase. It could be manually removed in a script after the build though, as it's now optionally linked to instead of mandatory. Fix #849.
1 parent ec8d479 commit 675cd65

12 files changed

Lines changed: 283 additions & 176 deletions

File tree

src/MacVim/English.lproj/MainMenu.nib/designable.nib

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
-68 Bytes
Binary file not shown.

src/MacVim/English.lproj/Preferences.nib/designable.nib

Lines changed: 199 additions & 173 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
823 Bytes
Binary file not shown.

src/MacVim/MMAppController.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
@class MMWindowController;
1616
@class MMVimController;
17+
@class SUUpdater;
1718

1819

1920
@interface MMAppController : NSObject <MMAppProtocol> {
@@ -30,6 +31,8 @@
3031
int numChildProcesses;
3132
NSMutableDictionary *inputQueues;
3233
int processingFlag;
34+
35+
SUUpdater *updater;
3336

3437
FSEventStreamRef fsEventStream;
3538
}
@@ -52,6 +55,7 @@
5255
- (IBAction)orderFrontPreferencePanel:(id)sender;
5356
- (IBAction)openWebsite:(id)sender;
5457
- (IBAction)showVimHelp:(id)sender;
58+
- (IBAction)checkForUpdates:(id)sender;
5559
- (IBAction)zoomAll:(id)sender;
5660
- (IBAction)stayInFront:(id)sender;
5761
- (IBAction)stayInBack:(id)sender;

src/MacVim/MMAppController.m

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#import "MMWindowController.h"
4444
#import "MMTextView.h"
4545
#import "Miscellaneous.h"
46+
#import "Sparkle.framework/Headers/Sparkle.h"
4647
#import <unistd.h>
4748
#import <CoreServices/CoreServices.h>
4849
// Need Carbon for TIS...() functions
@@ -298,6 +299,12 @@ - (id)init
298299
ASLogCrit(@"Failed to register connection with name '%@'", name);
299300
[connection release]; connection = nil;
300301
}
302+
303+
#if !DISABLE_SPARKLE
304+
// Sparkle is enabled (this is the default). Initialize it. It will
305+
// automatically check for update.
306+
updater = [[SUUpdater alloc] init];
307+
#endif
301308

302309
return self;
303310
}
@@ -315,6 +322,7 @@ - (void)dealloc
315322
[recentFilesMenuItem release]; recentFilesMenuItem = nil;
316323
[defaultMainMenu release]; defaultMainMenu = nil;
317324
[appMenuItemTemplate release]; appMenuItemTemplate = nil;
325+
[updater release]; updater = nil;
318326

319327
[super dealloc];
320328
}
@@ -892,6 +900,14 @@ - (void)setMainMenu:(NSMenu *)mainMenu
892900
// private so this will have to be considered a bit of a hack!)
893901
NSMenu *appMenu = [mainMenu findApplicationMenu];
894902
[NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu];
903+
904+
#if DISABLE_SPARKLE
905+
// If Sparkle is disabled, we want to remove the "Check for Updates" menu
906+
// item since it's no longer useful.
907+
NSMenuItem *checkForUpdatesItem = [appMenu itemAtIndex:
908+
[appMenu indexOfItemWithAction:@selector(checkForUpdates:)]];
909+
checkForUpdatesItem.hidden = true;
910+
#endif
895911

896912
NSMenu *servicesMenu = [mainMenu findServicesMenu];
897913
[NSApp setServicesMenu:servicesMenu];
@@ -1195,6 +1211,15 @@ - (IBAction)showVimHelp:(id)sender
11951211
@"-c", @":h gui_mac", @"-c", @":res", nil]
11961212
workingDirectory:nil];
11971213
}
1214+
1215+
- (IBAction)checkForUpdates:(id)sender
1216+
{
1217+
#if !DISABLE_SPARKLE
1218+
// Check for updates for new versions manually.
1219+
ASLogDebug(@"Check for software updates");
1220+
[updater checkForUpdates:sender];
1221+
#endif
1222+
}
11981223

11991224
- (IBAction)zoomAll:(id)sender
12001225
{

src/MacVim/MMPreferenceController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@
1818
// General pane
1919
IBOutlet NSPopUpButton *layoutPopUpButton;
2020
IBOutlet NSButton *autoInstallUpdateButton;
21+
IBOutlet NSView *sparkleUpdaterPane;
2122
}
2223

2324
// General pane
25+
- (IBAction)showWindow:(id)sender;
2426
- (IBAction)openInCurrentWindowSelectionChanged:(id)sender;
2527
- (IBAction)checkForUpdatesChanged:(id)sender;
2628

src/MacVim/MMPreferenceController.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ static void loadSymbols()
4343

4444
@implementation MMPreferenceController
4545

46+
- (IBAction)showWindow:(id)sender
47+
{
48+
[super showWindow:sender];
49+
#if DISABLE_SPARKLE
50+
// If Sparkle is disabled in config, we don't want to show the preference pane
51+
// which could be confusing as it won't do anything.
52+
[sparkleUpdaterPane setHidden:YES];
53+
#endif
54+
}
55+
4656
- (void)setupToolbar
4757
{
4858
loadSymbols();

src/MacVim/MacVim.xcodeproj/project.pbxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
1DFE25A50C527BC4003000F7 /* PSMTabBarControl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D493DB90C52533B00AB718C /* PSMTabBarControl.framework */; };
6767
52818B031C1C08CE00F59085 /* QLStephen.qlgenerator in Copy QuickLookPlugin */ = {isa = PBXBuildFile; fileRef = 52818AFF1C1C075300F59085 /* QLStephen.qlgenerator */; settings = {ATTRIBUTES = (CodeSignOnCopy, ); }; };
6868
528DA66A1426D4F9003380F1 /* macvim-askpass in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 528DA6691426D4EB003380F1 /* macvim-askpass */; };
69-
52A364731C4A5789005757EC /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; };
69+
52A364731C4A5789005757EC /* Sparkle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (Weak, ); }; };
7070
52A364761C4A57C1005757EC /* Sparkle.framework in Copy Frameworks */ = {isa = PBXBuildFile; fileRef = 52A364721C4A5789005757EC /* Sparkle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
7171
52B7ED9B1C4A4D6900AFFF15 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 52B7ED9A1C4A4D6900AFFF15 /* dsa_pub.pem */; };
7272
8D11072A0486CEB800E47090 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; };

src/MacVim/README

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,16 @@ be in when executing these commands):
162162
1. Configure Vim (call "./configure --help" to see a list of flags)
163163
src/$ ./configure
164164

165+
MacVim-specific flags that `./configure` supports:
166+
--disable-sparkle: Disable Sparkle auto-update. This is useful if you want
167+
to manually sync or building this as part of a package
168+
manager.
169+
--with-macsdk: Build MacVim against specific SDK versions.
170+
171+
You can also use environment variable `MACOSX_DEPLOYMENT_TARGET` to specify
172+
minimum target macOS version to deploy (e.g. '10.14'), and `XCODEFLAGS` for
173+
additional command-line arguments to pass to `xcodebuild`.
174+
165175
2. Build
166176
src/$ make
167177

0 commit comments

Comments
 (0)