[vlc-commits] macosx/library and playlist menus: simplify creation code
Felix Paul Kühne
git at videolan.org
Fri May 31 20:07:42 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri May 31 20:07:23 2019 +0200| [3f5ff5a4abbdd05f93cfa3a677cabe06f8b3ad36] | committer: Felix Paul Kühne
macosx/library and playlist menus: simplify creation code
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3f5ff5a4abbdd05f93cfa3a677cabe06f8b3ad36
---
.../gui/macosx/library/VLCLibraryMenuController.m | 25 ++++++++++++++--------
.../macosx/playlist/VLCPlaylistMenuController.m | 13 +++--------
2 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/modules/gui/macosx/library/VLCLibraryMenuController.m b/modules/gui/macosx/library/VLCLibraryMenuController.m
index e930e27bb2..355e3a8181 100644
--- a/modules/gui/macosx/library/VLCLibraryMenuController.m
+++ b/modules/gui/macosx/library/VLCLibraryMenuController.m
@@ -40,19 +40,26 @@
{
self = [super init];
if (self) {
- _libraryMenu = [[NSMenu alloc] initWithTitle:@""];
- [_libraryMenu addItemWithTitle:_NS("Play") action:@selector(play:) keyEquivalent:@""];
- [[_libraryMenu itemAtIndex:0] setTarget:self];
- [_libraryMenu addItemWithTitle:_NS("Append to Playlist") action:@selector(appendToPlaylist:) keyEquivalent:@""];
- [[_libraryMenu itemAtIndex:1] setTarget:self];
- [_libraryMenu addItemWithTitle:_NS("Add Media...") action:@selector(addMedia:) keyEquivalent:@""];
- [[_libraryMenu itemAtIndex:2] setTarget:self];
- [_libraryMenu addItemWithTitle:_NS("Reveal in Finder") action:@selector(revealInFinder:) keyEquivalent:@""];
- [[_libraryMenu itemAtIndex:3] setTarget:self];
+ [self createMenu];
}
return self;
}
+- (void)createMenu
+{
+ NSMenuItem *playItem = [[NSMenuItem alloc] initWithTitle:_NS("Play") action:@selector(play:) keyEquivalent:@""];
+ playItem.target = self;
+ NSMenuItem *appendItem = [[NSMenuItem alloc] initWithTitle:_NS("Append to Playlist") action:@selector(appendToPlaylist:) keyEquivalent:@""];
+ appendItem.target = self;
+ NSMenuItem *addItem = [[NSMenuItem alloc] initWithTitle:_NS("Add Media...") action:@selector(addMedia:) keyEquivalent:@""];
+ addItem.target = self;
+ NSMenuItem *revealItem = [[NSMenuItem alloc] initWithTitle:_NS("Reveal in Finder") action:@selector(revealInFinder:) keyEquivalent:@""];
+ revealItem.target = self;
+
+ _libraryMenu = [[NSMenu alloc] initWithTitle:@""];
+ _libraryMenu.itemArray = @[playItem, appendItem, revealItem, [NSMenuItem separatorItem], addItem];
+}
+
- (void)popupMenuWithEvent:(NSEvent *)theEvent forView:(NSView *)theView
{
[NSMenu popUpContextMenu:_libraryMenu withEvent:theEvent forView:theView];
diff --git a/modules/gui/macosx/playlist/VLCPlaylistMenuController.m b/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
index 446f04e46d..7aeed86620 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
@@ -60,34 +60,27 @@
- (void)createMenu
{
- _playlistMenu = [[NSMenu alloc] init];
-
_playMenuItem = [[NSMenuItem alloc] initWithTitle:_NS("Play") action:@selector(play:) keyEquivalent:@""];
_playMenuItem.target = self;
- [_playlistMenu addItem:_playMenuItem];
_removeMenuItem = [[NSMenuItem alloc] initWithTitle:_NS("Delete") action:@selector(remove:) keyEquivalent:@""];
_removeMenuItem.target = self;
- [_playlistMenu addItem:_removeMenuItem];
_revealInFinderMenuItem = [[NSMenuItem alloc] initWithTitle:_NS("Reveal in Finder") action:@selector(revealInFinder:) keyEquivalent:@""];
_revealInFinderMenuItem.target = self;
- [_playlistMenu addItem:_revealInFinderMenuItem];
-
- [_playlistMenu addItem:[NSMenuItem separatorItem]];
_addFilesToPlaylistMenuItem = [[NSMenuItem alloc] initWithTitle:_NS("Add File...") action:@selector(addFilesToPlaylist:) keyEquivalent:@""];
_addFilesToPlaylistMenuItem.target = self;
- [_playlistMenu addItem:_addFilesToPlaylistMenuItem];
_clearPlaylistMenuItem = [[NSMenuItem alloc] initWithTitle:_NS("Clear the playlist") action:@selector(clearPlaylist:) keyEquivalent:@""];
_clearPlaylistMenuItem.target = self;
- [_playlistMenu addItem:_clearPlaylistMenuItem];
_playlistSortingMenuController = [[VLCPlaylistSortingMenuController alloc] init];
_sortMenuItem = [[NSMenuItem alloc] initWithTitle:_NS("Sort") action:nil keyEquivalent:@""];
[_sortMenuItem setSubmenu:_playlistSortingMenuController.playlistSortingMenu];
- [_playlistMenu addItem:_sortMenuItem];
+
+ _playlistMenu = [[NSMenu alloc] init];
+ _playlistMenu.itemArray = @[_playMenuItem, _removeMenuItem, _revealInFinderMenuItem, [NSMenuItem separatorItem], _addFilesToPlaylistMenuItem, _clearPlaylistMenuItem, _sortMenuItem];
}
- (void)play:(id)sender
More information about the vlc-commits
mailing list