[vlc-commits] macosx: don't use NSNotifcations to handle VLC's dialog callbacks, always perform NSAlert and friends on main thread
Felix Paul Kühne
git at videolan.org
Sun Jul 24 15:32:04 CEST 2011
vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Jul 24 15:31:59 2011 +0200| [fca62c4911f707c776d33014c0b7cba88eebeb2f] | committer: Felix Paul Kühne
macosx: don't use NSNotifcations to handle VLC's dialog callbacks, always perform NSAlert and friends on main thread
additionally, removed 2 clients of the manageInterface loop, which will be removed all together shortly
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fca62c4911f707c776d33014c0b7cba88eebeb2f
---
modules/gui/macosx/coredialogs.h | 2 +-
modules/gui/macosx/coredialogs.m | 19 +++++++++----------
modules/gui/macosx/intf.h | 2 --
modules/gui/macosx/intf.m | 28 ++++++++++------------------
4 files changed, 20 insertions(+), 31 deletions(-)
diff --git a/modules/gui/macosx/coredialogs.h b/modules/gui/macosx/coredialogs.h
index 66b2f8b..ea3829c 100644
--- a/modules/gui/macosx/coredialogs.h
+++ b/modules/gui/macosx/coredialogs.h
@@ -78,7 +78,7 @@
}
+ (VLCCoreDialogProvider *)sharedInstance;
--(void)performDialogEvent: (NSNotification *)o_notification;
+-(void)performEventWithObject: (NSValue *)o_value ofType: (const char*)type;
-(void)showFatalDialog: (NSValue *)o_value;
-(void)showFatalWaitDialog: (NSValue *)o_value;
diff --git a/modules/gui/macosx/coredialogs.m b/modules/gui/macosx/coredialogs.m
index 078d4ba..b42d29d 100644
--- a/modules/gui/macosx/coredialogs.m
+++ b/modules/gui/macosx/coredialogs.m
@@ -68,25 +68,24 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
[o_prog_cancel_btn setTitle: _NS("Cancel")];
[o_prog_bar setUsesThreadedAnimation: YES];
-}
+}
--(void)performDialogEvent: (NSNotification *)o_notification
+-(void)performEventWithObject: (NSValue *)o_value ofType: (const char*)type
{
- NSValue *o_value = [[o_notification userInfo] objectForKey:@"VLCDialogPointer"];
- NSString *o_type = [[o_notification userInfo] objectForKey:@"VLCDialogType"];
+ NSString *o_type = [NSString stringWithUTF8String:type];
if( [o_type isEqualToString: @"dialog-error"] )
- [self showFatalDialog: o_value];
+ [self performSelectorOnMainThread:@selector(showFatalDialog:) withObject:o_value waitUntilDone:YES];
else if( [o_type isEqualToString: @"dialog-critical"] )
- [self showFatalWaitDialog: o_value];
+ [self performSelectorOnMainThread:@selector(showFatalWaitDialog:) withObject:o_value waitUntilDone:YES];
else if( [o_type isEqualToString: @"dialog-question"] )
- [self showQuestionDialog: o_value];
+ [self performSelectorOnMainThread:@selector(showQuestionDialog:) withObject:o_value waitUntilDone:YES];
else if( [o_type isEqualToString: @"dialog-login"] )
- [self showLoginDialog: o_value];
+ [self performSelectorOnMainThread:@selector(showLoginDialog:) withObject:o_value waitUntilDone:YES];
else if( [o_type isEqualToString: @"dialog-progress-bar"] )
- [self showProgressDialog: o_value];
+ [self performSelectorOnMainThread:@selector(showProgressDialog:) withObject:o_value waitUntilDone:YES];
else
- msg_Err( VLCIntf, "unhandled dialog type: '%s'", [o_type UTF8String] );
+ msg_Err( VLCIntf, "unhandled dialog type: '%s'", type );
}
-(void)showFatalDialog: (NSValue *)o_value
diff --git a/modules/gui/macosx/intf.h b/modules/gui/macosx/intf.h
index 57a4edc..37c39e1 100644
--- a/modules/gui/macosx/intf.h
+++ b/modules/gui/macosx/intf.h
@@ -75,8 +75,6 @@ struct intf_sys_t
bool b_playlist_update;
bool b_playmode_update;
bool b_current_title_update;
- bool b_fullscreen_update;
- bool b_intf_show;
/* menus handlers */
bool b_input_update;
diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index 765d36c..161779b 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -248,7 +248,14 @@ static int ShowController( vlc_object_t *p_this, const char *psz_variable,
{
intf_thread_t * p_intf = VLCIntf;
if( p_intf && p_intf->p_sys )
- p_intf->p_sys->b_intf_show = true;
+ {
+ NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
+ if( [[[VLCCoreInteraction sharedInstance] voutView] isFullscreen] && config_GetInt( VLCIntf, "macosx-fspanel" ) )
+ [[[[VLCMain sharedInstance] controls] fspanel] fadeIn];
+ else
+ [[VLCMainWindow sharedInstance] makeKeyAndOrderFront: nil];
+ [o_pool release];
+ }
return VLC_SUCCESS;
}
@@ -261,7 +268,7 @@ static int FullscreenChanged( vlc_object_t *p_this, const char *psz_variable,
{
intf_thread_t * p_intf = VLCIntf;
if( p_intf && p_intf->p_sys )
- p_intf->p_sys->b_fullscreen_update = true;
+ NSLog( @"we should update fullscreen state" ); //FIXME
return VLC_SUCCESS;
}
@@ -286,7 +293,7 @@ static int DialogCallback( vlc_object_t *p_this, const char *type, vlc_value_t p
}
NSValue *o_value = [NSValue valueWithPointer:value.p_address];
- [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCNewCoreDialogEventNotification" object:[interface coreDialogProvider] userInfo:[NSDictionary dictionaryWithObjectsAndKeys: o_value, @"VLCDialogPointer", [NSString stringWithUTF8String: type], @"VLCDialogType", nil]];
+ [[VLCCoreDialogProvider sharedInstance] performEventWithObject: o_value ofType: type];
[o_pool release];
return VLC_SUCCESS;
@@ -1374,21 +1381,6 @@ static void manage_cleanup( void * args )
p_intf->p_sys->b_playlist_update = false;
}
- if( p_intf->p_sys->b_fullscreen_update )
- {
- p_intf->p_sys->b_fullscreen_update = false;
- }
-
- if( p_intf->p_sys->b_intf_show )
- {
- if( [[o_coreinteraction voutView] isFullscreen] && config_GetInt( VLCIntf, "macosx-fspanel" ) )
- [[o_controls fspanel] fadeIn];
- else
- [o_mainwindow makeKeyAndOrderFront: self];
-
- p_intf->p_sys->b_intf_show = false;
- }
-
p_input = pl_CurrentInput( p_intf );
if( p_input && vlc_object_alive (p_input) )
{
More information about the vlc-commits
mailing list