[vlc-commits] macosx: Modernize VLCCoreDialogProvider
David Fuhrmann
git at videolan.org
Sun Jun 10 11:03:08 CEST 2018
vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sat Jun 9 20:53:48 2018 +0200| [121d020804f85213840dcdb71becd884f58389e2] | committer: David Fuhrmann
macosx: Modernize VLCCoreDialogProvider
Use properties for all outlets. Use correct references and update
function to load the xib.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=121d020804f85213840dcdb71becd884f58389e2
---
modules/gui/macosx/VLCCoreDialogProvider.h | 40 +++++++--------
modules/gui/macosx/VLCCoreDialogProvider.m | 78 +++++++++++++++---------------
2 files changed, 60 insertions(+), 58 deletions(-)
diff --git a/modules/gui/macosx/VLCCoreDialogProvider.h b/modules/gui/macosx/VLCCoreDialogProvider.h
index 211b4eee21..503725ccaf 100644
--- a/modules/gui/macosx/VLCCoreDialogProvider.h
+++ b/modules/gui/macosx/VLCCoreDialogProvider.h
@@ -33,26 +33,28 @@
@class VLCErrorWindowController;
@interface VLCCoreDialogProvider : NSObject
-{
- /* authentication dialog */
- IBOutlet NSButton *authenticationCancelButton;
- IBOutlet NSTextField *authenticationDescriptionLabel;
- IBOutlet NSTextField *authenticationLoginTextField;
- IBOutlet NSTextField *authenticationLoginLabel;
- IBOutlet NSButton *authenticationOkButton;
- IBOutlet NSTextField *authenticationPasswordTextField;
- IBOutlet NSTextField *authenticationPasswordLabel;
- IBOutlet NSTextField *authenticationTitleLabel;
- IBOutlet NSButton *authenticationStorePasswordCheckbox;
- IBOutlet NSWindow *authenticationWindow;
- /* progress dialog */
- IBOutlet NSProgressIndicator *progressIndicator;
- IBOutlet NSButton *progressCancelButton;
- IBOutlet NSTextField *progressDescriptionLabel;
- IBOutlet NSTextField *progressTitleLabel;
- IBOutlet NSWindow *progressWindow;
-}
+/* authentication dialog */
+ at property (readwrite, strong) IBOutlet NSWindow *authenticationWindow;
+
+ at property (readwrite, weak) IBOutlet NSButton *authenticationCancelButton;
+ at property (readwrite, weak) IBOutlet NSTextField *authenticationDescriptionLabel;
+ at property (readwrite, weak) IBOutlet NSTextField *authenticationLoginTextField;
+ at property (readwrite, weak) IBOutlet NSTextField *authenticationLoginLabel;
+ at property (readwrite, weak) IBOutlet NSButton *authenticationOkButton;
+ at property (readwrite, weak) IBOutlet NSTextField *authenticationPasswordTextField;
+ at property (readwrite, weak) IBOutlet NSTextField *authenticationPasswordLabel;
+ at property (readwrite, weak) IBOutlet NSTextField *authenticationTitleLabel;
+ at property (readwrite, weak) IBOutlet NSButton *authenticationStorePasswordCheckbox;
+
+/* progress dialog */
+ at property (readwrite, strong) IBOutlet NSWindow *progressWindow;
+
+ at property (readwrite, weak) IBOutlet NSProgressIndicator *progressIndicator;
+ at property (readwrite, weak) IBOutlet NSButton *progressCancelButton;
+ at property (readwrite, weak) IBOutlet NSTextField *progressDescriptionLabel;
+ at property (readwrite, weak) IBOutlet NSTextField *progressTitleLabel;
+
@property (readonly) VLCErrorWindowController* errorPanel;
diff --git a/modules/gui/macosx/VLCCoreDialogProvider.m b/modules/gui/macosx/VLCCoreDialogProvider.m
index 990402cc25..47e4564216 100644
--- a/modules/gui/macosx/VLCCoreDialogProvider.m
+++ b/modules/gui/macosx/VLCCoreDialogProvider.m
@@ -155,7 +155,7 @@ static void updateProgressCallback(void *p_data,
if (self) {
msg_Dbg(getIntf(), "Register dialog provider");
- [NSBundle loadNibNamed:@"CoreDialogs" owner: self];
+ [[NSBundle mainBundle] loadNibNamed:@"CoreDialogs" owner:self topLevelObjects:nil];
_errorPanel = [[VLCErrorWindowController alloc] init];
@@ -188,14 +188,14 @@ static void updateProgressCallback(void *p_data,
-(void)awakeFromNib
{
_progressCancelled = NO;
- [authenticationLoginLabel setStringValue: _NS("Username")];
- [authenticationPasswordLabel setStringValue: _NS("Password")];
- [authenticationCancelButton setTitle: _NS("Cancel")];
- [authenticationOkButton setTitle: _NS("OK")];
- [authenticationStorePasswordCheckbox setTitle:_NS("Remember")];
-
- [progressCancelButton setTitle: _NS("Cancel")];
- [progressIndicator setUsesThreadedAnimation: YES];
+ [_authenticationLoginLabel setStringValue: _NS("Username")];
+ [_authenticationPasswordLabel setStringValue: _NS("Password")];
+ [_authenticationCancelButton setTitle: _NS("Cancel")];
+ [_authenticationOkButton setTitle: _NS("OK")];
+ [_authenticationStorePasswordCheckbox setTitle:_NS("Remember")];
+
+ [_progressCancelButton setTitle: _NS("Cancel")];
+ [_progressIndicator setUsesThreadedAnimation: YES];
}
- (void)displayError:(NSArray *)dialogData
@@ -206,29 +206,29 @@ static void updateProgressCallback(void *p_data,
- (void)displayLoginDialog:(NSArray *)dialogData
{
- [authenticationTitleLabel setStringValue:[dialogData objectAtIndex:1]];
- authenticationWindow.title = [dialogData objectAtIndex:1];
- [authenticationDescriptionLabel setStringValue:[dialogData objectAtIndex:2]];
+ [_authenticationTitleLabel setStringValue:[dialogData objectAtIndex:1]];
+ _authenticationWindow.title = [dialogData objectAtIndex:1];
+ [_authenticationDescriptionLabel setStringValue:[dialogData objectAtIndex:2]];
- [authenticationLoginTextField setStringValue:[dialogData objectAtIndex:3]];
- [authenticationPasswordTextField setStringValue:@""];
+ [_authenticationLoginTextField setStringValue:[dialogData objectAtIndex:3]];
+ [_authenticationPasswordTextField setStringValue:@""];
- authenticationStorePasswordCheckbox.hidden = ![[dialogData objectAtIndex:4] boolValue];
- authenticationStorePasswordCheckbox.state = NSOffState;
+ _authenticationStorePasswordCheckbox.hidden = ![[dialogData objectAtIndex:4] boolValue];
+ _authenticationStorePasswordCheckbox.state = NSOffState;
- [authenticationWindow center];
- NSInteger returnValue = [NSApp runModalForWindow:authenticationWindow];
- [authenticationWindow close];
+ [_authenticationWindow center];
+ NSInteger returnValue = [NSApp runModalForWindow:_authenticationWindow];
+ [_authenticationWindow close];
- NSString *username = authenticationLoginTextField.stringValue;
- NSString *password = authenticationPasswordTextField.stringValue;
+ NSString *username = _authenticationLoginTextField.stringValue;
+ NSString *password = _authenticationPasswordTextField.stringValue;
if (returnValue == 0)
vlc_dialog_id_dismiss([[dialogData objectAtIndex:0] pointerValue]);
else
vlc_dialog_id_post_login([[dialogData objectAtIndex:0] pointerValue],
username ? [username UTF8String] : NULL,
password ? [password UTF8String] : NULL,
- authenticationStorePasswordCheckbox.state == NSOnState);
+ _authenticationStorePasswordCheckbox.state == NSOnState);
}
- (IBAction)authenticationDialogAction:(id)sender
@@ -279,29 +279,29 @@ static void updateProgressCallback(void *p_data,
- (void)displayProgressDialog:(NSArray *)dialogData
{
- progressTitleLabel.stringValue = [dialogData objectAtIndex:1];
- progressWindow.title = [dialogData objectAtIndex:1];
+ _progressTitleLabel.stringValue = [dialogData objectAtIndex:1];
+ _progressWindow.title = [dialogData objectAtIndex:1];
- progressDescriptionLabel.stringValue = [dialogData objectAtIndex:2];
+ _progressDescriptionLabel.stringValue = [dialogData objectAtIndex:2];
- progressIndicator.indeterminate = [[dialogData objectAtIndex:3] boolValue];
- progressIndicator.doubleValue = [[dialogData objectAtIndex:4] doubleValue];
+ _progressIndicator.indeterminate = [[dialogData objectAtIndex:3] boolValue];
+ _progressIndicator.doubleValue = [[dialogData objectAtIndex:4] doubleValue];
if ([[dialogData objectAtIndex:5] length] > 0) {
- progressCancelButton.title = [dialogData objectAtIndex:5];
- progressCancelButton.enabled = YES;
+ _progressCancelButton.title = [dialogData objectAtIndex:5];
+ _progressCancelButton.enabled = YES;
} else {
- progressCancelButton.title = _NS("Cancel");
- progressCancelButton.enabled = NO;
+ _progressCancelButton.title = _NS("Cancel");
+ _progressCancelButton.enabled = NO;
}
- [progressIndicator startAnimation:self];
+ [_progressIndicator startAnimation:self];
- [progressWindow center];
- [NSApp runModalForWindow:progressWindow];
- [progressWindow close];
+ [_progressWindow center];
+ [NSApp runModalForWindow:_progressWindow];
+ [_progressWindow close];
- [progressIndicator stopAnimation:self];
+ [_progressIndicator stopAnimation:self];
vlc_dialog_id_dismiss([[dialogData objectAtIndex:0] pointerValue]);
}
@@ -309,9 +309,9 @@ static void updateProgressCallback(void *p_data,
- (void)updateDisplayedProgressDialog:(NSArray *)dialogData
{
- if (!progressIndicator.indeterminate) {
- progressIndicator.doubleValue = [[dialogData objectAtIndex:1] doubleValue];
- progressDescriptionLabel.stringValue = [dialogData objectAtIndex:2];
+ if (!_progressIndicator.indeterminate) {
+ _progressIndicator.doubleValue = [[dialogData objectAtIndex:1] doubleValue];
+ _progressDescriptionLabel.stringValue = [dialogData objectAtIndex:2];
}
}
More information about the vlc-commits
mailing list