vlc | branch: master | David Fuhrmann <dfuhrm...@videolan.org> | Sun Aug 2 13:00:14 2015 +0200| [548807de5ad78c2d5fc2a7ce4c6aac24e6526c65] | committer: David Fuhrmann
macosx: Convert VLCTrackSync to NSWindowController subclass, remove singleton > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=548807de5ad78c2d5fc2a7ce4c6aac24e6526c65 --- modules/gui/macosx/InputManager.m | 2 +- modules/gui/macosx/MainMenu.m | 10 +-------- modules/gui/macosx/TrackSynchronization.h | 4 +--- modules/gui/macosx/TrackSynchronization.m | 31 ++++++++++++-------------- modules/gui/macosx/VLCVoutWindowController.m | 2 +- modules/gui/macosx/intf.h | 3 +++ modules/gui/macosx/intf.m | 9 ++++++++ 7 files changed, 30 insertions(+), 31 deletions(-) diff --git a/modules/gui/macosx/InputManager.m b/modules/gui/macosx/InputManager.m index a480fe1..e435a58 100644 --- a/modules/gui/macosx/InputManager.m +++ b/modules/gui/macosx/InputManager.m @@ -419,7 +419,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, - (void)updateDelays { - [[VLCTrackSynchronization sharedInstance] updateValues]; + [[[VLCMain sharedInstance] trackSyncPanel] updateValues]; } - (void)updateMainMenu diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m index 86d9641..d1fa3bc 100644 --- a/modules/gui/macosx/MainMenu.m +++ b/modules/gui/macosx/MainMenu.m @@ -55,7 +55,6 @@ { BOOL b_nib_videoeffects_loaded; BOOL b_nib_audioeffects_loaded; - BOOL b_nib_tracksynchrloaded; BOOL b_nib_bookmarks_loaded; BOOL b_nib_convertandsave_loaded; @@ -63,7 +62,6 @@ HelpWindowController *_helpWindowController; VLCVideoEffects *_videoEffectsWindowController; VLCAudioEffects *_audioEffectsWindowController; - VLCTrackSynchronization *_trackSynchronizationWindowController; VLCConvertAndSave *_convertAndSaveWindowController; AddonsWindowController *_addonsController; @@ -1294,13 +1292,7 @@ - (IBAction)showTrackSynchronization:(id)sender { - if (!_trackSynchronizationWindowController) - _trackSynchronizationWindowController = [[VLCTrackSynchronization alloc] init]; - - if (!b_nib_tracksynchrloaded) - b_nib_tracksynchrloaded = [NSBundle loadNibNamed:@"SyncTracks" owner:_trackSynchronizationWindowController]; - - [_trackSynchronizationWindowController toggleWindow:sender]; + [[[VLCMain sharedInstance] trackSyncPanel] toggleWindow:sender]; } - (IBAction)showAudioEffects:(id)sender diff --git a/modules/gui/macosx/TrackSynchronization.h b/modules/gui/macosx/TrackSynchronization.h index a6d0bbf..4cb32e4 100644 --- a/modules/gui/macosx/TrackSynchronization.h +++ b/modules/gui/macosx/TrackSynchronization.h @@ -24,10 +24,9 @@ #import <Cocoa/Cocoa.h> -@interface VLCTrackSynchronization : NSObject +@interface VLCTrackSynchronization : NSWindowController /* generic */ -@property (readwrite, weak) IBOutlet NSWindow *window; @property (readwrite, weak) IBOutlet NSButton *resetButton; /* Audio / Video */ @@ -48,7 +47,6 @@ @property (readwrite, weak) IBOutlet NSTextField *sv_durTextField; @property (readwrite, weak) IBOutlet NSStepper *sv_durStepper; -+ (VLCTrackSynchronization *)sharedInstance; - (void)updateCocoaWindowLevel:(NSInteger)i_level; - (IBAction)toggleWindow:(id)sender; diff --git a/modules/gui/macosx/TrackSynchronization.m b/modules/gui/macosx/TrackSynchronization.m index 4343cd4..3780195 100644 --- a/modules/gui/macosx/TrackSynchronization.m +++ b/modules/gui/macosx/TrackSynchronization.m @@ -36,21 +36,16 @@ @implementation VLCTrackSynchronization -+ (VLCTrackSynchronization *)sharedInstance +- (id)init { - static VLCTrackSynchronization *sharedInstance = nil; - static dispatch_once_t pred; + self = [super initWithWindowNibName:@"SyncTracks"]; - dispatch_once(&pred, ^{ - sharedInstance = [VLCTrackSynchronization new]; - }); - - return sharedInstance; + return self; } -- (void)awakeFromNib +- (void)windowDidLoad { - [_window setTitle:_NS("Track Synchronization")]; + [self.window setTitle:_NS("Track Synchronization")]; [_resetButton setTitle:_NS("Reset")]; [_avLabel setStringValue:_NS("Audio/Video")]; [_av_advanceLabel setStringValue: _NS("Audio track synchronization:")]; @@ -86,24 +81,26 @@ [[_sv_durTextField formatter] setFormat:[NSString stringWithFormat:@"#,##0.000%@", o_suffix]]; [_sv_durTextField setToolTip: o_toolTip]; - [_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; + [self.window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; [self resetValues:self]; } - (void)updateCocoaWindowLevel:(NSInteger)i_level { - if (_window && [_window isVisible] && [_window level] != i_level) - [_window setLevel: i_level]; + if (self.window && [self.window isVisible] && [self.window level] != i_level) + [self.window setLevel: i_level]; } - (IBAction)toggleWindow:(id)sender { - if ([_window isVisible]) - [_window orderOut:sender]; + if ([self.window isVisible]) + [self.window orderOut:sender]; else { - [_window setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]]; - [_window makeKeyAndOrderFront:sender]; + [self.window setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]]; + [self.window makeKeyAndOrderFront:sender]; + + [self updateValues]; } } diff --git a/modules/gui/macosx/VLCVoutWindowController.m b/modules/gui/macosx/VLCVoutWindowController.m index a588abf..20536ed 100644 --- a/modules/gui/macosx/VLCVoutWindowController.m +++ b/modules/gui/macosx/VLCVoutWindowController.m @@ -593,7 +593,7 @@ void WindowClose(vout_window_t *p_wnd) [[VLCAudioEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCInfo sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel]; - [[VLCTrackSynchronization sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; + [[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel]; } diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h index fec2eea..7ecedf8 100644 --- a/modules/gui/macosx/intf.h +++ b/modules/gui/macosx/intf.h @@ -65,6 +65,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; @class VLCBookmarks; @class VLCOpen; @class VLCDebugMessageVisualizer; +@class VLCTrackSynchronization; @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> { @@ -91,6 +92,8 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; - (VLCInputManager *)inputManager; - (VLCDebugMessageVisualizer *)debugMsgPanel; +- (VLCTrackSynchronization *)trackSyncPanel; + - (void)setActiveVideoPlayback:(BOOL)b_value; - (BOOL)activeVideoPlayback; - (void)applicationWillTerminate:(NSNotification *)notification; diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m index 7ffc099..5cba3bb 100644 --- a/modules/gui/macosx/intf.m +++ b/modules/gui/macosx/intf.m @@ -155,6 +155,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, VLCInputManager *_input_manager; VLCPlaylist *_playlist; VLCDebugMessageVisualizer *_messagePanelController; + VLCTrackSynchronization *_trackSyncPanel; bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */ } @@ -526,6 +527,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, return _messagePanelController; } +- (VLCTrackSynchronization *)trackSyncPanel +{ + if (!_trackSyncPanel) + _trackSyncPanel = [[VLCTrackSynchronization alloc] init]; + + return _trackSyncPanel; +} + - (VLCBookmarks *)bookmarks { if (!_bookmarks) _______________________________________________ vlc-commits mailing list vlc-commits@videolan.org https://mailman.videolan.org/listinfo/vlc-commits