10 changed files with 310 additions and 8 deletions
@ -0,0 +1,70 @@ |
|||
<?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> |
|||
@ -0,0 +1,50 @@ |
|||
/*****************************************************************************
|
|||
* VLCPlaylistMenuController.h: MacOS X interface module |
|||
***************************************************************************** |
|||
* Copyright (C) 2002-2019 VLC authors and VideoLAN |
|||
* |
|||
* Authors: Benjamin Pracht <bigben at videolan dot org> |
|||
* Felix Paul Kühne <fkuehne at videolan dot org> |
|||
* David Fuhrmann <dfuhrmann # videolan.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 |
|||
|
|||
@interface VLCPlaylistMenuController : NSObject |
|||
|
|||
@property (readwrite, weak) NSTableView *playlistTableView; |
|||
|
|||
@property (readwrite, strong) IBOutlet NSMenu *playlistMenu; |
|||
@property (readwrite, weak) IBOutlet NSMenuItem *playMenuItem; |
|||
@property (readwrite, weak) IBOutlet NSMenuItem *revealInFinderMenuItem; |
|||
@property (readwrite, weak) IBOutlet NSMenuItem *addFilesToPlaylistMenuItem; |
|||
@property (readwrite, weak) IBOutlet NSMenuItem *removeMenuItem; |
|||
@property (readwrite, weak) IBOutlet NSMenuItem *clearPlaylistMenuItem; |
|||
@property (readwrite, weak) IBOutlet NSMenuItem *sortPlaylistMenuItem; |
|||
@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; |
|||
|
|||
@end |
|||
|
|||
NS_ASSUME_NONNULL_END |
|||
@ -0,0 +1,125 @@ |
|||
/***************************************************************************** |
|||
* VLCPlaylistMenuController.m: MacOS X interface module |
|||
***************************************************************************** |
|||
* Copyright (C) 2002-2019 VLC authors and VideoLAN |
|||
* |
|||
* Authors: Benjamin Pracht <bigben at videolan dot org> |
|||
* Felix Paul Kühne <fkuehne at videolan dot org> |
|||
* David Fuhrmann <dfuhrmann # videolan.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 "VLCPlaylistMenuController.h" |
|||
#import "VLCMain.h" |
|||
#import "VLCPlaylistController.h" |
|||
#import "VLCPlaylistModel.h" |
|||
#import "VLCPlaylistItem.h" |
|||
#import "VLCOpenWindowController.h" |
|||
|
|||
@interface VLCPlaylistMenuController () |
|||
{ |
|||
VLCPlaylistController *_playlistController; |
|||
} |
|||
@end |
|||
|
|||
@implementation VLCPlaylistMenuController |
|||
|
|||
- (instancetype)init |
|||
{ |
|||
self = [super init]; |
|||
if (self) { |
|||
_playlistController = [[VLCMain sharedInstance] playlistController]; |
|||
[[NSBundle mainBundle] loadNibNamed:@"VLCPlaylistMenu" owner:self topLevelObjects:nil]; |
|||
} |
|||
return self; |
|||
} |
|||
|
|||
- (void)awakeFromNib |
|||
{ |
|||
[_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")]; |
|||
} |
|||
|
|||
- (IBAction)play:(id)sender |
|||
{ |
|||
NSInteger selectedRow = self.playlistTableView.selectedRow; |
|||
|
|||
if (selectedRow != -1) { |
|||
[_playlistController playItemAtIndex:selectedRow]; |
|||
} else { |
|||
[_playlistController startPlaylist]; |
|||
} |
|||
} |
|||
|
|||
- (IBAction)remove:(id)sender |
|||
{ |
|||
NSInteger selectedRow = self.playlistTableView.selectedRow; |
|||
|
|||
if (selectedRow != -1) { |
|||
[_playlistController removeItemAtIndex:selectedRow]; |
|||
} |
|||
} |
|||
|
|||
- (IBAction)revealInFinder:(id)sender |
|||
{ |
|||
NSInteger selectedRow = self.playlistTableView.selectedRow; |
|||
|
|||
if (selectedRow == -1) |
|||
return; |
|||
|
|||
VLCPlaylistItem *item = [_playlistController.playlistModel playlistItemAtIndex:selectedRow]; |
|||
if (item == nil) { |
|||
return; |
|||
} |
|||
|
|||
NSString *path = item.path; |
|||
[[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:path]; |
|||
} |
|||
|
|||
- (IBAction)addFilesToPlaylist:(id)sender |
|||
{ |
|||
NSInteger selectedRow = self.playlistTableView.selectedRow; |
|||
|
|||
[[[VLCMain sharedInstance] open] openFileWithAction:^(NSArray *files) { |
|||
[self->_playlistController addPlaylistItems:files |
|||
atPosition:selectedRow |
|||
startPlayback:NO]; |
|||
}]; |
|||
} |
|||
|
|||
- (IBAction)clearPlaylist:(id)sender |
|||
{ |
|||
[_playlistController clearPlaylist]; |
|||
} |
|||
|
|||
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem |
|||
{ |
|||
if (menuItem == self.addFilesToPlaylistMenuItem) { |
|||
return YES; |
|||
} |
|||
|
|||
if (_playlistController.playlistModel.numberOfPlaylistItems > 0) { |
|||
return YES; |
|||
} |
|||
|
|||
return NO; |
|||
} |
|||
|
|||
@end |
|||
Loading…
Reference in new issue