macosx: Convert VLCTrackSync to NSWindowController subclass, remove singleton
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 2 Aug 2015 11:00:14 +0000 (13:00 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 2 Aug 2015 11:26:19 +0000 (13:26 +0200)
modules/gui/macosx/InputManager.m
modules/gui/macosx/MainMenu.m
modules/gui/macosx/TrackSynchronization.h
modules/gui/macosx/TrackSynchronization.m
modules/gui/macosx/VLCVoutWindowController.m
modules/gui/macosx/intf.h
modules/gui/macosx/intf.m

index a480fe1..e435a58 100644 (file)
@@ -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
index 86d9641..d1fa3bc 100644 (file)
@@ -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;
 
 
 - (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
index a6d0bbf..4cb32e4 100644 (file)
 
 #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;
index 4343cd4..3780195 100644 (file)
 
 @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:")];
     [[_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];
     }
 }
 
index a588abf..20536ed 100644 (file)
@@ -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];
 }
 
index fec2eea..7ecedf8 100644 (file)
@@ -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;
index 7ffc099..5cba3bb 100644 (file)
@@ -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)