Commit 548807de authored by David Fuhrmann's avatar David Fuhrmann

macosx: Convert VLCTrackSync to NSWindowController subclass, remove singleton

parent c95d33f9
......@@ -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
......
......@@ -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
......
......@@ -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;
......
......@@ -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];
}
}
......
......@@ -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];
}
......
......@@ -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;
......
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment