Commit afe0a0c2 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: finally completed the progress-panel's implementation

parent b91b6e06
...@@ -69,23 +69,28 @@ ...@@ -69,23 +69,28 @@
IBOutlet id o_auth_win; IBOutlet id o_auth_win;
/* progress dialogue */ /* progress dialogue */
IBOutlet id o_prog_bar; IBOutlet NSProgressIndicator * o_prog_bar;
IBOutlet id o_prog_cancel_btn; IBOutlet id o_prog_cancel_btn;
IBOutlet id o_prog_description_txt; IBOutlet id o_prog_description_txt;
IBOutlet id o_prog_title_txt; IBOutlet id o_prog_title_txt;
IBOutlet id o_prog_win; IBOutlet id o_prog_win;
BOOL b_progress_cancelled;
} }
+ (VLCCoreDialogProvider *)sharedInstance; + (VLCCoreDialogProvider *)sharedInstance;
-(void)performDialogEvent: (NSNotification *)o_notification; -(void)performDialogEvent: (NSNotification *)o_notification;
-(void)performProgressBarEvent: (NSNotification *)o_notification;
-(void)showFatalDialog: (NSValue *)o_value; -(void)showFatalDialog: (NSValue *)o_value;
-(void)showQuestionDialog: (NSValue *)o_value; -(void)showQuestionDialog: (NSValue *)o_value;
-(void)showLoginDialog: (NSValue *)o_value; -(void)showLoginDialog: (NSValue *)o_value;
-(IBAction)loginDialogAction:(id)sender; -(IBAction)loginDialogAction:(id)sender;
-(void)showProgressDialog: (NSValue *)o_value; -(void)showProgressDialog: (NSValue *)o_value;
-(IBAction)progDialogAction:(id)sender; -(IBAction)progDialogAction:(id)sender;
-(BOOL)progressCancelled;
-(void)updateProgressPanelWithText: (NSString *)string andNumber: (double)d_number;
-(void)destroyProgressPanel;
-(id)errorPanel; -(id)errorPanel;
......
...@@ -29,16 +29,6 @@ ...@@ -29,16 +29,6 @@
/* for the icon in our custom error panel */ /* for the icon in our custom error panel */
#import <ApplicationServices/ApplicationServices.h> #import <ApplicationServices/ApplicationServices.h>
/*****************************************************************************
* Local prototypes.
*****************************************************************************/
bool b_progress_cancelled;
static void updateProgressPanel (void *, const char *, float);
static bool checkProgressPanel (void *);
static void destroyProgressPanel (void *);
/***************************************************************************** /*****************************************************************************
* VLCCoreDialogProvider implementation * VLCCoreDialogProvider implementation
*****************************************************************************/ *****************************************************************************/
...@@ -62,14 +52,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil; ...@@ -62,14 +52,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
selector:@selector(performDialogEvent:) selector:@selector(performDialogEvent:)
name: @"VLCNewCoreDialogEventNotification" name: @"VLCNewCoreDialogEventNotification"
object:self]; object:self];
[[NSNotificationCenter defaultCenter] addObserver: self
selector:@selector(performProgressBarEvent:)
name:@"VLCCoreDialogProgressBarUpdateNotification"
object: self];
[[NSNotificationCenter defaultCenter] addObserver: self
selector:@selector(performProgressBarEvent:)
name:@"VLCCoreDialogProgressBarDestroyNotification"
object: self];
o_error_panel = [[VLCErrorPanel alloc] init]; o_error_panel = [[VLCErrorPanel alloc] init];
b_progress_cancelled = NO; b_progress_cancelled = NO;
} }
...@@ -205,59 +187,33 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil; ...@@ -205,59 +187,33 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
else else
[o_prog_description_txt setStringValue: @""]; [o_prog_description_txt setStringValue: @""];
[o_prog_bar setDoubleValue: 0]; [o_prog_bar setDoubleValue: 0];
[o_prog_bar startAnimation: self];
p_dialog->pf_update = updateProgressPanel; [o_prog_win makeKeyAndOrderFront: self];
p_dialog->pf_check = checkProgressPanel;
p_dialog->pf_destroy = destroyProgressPanel;
p_dialog->p_sys = self;
[NSApp runModalForWindow: o_prog_win];
} }
-(void)performProgressBarEvent: (NSNotification *)o_notification -(void)updateProgressPanelWithText: (NSString *)string andNumber: (double)d_number
{ {
NSLog( @"%@ received", [o_notification name] ); [o_prog_description_txt setStringValue: string];
if( [[o_notification name] isEqualToString: @"VLCCoreDialogProgressBarUpdateNotification"] ) [o_prog_bar setDoubleValue: d_number];
{
NSNumber *o_number = [[o_notification userInfo] objectForKey:@"IntValue"];
NSString *o_text = [[o_notification userInfo] objectForKey:@"Text"];
[o_prog_description_txt setStringValue: o_text];
[o_prog_bar setDoubleValue: [o_number doubleValue]];
}
if( [[o_notification name] isEqualToString: @"VLCCoreDialogProgressBarDestroyNotification"] )
{
[NSApp stopModalWithCode: 0];
[o_prog_win close];
}
} }
void updateProgressPanel (void *priv, const char *text, float value) -(void)destroyProgressPanel
{ {
NSLog( @"we were updated with %s (%f)", text, value ); [o_prog_bar stopAnimation: self];
NSString *o_txt; [o_prog_win close];
if( text != NULL )
o_txt = [NSString stringWithUTF8String: text];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreDialogProgressBarUpdateNotification" object:[[VLCMain sharedInstance] coreDialogProvider] userInfo:[NSDictionary dictionaryWithObjectsAndKeys: o_txt, @"Text", [NSNumber numberWithInt: ((int)(value * 1000.))], @"IntValue", nil]];
} }
void destroyProgressPanel (void *priv) -(IBAction)progDialogAction:(id)sender
{ {
NSLog( @"we should destroy" ); b_progress_cancelled = YES;
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreDialogProgressBarDestroyNotification" object:[[VLCMain sharedInstance] coreDialogProvider] userInfo: nil];
} }
bool checkProgressPanel (void *priv) -(BOOL)progressCancelled
{ {
NSLog( @"we were checked" );
return b_progress_cancelled; return b_progress_cancelled;
} }
-(IBAction)progDialogAction:(id)sender
{
NSLog( @"buttonAction!" );
b_progress_cancelled = YES;
}
-(id)errorPanel -(id)errorPanel
{ {
return o_error_panel; return o_error_panel;
......
...@@ -83,8 +83,6 @@ struct intf_sys_t ...@@ -83,8 +83,6 @@ struct intf_sys_t
msg_subscription_t * p_sub; msg_subscription_t * p_sub;
}; };
static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned );
/***************************************************************************** /*****************************************************************************
* VLCMain interface * VLCMain interface
*****************************************************************************/ *****************************************************************************/
......
...@@ -69,6 +69,12 @@ static void * ManageThread( void *user_data ); ...@@ -69,6 +69,12 @@ static void * ManageThread( void *user_data );
static unichar VLCKeyToCocoa( unsigned int i_key ); static unichar VLCKeyToCocoa( unsigned int i_key );
static unsigned int VLCModifiersToCocoa( unsigned int i_key ); static unsigned int VLCModifiersToCocoa( unsigned int i_key );
static void updateProgressPanel (void *, const char *, float);
static bool checkProgressPanel (void *);
static void destroyProgressPanel (void *);
static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned );
#pragma mark - #pragma mark -
#pragma mark VLC Interface Object Callbacks #pragma mark VLC Interface Object Callbacks
...@@ -176,7 +182,6 @@ static void MsgCallback( msg_cb_data_t *data, msg_item_t *item, unsigned int i ) ...@@ -176,7 +182,6 @@ static void MsgCallback( msg_cb_data_t *data, msg_item_t *item, unsigned int i )
vlc_restorecancel( canc ); vlc_restorecancel( canc );
} }
/***************************************************************************** /*****************************************************************************
* playlistChanged: Callback triggered by the intf-change playlist * playlistChanged: Callback triggered by the intf-change playlist
* variable, to let the intf update the playlist. * variable, to let the intf update the playlist.
...@@ -231,15 +236,53 @@ static int DialogCallback( vlc_object_t *p_this, const char *type, vlc_value_t p ...@@ -231,15 +236,53 @@ static int DialogCallback( vlc_object_t *p_this, const char *type, vlc_value_t p
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
VLCMain *interface = (VLCMain *)data; VLCMain *interface = (VLCMain *)data;
const dialog_fatal_t *p_dialog = (const dialog_fatal_t *)value.p_address; if( [[NSString stringWithUTF8String: 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;
NSValue *o_value = [NSValue valueWithPointer:p_dialog]; p_dialog->pf_update = updateProgressPanel;
p_dialog->pf_check = checkProgressPanel;
p_dialog->pf_destroy = destroyProgressPanel;
p_dialog->p_sys = VLCIntf->p_libvlc;
}
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]]; [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCNewCoreDialogEventNotification" object:[interface coreDialogProvider] userInfo:[NSDictionary dictionaryWithObjectsAndKeys: o_value, @"VLCDialogPointer", [NSString stringWithUTF8String: type], @"VLCDialogType", nil]];
[o_pool release]; [o_pool release];
return VLC_SUCCESS; return VLC_SUCCESS;
} }
void updateProgressPanel (void *priv, const char *text, float value)
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
NSString *o_txt;
if( text != NULL )
o_txt = [NSString stringWithUTF8String: text];
else
o_txt = @"";
[[[VLCMain sharedInstance] coreDialogProvider] updateProgressPanelWithText: o_txt andNumber: (double)(value * 1000.)];
[o_pool release];
}
void destroyProgressPanel (void *priv)
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
[[[VLCMain sharedInstance] coreDialogProvider] destroyProgressPanel];
[o_pool release];
}
bool checkProgressPanel (void *priv)
{
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
return [[[VLCMain sharedInstance] coreDialogProvider] progressCancelled];
[o_pool release];
}
#pragma mark - #pragma mark -
#pragma mark Private #pragma mark Private
......
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