[vlc-commits] macosx: upgrade accessibility code

Felix Paul Kühne git at videolan.org
Sun Jun 10 14:47:30 CEST 2018


vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Jun 10 14:47:00 2018 +0200| [10711f6ad68984d35817b3a54703f595dcaf0092] | committer: Felix Paul Kühne

macosx: upgrade accessibility code

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=10711f6ad68984d35817b3a54703f595dcaf0092
---

 modules/gui/macosx/VLCControlsBarCommon.m     | 39 +++++++++++++--------------
 modules/gui/macosx/VLCFSPanelController.m     |  8 +++---
 modules/gui/macosx/VLCLogWindowController.m   |  6 ++---
 modules/gui/macosx/VLCMainWindowControlsBar.m | 20 +++++++-------
 modules/gui/macosx/VLCOpenWindowController.m  | 16 +++++------
 modules/gui/macosx/VLCStatusBarIcon.m         | 16 +++--------
 6 files changed, 46 insertions(+), 59 deletions(-)

diff --git a/modules/gui/macosx/VLCControlsBarCommon.m b/modules/gui/macosx/VLCControlsBarCommon.m
index a280416777..567bcbfb15 100644
--- a/modules/gui/macosx/VLCControlsBarCommon.m
+++ b/modules/gui/macosx/VLCControlsBarCommon.m
@@ -61,22 +61,22 @@
     [self.dropView setDrawBorder: NO];
 
     [self.playButton setToolTip: _NS("Play")];
-    [[self.playButton cell] accessibilitySetOverrideValue:[self.playButton toolTip] forAttribute:NSAccessibilityDescriptionAttribute];
+    self.playButton.accessibilityLabel = self.playButton.toolTip;
 
     [self.backwardButton setToolTip: _NS("Backward")];
