Commit f6c4ab14 authored by David's avatar David

macosx: Convert VLCAudioEffects to NSWindowController subclass

parent 548807de
...@@ -24,10 +24,9 @@ ...@@ -24,10 +24,9 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@interface VLCAudioEffects : NSObject @interface VLCAudioEffects : NSWindowController
/* generic */ /* generic */
@property (readwrite, weak) IBOutlet NSWindow *window;
@property (readwrite, weak) IBOutlet NSTabView *tabView; @property (readwrite, weak) IBOutlet NSTabView *tabView;
@property (readwrite, weak) IBOutlet NSPopUpButton *profilePopup; @property (readwrite, weak) IBOutlet NSPopUpButton *profilePopup;
...@@ -103,8 +102,6 @@ ...@@ -103,8 +102,6 @@
@property (readwrite, weak) IBOutlet NSButton *filterKaraokeCheckbox; @property (readwrite, weak) IBOutlet NSButton *filterKaraokeCheckbox;
/* generic */ /* generic */
+ (VLCAudioEffects *)sharedInstance;
- (IBAction)profileSelectorAction:(id)sender; - (IBAction)profileSelectorAction:(id)sender;
- (void)toggleWindow:(id)sender; - (void)toggleWindow:(id)sender;
......
...@@ -51,19 +51,8 @@ ...@@ -51,19 +51,8 @@
@implementation VLCAudioEffects @implementation VLCAudioEffects
+ (VLCAudioEffects *)sharedInstance + (void)initialize
{ {
static VLCAudioEffects *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCAudioEffects new];
});
return sharedInstance;
}
+ (void)initialize{
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
NSString *workString; NSString *workString;
...@@ -99,12 +88,15 @@ ...@@ -99,12 +88,15 @@
- (id)init - (id)init
{ {
self = [super init]; self = [super initWithWindowNibName:@"AudioEffects"];
i_old_profile_index = -1; if (self) {
i_old_profile_index = -1;
}
return self; return self;
} }
- (void)awakeFromNib - (void)windowDidLoad
{ {
/* setup the user's language */ /* setup the user's language */
/* Equalizer */ /* Equalizer */
...@@ -144,9 +136,9 @@ ...@@ -144,9 +136,9 @@
[[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"compressor"]] setLabel:_NS("Compressor")]; [[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"compressor"]] setLabel:_NS("Compressor")];
[[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"spatializer"]] setLabel:_NS("Spatializer")]; [[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"spatializer"]] setLabel:_NS("Spatializer")];
[[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"filter"]] setLabel:_NS("Filter")]; [[_tabView tabViewItemAtIndex:[_tabView indexOfTabViewItemWithIdentifier:@"filter"]] setLabel:_NS("Filter")];
[_window setTitle:_NS("Audio Effects")]; [self.window setTitle:_NS("Audio Effects")];
[_window setExcludedFromWindowsMenu:YES]; [self.window setExcludedFromWindowsMenu:YES];
[_window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; [self.window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
[self equalizerUpdated]; [self equalizerUpdated];
[self resetCompressor]; [self resetCompressor];
...@@ -200,17 +192,17 @@ ...@@ -200,17 +192,17 @@
#pragma mark generic code #pragma mark generic code
- (void)updateCocoaWindowLevel:(NSInteger)i_level - (void)updateCocoaWindowLevel:(NSInteger)i_level
{ {
if (_window && [_window isVisible] && [_window level] != i_level) if (self.window && [self.window isVisible] && [self.window level] != i_level)
[_window setLevel: i_level]; [self.window setLevel: i_level];
} }
- (IBAction)toggleWindow:(id)sender - (IBAction)toggleWindow:(id)sender
{ {
if ([_window isKeyWindow]) if ([self.window isKeyWindow])
[_window orderOut:sender]; [self.window orderOut:sender];
else { else {
[_window setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]]; [self.window setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]];
[_window makeKeyAndOrderFront:sender]; [self.window makeKeyAndOrderFront:sender];
} }
} }
...@@ -375,7 +367,7 @@ ...@@ -375,7 +367,7 @@
[panel setTarget:self]; [panel setTarget:self];
b_genericAudioProfileInInteraction = YES; b_genericAudioProfileInInteraction = YES;
[panel runModalForWindow:_window]; [panel runModalForWindow:self.window];
} }
- (void)removeAudioEffectsProfile:(id)sender - (void)removeAudioEffectsProfile:(id)sender
...@@ -390,7 +382,7 @@ ...@@ -390,7 +382,7 @@
[panel setTarget:self]; [panel setTarget:self];
b_genericAudioProfileInInteraction = YES; b_genericAudioProfileInInteraction = YES;
[panel runModalForWindow:_window]; [panel runModalForWindow:self.window];
} }
#pragma mark - #pragma mark -
...@@ -616,7 +608,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf, ...@@ -616,7 +608,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
[panel setTarget:self]; [panel setTarget:self];
b_genericAudioProfileInInteraction = NO; b_genericAudioProfileInInteraction = NO;
[panel runModalForWindow:_window]; [panel runModalForWindow:self.window];
} }
- (void)panel:(VLCEnterTextPanel *)panel returnValue:(NSUInteger)value text:(NSString *)text - (void)panel:(VLCEnterTextPanel *)panel returnValue:(NSUInteger)value text:(NSString *)text
...@@ -672,7 +664,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf, ...@@ -672,7 +664,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
[alert setMessageText:_NS("Please enter a unique name for the new profile.")]; [alert setMessageText:_NS("Please enter a unique name for the new profile.")];
[alert setInformativeText:_NS("Multiple profiles with the same name are not allowed.")]; [alert setInformativeText:_NS("Multiple profiles with the same name are not allowed.")];
[alert beginSheetModalForWindow:_window [alert beginSheetModalForWindow:self.window
modalDelegate:nil modalDelegate:nil
didEndSelector:nil didEndSelector:nil
contextInfo:nil]; contextInfo:nil];
...@@ -708,7 +700,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf, ...@@ -708,7 +700,7 @@ static bool GetEqualizerStatus(intf_thread_t *p_custom_intf,
[panel setTarget:self]; [panel setTarget:self];
b_genericAudioProfileInInteraction = NO; b_genericAudioProfileInInteraction = NO;
[panel runModalForWindow:_window]; [panel runModalForWindow:self.window];
} }
- (void)panel:(VLCSelectItemInPopupPanel *)panel returnValue:(NSUInteger)value item:(NSUInteger)item - (void)panel:(VLCSelectItemInPopupPanel *)panel returnValue:(NSUInteger)value item:(NSUInteger)item
......
...@@ -54,14 +54,12 @@ ...@@ -54,14 +54,12 @@
@interface VLCMainMenu() @interface VLCMainMenu()
{ {
BOOL b_nib_videoeffects_loaded; BOOL b_nib_videoeffects_loaded;
BOOL b_nib_audioeffects_loaded;
BOOL b_nib_bookmarks_loaded; BOOL b_nib_bookmarks_loaded;
BOOL b_nib_convertandsave_loaded; BOOL b_nib_convertandsave_loaded;
AboutWindowController *_aboutWindowController; AboutWindowController *_aboutWindowController;
HelpWindowController *_helpWindowController; HelpWindowController *_helpWindowController;
VLCVideoEffects *_videoEffectsWindowController; VLCVideoEffects *_videoEffectsWindowController;
VLCAudioEffects *_audioEffectsWindowController;
VLCConvertAndSave *_convertAndSaveWindowController; VLCConvertAndSave *_convertAndSaveWindowController;
AddonsWindowController *_addonsController; AddonsWindowController *_addonsController;
...@@ -1297,13 +1295,7 @@ ...@@ -1297,13 +1295,7 @@
- (IBAction)showAudioEffects:(id)sender - (IBAction)showAudioEffects:(id)sender
{ {
if (!_audioEffectsWindowController) [[[VLCMain sharedInstance] audioEffectsPanel] toggleWindow:sender];
_audioEffectsWindowController = [[VLCAudioEffects alloc] init];
if (!b_nib_audioeffects_loaded)
b_nib_audioeffects_loaded = [NSBundle loadNibNamed:@"AudioEffects" owner:_audioEffectsWindowController];
[_audioEffectsWindowController toggleWindow:sender];
} }
- (IBAction)showBookmarks:(id)sender - (IBAction)showBookmarks:(id)sender
......
...@@ -590,7 +590,7 @@ void WindowClose(vout_window_t *p_wnd) ...@@ -590,7 +590,7 @@ void WindowClose(vout_window_t *p_wnd)
VLCMain *main = [VLCMain sharedInstance]; VLCMain *main = [VLCMain sharedInstance];
[[VLCMainWindow sharedInstance] setWindowLevel:i_level]; [[VLCMainWindow sharedInstance] setWindowLevel:i_level];
[[VLCVideoEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCVideoEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[VLCAudioEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
[[VLCInfo sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCInfo sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
......
...@@ -66,6 +66,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -66,6 +66,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCOpen; @class VLCOpen;
@class VLCDebugMessageVisualizer; @class VLCDebugMessageVisualizer;
@class VLCTrackSynchronization; @class VLCTrackSynchronization;
@class VLCAudioEffects;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{ {
...@@ -93,6 +94,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -93,6 +94,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCDebugMessageVisualizer *)debugMsgPanel; - (VLCDebugMessageVisualizer *)debugMsgPanel;
- (VLCTrackSynchronization *)trackSyncPanel; - (VLCTrackSynchronization *)trackSyncPanel;
- (VLCAudioEffects *)audioEffectsPanel;
- (void)setActiveVideoPlayback:(BOOL)b_value; - (void)setActiveVideoPlayback:(BOOL)b_value;
- (BOOL)activeVideoPlayback; - (BOOL)activeVideoPlayback;
......
...@@ -156,6 +156,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -156,6 +156,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCPlaylist *_playlist; VLCPlaylist *_playlist;
VLCDebugMessageVisualizer *_messagePanelController; VLCDebugMessageVisualizer *_messagePanelController;
VLCTrackSynchronization *_trackSyncPanel; VLCTrackSynchronization *_trackSyncPanel;
VLCAudioEffects *_audioEffectsPanel;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */ bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */
} }
...@@ -344,7 +345,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -344,7 +345,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
/* save current video and audio profiles */ /* save current video and audio profiles */
[[VLCVideoEffects sharedInstance] saveCurrentProfile]; [[VLCVideoEffects sharedInstance] saveCurrentProfile];
[[VLCAudioEffects sharedInstance] saveCurrentProfile]; [[self audioEffectsPanel] saveCurrentProfile];
/* Save some interface state in configuration, at module quit */ /* Save some interface state in configuration, at module quit */
config_PutInt(p_intf, "random", var_GetBool(p_playlist, "random")); config_PutInt(p_intf, "random", var_GetBool(p_playlist, "random"));
...@@ -535,6 +536,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -535,6 +536,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return _trackSyncPanel; return _trackSyncPanel;
} }
- (VLCAudioEffects *)audioEffectsPanel
{
if (!_audioEffectsPanel)
_audioEffectsPanel = [[VLCAudioEffects alloc] init];
return _audioEffectsPanel;
}
- (VLCBookmarks *)bookmarks - (VLCBookmarks *)bookmarks
{ {
if (!_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