[vlc-commits] macosx: convert cas to NSWindowController subclass, remove singleton
David Fuhrmann
git at videolan.org
Thu Aug 6 12:38:27 CEST 2015
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Wed Aug 5 16:37:52 2015 +0200| [91e3caa67669c95b1ef38d3a241daabd3e21ee29] | committer: David Fuhrmann
macosx: convert cas to NSWindowController subclass, remove singleton
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=91e3caa67669c95b1ef38d3a241daabd3e21ee29
---
modules/gui/macosx/ConvertAndSave.h | 7 +------
modules/gui/macosx/ConvertAndSave.m | 37 ++++++++++++-----------------------
modules/gui/macosx/MainMenu.m | 10 +---------
modules/gui/macosx/intf.h | 3 +++
modules/gui/macosx/intf.m | 10 ++++++++++
5 files changed, 27 insertions(+), 40 deletions(-)
diff --git a/modules/gui/macosx/ConvertAndSave.h b/modules/gui/macosx/ConvertAndSave.h
index d27edf9..6488964 100644
--- a/modules/gui/macosx/ConvertAndSave.h
+++ b/modules/gui/macosx/ConvertAndSave.h
@@ -27,10 +27,9 @@
@class VLCDropDisabledImageView;
@class VLCDragDropView;
- at interface VLCConvertAndSave : NSObject
+ at interface VLCConvertAndSave : NSWindowController
// main panel
- at 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;
diff --git a/modules/gui/macosx/ConvertAndSave.m b/modules/gui/macosx/ConvertAndSave.m
index 7aa9131..60a72a8 100644
--- a/modules/gui/macosx/ConvertAndSave.m
+++ b/modules/gui/macosx/ConvertAndSave.m
@@ -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...")];
@@ -255,14 +250,6 @@
}
# pragma mark -
-# pragma mark Code to Communicate with other objects
-
-- (void)toggleWindow
-{
- [_window makeKeyAndOrderFront: nil];
-}
-
-# pragma mark -
# pragma mark User Interaction
- (IBAction)finalizePanel:(id)sender
@@ -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
diff --git a/modules/gui/macosx/MainMenu.m b/modules/gui/macosx/MainMenu.m
index 269f37a..9f3c855 100644
--- a/modules/gui/macosx/MainMenu.m
+++ b/modules/gui/macosx/MainMenu.m
@@ -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
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index abae889..9ae31fc 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -68,6 +68,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCTrackSynchronization;
@class VLCAudioEffects;
@class VLCVideoEffects;
+ at 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;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index c9e87fe..23d39b8 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -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)
More information about the vlc-commits
mailing list