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{
0 commit comments