[vlc-commits] macosx/menu: replace implicit 10.14 dependency (closes #23694)
Felix Paul Kühne
git at videolan.org
Sun Feb 2 16:30:02 CET 2020
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Feb 2 16:23:20 2020 +0100| [27a98ee4a92e429e73de9169fbe468b85a6a2940] | committer: Felix Paul Kühne
macosx/menu: replace implicit 10.14 dependency (closes #23694)
The itemArray property is settable in 10.14 and above only, so this commit adds a work-around to retain support with previous releases of macOS.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27a98ee4a92e429e73de9169fbe468b85a6a2940
---
.../package/macosx/VLC.xcodeproj/project.pbxproj | 6 ++++
modules/gui/macosx/Makefile.am | 2 ++
.../gui/macosx/extensions/NSMenu+VLCAdditions.h | 35 +++++++++++++++++++
.../gui/macosx/extensions/NSMenu+VLCAdditions.m | 39 ++++++++++++++++++++++
.../gui/macosx/library/VLCLibraryMenuController.m | 5 +--
.../macosx/playlist/VLCPlaylistMenuController.m | 3 +-
po/POTFILES.in | 2 ++
7 files changed, 89 insertions(+), 3 deletions(-)
diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index 3cd3787692..bc80f68022 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -169,6 +169,7 @@
7DE7232E22A51F8D00D72616 /* VLCPositionFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE7232D22A51F8D00D72616 /* VLCPositionFormatter.m */; };
7DE82E7922843781002D341A /* VLCLibraryAlbumTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE82E7822843781002D341A /* VLCLibraryAlbumTableCellView.m */; };
7DE9C7DD220728420089108F /* VLCPlayerController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DE9C7DC220728420089108F /* VLCPlayerController.m */; };
+ 7DF0994F23E71E76007CA6EE /* NSMenu+VLCAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0994E23E71E76007CA6EE /* NSMenu+VLCAdditions.m */; };
7DFBDCA82269E77500B700A5 /* VLCLibraryController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCA72269E77500B700A5 /* VLCLibraryController.m */; };
7DFBDCAB2269E77F00B700A5 /* VLCLibraryModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCAA2269E77F00B700A5 /* VLCLibraryModel.m */; };
7DFBDCAE2269ED0C00B700A5 /* VLCLibraryVideoDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DFBDCAD2269ED0C00B700A5 /* VLCLibraryVideoDataSource.m */; };
@@ -593,6 +594,8 @@
7DE9C7DC220728420089108F /* VLCPlayerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = VLCPlayerController.m; sourceTree = "<group>"; };
7DF0435E1972E26A0022B534 /* VLCAddonListItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCAddonListItem.h; sourceTree = "<group>"; };
7DF0435F1972E26A0022B534 /* VLCAddonListItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCAddonListItem.m; sourceTree = "<group>"; };
+ 7DF0994D23E71E5B007CA6EE /* NSMenu+VLCAdditions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSMenu+VLCAdditions.h"; sourceTree = "<group>"; };
+ 7DF0994E23E71E76007CA6EE /* NSMenu+VLCAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSMenu+VLCAdditions.m"; sourceTree = "<group>"; };
7DF14FBC2270CB1C0008ABE4 /* VLCMediaSourceDeviceCollectionViewItem.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCMediaSourceDeviceCollectionViewItem.xib; sourceTree = "<group>"; };
7DF812ED1B555A340052293C /* VLCPlaybackContinuityController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaybackContinuityController.h; sourceTree = "<group>"; };
7DF812EE1B555A340052293C /* VLCPlaybackContinuityController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaybackContinuityController.m; sourceTree = "<group>"; };
@@ -1026,6 +1029,8 @@
7D28E6382275B7340098D30E /* NSFont+VLCAdditions.m */,
7D404ABD2281892C00B28EF4 /* NSView+VLCAdditions.h */,
7D404ABE2281892C00B28EF4 /* NSView+VLCAdditions.m */,
+ 7DF0994D23E71E5B007CA6EE /* NSMenu+VLCAdditions.h */,
+ 7DF0994E23E71E76007CA6EE /* NSMenu+VLCAdditions.m */,
);
path = extensions;
sourceTree = "<group>";
@@ -1823,6 +1828,7 @@
1C3113D51E508C6900D4DD76 /* VLCTextfieldPanelController.m in Sources */,
7DFBDCAE2269ED0C00B700A5 /* VLCLibraryVideoDataSource.m in Sources */,
1C3113D71E508C6900D4DD76 /* VLCPopupPanelController.m in Sources */,
+ 7DF0994F23E71E76007CA6EE /* NSMenu+VLCAdditions.m in Sources */,
7D445D8B22032B9200263D34 /* VLCPlaylistTableView.m in Sources */,
1C3113D91E508C6900D4DD76 /* VLCSimplePrefsController.m in Sources */,
7DFBDCC4226E445500B700A5 /* VLCMediaSourceBaseDataSource.m in Sources */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 2b665a04a6..eeb17c10d9 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -34,6 +34,8 @@ libmacosx_plugin_la_SOURCES = \
gui/macosx/extensions/NSColor+VLCAdditions.m \
gui/macosx/extensions/NSFont+VLCAdditions.h \
gui/macosx/extensions/NSFont+VLCAdditions.m \
+ gui/macosx/extensions/NSMenu+VLCAdditions.h \
+ gui/macosx/extensions/NSMenu+VLCAdditions.m \
gui/macosx/extensions/NSScreen+VLCAdditions.h \
gui/macosx/extensions/NSScreen+VLCAdditions.m \
gui/macosx/extensions/NSSound+VLCAdditions.h \
diff --git a/modules/gui/macosx/extensions/NSMenu+VLCAdditions.h b/modules/gui/macosx/extensions/NSMenu+VLCAdditions.h
new file mode 100644
index 0000000000..75fb85065a
--- /dev/null
+++ b/modules/gui/macosx/extensions/NSMenu+VLCAdditions.h
@@ -0,0 +1,35 @@
+/*****************************************************************************
+* NSMenu+ItemAddition.h: MacOS X interface module
+*****************************************************************************
+* Copyright (C) 2020 VLC authors and VideoLAN
+*
+* Author: Felix Paul Kühne <fkuehne at videolan dot org>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+*****************************************************************************/
+
+#import <Cocoa/Cocoa.h>
+
+NS_ASSUME_NONNULL_BEGIN
+
+ at interface NSMenu (VLCAdditions)
+
+/* NSMenu's property itemArray becomes writeable in 10.14 and above only
+ * so the following is provided as a convenience method to add multiple entries */
+- (void)addMenuItemsFromArray:(NSArray <NSMenuItem *>*)array;
+
+ at end
+
+NS_ASSUME_NONNULL_END
diff --git a/modules/gui/macosx/extensions/NSMenu+VLCAdditions.m b/modules/gui/macosx/extensions/NSMenu+VLCAdditions.m
new file mode 100644
index 0000000000..ec2b95a3d1
--- /dev/null
+++ b/modules/gui/macosx/extensions/NSMenu+VLCAdditions.m
@@ -0,0 +1,39 @@
+/*****************************************************************************
+* NSMenu+ItemAddition.m: MacOS X interface module
+*****************************************************************************
+* Copyright (C) 2020 VLC authors and VideoLAN
+*
+* Author: Felix Paul Kühne <fkuehne at videolan dot org>
+*
+* This program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+*****************************************************************************/
+
+#import "NSMenu+VLCAdditions.h"
+
+ at implementation NSMenu (VLCAdditions)
+
+- (void)addMenuItemsFromArray:(NSArray <NSMenuItem *>*)array
+{
+ if (!array) {
+ return;
+ }
+
+ NSUInteger count = array.count;
+ for (NSUInteger x = 0; x < count; x++) {
+ [self addItem:array[x]];
+ }
+}
+
+ at end
diff --git a/modules/gui/macosx/library/VLCLibraryMenuController.m b/modules/gui/macosx/library/VLCLibraryMenuController.m
index 53a365ae1c..e813d96f96 100644
--- a/modules/gui/macosx/library/VLCLibraryMenuController.m
+++ b/modules/gui/macosx/library/VLCLibraryMenuController.m
@@ -28,6 +28,7 @@
#import "library/VLCLibraryInformationPanel.h"
#import "extensions/NSString+Helpers.h"
+#import "extensions/NSMenu+VLCAdditions.h"
@interface VLCLibraryMenuController ()
{
@@ -63,7 +64,7 @@
informationItem.target = self;
_libraryMenu = [[NSMenu alloc] initWithTitle:@""];
- _libraryMenu.itemArray = @[playItem, appendItem, revealItem, deleteItem, informationItem, [NSMenuItem separatorItem], addItem];
+ [_libraryMenu addMenuItemsFromArray:@[playItem, appendItem, revealItem, deleteItem, informationItem, [NSMenuItem separatorItem], addItem]];
}
- (void)popupMenuWithEvent:(NSEvent *)theEvent forView:(NSView *)theView
@@ -74,7 +75,7 @@
NSMenu *minimalMenu = [[NSMenu alloc] initWithTitle:@""];
NSMenuItem *addItem = [[NSMenuItem alloc] initWithTitle:_NS("Add Media Folder...") action:@selector(addMedia:) keyEquivalent:@""];
addItem.target = self;
- minimalMenu.itemArray = @[addItem];
+ [minimalMenu addItem:addItem];
[NSMenu popUpContextMenu:minimalMenu withEvent:theEvent forView:theView];
}
}
diff --git a/modules/gui/macosx/playlist/VLCPlaylistMenuController.m b/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
index 2cb55cd40b..17879916df 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
@@ -25,6 +25,7 @@
#import "VLCPlaylistMenuController.h"
#import "extensions/NSString+Helpers.h"
+#import "extensions/NSMenu+VLCAdditions.h"
#import "main/VLCMain.h"
#import "playlist/VLCPlaylistController.h"
#import "playlist/VLCPlaylistModel.h"
@@ -86,7 +87,7 @@
[_sortMenuItem setSubmenu:_playlistSortingMenuController.playlistSortingMenu];
_playlistMenu = [[NSMenu alloc] init];
- _playlistMenu.itemArray = @[_playMenuItem, _removeMenuItem, _revealInFinderMenuItem, _informationMenuItem, [NSMenuItem separatorItem], _addFilesToPlaylistMenuItem, _clearPlaylistMenuItem, _sortMenuItem];
+ [_playlistMenu addMenuItemsFromArray:@[_playMenuItem, _removeMenuItem, _revealInFinderMenuItem, _informationMenuItem, [NSMenuItem separatorItem], _addFilesToPlaylistMenuItem, _clearPlaylistMenuItem, _sortMenuItem]];
}
- (void)play:(id)sender
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5a60e71ebc..3c99388345 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -445,6 +445,8 @@ modules/gui/macosx/extensions/NSColor+VLCAdditions.h
modules/gui/macosx/extensions/NSColor+VLCAdditions.m
modules/gui/macosx/extensions/NSFont+VLCAdditions.h
modules/gui/macosx/extensions/NSFont+VLCAdditions.m
+modules/gui/macosx/extensions/NSMenu+VLCAdditions.h
+modules/gui/macosx/extensions/NSMenu+VLCAdditions.m
modules/gui/macosx/extensions/NSScreen+VLCAdditions.h
modules/gui/macosx/extensions/NSScreen+VLCAdditions.m
modules/gui/macosx/extensions/NSSound+VLCAdditions.h
More information about the vlc-commits
mailing list