[vlc-commits] macosx: generate playlist menu in code instead of using a xib file
Felix Paul Kühne
git at videolan.org
Fri May 31 18:22:20 CEST 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Fri May 31 18:20:18 2019 +0200| [0137809a82ae57d3ece480a5e5a76c1664b02b3f] | committer: Felix Paul Kühne
macosx: generate playlist menu in code instead of using a xib file
No functional changes except for removing the sorting stub
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0137809a82ae57d3ece480a5e5a76c1664b02b3f
---
.../package/macosx/VLC.xcodeproj/project.pbxproj | 2 -
modules/gui/macosx/Makefile.am | 1 -
modules/gui/macosx/UI/VLCPlaylistMenu.xib | 70 ----------------------
.../macosx/playlist/VLCPlaylistMenuController.h | 16 +----
.../macosx/playlist/VLCPlaylistMenuController.m | 59 ++++++++++++------
5 files changed, 42 insertions(+), 106 deletions(-)
diff --git a/extras/package/macosx/VLC.xcodeproj/project.pbxproj b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
index fea8965c80..a5d6ad34d0 100644
--- a/extras/package/macosx/VLC.xcodeproj/project.pbxproj
+++ b/extras/package/macosx/VLC.xcodeproj/project.pbxproj
@@ -486,7 +486,6 @@
7D445D8A22032B9200263D34 /* VLCPlaylistTableView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistTableView.m; sourceTree = "<group>"; };
7D445D8C2203375100263D34 /* VLCPlaylistMenuController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCPlaylistMenuController.h; sourceTree = "<group>"; };
7D445D8D2203375100263D34 /* VLCPlaylistMenuController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCPlaylistMenuController.m; sourceTree = "<group>"; };
- 7D445D8F220339D400263D34 /* VLCPlaylistMenu.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = VLCPlaylistMenu.xib; sourceTree = "<group>"; };
7D460B0A229EB4C700097948 /* VLCDragDropView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VLCDragDropView.h; sourceTree = "<group>"; };
7D460B0B229EB4C700097948 /* VLCDragDropView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VLCDragDropView.m; sourceTree = "<group>"; };
7D5678EB1D5BA1DC002698F3 /* VLCApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VLCApplication.h; sourceTree = "<group>"; };
@@ -1518,7 +1517,6 @@
6B8224091E4D2A9000833BE1 /* MainMenu.xib */,
7D713D332201BB130042BEB7 /* VLCLibraryWindow.xib */,
7D0F64002201F66D00FDB91F /* VLCPlaylistTableCellView.xib */,
- 7D445D8F220339D400263D34 /* VLCPlaylistMenu.xib */,
7D0F64052202047900FDB91F /* VLCLibraryCollectionViewItem.xib */,
7DE2F0482282D7980040DD0A /* VLCLibraryTableCellView.xib */,
7DE82E7A228437AA002D341A /* VLCLibraryAlbumTableCellView.xib */,
diff --git a/modules/gui/macosx/Makefile.am b/modules/gui/macosx/Makefile.am
index 9be4e91373..d8f313a29d 100644
--- a/modules/gui/macosx/Makefile.am
+++ b/modules/gui/macosx/Makefile.am
@@ -266,7 +266,6 @@ libmacosx_plugin_la_XIB_SOURCES = \
gui/macosx/UI/VLCLibraryAlbumTableCellView.xib \
gui/macosx/UI/VLCLibraryWindow.xib \
gui/macosx/UI/VLCLibraryTableCellView.xib \
- gui/macosx/UI/VLCPlaylistMenu.xib \
gui/macosx/UI/VLCPlaylistTableCellView.xib \
gui/macosx/UI/VLCLibraryCollectionViewItem.xib \
gui/macosx/UI/VLCMediaSourceCollectionViewItem.xib \
diff --git a/modules/gui/macosx/UI/VLCPlaylistMenu.xib b/modules/gui/macosx/UI/VLCPlaylistMenu.xib
deleted file mode 100644
index abeb2628f9..0000000000
--- a/modules/gui/macosx/UI/VLCPlaylistMenu.xib
+++ /dev/null
@@ -1,70 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
- <dependencies>
- <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
- </dependencies>
- <objects>
- <customObject id="-2" userLabel="File's Owner" customClass="VLCPlaylistMenuController">
- <connections>
- <outlet property="addFilesToPlaylistMenuItem" destination="Mdx-tr-uuI" id="XXf-67-eWE"/>
- <outlet property="clearPlaylistMenuItem" destination="mfa-zG-Des" id="NjY-ev-rHM"/>
- <outlet property="playMenuItem" destination="f6u-YD-nbW" id="cf7-f3-bCx"/>
- <outlet property="playlistMenu" destination="dq6-Th-J8r" id="9Tj-Qo-HbU"/>
- <outlet property="removeMenuItem" destination="YHt-8w-4G2" id="bRJ-4k-Oa5"/>
- <outlet property="revealInFinderMenuItem" destination="FgT-MW-hvr" id="677-Gn-fVV"/>
- <outlet property="sortPlaylistMenu" destination="fcX-EB-mJe" id="ww1-Y1-3SO"/>
- <outlet property="sortPlaylistMenuItem" destination="fcX-EB-mJe" id="61o-Ll-UrY"/>
- </connections>
- </customObject>
- <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
- <customObject id="-3" userLabel="Application" customClass="NSObject"/>
- <customObject id="YLy-65-1bz" customClass="NSFontManager"/>
- <menu id="dq6-Th-J8r">
- <items>
- <menuItem title="Play" id="f6u-YD-nbW">
- <modifierMask key="keyEquivalentModifierMask"/>
- <connections>
- <action selector="play:" target="-2" id="baE-Tq-f7Q"/>
- </connections>
- </menuItem>
- <menuItem title="Remove" id="YHt-8w-4G2">
- <modifierMask key="keyEquivalentModifierMask"/>
- <connections>
- <action selector="remove:" target="-2" id="d7Q-Rl-br2"/>
- </connections>
- </menuItem>
- <menuItem title="Reveal in Finder" id="FgT-MW-hvr">
- <modifierMask key="keyEquivalentModifierMask"/>
- <connections>
- <action selector="revealInFinder:" target="-2" id="1hT-vw-QWq"/>
- </connections>
- </menuItem>
- <menuItem isSeparatorItem="YES" id="hKI-E8-VMA"/>
- <menuItem title="Add Files" id="Mdx-tr-uuI">
- <modifierMask key="keyEquivalentModifierMask"/>
- <connections>
- <action selector="addFilesToPlaylist:" target="-2" id="1MB-8E-leR"/>
- </connections>
- </menuItem>
- <menuItem title="Clear Playlist" id="mfa-zG-Des">
- <modifierMask key="keyEquivalentModifierMask"/>
- <connections>
- <action selector="clearPlaylist:" target="-2" id="yy4-15-pKY"/>
- </connections>
- </menuItem>
- <menuItem isSeparatorItem="YES" id="8XF-0j-B5C"/>
- <menuItem title="Sort" id="fcX-EB-mJe">
- <modifierMask key="keyEquivalentModifierMask"/>
- <menu key="submenu" title="Sort" id="7gg-17-3N9">
- <items>
- <menuItem title="Item" id="cjh-Mt-gsu">
- <modifierMask key="keyEquivalentModifierMask"/>
- </menuItem>
- </items>
- </menu>
- </menuItem>
- </items>
- <point key="canvasLocation" x="-88" y="-124"/>
- </menu>
- </objects>
-</document>
diff --git a/modules/gui/macosx/playlist/VLCPlaylistMenuController.h b/modules/gui/macosx/playlist/VLCPlaylistMenuController.h
index 5c42e483d6..ac78cb0618 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistMenuController.h
+++ b/modules/gui/macosx/playlist/VLCPlaylistMenuController.h
@@ -29,21 +29,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCPlaylistMenuController : NSObject
@property (readwrite, weak) NSTableView *playlistTableView;
-
- at property (readwrite, strong) IBOutlet NSMenu *playlistMenu;
- at property (readwrite, weak) IBOutlet NSMenuItem *playMenuItem;
- at property (readwrite, weak) IBOutlet NSMenuItem *revealInFinderMenuItem;
- at property (readwrite, weak) IBOutlet NSMenuItem *addFilesToPlaylistMenuItem;
- at property (readwrite, weak) IBOutlet NSMenuItem *removeMenuItem;
- at property (readwrite, weak) IBOutlet NSMenuItem *clearPlaylistMenuItem;
- at property (readwrite, weak) IBOutlet NSMenuItem *sortPlaylistMenuItem;
- at property (readwrite, weak) IBOutlet NSMenuItem *sortPlaylistMenu;
-
-- (IBAction)play:(id)sender;
-- (IBAction)remove:(id)sender;
-- (IBAction)revealInFinder:(id)sender;
-- (IBAction)addFilesToPlaylist:(id)sender;
-- (IBAction)clearPlaylist:(id)sender;
+ at property (readonly) NSMenu *playlistMenu;
@end
diff --git a/modules/gui/macosx/playlist/VLCPlaylistMenuController.m b/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
index c5c887d00e..3f627a9a3f 100644
--- a/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
+++ b/modules/gui/macosx/playlist/VLCPlaylistMenuController.m
@@ -34,6 +34,12 @@
@interface VLCPlaylistMenuController ()
{
VLCPlaylistController *_playlistController;
+
+ NSMenuItem *_playMenuItem;
+ NSMenuItem *_revealInFinderMenuItem;
+ NSMenuItem *_addFilesToPlaylistMenuItem;
+ NSMenuItem *_removeMenuItem;
+ NSMenuItem *_clearPlaylistMenuItem;
}
@end
@@ -43,23 +49,40 @@
{
self = [super init];
if (self) {
+ [self createMenu];
_playlistController = [[VLCMain sharedInstance] playlistController];
- [[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistMenu" owner:self topLevelObjects:nil];
}
return self;
}
-- (void)awakeFromNib
+- (void)createMenu
{
- [_playMenuItem setTitle:_NS("Play")];
- [_revealInFinderMenuItem setTitle:_NS("Reveal in Finder")];
- [_addFilesToPlaylistMenuItem setTitle:_NS("Add File...")];
- [_removeMenuItem setTitle:_NS("Delete")];
- [_clearPlaylistMenuItem setTitle:_NS("Clear the playlist")];
- [_sortPlaylistMenuItem setTitle:_NS("Sort by")];
+ _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];
}
-- (IBAction)play:(id)sender
+- (void)play:(id)sender
{
NSInteger selectedRow = self.playlistTableView.selectedRow;
@@ -70,7 +93,7 @@
}
}
-- (IBAction)remove:(id)sender
+- (void)remove:(id)sender
{
if (self.playlistTableView.selectedRow == -1)
return;
@@ -78,7 +101,7 @@
[_playlistController removeItemsAtIndexes:self.playlistTableView.selectedRowIndexes];
}
-- (IBAction)revealInFinder:(id)sender
+- (void)revealInFinder:(id)sender
{
NSInteger selectedRow = self.playlistTableView.selectedRow;
@@ -93,7 +116,7 @@
[[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:path];
}
-- (IBAction)addFilesToPlaylist:(id)sender
+- (void)addFilesToPlaylist:(id)sender
{
NSInteger selectedRow = self.playlistTableView.selectedRow;
@@ -104,24 +127,24 @@
}];
}
-- (IBAction)clearPlaylist:(id)sender
+- (void)clearPlaylist:(id)sender
{
[_playlistController clearPlaylist];
}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
- if (menuItem == self.addFilesToPlaylistMenuItem) {
+ if (menuItem == _addFilesToPlaylistMenuItem) {
return YES;
- } else if (menuItem == self.clearPlaylistMenuItem) {
+ } else if (menuItem == _clearPlaylistMenuItem) {
return (self.playlistTableView.numberOfRows > 0);
- } else if (menuItem == self.removeMenuItem ||
- menuItem == self.playMenuItem) {
+ } else if (menuItem == _removeMenuItem ||
+ menuItem == _playMenuItem) {
return (self.playlistTableView.numberOfSelectedRows > 0);
- } else if (menuItem == self.revealInFinderMenuItem) {
+ } else if (menuItem == _revealInFinderMenuItem) {
return (self.playlistTableView.numberOfSelectedRows == 1);
}
More information about the vlc-commits
mailing list