Commit 4aa458cd authored by David Fuhrmann's avatar David Fuhrmann

macosx: fix coredialog provider, fix dialog initialization

This removes the singleton, fixes the xib, and initializes
the dialog provider class at the correct time. dialog_Register
will be called only once now.
parent 673cd4db
......@@ -273,7 +273,7 @@ static int extensionDialogCallback(vlc_object_t *p_this, const char *psz_variabl
intf_thread_t *p_intf = VLCIntf;
var_Create(p_intf, "dialog-extension", VLC_VAR_ADDRESS);
var_AddCallback(p_intf, "dialog-extension", extensionDialogCallback, (__bridge void *)self);
dialog_Register(p_intf);
// dialog_Register(p_intf) is called by coredialog provider
}
return self;
}
......
......@@ -51,7 +51,6 @@
IBOutlet id o_prog_title_txt;
IBOutlet id o_prog_win;
}
+ (VLCCoreDialogProvider *)sharedInstance;
@property (atomic,readwrite) BOOL progressCancelled;
......
......@@ -29,55 +29,56 @@
/* for the icon in our custom error panel */
#import <ApplicationServices/ApplicationServices.h>
static void updateProgressPanel (void *, const char *, float);
static bool checkProgressPanel (void *);
static void destroyProgressPanel (void *);
static int DialogCallback(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
void updateProgressPanel (void *data, const char *text, float value)
{
@autoreleasepool {
if ([toNSStr(type) isEqualToString: @"dialog-progress-bar"]) {
/* the progress panel needs to update itself and therefore wants special treatment within this context */
dialog_progress_bar_t *p_dialog = (dialog_progress_bar_t *)value.p_address;
p_dialog->pf_update = updateProgressPanel;
p_dialog->pf_check = checkProgressPanel;
p_dialog->pf_destroy = destroyProgressPanel;
p_dialog->p_sys = VLCIntf->p_libvlc;
}
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)data;
NSValue *o_value = [NSValue valueWithPointer:value.p_address];
[[VLCCoreDialogProvider sharedInstance] performEventWithObject: o_value ofType: type];
return VLC_SUCCESS;
}
}
void updateProgressPanel (void *priv, const char *text, float value)
{
@autoreleasepool {
NSString *o_txt = toNSStr(text);
dispatch_async(dispatch_get_main_queue(), ^{
[[VLCCoreDialogProvider sharedInstance] updateProgressPanelWithText: o_txt andNumber: (double)(value * 1000.)];
[dialogProvider updateProgressPanelWithText: o_txt andNumber: (double)(value * 1000.)];
});
}
}
void destroyProgressPanel (void *priv)
void destroyProgressPanel (void *data)
{
@autoreleasepool {
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)data;
if ([[NSApplication sharedApplication] isRunning])
[[VLCCoreDialogProvider sharedInstance] performSelectorOnMainThread:@selector(destroyProgressPanel) withObject:nil waitUntilDone:YES];
[dialogProvider performSelectorOnMainThread:@selector(destroyProgressPanel) withObject:nil waitUntilDone:YES];
}
}
bool checkProgressPanel (void *priv)
bool checkProgressPanel (void *data)
{
@autoreleasepool {
return [[VLCCoreDialogProvider sharedInstance] progressCancelled];
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)data;
return [dialogProvider progressCancelled];
}
}
static int DialogCallback(vlc_object_t *p_this, const char *type, vlc_value_t previous, vlc_value_t value, void *data)
{
@autoreleasepool {
VLCCoreDialogProvider *dialogProvider = (__bridge VLCCoreDialogProvider *)data;
if ([toNSStr(type) isEqualToString: @"dialog-progress-bar"]) {
/* the progress panel needs to update itself and therefore wants special treatment within this context */
dialog_progress_bar_t *p_dialog = (dialog_progress_bar_t *)value.p_address;
p_dialog->pf_update = updateProgressPanel;
p_dialog->pf_check = checkProgressPanel;
p_dialog->pf_destroy = destroyProgressPanel;
p_dialog->p_sys = (__bridge void *)dialogProvider;
}
NSValue *o_value = [NSValue valueWithPointer:value.p_address];
[dialogProvider performEventWithObject: o_value ofType: type];
return VLC_SUCCESS;
}
}
@interface VLCCoreDialogProvider()
{
......@@ -87,23 +88,14 @@ bool checkProgressPanel (void *priv)
@implementation VLCCoreDialogProvider
+ (VLCCoreDialogProvider *)sharedInstance
{
static VLCCoreDialogProvider *sharedInstance = nil;
static dispatch_once_t pred;
dispatch_once(&pred, ^{
sharedInstance = [VLCCoreDialogProvider new];
});
return sharedInstance;
}
- (instancetype)init
{
self = [super init];
if (self) {
msg_Dbg(VLCIntf, "Register dialog provider");
[NSBundle loadNibNamed:@"CoreDialogs" owner: self];
intf_thread_t *p_intf = VLCIntf;
/* subscribe to various interactive dialogues */
var_Create(p_intf, "dialog-error", VLC_VAR_ADDRESS);
......@@ -118,18 +110,21 @@ bool checkProgressPanel (void *priv)
var_AddCallback(p_intf, "dialog-progress-bar", DialogCallback, (__bridge void *)self);
dialog_Register(p_intf);
}
return self;
}
- (void)dealloc
{
msg_Dbg(VLCIntf, "Deinitializing dialog provider");
intf_thread_t *p_intf = VLCIntf;
dialog_Unregister(p_intf);
var_DelCallback(p_intf, "dialog-error", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-critical", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-login", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-question", DialogCallback, (__bridge void *)self);
var_DelCallback(p_intf, "dialog-progress-bar", DialogCallback, (__bridge void *)self);
dialog_Unregister(p_intf);
}
-(void)awakeFromNib
......
......@@ -154,7 +154,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
int items_at_launch;
BOOL nib_about_loaded; /* about nibfile */
BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
BOOL b_active_videoplayback;
NSWindowController *_mainWindowController;
......@@ -215,7 +214,11 @@ static VLCMain *sharedInstance = nil;
[VLCApplication sharedApplication].delegate = self;
_input_manager = [[VLCInputManager alloc] initWithMain:self];
// first initalize extensions dialog provider, then core dialog
// provider which will register both at the core
_extensionsManager = [[ExtensionsManager alloc] init];
_coredialogs = [[VLCCoreDialogProvider alloc] init];
_mainmenu = [[VLCMainMenu alloc] init];
_voutController = [[VLCVoutWindowController alloc] init];
......@@ -600,11 +603,6 @@ static VLCMain *sharedInstance = nil;
- (VLCCoreDialogProvider *)coreDialogProvider
{
_coredialogs = [VLCCoreDialogProvider sharedInstance];
if (!nib_coredialogs_loaded) {
nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: _coredialogs];
}
return _coredialogs;
}
......
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