Commit 45c25b5d authored by Felix Paul Kühne's avatar Felix Paul Kühne
Browse files

macosx: finally completed the progress-panel's implementation

parent 8ca26472
......@@ -69,23 +69,28 @@
IBOutlet id o_auth_win;
/* progress dialogue */
IBOutlet id o_prog_bar;
IBOutlet NSProgressIndicator * o_prog_bar;
IBOutlet id o_prog_cancel_btn;
IBOutlet id o_prog_description_txt;
IBOutlet id o_prog_title_txt;
IBOutlet id o_prog_win;
BOOL b_progress_cancelled;
}
+ (VLCCoreDialogProvider *)sharedInstance;
-(void)performDialogEvent: (NSNotification *)o_notification;
-(void)performProgressBarEvent: (NSNotification *)o_notification;
-(void)showFatalDialog: (NSValue *)o_value;
-(void)showQuestionDialog: (NSValue *)o_value;
-(void)showLoginDialog: (NSValue *)o_value;
-(IBAction)loginDialogAction:(id)sender;
-(void)showProgressDialog: (NSValue *)o_value;
-(IBAction)progDialogAction:(id)sender;
-(BOOL)progressCancelled;
-(void)updateProgressPanelWithText: (NSString *)string andNumber: (double)d_number;
-(void)destroyProgressPanel;
-(id)errorPanel;
......
......@@ -29,16 +29,6 @@
/* for the icon in our custom error panel */
#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
*****************************************************************************/
......@@ -62,14 +52,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
selector:@selector(performDialogEvent:)
name: @"VLCNewCoreDialogEventNotification"
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];
b_progress_cancelled = NO;
}
......@@ -205,59 +187,33 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
else
[o_prog_description_txt setStringValue: @""];
[o_prog_bar setDoubleValue: 0];
[o_prog_bar startAnimation: self];
p_dialog->pf_update = updateProgressPanel;
p_dialog->pf_check = checkProgressPanel;
p_dialog->pf_destroy = destroyProgressPanel;
p_dialog->p_sys = self;
[NSApp runModalForWindow: o_prog_win];
[o_prog_win makeKeyAndOrderFront: self];
}
-(void)performProgressBarEvent: (NSNotification *)o_notification
-(void)updateProgressPanelWithText: (NSString *)string andNumber: (double)d_number
{
NSLog( @"%@ received", [o_notification name] );
if( [[o_notification name] isEqualToString: @"VLCCoreDialogProgressBarUpdateNotification"] )
{
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];
}
[o_prog_description_txt setStringValue: string];
[o_prog_bar setDoubleValue: d_number];
}
void updateProgressPanel (void *priv, const char *text, float value)
-(void)destroyProgressPanel
{
NSLog( @"we were updated with %s (%f)", text, value );
NSString *o_txt;
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]];
[o_prog_bar stopAnimation: self];
[o_prog_win close];
}
void destroyProgressPanel (void *priv)
-(IBAction)progDialogAction:(id)sender
{
NSLog( @"we should destroy" );
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreDialogProgressBarDestroyNotification" object:[[VLCMain sharedInstance] coreDialogProvider] userInfo: nil];
b_progress_cancelled = YES;
}
bool checkProgressPanel (void *priv)
-(BOOL)progressCancelled
{
NSLog( @"we were checked" );
return b_progress_cancelled;
}
-(IBAction)progDialogAction:(id)sender
{
NSLog( @"buttonAction!" );
b_progress_cancelled = YES;
}
-(id)errorPanel
{
return o_error_panel;
......
......@@ -83,8 +83,6 @@ struct intf_sys_t
msg_subscription_t * p_sub;
};
static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned );
/*****************************************************************************
* VLCMain interface
*****************************************************************************/
......
......@@ -69,6 +69,12 @@ static void * ManageThread( void *user_data );
static unichar VLCKeyToCocoa( 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 VLC Interface Object Callbacks
......@@ -176,7 +182,6 @@ static void MsgCallback( msg_cb_data_t *data, msg_item_t *item, unsigned int i )
vlc_restorecancel( canc );
}
/*****************************************************************************
* playlistChanged: Callback triggered by the intf-change 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
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
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]];
[o_pool release];
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 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