[vlc-commits] [Git][videolan/vlc][master] 2 commits: macosx: Migrate Sparkle 1 code to Sparkle 2 types and classes
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Tue Aug 4 17:13:27 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
2c6e9a68 by Claudio Cambra at 2026-08-04T18:30:47+02:00
macosx: Migrate Sparkle 1 code to Sparkle 2 types and classes
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
f8b79b69 by Claudio Cambra at 2026-08-04T18:30:47+02:00
macosx: Split sparkle code into separate VLCMain extension
Signed-off-by: Claudio Cambra <developer at claudiocambra.com>
- - - - -
7 changed files:
- modules/gui/macosx/Makefile.am
- + modules/gui/macosx/main/VLCMain+Sparkle.h
- + modules/gui/macosx/main/VLCMain+Sparkle.m
- modules/gui/macosx/main/VLCMain.h
- modules/gui/macosx/main/VLCMain.m
- modules/gui/macosx/menus/VLCMainMenu.m
- modules/gui/macosx/preferences/VLCSimplePrefsController.m
Changes:
=====================================
modules/gui/macosx/Makefile.am
=====================================
@@ -352,6 +352,8 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/main/CompatibilityFixes.m \
gui/macosx/main/VLCApplication.h \
gui/macosx/main/VLCApplication.m \
+ gui/macosx/main/VLCMain+Sparkle.h \
+ gui/macosx/main/VLCMain+Sparkle.m \
gui/macosx/main/VLCMain+OldPrefs.h \
gui/macosx/main/VLCMain+OldPrefs.m \
gui/macosx/main/VLCMain.h \
=====================================
modules/gui/macosx/main/VLCMain+Sparkle.h
=====================================
@@ -0,0 +1,34 @@
+/*****************************************************************************
+ * VLCMain+Sparkle.h: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2026 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
+ * Claudio Cambra <developer at claudiocambra dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "main/VLCMain.h"
+
+#ifdef HAVE_SPARKLE
+
+ at interface VLCMain (Sparkle)
+
+- (void)setupSparkle;
+
+ at end
+
+#endif
=====================================
modules/gui/macosx/main/VLCMain+Sparkle.m
=====================================
@@ -0,0 +1,108 @@
+/*****************************************************************************
+ * VLCMain+Sparkle.m: MacOS X interface module
+ *****************************************************************************
+ * Copyright (C) 2026 VLC authors and VideoLAN
+ *
+ * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
+ * Claudio Cambra <developer at claudiocambra dot com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#import "VLCMain+Sparkle.h"
+
+#ifdef HAVE_SPARKLE
+
+#import <Sparkle/Sparkle.h>
+
+#import "extensions/NSString+Helpers.h"
+#import "main/CompatibilityFixes.h"
+#import "main/VLCMain.h"
+#import "playqueue/VLCPlayQueueController.h"
+#import "playqueue/VLCPlayerController.h"
+
+NSString *const kIntel64UpdateURLString = @"https://update.videolan.org/vlc/sparkle/vlc-intel64.xml";
+NSString *const kARM64UpdateURLString = @"https://update.videolan.org/vlc/sparkle/vlc-arm64.xml";
+
+ at interface VLCMain () <SPUUpdaterDelegate>
+ at property (readwrite) SPUStandardUpdaterController *sparkleUpdaterController;
+ at end
+
+ at implementation VLCMain (Sparkle)
+
+- (void)setupSparkle
+{
+ self.sparkleUpdaterController = [[SPUStandardUpdaterController alloc]
+ initWithStartingUpdater:YES updaterDelegate:self userDriverDelegate:nil];
+}
+
+/* received directly before the update gets installed, so let's shut down a bit */
+- (void)updater:(SPUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update
+{
+ [NSApp activateIgnoringOtherApps:YES];
+ [self.playQueueController stopPlayback];
+}
+
+/* don't be enthusiastic about an update if we currently play a video */
+- (BOOL)updater:(SPUUpdater *)updater mayPerformUpdateCheck:(SPUUpdateCheck)updateCheck error:(NSError * __autoreleasing *)error
+{
+ if ([self.playQueueController.playerController activeVideoPlayback]) {
+ if (error != NULL) {
+ *error = [NSError errorWithDomain:@"org.videolan.vlc.Sparkle"
+ code:1
+ userInfo:@{NSLocalizedDescriptionKey: _NS("VLC is currently playing video.")}];
+ }
+ return NO;
+ }
+
+ return YES;
+}
+
+/* use the correct feed depending on the hardware architecture */
+- (nullable NSString *)feedURLStringForUpdater:(SPUUpdater *)updater
+{
+#ifdef __x86_64__
+ if (OSX_BIGSUR_AND_HIGHER) {
+ if ([self processIsTranslated] > 0) {
+ msg_Dbg(getIntf(), "Process is translated. On update, VLC will install the native ARM-64 binary.");
+ return kARM64UpdateURLString;
+ }
+ }
+ return kIntel64UpdateURLString;
+#elif __arm64__
+ return kARM64UpdateURLString;
+#else
+ #error unsupported architecture
+#endif
+}
+
+- (void)updaterDidNotFindUpdate:(SPUUpdater *)updater error:(NSError *)error
+{
+ msg_Dbg(getIntf(), "No update found");
+}
+
+- (void)updater:(SPUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error
+{
+ msg_Warn(getIntf(), "Failed to download update with error %li", error.code);
+}
+
+- (void)updater:(SPUUpdater *)updater didAbortWithError:(NSError *)error
+{
+ msg_Err(getIntf(), "Updater aborted with error %li", error.code);
+}
+
+ at end
+
+#endif
=====================================
modules/gui/macosx/main/VLCMain.h
=====================================
@@ -66,6 +66,9 @@ extern NSString * const kVLCPreferencesVersion;
@class VLCPlayQueueController;
@class VLCVideoOutputProvider;
@class VLCDetachedAudioWindow;
+#ifdef HAVE_SPARKLE
+ at class SPUStandardUpdaterController;
+#endif
@interface VLCMain : NSObject
@@ -94,5 +97,10 @@ extern NSString * const kVLCPreferencesVersion;
@property (readonly) VLCDetachedAudioWindow *detachedAudioWindow;
@property (readonly) id<MTLDevice> metalDevice;
@property (readonly) id<MTLLibrary> metalLibrary;
+#ifdef HAVE_SPARKLE
+ at property (readonly) SPUStandardUpdaterController *sparkleUpdaterController;
+#endif
+
+- (int)processIsTranslated;
@end
=====================================
modules/gui/macosx/main/VLCMain.m
=====================================
@@ -89,9 +89,7 @@
#import "windows/video/VLCMainVideoViewController.h"
#ifdef HAVE_SPARKLE
-#import <Sparkle/Sparkle.h> /* we're the update delegate */
-NSString *const kIntel64UpdateURLString = @"https://update.videolan.org/vlc/sparkle/vlc-intel64.xml";
-NSString *const kARM64UpdateURLString = @"https://update.videolan.org/vlc/sparkle/vlc-arm64.xml";
+#import "main/VLCMain+Sparkle.h"
#endif
NSString *VLCConfigurationChangedNotification = @"VLCConfigurationChangedNotification";
@@ -102,11 +100,7 @@ NSString * const kVLCPreferencesVersion = @"VLCPreferencesVersion";
#pragma mark Private extension
@interface VLCMain ()
-#ifdef HAVE_SPARKLE
-<SUUpdaterDelegate, NSApplicationDelegate>
-#else
<NSApplicationDelegate>
-#endif
{
intf_thread_t *_p_intf;
BOOL _launched;
@@ -126,11 +120,17 @@ NSString * const kVLCPreferencesVersion = @"VLCPreferencesVersion";
VLCConvertAndSaveWindowController *_convertAndSaveWindow;
VLCClickerManager *_clickerManager;
VLCDetachedAudioWindow *_detachedAudioWindow;
+#ifdef HAVE_SPARKLE
+ SPUStandardUpdaterController *_sparkleUpdaterController;
+#endif
bool _interfaceIsTerminating; /* Makes sure applicationWillTerminate will be called only once */
}
+ (void)killInstance;
- (void)applicationWillTerminate:(NSNotification *)notification;
+#ifdef HAVE_SPARKLE
+ at property (readwrite) SPUStandardUpdaterController *sparkleUpdaterController;
+#endif
@end
@@ -322,12 +322,12 @@ static VLCMain *sharedInstance = nil;
_clickerManager = [[VLCClickerManager alloc] init];
- [[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:_mainmenu topLevelObjects:nil];
-
#ifdef HAVE_SPARKLE
- [[SUUpdater sharedUpdater] setDelegate:self];
+ [self setupSparkle];
#endif
+ [[NSBundle mainBundle] loadNibNamed:@"MainMenu" owner:_mainmenu topLevelObjects:nil];
+
NSImage *appIconImage = [VLCApplication.sharedApplication vlcAppIconImage];
[VLCApplication.sharedApplication
setApplicationIconImage:appIconImage];
@@ -405,60 +405,6 @@ static VLCMain *sharedInstance = nil;
CFPreferencesAppSynchronize(kCFPreferencesCurrentApplication);
}
-#pragma mark -
-#pragma mark Sparkle delegate
-
-#ifdef HAVE_SPARKLE
-/* received directly before the update gets installed, so let's shut down a bit */
-- (void)updater:(SUUpdater *)updater willInstallUpdate:(SUAppcastItem *)update
-{
- [NSApp activateIgnoringOtherApps:YES];
- [_playQueueController stopPlayback];
-}
-
-/* don't be enthusiastic about an update if we currently play a video */
-- (BOOL)updaterMayCheckForUpdates:(SUUpdater *)bundle
-{
- if ([_playQueueController.playerController activeVideoPlayback])
- return NO;
-
- return YES;
-}
-
-/* use the correct feed depending on the hardware architecture */
-- (nullable NSString *)feedURLStringForUpdater:(SUUpdater *)updater
-{
-#ifdef __x86_64__
- if (OSX_BIGSUR_AND_HIGHER) {
- if ([self processIsTranslated] > 0) {
- msg_Dbg(getIntf(), "Process is translated. On update, VLC will install the native ARM-64 binary.");
- return kARM64UpdateURLString;
- }
- }
- return kIntel64UpdateURLString;
-#elif __arm64__
- return kARM64UpdateURLString;
-#else
- #error unsupported architecture
-#endif
-}
-
-- (void)updaterDidNotFindUpdate:(SUUpdater *)updater
-{
- msg_Dbg(getIntf(), "No update found");
-}
-
-- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error
-{
- msg_Warn(getIntf(), "Failed to download update with error %li", error.code);
-}
-
-- (void)updater:(SUUpdater *)updater didAbortWithError:(NSError *)error
-{
- msg_Err(getIntf(), "Updater aborted with error %li", error.code);
-}
-#endif
-
#pragma mark -
#pragma mark File opening over dock icon
=====================================
modules/gui/macosx/menus/VLCMainMenu.m
=====================================
@@ -145,7 +145,7 @@ typedef NS_ENUM(NSInteger, VLCObjectType) {
#ifdef HAVE_SPARKLE
[_checkForUpdate setAction:@selector(checkForUpdates:)];
- [_checkForUpdate setTarget:[SUUpdater sharedUpdater]];
+ [_checkForUpdate setTarget:VLCMain.sharedInstance.sparkleUpdaterController];
#else
[_checkForUpdate setEnabled:NO];
#endif
=====================================
modules/gui/macosx/preferences/VLCSimplePrefsController.m
=====================================
@@ -199,7 +199,7 @@ static NSString* VLCHotkeysSettingToolbarIdentifier = @"Hotkeys Settings Item Id
#ifdef HAVE_SPARKLE
[_intf_updateCheckbox bind:@"value"
- toObject:[SUUpdater sharedUpdater]
+ toObject:VLCMain.sharedInstance.sparkleUpdaterController.updater
withKeyPath:@"automaticallyChecksForUpdates"
options:nil];
#else
@@ -654,8 +654,9 @@ create_toolbar_item(NSString *itemIdent, NSString *name, NSString *desc, NSStrin
#ifdef HAVE_SPARKLE
- if ([[SUUpdater sharedUpdater] lastUpdateCheckDate] != NULL)
- [_intf_last_updateLabel setStringValue: [NSString stringWithFormat: _NS("Last check on: %@"), [[[SUUpdater sharedUpdater] lastUpdateCheckDate] descriptionWithLocale: [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]]]];
+ NSDate * const lastUpdateCheckDate = VLCMain.sharedInstance.sparkleUpdaterController.updater.lastUpdateCheckDate;
+ if (lastUpdateCheckDate != NULL)
+ [_intf_last_updateLabel setStringValue: [NSString stringWithFormat: _NS("Last check on: %@"), [lastUpdateCheckDate descriptionWithLocale: [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]]]];
else
[_intf_last_updateLabel setStringValue: _NS("No check was performed yet.")];
#endif
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6c097ec6605a9a19919e620641ad0412cea228e3...f8b79b69ca13c81b5e73581e0b13c1415d4e7183
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/6c097ec6605a9a19919e620641ad0412cea228e3...f8b79b69ca13c81b5e73581e0b13c1415d4e7183
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list