-    [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Seek backward") forAttribute:NSAccessibilityDescriptionAttribute];
-    [[self.backwardButton cell] accessibilitySetOverrideValue:[self.backwardButton toolTip] forAttribute:NSAccessibilityTitleAttribute];
+    self.backwardButton.accessibilityLabel = _NS("Seek backward");
+    self.backwardButton.accessibilityTitle = self.backwardButton.toolTip;
 
     [self.forwardButton setToolTip: _NS("Forward")];
-    [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Seek forward") forAttribute:NSAccessibilityDescriptionAttribute];
-    [[self.forwardButton cell] accessibilitySetOverrideValue:[self.forwardButton toolTip] forAttribute:NSAccessibilityTitleAttribute];
+    self.forwardButton.accessibilityLabel = _NS("Seek forward");
+    self.forwardButton.accessibilityTitle = self.forwardButton.toolTip;
 
     [self.timeSlider setToolTip: _NS("Position")];
-    [[self.timeSlider cell] accessibilitySetOverrideValue:_NS("Playback position") forAttribute:NSAccessibilityDescriptionAttribute];
-    [[self.timeSlider cell] accessibilitySetOverrideValue:[self.timeSlider toolTip] forAttribute:NSAccessibilityTitleAttribute];
+    self.timeSlider.accessibilityLabel = _NS("Playback position");
+    self.timeSlider.accessibilityTitle = self.timeSlider.toolTip;
 
     [self.fullscreenButton setToolTip: _NS("Enter fullscreen")];
-    [[self.fullscreenButton cell] accessibilitySetOverrideValue:[self.fullscreenButton toolTip] forAttribute:NSAccessibilityDescriptionAttribute];
+    self.fullscreenButton.accessibilityLabel = self.fullscreenButton.toolTip;
 
     [self.backwardButton setImage: imageFromRes(@"backward-3btns")];
     [self.backwardButton setAlternateImage: imageFromRes(@"backward-3btns-pressed")];
@@ -99,8 +99,7 @@
     [self.timeField setAlignment: NSCenterTextAlignment];
     [self.timeField setNeedsDisplay:YES];
     [self.timeField setRemainingIdentifier:@"DisplayTimeAsTimeRemaining"];
-    [[self.timeField cell] accessibilitySetOverrideValue:_NS("Playback time")
-                                            forAttribute:NSAccessibilityDescriptionAttribute];
+    self.timeField.accessibilityLabel = _NS("Playback time");
 
     // remove fullscreen button for lion fullscreen
     if (_nativeFullscreenMode) {
@@ -120,22 +119,22 @@
 {
     if (b_alt == YES) {
         /* change the accessibility help for the backward/forward buttons accordingly */
-        [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Backward") forAttribute:NSAccessibilityTitleAttribute];
-        [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Seek backward") forAttribute:NSAccessibilityDescriptionAttribute];
+        self.backwardButton.accessibilityTitle = _NS("Backward");
+        self.backwardButton.accessibilityLabel = _NS("Seek backward");
 
-        [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Forward") forAttribute:NSAccessibilityTitleAttribute];
-        [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Seek forward") forAttribute:NSAccessibilityDescriptionAttribute];
+        self.forwardButton.accessibilityTitle = _NS("Forward");
+        self.forwardButton.accessibilityLabel = _NS("Seek forward");
 
         [self.forwardButton setAction:@selector(alternateForward:)];
         [self.backwardButton setAction:@selector(alternateBackward:)];
 
     } else {
         /* change the accessibility help for the backward/forward buttons accordingly */
-        [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Previous") forAttribute:NSAccessibilityTitleAttribute];
-        [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Go to previous item") forAttribute:NSAccessibilityDescriptionAttribute];
+        self.backwardButton.accessibilityTitle = _NS("Previous");
+        self.backwardButton.accessibilityLabel = _NS("Go to previous item");
 
-        [[self.backwardButton cell] accessibilitySetOverrideValue:_NS("Next") forAttribute:NSAccessibilityTitleAttribute];
-        [[self.forwardButton cell] accessibilitySetOverrideValue:_NS("Go to next item") forAttribute:NSAccessibilityDescriptionAttribute];
+        self.forwardButton.accessibilityTitle = _NS("Next");
+        self.forwardButton.accessibilityLabel = _NS("Go to next item");
 
         [self.forwardButton setAction:@selector(fwd:)];
         [self.backwardButton setAction:@selector(bwd:)];
@@ -356,7 +355,7 @@
     [self.playButton setImage: _pauseImage];
     [self.playButton setAlternateImage: _pressedPauseImage];
     [self.playButton setToolTip: _NS("Pause")];
-    [[self.playButton cell] accessibilitySetOverrideValue:[self.playButton toolTip] forAttribute:NSAccessibilityTitleAttribute];
+    self.playButton.accessibilityLabel = self.playButton.toolTip;
 }
 
 - (void)setPlay
@@ -364,7 +363,7 @@
     [self.playButton setImage: _playImage];
     [self.playButton setAlternateImage: _pressedPlayImage];
     [self.playButton setToolTip: _NS("Play")];
-    [[self.playButton cell] accessibilitySetOverrideValue:[self.playButton toolTip] forAttribute:NSAccessibilityTitleAttribute];
+    self.playButton.accessibilityLabel = self.playButton.toolTip;
 }
 
 - (void)setFullscreenState:(BOOL)b_fullscreen
diff --git a/modules/gui/macosx/VLCFSPanelController.m b/modules/gui/macosx/VLCFSPanelController.m
index 58c37daf70..d4d6bc7734 100644
--- a/modules/gui/macosx/VLCFSPanelController.m
+++ b/modules/gui/macosx/VLCFSPanelController.m
@@ -87,11 +87,9 @@ static NSString *kAssociatedFullscreenRect = @"VLCFullscreenAssociatedWindowRect
     [self setupControls];
 }
 
-#define setupButton(target, title, desc)                                              \
-    [target accessibilitySetOverrideValue:title                                       \
-                             forAttribute:NSAccessibilityTitleAttribute];             \
-    [target accessibilitySetOverrideValue:desc                                        \
-                             forAttribute:NSAccessibilityDescriptionAttribute];       \
+#define setupButton(target, title, desc)            \
+    target.accessibilityTitle = title;              \
+    target.accessibilityLabel = desc;               \
     [target setToolTip:title];
 
 - (void)setupControls
diff --git a/modules/gui/macosx/VLCLogWindowController.m b/modules/gui/macosx/VLCLogWindowController.m
index d01d8ad360..7818bfef25 100644
--- a/modules/gui/macosx/VLCLogWindowController.m
+++ b/modules/gui/macosx/VLCLogWindowController.m
@@ -94,10 +94,8 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
     [self.window setTitle:_NS("Messages")];
 
 #define setupButton(target, title, desc)                                              \
-    [target accessibilitySetOverrideValue:title                                       \
-                             forAttribute:NSAccessibilityTitleAttribute];             \
-    [target accessibilitySetOverrideValue:desc                                        \
-                             forAttribute:NSAccessibilityDescriptionAttribute];       \
+    target.accessibilityTitle = title;                                                \
+    target.accessibilityLabel = desc;                                                 \
     [target setToolTip:desc];
 
     setupButton(_saveButton,
diff --git a/modules/gui/macosx/VLCMainWindowControlsBar.m b/modules/gui/macosx/VLCMainWindowControlsBar.m
index 53470fc8ab..91805b8f04 100644
--- a/modules/gui/macosx/VLCMainWindowControlsBar.m
+++ b/modules/gui/macosx/VLCMainWindowControlsBar.m
@@ -60,31 +60,31 @@
     [super awakeFromNib];
 
     [self.stopButton setToolTip: _NS("Stop")];
-    [[self.stopButton cell] accessibilitySetOverrideValue:[self.stopButton toolTip] forAttribute:NSAccessibilityDescriptionAttribute];
+    self.stopButton.accessibilityLabel = self.stopButton.toolTip;
 
     [self.playlistButton setToolTip: _NS("Show/Hide Playlist")];
-    [[self.playlistButton cell] accessibilitySetOverrideValue:[self.playlistButton toolTip] forAttribute:NSAccessibilityDescriptionAttribute];
+    self.playlistButton.accessibilityLabel = self.playlistButton.toolTip;
 
     [self.repeatButton setToolTip: _NS("Repeat")];
-    [[self.repeatButton cell] accessibilitySetOverrideValue:_NS("Change repeat mode. Modes: repeat one, repeat all and no repeat.") forAttribute:NSAccessibilityDescriptionAttribute];
-    [[self.repeatButton cell] accessibilitySetOverrideValue:[self.repeatButton toolTip] forAttribute:NSAccessibilityTitleAttribute];
+    self.repeatButton.accessibilityLabel = _NS("Change repeat mode. Modes: repeat one, repeat all and no repeat.");
+    self.repeatButton.accessibilityTitle = self.repeatButton.toolTip;
 
     [self.shuffleButton setToolTip: _NS("Shuffle")];
-    [[self.shuffleButton cell] accessibilitySetOverrideValue:[self.shuffleButton toolTip] forAttribute:NSAccessibilityDescriptionAttribute];
+    self.shuffleButton.accessibilityLabel = self.shuffleButton.toolTip;
 
     NSString *volumeTooltip = [NSString stringWithFormat:_NS("Volume: %i %%"), 100];
     [self.volumeSlider setToolTip: volumeTooltip];
-    [[self.volumeSlider cell] accessibilitySetOverrideValue:_NS("Volume") forAttribute:NSAccessibilityDescriptionAttribute];
+    self.volumeSlider.accessibilityLabel = _NS("Volume");
     
     [self.volumeDownButton setToolTip: _NS("Mute")];
-    [[self.volumeDownButton cell] accessibilitySetOverrideValue:[self.volumeDownButton toolTip] forAttribute:NSAccessibilityDescriptionAttribute];
+    self.volumeDownButton.accessibilityLabel = self.volumeDownButton.toolTip;
     
     [self.volumeUpButton setToolTip: _NS("Full Volume")];
-    [[self.volumeUpButton cell] accessibilitySetOverrideValue:[self.volumeUpButton toolTip] forAttribute:NSAccessibilityDescriptionAttribute];
+    self.volumeUpButton.accessibilityLabel = self.volumeUpButton.toolTip;
 
     [self.effectsButton setToolTip: _NS("Audio Effects")];
-    [[self.effectsButton cell] accessibilitySetOverrideValue:_NS("Open Audio Effects window") forAttribute:NSAccessibilityDescriptionAttribute];
-    [[self.effectsButton cell] accessibilitySetOverrideValue:[self.effectsButton toolTip] forAttribute:NSAccessibilityTitleAttribute];
+    self.effectsButton.accessibilityTitle = _NS("Open Audio Effects window");
+    self.effectsButton.accessibilityLabel = self.effectsButton.toolTip;
 
     [self.stopButton setImage: imageFromRes(@"stop")];
     [self.stopButton setAlternateImage: imageFromRes(@"stop-pressed")];
diff --git a/modules/gui/macosx/VLCOpenWindowController.m b/modules/gui/macosx/VLCOpenWindowController.m
index 584f448046..5a09c0ac85 100644
--- a/modules/gui/macosx/VLCOpenWindowController.m
+++ b/modules/gui/macosx/VLCOpenWindowController.m
@@ -136,7 +136,7 @@ static NSString *kCaptureTabViewId  = @"capture";
     [_outputCheckbox setTitle:_NS("Stream output:")];
     [_outputSettingsButton setTitle:_NS("Settings...")];
 
-    [_tabView accessibilitySetOverrideValue:_NS("Choose media input type") forAttribute:NSAccessibilityDescriptionAttribute];
+    _tabView.accessibilityLabel = _NS("Choose media input type");
     [[_tabView tabViewItemAtIndex: 0] setLabel: _NS("File")];
     [[_tabView tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
     [[_tabView tabViewItemAtIndex: 2] setLabel: _NS("Network")];
@@ -145,12 +145,12 @@ static NSString *kCaptureTabViewId  = @"capture";
     [_fileNameStubLabel setStringValue: _NS("Choose a file")];
     [_fileIconWell setImage: [NSImage imageNamed:@"generic"]];
     [_fileBrowseButton setTitle: _NS("Browse...")];
-    [[_fileBrowseButton cell] accessibilitySetOverrideValue:_NS("Select a file for playback") forAttribute:NSAccessibilityDescriptionAttribute];
+    _fileBrowseButton.accessibilityLabel = _NS("Select a file for playback");
     [_fileTreatAsPipeButton setTitle: _NS("Treat as a pipe rather than as a file")];
     [_fileTreatAsPipeButton setHidden: NO];
     [_fileSlaveCheckbox setTitle: _NS("Play another media synchronously")];
     [_fileSelectSlaveButton setTitle: _NS("Choose...")];
-    [[_fileBrowseButton cell] accessibilitySetOverrideValue:_NS("Select another file to play in sync with the previously selected file") forAttribute:NSAccessibilityDescriptionAttribute];
+    _fileBrowseButton.accessibilityLabel = _NS("Select another file to play in sync with the previously selected file");
     [_fileSlaveFilenameLabel setStringValue: @""];
     [_fileSlaveIconWell setImage: NULL];
     [_fileSubtitlesFilenameLabel setStringValue: @""];
@@ -188,7 +188,7 @@ static NSString *kCaptureTabViewId  = @"capture";
     [_netHTTPURLLabel setStringValue: _NS("URL")];
     [_netHelpLabel setStringValue: _NS("To Open a usual network stream (HTTP, RTSP, RTMP, MMS, FTP, etc.), just enter the URL in the field above. If you want to open a RTP or UDP stream, press the button below.")];
     [_netHelpUDPLabel setStringValue: _NS("If you want to open a multicast stream, enter the respective IP address given by the stream provider. In unicast mode, VLC will use your machine's IP automatically.\n\nTo open a stream using a different protocol, just press Cancel to close this sheet.")];
-    [_netHTTPURLTextField accessibilitySetOverrideValue:_NS("Enter a stream URL here. To open RTP or UDP streams, use the respective button below.") forAttribute:NSAccessibilityDescriptionAttribute];
+    _netHTTPURLTextField.accessibilityLabel = _NS("Enter a stream URL here. To open RTP or UDP streams, use the respective button below.");
     [_netUDPCancelButton setTitle: _NS("Cancel")];
     [_netUDPOKButton setTitle: _NS("Open")];
     [_netOpenUDPButton setTitle: _NS("Open RTP/UDP Stream")];
@@ -351,10 +351,10 @@ static NSString *kCaptureTabViewId  = @"capture";
     [_fileSubPathLabel setHidden: NO];
     [_fileSubPathTextField setStringValue: @""];
     [_fileSubSettingsButton setTitle: _NS("Choose...")];
-    [[_fileSubSettingsButton cell] accessibilitySetOverrideValue:_NS("Setup subtitle playback details") forAttribute:NSAccessibilityDescriptionAttribute];
-    [[_fileBrowseButton cell] accessibilitySetOverrideValue:_NS("Select a file for playback") forAttribute:NSAccessibilityDescriptionAttribute];
+    _fileSubSettingsButton.accessibilityLabel = _NS("Setup subtitle playback details");
+    _fileBrowseButton.accessibilityLabel = _NS("Select a file for playback");
     [_fileSubBrowseButton setTitle: _NS("Browse...")];
-    [[_fileSubBrowseButton cell] accessibilitySetOverrideValue:_NS("Select a subtitle file") forAttribute:NSAccessibilityDescriptionAttribute];
+    _fileSubBrowseButton.accessibilityLabel = _NS("Select a subtitle file");
     [_fileSubOverrideCheckbox setTitle: _NS("Override parameters")];
     [_fileSubDelayLabel setStringValue: _NS("Delay")];
     [_fileSubDelayStepper setEnabled: NO];
@@ -367,7 +367,7 @@ static NSString *kCaptureTabViewId  = @"capture";
     [_fileSubAlignLabel setStringValue: _NS("Subtitle alignment")];
     [_fileSubAlignPopup removeAllItems];
     [_fileSubOKButton setStringValue: _NS("OK")];
-    [[_fileSubOKButton cell] accessibilitySetOverrideValue:_NS("Dismiss the subtitle setup dialog") forAttribute:NSAccessibilityDescriptionAttribute];
+    _fileSubOKButton.accessibilityLabel = _NS("Dismiss the subtitle setup dialog");
     [_fileSubFontBox setTitle: _NS("Font Properties")];
     [_fileSubFileBox setTitle: _NS("Subtitle File")];
 
diff --git a/modules/gui/macosx/VLCStatusBarIcon.m b/modules/gui/macosx/VLCStatusBarIcon.m
index 0da41074a8..72201064ef 100644
--- a/modules/gui/macosx/VLCStatusBarIcon.m
+++ b/modules/gui/macosx/VLCStatusBarIcon.m
@@ -97,18 +97,10 @@
     [self configurationChanged:nil];
 
     // Set Accessibility Attributes for Image Buttons
-    [backwardsButton.cell accessibilitySetOverrideValue:_NS("Go to previous item")
-                                           forAttribute:NSAccessibilityDescriptionAttribute];
-
-    [playPauseButton.cell accessibilitySetOverrideValue:_NS("Toggle Play/Pause")
-                                           forAttribute:NSAccessibilityDescriptionAttribute];
-
-    [forwardButton.cell accessibilitySetOverrideValue:_NS("Go to next item")
-                                         forAttribute:NSAccessibilityDescriptionAttribute];
-
-    [randButton.cell accessibilitySetOverrideValue:_NS("Toggle random order playback")
-                                      forAttribute:NSAccessibilityDescriptionAttribute];
-    
+    backwardsButton.accessibilityLabel = _NS("Go to previous item");
+    playPauseButton.accessibilityLabel = _NS("Toggle Play/Pause");
+    forwardButton.accessibilityLabel = _NS("Go to next item");
+    randButton.accessibilityLabel = _NS("Toggle random order playback");
 
     // Populate menu items with localized strings
     [showMainWindowItem setTitle:_NS("Show Main Window")];



More information about the vlc-commits mailing list