[vlc-commits] macosx/main: improve lazy loading
Felix Paul Kühne
git at videolan.org
Thu Sep 12 19:19:40 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Wed Sep 11 18:48:58 2019 +0200| [5a42051d67a540fef52a93b71bc2942809e86087] | committer: Felix Paul Kühne
macosx/main: improve lazy loading
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5a42051d67a540fef52a93b71bc2942809e86087
---
modules/gui/macosx/library/VLCLibraryController.m | 12 +++----
modules/gui/macosx/main/VLCMain.m | 40 ++++++++++------------
.../panels/VLCAudioEffectsWindowController.h | 3 --
.../panels/VLCAudioEffectsWindowController.m | 21 ++++++++++--
.../panels/VLCVideoEffectsWindowController.h | 3 --
.../panels/VLCVideoEffectsWindowController.m | 18 ++++++++--
.../macosx/panels/dialogs/VLCCoreDialogProvider.m | 5 +--
.../playlist/VLCPlaybackContinuityController.m | 9 ++++-
8 files changed, 67 insertions(+), 44 deletions(-)
diff --git a/modules/gui/macosx/library/VLCLibraryController.m b/modules/gui/macosx/library/VLCLibraryController.m
index da62097af3..ddfe170ab3 100644
--- a/modules/gui/macosx/library/VLCLibraryController.m
+++ b/modules/gui/macosx/library/VLCLibraryController.m
@@ -64,12 +64,13 @@ float kVLCDefaultThumbnailPosition = .15;
name:NSApplicationWillBecomeActiveNotification
object:nil];
[defaultNotificationCenter addObserver:self
+ selector:@selector(applicationWillBecomeActive:)
+ name:NSApplicationDidFinishLaunchingNotification
+ object:nil];
+ [defaultNotificationCenter addObserver:self
selector:@selector(playbackStateChanged:)
name:VLCPlayerStateChanged
object:nil];
- dispatch_async(dispatch_get_main_queue(), ^{
- [self lazyLoad];
- });
}
return self;
}
@@ -80,11 +81,6 @@ float kVLCDefaultThumbnailPosition = .15;
_p_libraryInstance = NULL;
}
-- (void)lazyLoad
-{
- [self applicationWillEnterBackground:nil];
-}
-
- (void)applicationWillEnterBackground:(NSNotification *)aNotification
{
if (_p_libraryInstance) {
diff --git a/modules/gui/macosx/main/VLCMain.m b/modules/gui/macosx/main/VLCMain.m
index 0353925837..d8141913e8 100644
--- a/modules/gui/macosx/main/VLCMain.m
+++ b/modules/gui/macosx/main/VLCMain.m
@@ -207,8 +207,7 @@ static VLCMain *sharedInstance = nil;
if (self) {
_p_intf = getIntf();
- VLCApplication *sharedApplication = [VLCApplication sharedApplication];
- sharedApplication.delegate = self;
+ [VLCApplication sharedApplication].delegate = self;
_playlistController = [[VLCPlaylistController alloc] initWithPlaylist:vlc_intf_GetMainPlaylist(_p_intf)];
_libraryController = [[VLCLibraryController alloc] init];
@@ -220,33 +219,14 @@ static VLCMain *sharedInstance = nil;
_coredialogs = [[VLCCoreDialogProvider alloc] init];
_mainmenu = [[VLCMainMenu alloc] init];
- _statusBarIcon = [[VLCStatusBarIcon alloc] init];
-
_voutProvider = [[VLCVideoOutputProvider alloc] init];
- _libraryWindowController = [[VLCLibraryWindowController alloc] initWithLibraryWindow];
-
// Load them here already to apply stored profiles
_videoEffectsPanel = [[VLCVideoEffectsWindowController alloc] init];
_audioEffectsPanel = [[VLCAudioEffectsWindowController alloc] init];
if ([NSApp currentSystemPresentationOptions] & NSApplicationPresentationFullScreen)
[_playlistController.playerController setFullscreen:YES];
-
- if (var_InheritInteger(_p_intf, "macosx-icon-change")) {
- /* After day 354 of the year, the usual VLC cone is replaced by another cone
- * wearing a Father Xmas hat.
- * Note: this icon doesn't represent an endorsement of The Coca-Cola Company.
- */
- NSCalendar *gregorian =
- [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
- NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitYear forDate:[NSDate date]];
-
- if (dayOfYear >= 354)
- [sharedApplication setApplicationIconImage: [NSImage imageNamed:@"VLC-Xmas"]];
- else
- [sharedApplication setApplicationIconImage: [NSImage imageNamed:@"VLC"]];
- }
}
return self;
@@ -261,17 +241,35 @@ static VLCMain *sharedInstance = nil;
#ifdef HAVE_SPARKLE
[[SUUpdater sharedUpdater] setDelegate:self];
#endif
+
+ if (var_InheritInteger(_p_intf, "macosx-icon-change")) {
+ /* After day 354 of the year, the usual VLC cone is replaced by another cone
+ * wearing a Father Xmas hat.
+ * Note: this icon doesn't represent an endorsement of The Coca-Cola Company.
+ */
+ NSCalendar *gregorian =
+ [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];
+ NSUInteger dayOfYear = [gregorian ordinalityOfUnit:NSCalendarUnitDay inUnit:NSCalendarUnitYear forDate:[NSDate date]];
+
+ if (dayOfYear >= 354)
+ [[VLCApplication sharedApplication] setApplicationIconImage: [NSImage imageNamed:@"VLC-Xmas"]];
+ else
+ [[VLCApplication sharedApplication] setApplicationIconImage: [NSImage imageNamed:@"VLC"]];
+ }
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
_launched = YES;
+ _libraryWindowController = [[VLCLibraryWindowController alloc] initWithLibraryWindow];
[_libraryWindowController.window makeKeyAndOrderFront:nil];
if (!_p_intf)
return;
[self migrateOldPreferences];
+
+ _statusBarIcon = [[VLCStatusBarIcon alloc] init];
}
#pragma mark -
diff --git a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h
index bb5a1c8c08..951b81207b 100644
--- a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h
+++ b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.h
@@ -106,9 +106,6 @@
@property (readwrite, weak) IBOutlet NSButton *filterScaleTempoCheckbox;
@property (readwrite, weak) IBOutlet NSButton *filterStereoEnhancerCheckbox;
- at property (strong) VLCPopupPanelController *popupPanel;
- at property (strong) VLCTextfieldPanelController *textfieldPanel;
-
/* generic */
- (IBAction)profileSelectorAction:(id)sender;
- (IBAction)applyProfileCheckboxChanged:(id)sender;
diff --git a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
index 2929cb85b2..2015c1f72b 100644
--- a/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
+++ b/modules/gui/macosx/panels/VLCAudioEffectsWindowController.m
@@ -53,6 +53,8 @@ NSString *VLCAudioEffectsProfileNamesKey = @"AudioEffectProfileNames";
@interface VLCAudioEffectsWindowController ()
{
VLCPlayerController *_playerController;
+ VLCPopupPanelController *_popupPanel;
+ VLCTextfieldPanelController *_textfieldPanel;
}
@end
@@ -113,9 +115,6 @@ NSString *VLCAudioEffectsProfileNamesKey = @"AudioEffectProfileNames";
dispatch_async(dispatch_get_main_queue(), ^{
self->_playerController = [[[VLCMain sharedInstance] playlistController] playerController];
- self.popupPanel = [[VLCPopupPanelController alloc] init];
- self.textfieldPanel = [[VLCTextfieldPanelController alloc] init];
-
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults boolForKey:@"AudioEffectApplyProfileOnStartup"])
{
@@ -512,6 +511,10 @@ NSString *VLCAudioEffectsProfileNamesKey = @"AudioEffectProfileNames";
- (void)addAudioEffectsProfile:(id)sender
{
+ if (!_textfieldPanel) {
+ _textfieldPanel = [[VLCTextfieldPanelController alloc] init];
+ }
+
/* show panel */
[_textfieldPanel setTitleString:_NS("Duplicate current profile for a new profile")];
[_textfieldPanel setSubTitleString:_NS("Enter a name for the new profile:")];
@@ -562,6 +565,10 @@ NSString *VLCAudioEffectsProfileNamesKey = @"AudioEffectProfileNames";
- (void)removeAudioEffectsProfile:(id)sender
{
+ if (!_popupPanel) {
+ _popupPanel = [[VLCPopupPanelController alloc] init];
+ }
+
/* show panel */
[_popupPanel setTitleString:_NS("Remove a preset")];
[_popupPanel setSubTitleString:_NS("Select the preset you would like to remove:")];
@@ -807,6 +814,10 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
- (IBAction)addPresetAction:(id)sender
{
+ if (!_textfieldPanel) {
+ _textfieldPanel = [[VLCTextfieldPanelController alloc] init];
+ }
+
/* show panel */
[_textfieldPanel setTitleString:_NS("Save current selection as new preset")];
[_textfieldPanel setSubTitleString:_NS("Enter a name for the new preset:")];
@@ -850,6 +861,10 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
- (IBAction)deletePresetAction:(id)sender
{
+ if (!_popupPanel) {
+ _popupPanel = [[VLCPopupPanelController alloc] init];
+ }
+
[_popupPanel setTitleString:_NS("Remove a preset")];
[_popupPanel setSubTitleString:_NS("Select the preset you would like to remove:")];
[_popupPanel setOkButtonString:_NS("Remove")];
diff --git a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h
index 2adee19826..28dc8fb99f 100644
--- a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h
+++ b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.h
@@ -144,9 +144,6 @@
@property (readwrite, weak) IBOutlet NSSlider *addLogoTransparencySlider;
@property (readwrite, weak) IBOutlet NSButton *anaglyphCheckbox;
- at property (strong) VLCPopupPanelController *popupPanel;
- at property (strong) VLCTextfieldPanelController *textfieldPanel;
-
/* text field / stepper binding values */
/* use setter to modify gui elements */
@property (nonatomic) int cropLeftValue;
diff --git a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
index 6f233cc651..d3c27797e4 100644
--- a/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
+++ b/modules/gui/macosx/panels/VLCVideoEffectsWindowController.m
@@ -45,6 +45,13 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
#pragma mark -
#pragma mark Initialization
+ at interface VLCVideoEffectsWindowController()
+{
+ VLCPopupPanelController *_popupPanel;
+ VLCTextfieldPanelController *_textfieldPanel;
+}
+ at end
+
@implementation VLCVideoEffectsWindowController
+ (void)initialize
@@ -82,9 +89,6 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
name:NSApplicationWillTerminateNotification
object:nil];
- self.popupPanel = [[VLCPopupPanelController alloc] init];
- self.textfieldPanel = [[VLCTextfieldPanelController alloc] init];
-
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults boolForKey:@"VideoEffectApplyProfileOnStartup"]) {
// This does not reset the UI (which does not exist yet), but it initalizes needed playlist vars
@@ -789,6 +793,10 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
- (void)addProfile:(id)sender
{
+ if (!_textfieldPanel) {
+ _textfieldPanel = [[VLCTextfieldPanelController alloc] init];
+ }
+
/* show panel */
[[_textfieldPanel window] setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
[_textfieldPanel setTitleString:_NS("Duplicate current profile for a new profile")];
@@ -843,6 +851,10 @@ NSString *VLCVideoEffectsProfileNamesKey = @"VideoEffectProfileNames";
- (void)removeProfile:(id)sender
{
+ if (!_popupPanel) {
+ _popupPanel = [[VLCPopupPanelController alloc] init];
+ }
+
/* show panel */
[[_popupPanel window] setAppearance:[NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]];
[_popupPanel setTitleString:_NS("Remove a preset")];
diff --git a/modules/gui/macosx/panels/dialogs/VLCCoreDialogProvider.m b/modules/gui/macosx/panels/dialogs/VLCCoreDialogProvider.m
index c5c65b9f39..76f696030f 100644
--- a/modules/gui/macosx/panels/dialogs/VLCCoreDialogProvider.m
+++ b/modules/gui/macosx/panels/dialogs/VLCCoreDialogProvider.m
@@ -156,8 +156,6 @@ static void updateProgressCallback(void *p_data,
msg_Dbg(getIntf(), "Register dialog provider");
[[NSBundle mainBundle] loadNibNamed:@"CoreDialogs" owner:self topLevelObjects:nil];
- _errorPanel = [[VLCErrorWindowController alloc] init];
-
intf_thread_t *p_intf = getIntf();
/* subscribe to various interactive dialogues */
@@ -199,6 +197,9 @@ static void updateProgressCallback(void *p_data,
- (void)displayError:(NSArray *)dialogData
{
+ if (!_errorPanel) {
+ _errorPanel = [[VLCErrorWindowController alloc] init];
+ }
[_errorPanel showWindow:nil];
[_errorPanel addError:[dialogData objectAtIndex:0] withMsg:[dialogData objectAtIndex:1]];
}
diff --git a/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m b/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
index 610e3d7bf6..3bfefa4815 100644
--- a/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
+++ b/modules/gui/macosx/playlist/VLCPlaybackContinuityController.m
@@ -63,7 +63,6 @@
selector:@selector(playbackStatusUpdated:)
name:VLCPlayerStateChanged
object:nil];
- _resumeDialogController = [[VLCResumeDialogController alloc] init];
}
return self;
}
@@ -196,6 +195,10 @@
return;
}
+ if (!_resumeDialogController) {
+ _resumeDialogController = [[VLCResumeDialogController alloc] init];
+ }
+
[_resumeDialogController showWindowWithItem:inputItem
withLastPosition:(lastPlaybackPosition * duration) / 1000
completionBlock:completionBlock];
@@ -228,6 +231,10 @@
return;
}
+ if (!_resumeDialogController) {
+ _resumeDialogController = [[VLCResumeDialogController alloc] init];
+ }
+
[_resumeDialogController showWindowWithItem:inputItem
withLastPosition:lastPosition.intValue
completionBlock:completionBlock];
More information about the vlc-commits
mailing list