Commit 5fb6cff9 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: update singleton creation

parent 9632dfbb
...@@ -66,50 +66,50 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4; ...@@ -66,50 +66,50 @@ const NSTimeInterval HOLD_RECOGNITION_TIME_INTERVAL=0.4;
#pragma public interface #pragma public interface
static AppleRemote *_o_sharedInstance = nil;
+ (AppleRemote *)sharedInstance + (AppleRemote *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static AppleRemote *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [AppleRemote new];
});
return sharedInstance;
} }
- (id)init - (id)init
{ {
if (!_o_sharedInstance) { _openInExclusiveMode = YES;
_o_sharedInstance = [super init]; queue = NULL;
_openInExclusiveMode = YES; hidDeviceInterface = NULL;
queue = NULL; NSMutableDictionary * mutableCookieToButtonMapping = [[NSMutableDictionary alloc] init];
hidDeviceInterface = NULL;
NSMutableDictionary * mutableCookieToButtonMapping = [[NSMutableDictionary alloc] init]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Plus] forKey:@"33_31_30_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Minus] forKey:@"33_32_30_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Plus] forKey:@"33_31_30_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"33_22_21_20_2_33_22_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonVolume_Minus] forKey:@"33_32_30_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"33_23_21_20_2_33_23_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu] forKey:@"33_22_21_20_2_33_22_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"33_24_21_20_2_33_24_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay] forKey:@"33_23_21_20_2_33_23_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"33_25_21_20_2_33_25_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight] forKey:@"33_24_21_20_2_33_24_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold] forKey:@"33_21_20_14_12_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft] forKey:@"33_25_21_20_2_33_25_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"33_21_20_13_12_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonRight_Hold] forKey:@"33_21_20_14_12_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"33_21_20_2_33_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonLeft_Hold] forKey:@"33_21_20_13_12_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"37_33_21_20_2_37_33_21_20_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonMenu_Hold] forKey:@"33_21_20_2_33_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonPlay] forKey:@"33_21_20_8_2_33_21_20_8_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"37_33_21_20_2_37_33_21_20_2_"]; [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonPlay] forKey:@"33_21_20_8_2_33_21_20_8_2_"];
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"]; if( OSX_SNOW_LEOPARD )
/* 10.6.2+ Snow Leopard cookies */
if( OSX_SNOW_LEOPARD ) [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"];
/* 10.6.2+ Snow Leopard cookies */ else
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"19_"]; /* Lion cookies */
else [mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"42_33_23_21_20_2_33_23_21_20_2_"];
/* Lion cookies */
[mutableCookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"42_33_23_21_20_2_33_23_21_20_2_"]; _cookieToButtonMapping = [[NSDictionary alloc] initWithDictionary: mutableCookieToButtonMapping];
_cookieToButtonMapping = [[NSDictionary alloc] initWithDictionary: mutableCookieToButtonMapping]; /* defaults */
_simulatesPlusMinusHold = YES;
/* defaults */ _maximumClickCountTimeDifference = DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE;
_simulatesPlusMinusHold = YES;
_maximumClickCountTimeDifference = DEFAULT_MAXIMUM_CLICK_TIME_DIFFERENCE;
}
return _o_sharedInstance;
} }
- (void) dealloc { - (void) dealloc {
......
...@@ -51,11 +51,17 @@ ...@@ -51,11 +51,17 @@
#pragma mark Initialization #pragma mark Initialization
@implementation VLCAudioEffects @implementation VLCAudioEffects
static VLCAudioEffects *_o_sharedInstance = nil;
+ (VLCAudioEffects *)sharedInstance + (VLCAudioEffects *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCAudioEffects *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCAudioEffects new];
});
return sharedInstance;
} }
+ (void)initialize{ + (void)initialize{
...@@ -94,13 +100,10 @@ static VLCAudioEffects *_o_sharedInstance = nil; ...@@ -94,13 +100,10 @@ static VLCAudioEffects *_o_sharedInstance = nil;
- (id)init - (id)init
{ {
if (!_o_sharedInstance) { self = [super init];
p_intf = VLCIntf; p_intf = VLCIntf;
i_old_profile_index = -1; i_old_profile_index = -1;
_o_sharedInstance = [super init]; return self;
}
return _o_sharedInstance;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
...@@ -65,8 +65,6 @@ ...@@ -65,8 +65,6 @@
@implementation VLCConvertAndSave @implementation VLCConvertAndSave
static VLCConvertAndSave *_o_sharedInstance = nil;
#pragma mark - #pragma mark -
#pragma mark Initialization #pragma mark Initialization
...@@ -120,15 +118,14 @@ static VLCConvertAndSave *_o_sharedInstance = nil; ...@@ -120,15 +118,14 @@ static VLCConvertAndSave *_o_sharedInstance = nil;
+ (VLCConvertAndSave *)sharedInstance + (VLCConvertAndSave *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCConvertAndSave *sharedInstance = nil;
} static dispatch_once_t pred;
- (id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCConvertAndSave new];
if (!_o_sharedInstance) });
_o_sharedInstance = [super init];
return _o_sharedInstance; return sharedInstance;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
...@@ -47,21 +47,19 @@ ...@@ -47,21 +47,19 @@
@end @end
@implementation VLCCoreInteraction @implementation VLCCoreInteraction
static VLCCoreInteraction *_o_sharedInstance = nil;
+ (VLCCoreInteraction *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}
#pragma mark - Initialization #pragma mark - Initialization
- (id)init + (VLCCoreInteraction *)sharedInstance
{ {
if (!_o_sharedInstance) static VLCCoreInteraction *sharedInstance = nil;
_o_sharedInstance = [super init]; static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCCoreInteraction new];
});
return _o_sharedInstance; return sharedInstance;
} }
- (void)dealloc - (void)dealloc
......
...@@ -64,23 +64,27 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char ...@@ -64,23 +64,27 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
@implementation VLCDebugMessageVisualizer @implementation VLCDebugMessageVisualizer
static VLCDebugMessageVisualizer *_sharedMainInstance = nil;
+ (VLCDebugMessageVisualizer *)sharedInstance + (VLCDebugMessageVisualizer *)sharedInstance
{ {
return _sharedMainInstance ? _sharedMainInstance : [[self alloc] init]; static VLCDebugMessageVisualizer *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCDebugMessageVisualizer new];
});
return sharedInstance;
} }
- (id)init - (id)init
{ {
if (!_sharedMainInstance) { self = [super init];
_sharedMainInstance = [super init]; if (self) {
_msg_lock = [[NSLock alloc] init]; _msg_lock = [[NSLock alloc] init];
_msg_arr = [NSMutableArray arrayWithCapacity:600]; _msg_arr = [NSMutableArray arrayWithCapacity:600];
BOOL loaded = [NSBundle loadNibNamed:@"DebugMessageVisualizer" owner:self]; BOOL loaded = [NSBundle loadNibNamed:@"DebugMessageVisualizer" owner:self];
} }
return self;
return _sharedMainInstance;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
...@@ -276,30 +276,36 @@ static int dialogCallback(vlc_object_t *p_this, const char *psz_variable, ...@@ -276,30 +276,36 @@ static int dialogCallback(vlc_object_t *p_this, const char *psz_variable,
@implementation ExtensionsDialogProvider @implementation ExtensionsDialogProvider
static ExtensionsDialogProvider *_o_sharedInstance = nil; static ExtensionsDialogProvider *sharedInstance = nil;
+ (ExtensionsDialogProvider *)sharedInstance:(intf_thread_t *)_p_intf + (ExtensionsDialogProvider *)sharedInstance:(intf_thread_t *)_p_intf
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] initWithIntf:_p_intf];
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [[ExtensionsDialogProvider alloc] initWithIntf:_p_intf];
});
return sharedInstance;
} }
+ (void)killInstance + (void)killInstance
{ {
_o_sharedInstance = nil; sharedInstance = nil;
} }
- (id)initWithIntf:(intf_thread_t *)_p_intf - (id)initWithIntf:(intf_thread_t *)_p_intf
{ {
if (!_o_sharedInstance) { self = [super init];
_o_sharedInstance = [super init]; if (self) {
p_intf = _p_intf; p_intf = _p_intf;
// The Cocoa interface already called dialog_Register() // The Cocoa interface already called dialog_Register()
var_Create(p_intf, "dialog-extension", VLC_VAR_ADDRESS); var_Create(p_intf, "dialog-extension", VLC_VAR_ADDRESS);
var_AddCallback(p_intf, "dialog-extension", dialogCallback, NULL); var_AddCallback(p_intf, "dialog-extension", dialogCallback, NULL);
} }
return self;
return _o_sharedInstance;
} }
- (void)dealloc - (void)dealloc
......
...@@ -74,7 +74,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -74,7 +74,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
break; break;
case INPUT_EVENT_STATISTICS: case INPUT_EVENT_STATISTICS:
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[[[VLCMain sharedInstance] info] updateStatistics]; [[VLCInfo sharedInstance] updateStatistics];
}); });
break; break;
case INPUT_EVENT_ES: case INPUT_EVENT_ES:
...@@ -395,14 +395,14 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -395,14 +395,14 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
- (void)updateMetaAndInfo - (void)updateMetaAndInfo
{ {
if (!p_current_input) { if (!p_current_input) {
[[o_main info] updatePanelWithItem:nil]; [[VLCInfo sharedInstance] updatePanelWithItem:nil];
return; return;
} }
input_item_t *p_input_item = input_GetItem(p_current_input); input_item_t *p_input_item = input_GetItem(p_current_input);
[[[o_main playlist] model] updateItem:p_input_item]; [[[o_main playlist] model] updateItem:p_input_item];
[[o_main info] updatePanelWithItem:p_input_item]; [[VLCInfo sharedInstance] updatePanelWithItem:p_input_item];
} }
- (void)updateMainWindow - (void)updateMainWindow
......
...@@ -55,7 +55,6 @@ ...@@ -55,7 +55,6 @@
@interface VLCMainMenu() @interface VLCMainMenu()
{ {
intf_thread_t *p_intf;
BOOL b_mainMenu_setup; BOOL b_mainMenu_setup;
BOOL b_nib_videoeffects_loaded; BOOL b_nib_videoeffects_loaded;
BOOL b_nib_audioeffects_loaded; BOOL b_nib_audioeffects_loaded;
...@@ -81,20 +80,25 @@ ...@@ -81,20 +80,25 @@
@end @end
@implementation VLCMainMenu @implementation VLCMainMenu
static VLCMainMenu *_o_sharedInstance = nil;
+ (VLCMainMenu *)sharedInstance + (VLCMainMenu *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCMainMenu *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCMainMenu new];
});
return sharedInstance;
} }
#pragma mark - Initialization #pragma mark - Initialization
- (id)init - (id)init
{ {
if (!_o_sharedInstance) { self = [super init];
_o_sharedInstance = [super init]; if (self) {
o_ptc_translation_dict = [[NSDictionary alloc] initWithObjectsAndKeys: o_ptc_translation_dict = [[NSDictionary alloc] initWithObjectsAndKeys:
_NS("Track Number"), TRACKNUM_COLUMN, _NS("Track Number"), TRACKNUM_COLUMN,
_NS("Title"), TITLE_COLUMN, _NS("Title"), TITLE_COLUMN,
...@@ -114,8 +118,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -114,8 +118,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN, DESCRIPTION_COLUMN, DATE_COLUMN, LANGUAGE_COLUMN, URI_COLUMN,
FILESIZE_COLUMN,nil]; FILESIZE_COLUMN,nil];
} }
return self;
return _o_sharedInstance;
} }
- (void)dealloc - (void)dealloc
...@@ -143,8 +146,6 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -143,8 +146,6 @@ static VLCMainMenu *_o_sharedInstance = nil;
[self setRateControlsEnabled:NO]; [self setRateControlsEnabled:NO];
p_intf = VLCIntf;
#ifdef HAVE_SPARKLE #ifdef HAVE_SPARKLE
[o_mi_checkForUpdate setAction:@selector(checkForUpdates:)]; [o_mi_checkForUpdate setAction:@selector(checkForUpdates:)];
[o_mi_checkForUpdate setTarget:[SUUpdater sharedUpdater]]; [o_mi_checkForUpdate setTarget:[SUUpdater sharedUpdater]];
...@@ -167,6 +168,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -167,6 +168,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
return; return;
/* Get ExtensionsManager */ /* Get ExtensionsManager */
intf_thread_t *p_intf = VLCIntf;
o_extMgr = [ExtensionsManager getInstance:p_intf]; o_extMgr = [ExtensionsManager getInstance:p_intf];
[self initStrings]; [self initStrings];
...@@ -332,7 +334,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -332,7 +334,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
module_config_t *p_item; module_config_t *p_item;
[menu removeAllItems]; [menu removeAllItems];
p_item = config_FindConfig(VLC_OBJECT(p_intf), psz_name); p_item = config_FindConfig(VLC_OBJECT(VLCIntf), psz_name);
/* serious problem, if no item found */ /* serious problem, if no item found */
assert(p_item); assert(p_item);
...@@ -344,7 +346,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -344,7 +346,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
else if (p_item->list.i[i]) else if (p_item->list.i[i])
mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: @"%d", p_item->list.i[i]] action:NULL keyEquivalent: @""]; mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: @"%d", p_item->list.i[i]] action:NULL keyEquivalent: @""];
else { else {
msg_Err(p_intf, "item %d of pref %s failed to be created", i, psz_name); msg_Err(VLCIntf, "item %d of pref %s failed to be created", i, psz_name);
continue; continue;
} }
...@@ -566,8 +568,6 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -566,8 +568,6 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (void)releaseRepresentedObjects:(NSMenu *)the_menu - (void)releaseRepresentedObjects:(NSMenu *)the_menu
{ {
if (!p_intf) return;
NSArray *menuitems_array = [the_menu itemArray]; NSArray *menuitems_array = [the_menu itemArray];
NSUInteger menuItemCount = [menuitems_array count]; NSUInteger menuItemCount = [menuitems_array count];
for (NSUInteger i=0; i < menuItemCount; i++) { for (NSUInteger i=0; i < menuItemCount; i++) {
...@@ -583,7 +583,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -583,7 +583,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (void)setupMenus - (void)setupMenus
{ {
playlist_t * p_playlist = pl_Get(p_intf); playlist_t * p_playlist = pl_Get(VLCIntf);
input_thread_t * p_input = playlist_CurrentInput(p_playlist); input_thread_t * p_input = playlist_CurrentInput(p_playlist);
if (p_input != NULL) { if (p_input != NULL) {
[self setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input [self setupVarMenuItem: o_mi_program target: (vlc_object_t *)p_input
...@@ -792,7 +792,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -792,7 +792,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
playlist_t *p_playlist = pl_Get(VLCIntf); playlist_t *p_playlist = pl_Get(VLCIntf);
bool b_value = !var_CreateGetBool(p_playlist, "play-and-exit"); bool b_value = !var_CreateGetBool(p_playlist, "play-and-exit");
var_SetBool(p_playlist, "play-and-exit", b_value); var_SetBool(p_playlist, "play-and-exit", b_value);
config_PutInt(p_intf, "play-and-exit", b_value); config_PutInt(VLCIntf, "play-and-exit", b_value);
} }
- (IBAction)toggleRecord:(id)sender - (IBAction)toggleRecord:(id)sender
...@@ -926,7 +926,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -926,7 +926,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
vout_thread_t *p_vout = getVoutForActiveWindow(); vout_thread_t *p_vout = getVoutForActiveWindow();
if (p_vout) { if (p_vout) {
BOOL b_fs = var_ToggleBool(p_vout, "video-on-top"); BOOL b_fs = var_ToggleBool(p_vout, "video-on-top");
var_SetBool(pl_Get(p_intf), "video-on-top", b_fs); var_SetBool(pl_Get(VLCIntf), "video-on-top", b_fs);
vlc_object_release(p_vout); vlc_object_release(p_vout);
} }
...@@ -1030,7 +1030,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -1030,7 +1030,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
int intValue = [sender tag]; int intValue = [sender tag];
NSString *representedObject = [sender representedObject]; NSString *representedObject = [sender representedObject];
config_PutInt(p_intf, [representedObject UTF8String], intValue); config_PutInt(VLCIntf, [representedObject UTF8String], intValue);
NSMenu *menu = [sender menu]; NSMenu *menu = [sender menu];
NSUInteger count = (NSUInteger) [menu numberOfItems]; NSUInteger count = (NSUInteger) [menu numberOfItems];
...@@ -1041,7 +1041,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -1041,7 +1041,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)switchSubtitleBackgroundOpacity:(id)sender - (IBAction)switchSubtitleBackgroundOpacity:(id)sender
{ {
config_PutInt(p_intf, "freetype-background-opacity", [sender intValue]); config_PutInt(VLCIntf, "freetype-background-opacity", [sender intValue]);
} }
- (IBAction)telxTransparent:(id)sender - (IBAction)telxTransparent:(id)sender
...@@ -1272,7 +1272,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -1272,7 +1272,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)showInformationPanel:(id)sender - (IBAction)showInformationPanel:(id)sender
{ {
[[[VLCMain sharedInstance] info] initPanel]; [[VLCInfo sharedInstance] initPanel];
} }
#pragma mark - convinience stuff for other objects #pragma mark - convinience stuff for other objects
...@@ -1528,7 +1528,7 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -1528,7 +1528,7 @@ static VLCMainMenu *_o_sharedInstance = nil;
NSString *o_title = [o_mi title]; NSString *o_title = [o_mi title];
BOOL bEnabled = TRUE; BOOL bEnabled = TRUE;
vlc_value_t val; vlc_value_t val;
playlist_t * p_playlist = pl_Get(p_intf); playlist_t * p_playlist = pl_Get(VLCIntf);
input_thread_t * p_input = playlist_CurrentInput(p_playlist); input_thread_t * p_input = playlist_CurrentInput(p_playlist);
if ([o_title isEqualToString: _NS("Stop")]) { if ([o_title isEqualToString: _NS("Stop")]) {
......
...@@ -77,34 +77,32 @@ static const float f_min_window_height = 307.; ...@@ -77,34 +77,32 @@ static const float f_min_window_height = 307.;
@implementation VLCMainWindow @implementation VLCMainWindow
static VLCMainWindow *_o_sharedInstance = nil;
+ (VLCMainWindow *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}
#pragma mark - #pragma mark -
#pragma mark Initialization #pragma mark Initialization
- (id)init static VLCMainWindow *sharedInstance = nil;
+ (VLCMainWindow *)sharedInstance
{ {
if (!_o_sharedInstance) return sharedInstance;
_o_sharedInstance = [super init];
return _o_sharedInstance;
} }
- (id)initWithContentRect:(NSRect)contentRect styleMask:(NSUInteger)styleMask - (id)initWithContentRect:(NSRect)contentRect
backing:(NSBackingStoreType)backingType defer:(BOOL)flag styleMask:(NSUInteger)styleMask
backing:(NSBackingStoreType)backingType
defer:(BOOL)flag
{ {
self = [super initWithContentRect:contentRect styleMask:styleMask static dispatch_once_t pred;
backing:backingType defer:flag];
_o_sharedInstance = self; dispatch_once(&pred, ^{
sharedInstance = [super initWithContentRect:contentRect
styleMask:styleMask
backing:backingType
defer:flag];
});
[[VLCMain sharedInstance] updateTogglePlaylistState]; [[VLCMain sharedInstance] updateTogglePlaylistState];
return self; return sharedInstance;
} }
- (BOOL)isEvent:(NSEvent *)o_event forKey:(const char *)keyString - (BOOL)isEvent:(NSEvent *)o_event forKey:(const char *)keyString
......
...@@ -23,21 +23,17 @@ ...@@ -23,21 +23,17 @@
#import "SharedDialogs.h" #import "SharedDialogs.h"
static VLCEnterTextPanel *_textPanelInstance = nil;
static VLCSelectItemInPopupPanel *_selectItemPanelInstance = nil;
@implementation VLCEnterTextPanel @implementation VLCEnterTextPanel
+ (VLCEnterTextPanel *)sharedInstance + (VLCEnterTextPanel *)sharedInstance
{ {
return _textPanelInstance ? _textPanelInstance : [[self alloc] init]; static VLCEnterTextPanel *sharedInstance = nil;
} static dispatch_once_t pred;
- (id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCEnterTextPanel new];
if (!_textPanelInstance) });
_textPanelInstance = [super init];
return _textPanelInstance; return sharedInstance;
} }
- (IBAction)windowElementAction:(id)sender - (IBAction)windowElementAction:(id)sender
...@@ -77,15 +73,14 @@ static VLCSelectItemInPopupPanel *_selectItemPanelInstance = nil; ...@@ -77,15 +73,14 @@ static VLCSelectItemInPopupPanel *_selectItemPanelInstance = nil;
+ (VLCSelectItemInPopupPanel *)sharedInstance + (VLCSelectItemInPopupPanel *)sharedInstance
{ {
return _selectItemPanelInstance ? _selectItemPanelInstance : [[self alloc] init]; static VLCSelectItemInPopupPanel *sharedInstance = nil;
} static dispatch_once_t pred;
- (id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCSelectItemInPopupPanel new];
if (!_selectItemPanelInstance) });
_selectItemPanelInstance = [super init];
return _selectItemPanelInstance; return sharedInstance;
} }
- (IBAction)windowElementAction:(id)sender - (IBAction)windowElementAction:(id)sender
......
...@@ -33,19 +33,17 @@ ...@@ -33,19 +33,17 @@
@implementation VLCStringUtility @implementation VLCStringUtility
static VLCStringUtility *_o_sharedInstance = nil;
+ (VLCStringUtility *)sharedInstance + (VLCStringUtility *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCStringUtility *sharedInstance = nil;
} static dispatch_once_t pred;
- (id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCStringUtility new];
if (!_o_sharedInstance) });
_o_sharedInstance = [super init];
return _o_sharedInstance; return sharedInstance;
} }
#pragma mark - #pragma mark -
......
...@@ -41,21 +41,24 @@ ...@@ -41,21 +41,24 @@
@end @end
@implementation VLCTrackSynchronization @implementation VLCTrackSynchronization
static VLCTrackSynchronization *_o_sharedInstance = nil;
+ (VLCTrackSynchronization *)sharedInstance + (VLCTrackSynchronization *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCTrackSynchronization *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCTrackSynchronization new];
});
return sharedInstance;
} }
- (id)init - (id)init
{ {
if (!_o_sharedInstance) { self = [super init];
p_intf = VLCIntf; p_intf = VLCIntf;
_o_sharedInstance = [super init]; return self;
}
return _o_sharedInstance;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
...@@ -430,7 +430,7 @@ ...@@ -430,7 +430,7 @@
[[VLCVideoEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCVideoEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[VLCAudioEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCAudioEffects sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[[VLCMain sharedInstance] info] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCInfo sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[VLCBookmarks sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCBookmarks sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[VLCTrackSynchronization sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[VLCTrackSynchronization sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel];
[[[VLCMain sharedInstance] resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel]; [[[VLCMain sharedInstance] resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel];
......
...@@ -39,11 +39,17 @@ ...@@ -39,11 +39,17 @@
#pragma mark Initialization #pragma mark Initialization
@implementation VLCVideoEffects @implementation VLCVideoEffects
static VLCVideoEffects *_o_sharedInstance = nil;
+ (VLCVideoEffects *)sharedInstance + (VLCVideoEffects *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCVideoEffects *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCVideoEffects new];
});
return sharedInstance;
} }
+ (void)initialize + (void)initialize
...@@ -55,13 +61,11 @@ static VLCVideoEffects *_o_sharedInstance = nil; ...@@ -55,13 +61,11 @@ static VLCVideoEffects *_o_sharedInstance = nil;
- (id)init - (id)init
{ {
if (!_o_sharedInstance) { self = [super init];
p_intf = VLCIntf; p_intf = VLCIntf;
i_old_profile_index = -1; i_old_profile_index = -1;
_o_sharedInstance = [super init];
}
return _o_sharedInstance; return self;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
...@@ -47,19 +47,16 @@ ...@@ -47,19 +47,16 @@
@implementation VLCBookmarks @implementation VLCBookmarks
static VLCBookmarks *_o_sharedInstance = nil;
+ (VLCBookmarks *)sharedInstance + (VLCBookmarks *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCBookmarks *sharedInstance = nil;
} static dispatch_once_t pred;
- (id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCBookmarks new];
if (!_o_sharedInstance) });
_o_sharedInstance = [super init];
return _o_sharedInstance; return sharedInstance;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -40,32 +40,27 @@ ...@@ -40,32 +40,27 @@
@implementation VLCCoreDialogProvider @implementation VLCCoreDialogProvider
static VLCCoreDialogProvider *_o_sharedInstance = nil;
+ (VLCCoreDialogProvider *)sharedInstance + (VLCCoreDialogProvider *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCCoreDialogProvider *sharedInstance = nil;
} static dispatch_once_t pred;
-(id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCCoreDialogProvider new];
if (!_o_sharedInstance) { });
_o_sharedInstance = [super init];
_progressCancelled = NO;
}
return _o_sharedInstance; return sharedInstance;
} }
-(void)awakeFromNib -(void)awakeFromNib
{ {
_progressCancelled = NO;
[o_auth_login_txt setStringValue: _NS("Username")]; [o_auth_login_txt setStringValue: _NS("Username")];
[o_auth_pw_txt setStringValue: _NS("Password")]; [o_auth_pw_txt setStringValue: _NS("Password")];
[o_auth_cancel_btn setTitle: _NS("Cancel")]; [o_auth_cancel_btn setTitle: _NS("Cancel")];
[o_auth_ok_btn setTitle: _NS("OK")]; [o_auth_ok_btn setTitle: _NS("OK")];
[o_prog_cancel_btn setTitle: _NS("Cancel")]; [o_prog_cancel_btn setTitle: _NS("Cancel")];
[o_prog_bar setUsesThreadedAnimation: YES]; [o_prog_bar setUsesThreadedAnimation: YES];
} }
-(void)performEventWithObject: (NSValue *)o_value ofType: (const char*)type -(void)performEventWithObject: (NSValue *)o_value ofType: (const char*)type
......
...@@ -30,27 +30,30 @@ ...@@ -30,27 +30,30 @@
@implementation VLCEyeTVController @implementation VLCEyeTVController
static VLCEyeTVController *_o_sharedInstance = nil;
+ (VLCEyeTVController *)sharedInstance + (VLCEyeTVController *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCEyeTVController *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCEyeTVController new];
});
return sharedInstance;
} }
- (id)init - (id)init
{ {
if (!_o_sharedInstance) { self = [super init];
_o_sharedInstance = [super init]; if (self) {
[[NSDistributedNotificationCenter defaultCenter] [[NSDistributedNotificationCenter defaultCenter]
addObserver: self addObserver:self
selector: @selector(globalNotificationReceived:) selector:@selector(globalNotificationReceived:)
name: NULL name:NULL
object: @"VLCEyeTVSupport" object:@"VLCEyeTVSupport"
suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately]; suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];
} }
return self;
return _o_sharedInstance;
} }
- (void)globalNotificationReceived: (NSNotification *)theNotification - (void)globalNotificationReceived: (NSNotification *)theNotification
......
...@@ -92,7 +92,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -92,7 +92,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (id)simplePreferences; - (id)simplePreferences;
- (id)preferences; - (id)preferences;
- (VLCPlaylist *)playlist; - (VLCPlaylist *)playlist;
- (VLCInfo *)info;
- (id)wizard; - (id)wizard;
- (id)coreDialogProvider; - (id)coreDialogProvider;
- (ResumeDialogController *)resumeDialog; - (ResumeDialogController *)resumeDialog;
......
...@@ -544,17 +544,21 @@ audio_output_t *getAout(void) ...@@ -544,17 +544,21 @@ audio_output_t *getAout(void)
#pragma mark - #pragma mark -
#pragma mark Initialization #pragma mark Initialization
static VLCMain *_o_sharedMainInstance = nil;
+ (VLCMain *)sharedInstance + (VLCMain *)sharedInstance
{ {
return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init]; static VLCMain *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCMain new];
});
return sharedInstance;
} }
- (id)init - (id)init
{ {
if (!_o_sharedMainInstance) self = [super init];
_o_sharedMainInstance = [super init];
p_intf = NULL; p_intf = NULL;
...@@ -576,7 +580,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -576,7 +580,7 @@ static VLCMain *_o_sharedMainInstance = nil;
_voutController = [[VLCVoutWindowController alloc] init]; _voutController = [[VLCVoutWindowController alloc] init];
return _o_sharedMainInstance; return self;
} }
- (void)setIntf: (intf_thread_t *)p_mainintf - (void)setIntf: (intf_thread_t *)p_mainintf
...@@ -641,7 +645,7 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -641,7 +645,7 @@ static VLCMain *_o_sharedMainInstance = nil;
/* init Apple Remote support */ /* init Apple Remote support */
o_remote = [[AppleRemote alloc] init]; o_remote = [[AppleRemote alloc] init];
[o_remote setClickCountEnabledButtons: kRemoteButtonPlay]; [o_remote setClickCountEnabledButtons: kRemoteButtonPlay];
[o_remote setDelegate: _o_sharedMainInstance]; [o_remote setDelegate: self];
/* yeah, we are done */ /* yeah, we are done */
_nativeFullscreenMode = NO; _nativeFullscreenMode = NO;
...@@ -1312,17 +1316,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -1312,17 +1316,6 @@ static VLCMain *_o_sharedMainInstance = nil;
return o_playlist; return o_playlist;
} }
- (VLCInfo *)info
{
if (!o_info)
o_info = [[VLCInfo alloc] init];
if (! nib_info_loaded)
nib_info_loaded = [NSBundle loadNibNamed:@"MediaInfo" owner: NSApp];
return o_info;
}
- (id)wizard - (id)wizard
{ {
if (!o_wizard) if (!o_wizard)
......
...@@ -97,19 +97,16 @@ struct display_info_t ...@@ -97,19 +97,16 @@ struct display_info_t
#pragma mark - #pragma mark -
#pragma mark Init #pragma mark Init
static VLCOpen *_o_sharedMainInstance = nil;
+ (VLCOpen *)sharedInstance + (VLCOpen *)sharedInstance
{ {
return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init]; static VLCOpen *sharedInstance = nil;
} static dispatch_once_t pred;
- (id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCOpen new];
if (!_o_sharedMainInstance) });
_o_sharedMainInstance = [super init];
return _o_sharedMainInstance; return sharedInstance;
} }
- (void)dealloc - (void)dealloc
......
...@@ -330,7 +330,7 @@ ...@@ -330,7 +330,7 @@
// } // }
// //
// /* update our info-panel to reflect the new item */ // /* update our info-panel to reflect the new item */
// [[[VLCMain sharedInstance] info] updatePanelWithItem:p_item->p_input]; // [[VLCInfo sharedInstance] updatePanelWithItem:p_item->p_input];
// } // }
} }
...@@ -542,7 +542,7 @@ ...@@ -542,7 +542,7 @@
- (IBAction)showInfoPanel:(id)sender - (IBAction)showInfoPanel:(id)sender
{ {
[[[VLCMain sharedInstance] info] initPanel]; [[VLCInfo sharedInstance] initPanel];
} }
- (void)deletionCompleted - (void)deletionCompleted
......
...@@ -156,23 +156,27 @@ ...@@ -156,23 +156,27 @@
@implementation VLCPrefs @implementation VLCPrefs
static VLCPrefs *_o_sharedMainInstance = nil;
+ (VLCPrefs *)sharedInstance + (VLCPrefs *)sharedInstance
{ {
return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init]; static VLCPrefs *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCPrefs new];
});
return sharedInstance;
} }
- (id)init - (id)init
{ {
if (!_o_sharedMainInstance) { self = [super init];
_o_sharedMainInstance = [super init]; if (self) {
p_intf = VLCIntf; p_intf = VLCIntf;
o_empty_view = [[NSView alloc] init]; o_empty_view = [[NSView alloc] init];
_rootTreeItem = [[VLCTreeMainItem alloc] init]; _rootTreeItem = [[VLCTreeMainItem alloc] init];
} }
return self;
return _o_sharedMainInstance;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
...@@ -202,23 +202,25 @@ static NSString* VLCHotkeysSettingToolbarIdentifier = @"Hotkeys Settings Item Id ...@@ -202,23 +202,25 @@ static NSString* VLCHotkeysSettingToolbarIdentifier = @"Hotkeys Settings Item Id
@implementation VLCSimplePrefs @implementation VLCSimplePrefs
static VLCSimplePrefs *_o_sharedInstance = nil;
#pragma mark Initialisation #pragma mark Initialisation
+ (VLCSimplePrefs *)sharedInstance + (VLCSimplePrefs *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCSimplePrefs *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCSimplePrefs new];
});
return sharedInstance;
} }
- (id)init - (id)init
{ {
if (!_o_sharedInstance) { self = [super init];
_o_sharedInstance = [super init]; p_intf = VLCIntf;
p_intf = VLCIntf; return self;
}
return _o_sharedInstance;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
...@@ -55,20 +55,16 @@ ...@@ -55,20 +55,16 @@
@implementation VLCWizard @implementation VLCWizard
static VLCWizard *_o_sharedInstance = nil;
+ (VLCWizard *)sharedInstance + (VLCWizard *)sharedInstance
{ {
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init]; static VLCWizard *sharedInstance = nil;
} static dispatch_once_t pred;
- (id)init dispatch_once(&pred, ^{
{ sharedInstance = [VLCWizard new];
if (!_o_sharedInstance) { });
_o_sharedInstance = [super init];
}
return _o_sharedInstance; return sharedInstance;
} }
- (void)awakeFromNib - (void)awakeFromNib
......
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