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

macosx: convert cas to NSWindowController subclass, remove singleton

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