Commit 91e3caa6 authored by David Fuhrmann's avatar David Fuhrmann

macosx: convert cas to NSWindowController subclass, remove singleton

parent dc7a2831
...@@ -27,10 +27,9 @@ ...@@ -27,10 +27,9 @@
@class VLCDropDisabledImageView; @class VLCDropDisabledImageView;
@class VLCDragDropView; @class VLCDragDropView;
@interface VLCConvertAndSave : NSObject @interface VLCConvertAndSave : NSWindowController
// main panel // main panel
@property (weak) IBOutlet NSWindow *window;
@property (weak) IBOutlet VLCDragDropView *dropBox; @property (weak) IBOutlet VLCDragDropView *dropBox;
@property (weak) IBOutlet NSTextField *dropLabel; @property (weak) IBOutlet NSTextField *dropLabel;
...@@ -141,10 +140,6 @@ ...@@ -141,10 +140,6 @@
@property (nonatomic) int audChannels; @property (nonatomic) int audChannels;
+ (VLCConvertAndSave *)sharedInstance;
- (IBAction)toggleWindow;
- (IBAction)finalizePanel:(id)sender; - (IBAction)finalizePanel:(id)sender;
- (IBAction)openMedia:(id)sender; - (IBAction)openMedia:(id)sender;
- (IBAction)switchProfile:(id)sender; - (IBAction)switchProfile:(id)sender;
......
...@@ -118,21 +118,16 @@ ...@@ -118,21 +118,16 @@
[defaults registerDefaults:appDefaults]; [defaults registerDefaults:appDefaults];
} }
+ (VLCConvertAndSave *)sharedInstance - (id)init
{ {
static VLCConvertAndSave *sharedInstance = nil; self = [super initWithWindowNibName:@"ConvertAndSave"];
static dispatch_once_t pred;
dispatch_once(&pred, ^{ return self;
sharedInstance = [VLCConvertAndSave new];
});
return sharedInstance;
} }
- (void)awakeFromNib - (void)windowDidLoad
{ {
[_window setTitle: _NS("Convert & Stream")]; [self.window setTitle: _NS("Convert & Stream")];
[_okButton setTitle: _NS("Go!")]; [_okButton setTitle: _NS("Go!")];
[_dropLabel setStringValue: _NS("Drop media here")]; [_dropLabel setStringValue: _NS("Drop media here")];
[_dropButton setTitle: _NS("Open media...")]; [_dropButton setTitle: _NS("Open media...")];
...@@ -254,14 +249,6 @@ ...@@ -254,14 +249,6 @@
[self resetCustomizationSheetBasedOnProfile:[self.profileValueList firstObject]]; [self resetCustomizationSheetBasedOnProfile:[self.profileValueList firstObject]];
} }
# pragma mark -
# pragma mark Code to Communicate with other objects
- (void)toggleWindow
{
[_window makeKeyAndOrderFront: nil];
}
# pragma mark - # pragma mark -
# pragma mark User Interaction # pragma mark User Interaction
...@@ -271,7 +258,7 @@ ...@@ -271,7 +258,7 @@
if ([[[_streamTypePopup selectedItem] title] isEqualToString:@"HTTP"]) { if ([[[_streamTypePopup selectedItem] title] isEqualToString:@"HTTP"]) {
NSString *muxformat = [self.currentProfile firstObject]; NSString *muxformat = [self.currentProfile firstObject];
if ([muxformat isEqualToString:@"wav"] || [muxformat isEqualToString:@"mov"] || [muxformat isEqualToString:@"mp4"] || [muxformat isEqualToString:@"mkv"]) { if ([muxformat isEqualToString:@"wav"] || [muxformat isEqualToString:@"mov"] || [muxformat isEqualToString:@"mp4"] || [muxformat isEqualToString:@"mkv"]) {
NSBeginInformationalAlertSheet(_NS("Invalid container format for HTTP streaming"), _NS("OK"), @"", @"", _window, NSBeginInformationalAlertSheet(_NS("Invalid container format for HTTP streaming"), _NS("OK"), @"", @"", self.window,
nil, nil, nil, nil, nil, nil, nil, nil,
_NS("Media encapsulated as %@ cannot be streamed through the HTTP protocol for technical reasons."), _NS("Media encapsulated as %@ cannot be streamed through the HTTP protocol for technical reasons."),
[[self currentEncapsulationFormatAsFileExtension:YES] uppercaseString]); [[self currentEncapsulationFormatAsFileExtension:YES] uppercaseString]);
...@@ -307,7 +294,7 @@ ...@@ -307,7 +294,7 @@
/* we're done with this input */ /* we're done with this input */
vlc_gc_decref(p_input); vlc_gc_decref(p_input);
[_window performClose:sender]; [self.window performClose:sender];
} }
- (IBAction)openMedia:(id)sender - (IBAction)openMedia:(id)sender
...@@ -317,7 +304,7 @@ ...@@ -317,7 +304,7 @@
[openPanel setCanChooseDirectories:NO]; [openPanel setCanChooseDirectories:NO];
[openPanel setResolvesAliases:YES]; [openPanel setResolvesAliases:YES];
[openPanel setAllowsMultipleSelection:NO]; [openPanel setAllowsMultipleSelection:NO];
[openPanel beginSheetModalForWindow:_window completionHandler:^(NSInteger returnCode) { [openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger returnCode) {
if (returnCode == NSOKButton) if (returnCode == NSOKButton)
{ {
[self setMRL: toNSStr(vlc_path2uri([[[openPanel URL] path] UTF8String], NULL))]; [self setMRL: toNSStr(vlc_path2uri([[[openPanel URL] path] UTF8String], NULL))];
...@@ -337,7 +324,7 @@ ...@@ -337,7 +324,7 @@
- (IBAction)customizeProfile:(id)sender - (IBAction)customizeProfile:(id)sender
{ {
[NSApp beginSheet:_customizePanel modalForWindow:_window modalDelegate:self didEndSelector:NULL contextInfo:nil]; [NSApp beginSheet:_customizePanel modalForWindow:self.window modalDelegate:self didEndSelector:NULL contextInfo:nil];
} }
- (IBAction)closeCustomizationSheet:(id)sender - (IBAction)closeCustomizationSheet:(id)sender
...@@ -373,7 +360,7 @@ ...@@ -373,7 +360,7 @@
[panel setPopupButtonContent:self.profileNames]; [panel setPopupButtonContent:self.profileNames];
[panel setTarget:self]; [panel setTarget:self];
[panel runModalForWindow:_window]; [panel runModalForWindow:self.window];
} }
- (IBAction)iWantAFile:(id)sender - (IBAction)iWantAFile:(id)sender
...@@ -426,7 +413,7 @@ ...@@ -426,7 +413,7 @@
[saveFilePanel setCanCreateDirectories: YES]; [saveFilePanel setCanCreateDirectories: YES];
if ([[_customizeEncapMatrix selectedCell] tag] != RAW) // there is no clever guess for this if ([[_customizeEncapMatrix selectedCell] tag] != RAW) // there is no clever guess for this
[saveFilePanel setAllowedFileTypes:[NSArray arrayWithObject:[self currentEncapsulationFormatAsFileExtension:YES]]]; [saveFilePanel setAllowedFileTypes:[NSArray arrayWithObject:[self currentEncapsulationFormatAsFileExtension:YES]]];
[saveFilePanel beginSheetModalForWindow:_window completionHandler:^(NSInteger returnCode) { [saveFilePanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger returnCode) {
if (returnCode == NSOKButton) { if (returnCode == NSOKButton) {
[self setOutputDestination:[[saveFilePanel URL] path]]; [self setOutputDestination:[[saveFilePanel URL] path]];
[_fileDestinationFileName setStringValue: [[NSFileManager defaultManager] displayNameAtPath:_outputDestination]]; [_fileDestinationFileName setStringValue: [[NSFileManager defaultManager] displayNameAtPath:_outputDestination]];
...@@ -443,7 +430,7 @@ ...@@ -443,7 +430,7 @@
- (IBAction)showStreamPanel:(id)sender - (IBAction)showStreamPanel:(id)sender
{ {
[NSApp beginSheet:_streamPanel modalForWindow:_window modalDelegate:self didEndSelector:NULL contextInfo:nil]; [NSApp beginSheet:_streamPanel modalForWindow:self.window modalDelegate:self didEndSelector:NULL contextInfo:nil];
} }
- (IBAction)closeStreamPanel:(id)sender - (IBAction)closeStreamPanel:(id)sender
......
...@@ -54,11 +54,9 @@ ...@@ -54,11 +54,9 @@
@interface VLCMainMenu() @interface VLCMainMenu()
{ {
BOOL b_nib_bookmarks_loaded; BOOL b_nib_bookmarks_loaded;
BOOL b_nib_convertandsave_loaded;
AboutWindowController *_aboutWindowController; AboutWindowController *_aboutWindowController;
HelpWindowController *_helpWindowController; HelpWindowController *_helpWindowController;
VLCConvertAndSave *_convertAndSaveWindowController;
AddonsWindowController *_addonsController; AddonsWindowController *_addonsController;
ExtensionsManager *_extensionManager; ExtensionsManager *_extensionManager;
...@@ -1266,13 +1264,7 @@ ...@@ -1266,13 +1264,7 @@
- (IBAction)showConvertAndSave:(id)sender - (IBAction)showConvertAndSave:(id)sender
{ {
if (_convertAndSaveWindowController == nil) [[[VLCMain sharedInstance] convertAndSaveWindow] showWindow:self];
_convertAndSaveWindowController = [[VLCConvertAndSave alloc] init];
if (!b_nib_convertandsave_loaded)
b_nib_convertandsave_loaded = [NSBundle loadNibNamed:@"ConvertAndSave" owner: _convertAndSaveWindowController];
[_convertAndSaveWindowController toggleWindow];
} }
- (IBAction)showVideoEffects:(id)sender - (IBAction)showVideoEffects:(id)sender
......
...@@ -68,6 +68,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -68,6 +68,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCTrackSynchronization; @class VLCTrackSynchronization;
@class VLCAudioEffects; @class VLCAudioEffects;
@class VLCVideoEffects; @class VLCVideoEffects;
@class VLCConvertAndSave;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{ {
...@@ -98,6 +99,8 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -98,6 +99,8 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCAudioEffects *)audioEffectsPanel; - (VLCAudioEffects *)audioEffectsPanel;
- (VLCVideoEffects *)videoEffectsPanel; - (VLCVideoEffects *)videoEffectsPanel;
- (VLCConvertAndSave *)convertAndSaveWindow;
- (void)setActiveVideoPlayback:(BOOL)b_value; - (void)setActiveVideoPlayback:(BOOL)b_value;
- (BOOL)activeVideoPlayback; - (BOOL)activeVideoPlayback;
- (void)applicationWillTerminate:(NSNotification *)notification; - (void)applicationWillTerminate:(NSNotification *)notification;
......
...@@ -59,6 +59,7 @@ ...@@ -59,6 +59,7 @@
#import "BWQuincyManager.h" #import "BWQuincyManager.h"
#import "ResumeDialogController.h" #import "ResumeDialogController.h"
#import "DebugMessageVisualizer.h" #import "DebugMessageVisualizer.h"
#import "ConvertAndSave.h"
#import "VideoEffects.h" #import "VideoEffects.h"
#import "AudioEffects.h" #import "AudioEffects.h"
...@@ -158,6 +159,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -158,6 +159,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCTrackSynchronization *_trackSyncPanel; VLCTrackSynchronization *_trackSyncPanel;
VLCAudioEffects *_audioEffectsPanel; VLCAudioEffects *_audioEffectsPanel;
VLCVideoEffects *_videoEffectsPanel; VLCVideoEffects *_videoEffectsPanel;
VLCConvertAndSave *_convertAndSaveWindow;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */ bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */
} }
...@@ -569,6 +571,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -569,6 +571,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return _open; return _open;
} }
- (VLCConvertAndSave *)convertAndSaveWindow
{
if (_convertAndSaveWindow == nil)
_convertAndSaveWindow = [[VLCConvertAndSave alloc] init];
return _convertAndSaveWindow;
}
- (VLCSimplePrefs *)simplePreferences - (VLCSimplePrefs *)simplePreferences
{ {
if (!_sprefs) if (!_sprefs)
......
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