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

macosx: draft for 'dialog-progress-bar' and clean up

This isn't fully functional, as the callbacks aren't being triggered, although set. Needs some more investigation.
parent 3bb39472
......@@ -8,6 +8,7 @@
{
ACTIONS = {
loginDialogAction = id;
progDialogAction = id;
};
CLASS = VLCCoreDialogProvider;
LANGUAGE = ObjC;
......@@ -23,9 +24,8 @@
"o_auth_win" = id;
"o_prog_bar" = id;
"o_prog_cancel_btn" = id;
"o_prog_description" = id;
"o_prog_timeToGo" = id;
"o_prog_title" = id;
"o_prog_description_txt" = id;
"o_prog_title_txt" = id;
"o_prog_win" = id;
};
SUPERCLASS = NSObject;
......
......@@ -262,8 +262,6 @@
CC0B723C0D54F2B000448E00 /* spref_cone_Video_64.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = spref_cone_Video_64.png; path = Resources/spref_cone_Video_64.png; sourceTree = "<group>"; };
CC0FB34B0F8BED1100F057F7 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/CoreDialogs.nib; sourceTree = "<group>"; };
CC1941240B9C1F8400635F6B /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
CC1B4C1409A8EC690078AD2E /* interaction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = interaction.h; path = ../../../modules/gui/macosx/interaction.h; sourceTree = "<group>"; };
CC1B4C1509A8EC690078AD2E /* interaction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = interaction.m; path = ../../../modules/gui/macosx/interaction.m; sourceTree = "<group>"; };
CC1C41D00D9BAD7F002728FA /* noart.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = noart.png; path = Resources/noart.png; sourceTree = "<group>"; };
CC26BF2B09A7A05000E94D62 /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/Update.nib; sourceTree = "<group>"; };
CC26BF3109A7A08C00E94D62 /* update.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = update.h; path = ../../../modules/gui/macosx/update.h; sourceTree = SOURCE_ROOT; };
......@@ -289,6 +287,8 @@
CC33C2500D2578F5008C4683 /* fullscreen_graphite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = fullscreen_graphite.png; path = Resources/fullscreen_graphite.png; sourceTree = "<group>"; };
CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
CC402F4B0E00ABBB006A4BA4 /* VLC.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VLC.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
CC4A33210F8CB017000FC4A7 /* coredialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = coredialogs.m; path = ../../../modules/gui/macosx/coredialogs.m; sourceTree = SOURCE_ROOT; };
CC4A33220F8CB017000FC4A7 /* coredialogs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = coredialogs.h; path = ../../../modules/gui/macosx/coredialogs.h; sourceTree = SOURCE_ROOT; };
CC4ED9AC0ABE07C800CA4CC5 /* add_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = add_embedded_blue.png; path = Resources/add_embedded_blue.png; sourceTree = "<group>"; };
CC4ED9AD0ABE07C800CA4CC5 /* add_embedded.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = add_embedded.png; path = Resources/add_embedded.png; sourceTree = "<group>"; };
CC4ED9AE0ABE07C800CA4CC5 /* repeat_embedded_blue.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = repeat_embedded_blue.png; path = Resources/repeat_embedded_blue.png; sourceTree = "<group>"; };
......@@ -446,8 +446,8 @@
8ED6C27E03E2EB1C0059A3A7 /* macosx.m */,
8ED6C27C03E2EB1C0059A3A7 /* intf.h */,
8ED6C27D03E2EB1C0059A3A7 /* intf.m */,
CC1B4C1409A8EC690078AD2E /* interaction.h */,
CC1B4C1509A8EC690078AD2E /* interaction.m */,
CC4A33220F8CB017000FC4A7 /* coredialogs.h */,
CC4A33210F8CB017000FC4A7 /* coredialogs.m */,
8E6BC6FA041684EC0059A3A7 /* controls.h */,
8ED6C27B03E2EB1C0059A3A7 /* controls.m */,
8E6BC6F6041643860059A3A7 /* applescript.h */,
......
......@@ -50,7 +50,6 @@
@end
/*****************************************************************************
* VLCCoreDialogProvider interface
*****************************************************************************/
......@@ -72,19 +71,21 @@
/* progress dialogue */
IBOutlet id o_prog_bar;
IBOutlet id o_prog_cancel_btn;
IBOutlet id o_prog_description;
IBOutlet id o_prog_title;
IBOutlet id o_prog_description_txt;
IBOutlet id o_prog_title_txt;
IBOutlet id o_prog_win;
IBOutlet id o_prog_timeToGo;
}
+ (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;
-(id)getErrorPanel;
......
......@@ -26,9 +26,19 @@
#import "coredialogs.h"
#import "misc.h"
/* for the icons in our custom error panel */
/* 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
*****************************************************************************/
......@@ -52,8 +62,16 @@ 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;
}
return _o_sharedInstance;
......@@ -81,6 +99,8 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
[self showQuestionDialog: o_value];
else if( [o_type isEqualToString: @"dialog-login"] )
[self showLoginDialog: o_value];
else if( [o_type isEqualToString: @"dialog-progress-bar"] )
[self showProgressDialog: o_value];
else
msg_Err( VLCIntf, "unhandled dialog type: '%s'", [o_type UTF8String] );
}
......@@ -162,6 +182,82 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
[NSApp stopModalWithCode: 0];
}
-(void)showProgressDialog: (NSValue *)o_value
{
dialog_progress_bar_t *p_dialog = [o_value pointerValue];
if( p_dialog->title != NULL )
{
[o_prog_win setTitle: [NSString stringWithUTF8String: p_dialog->title]];
[o_prog_title_txt setStringValue: [NSString stringWithUTF8String: p_dialog->title]];
}
else
{
[o_prog_win setTitle: @""];
[o_prog_title_txt setStringValue: @""];
}
if( p_dialog->cancel != NULL )
[o_prog_cancel_btn setTitle: [NSString stringWithUTF8String: p_dialog->cancel]];
else
[o_prog_cancel_btn setTitle: _NS("Cancel")];
if( p_dialog->message != NULL )
[o_prog_description_txt setStringValue: [NSString stringWithUTF8String: p_dialog->message]];
else
[o_prog_description_txt setStringValue: @""];
[o_prog_bar setDoubleValue: 0];
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];
}
-(void)performProgressBarEvent: (NSNotification *)o_notification
{
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];
}
}
void updateProgressPanel (void *priv, const char *text, float value)
{
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] getCoreDialogProvider] userInfo:[NSDictionary dictionaryWithObjectsAndKeys: o_txt, @"Text", [NSNumber numberWithInt: ((int)(value * 1000.))], @"IntValue", nil]];
}
void destroyProgressPanel (void *priv)
{
NSLog( @"we should destroy" );
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreDialogProgressBarDestroyNotification" object:[[VLCMain sharedInstance] getCoreDialogProvider] userInfo: nil];
}
bool checkProgressPanel (void *priv)
{
NSLog( @"we were checked" );
return b_progress_cancelled;
}
-(IBAction)progDialogAction:(id)sender
{
NSLog( @"buttonAction!" );
b_progress_cancelled = YES;
}
-(id)getErrorPanel
{
return o_error_panel;
......@@ -174,47 +270,6 @@ static VLCCoreDialogProvider *_o_sharedInstance = nil;
}
@end
#if 0
dialog_progress_bar_t
{
msg_Dbg( p_intf, "user progress dialog requested" );
[o_prog_title setStringValue: o_title];
[o_prog_description setStringValue: o_description];
[o_prog_bar setDoubleValue: (double)p_dialog->val.f_float];
if( p_dialog->i_timeToGo < 1 )
[o_prog_timeToGo setStringValue: @""];
else
[o_prog_timeToGo setStringValue: [NSString stringWithFormat:
_NS("Remaining time: %i seconds"), p_dialog->i_timeToGo]];
[NSApp beginSheet: o_prog_win modalForWindow: o_window
modalDelegate: self didEndSelector: nil contextInfo: nil];
[o_prog_win makeKeyWindow];
}
-(void)updateDialog
{
if( p_dialog->i_flags & DIALOG_USER_PROGRESS )
{
[o_prog_description setStringValue:
[NSString stringWithUTF8String: p_dialog->psz_description]];
[o_prog_bar setDoubleValue: (double)p_dialog->val.f_float];
if( [o_prog_bar doubleValue] == 100.0 )
{
/* we are done, let's hide */
[self hideDialog];
}
if( p_dialog->i_timeToGo < 1 )
[o_prog_timeToGo setStringValue: @""];
else
[o_prog_timeToGo setStringValue: [NSString stringWithFormat:
_NS("Remaining time: %i seconds"), p_dialog->i_timeToGo]];
return;
}
}
#endif
/*****************************************************************************
* VLCErrorPanel implementation
*****************************************************************************/
......
......@@ -231,8 +231,6 @@ static int DialogCallback( vlc_object_t *p_this, const char *type, vlc_value_t p
const dialog_fatal_t *p_dialog = (const dialog_fatal_t *)value.p_address;
NSLog( @"dialog callback triggered; type of dialogue is '%s'", type );
NSValue *o_value = [NSValue valueWithPointer:p_dialog];
[[NSNotificationCenter defaultCenter] postNotificationName: @"VLCNewCoreDialogEventNotification" object:[interface getCoreDialogProvider] userInfo:[NSDictionary dictionaryWithObjectsAndKeys: o_value, @"VLCDialogPointer", [NSString stringWithUTF8String: type], @"VLCDialogType", nil]];
......@@ -2124,8 +2122,6 @@ end:
- (IBAction)showBookmarks:(id)sender
{
dialog_Fatal( p_intf, "Title", "Message" );
/* we need the wizard-nib for the bookmarks's extract functionality */
if( !nib_wizard_loaded )
{
......
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