Commit 68827bcd authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: split playlist object from MainWindow.xib

parent 2f854ae3
......@@ -211,6 +211,10 @@
@property (readwrite, weak) IBOutlet NSStepper *specificTime_stepper;
@property (nonatomic) int jumpTimeValue;
@property (readwrite, weak) IBOutlet NSView *playlistSaveAccessoryView;
@property (readwrite, weak) IBOutlet NSPopUpButton *playlistSaveAccessoryPopup;
@property (readwrite, weak) IBOutlet NSTextField *playlistSaveAccessoryText;
- (void)releaseRepresentedObjects:(NSMenu *)the_menu;
- (void)setupMenus;
......
......@@ -1212,7 +1212,70 @@
- (IBAction)savePlaylist:(id)sender
{
[[[VLCMain sharedInstance] playlist] savePlaylist:sender];
playlist_t *p_playlist = pl_Get(VLCIntf);
NSSavePanel *savePanel = [NSSavePanel savePanel];
NSString * name = [NSString stringWithFormat: @"%@", _NS("Untitled")];
[NSBundle loadNibNamed:@"PlaylistAccessoryView" owner:self];
[_playlistSaveAccessoryText setStringValue: _NS("File Format:")];
[[_playlistSaveAccessoryPopup itemAtIndex:0] setTitle: _NS("Extended M3U")];
[[_playlistSaveAccessoryPopup itemAtIndex:1] setTitle: _NS("XML Shareable Playlist Format (XSPF)")];
[[_playlistSaveAccessoryPopup itemAtIndex:2] setTitle: _NS("HTML playlist")];
[savePanel setTitle: _NS("Save Playlist")];
[savePanel setPrompt: _NS("Save")];
[savePanel setAccessoryView: _playlistSaveAccessoryView];
[savePanel setNameFieldStringValue: name];
if ([savePanel runModal] == NSFileHandlingPanelOKButton) {
NSString *filename = [[savePanel URL] path];
if ([_playlistSaveAccessoryPopup indexOfSelectedItem] == 0) {
NSString *actualFilename;
NSRange range;
range.location = [filename length] - [@".m3u" length];
range.length = [@".m3u" length];
if ([filename compare:@".m3u" options: NSCaseInsensitiveSearch range: range] != NSOrderedSame)
actualFilename = [NSString stringWithFormat: @"%@.m3u", filename];
else
actualFilename = filename;
playlist_Export(p_playlist,
[actualFilename fileSystemRepresentation],
p_playlist->p_local_category, "export-m3u");
} else if ([_playlistSaveAccessoryPopup indexOfSelectedItem] == 1) {
NSString *actualFilename;
NSRange range;
range.location = [filename length] - [@".xspf" length];
range.length = [@".xspf" length];
if ([filename compare:@".xspf" options: NSCaseInsensitiveSearch range: range] != NSOrderedSame)
actualFilename = [NSString stringWithFormat: @"%@.xspf", filename];
else
actualFilename = filename;
playlist_Export(p_playlist,
[actualFilename fileSystemRepresentation],
p_playlist->p_local_category, "export-xspf");
} else {
NSString *actualFilename;
NSRange range;
range.location = [filename length] - [@".html" length];
range.length = [@".html" length];
if ([filename compare:@".html" options: NSCaseInsensitiveSearch range: range] != NSOrderedSame)
actualFilename = [NSString stringWithFormat: @"%@.html", filename];
else
actualFilename = filename;
playlist_Export(p_playlist,
[actualFilename fileSystemRepresentation],
p_playlist->p_local_category, "export-html");
}
}
}
- (IBAction)revealItemInFinder:(id)sender
......
......@@ -53,6 +53,7 @@ typedef enum {
IBOutlet id o_search_fld;
IBOutlet id o_playlist_table;
IBOutlet id o_outline_view;
IBOutlet id o_split_view;
IBOutlet id o_left_split_view;
IBOutlet id o_right_split_view;
......@@ -97,6 +98,8 @@ typedef enum {
- (IBAction)removePodcast:(id)sender;
- (IBAction)removePodcastWindowAction:(id)sender;
- (IBAction)searchItem:(id)sender;
- (void)windowResizedOrMoved:(NSNotification *)notification;
- (void)reloadSidebar;
......
......@@ -99,8 +99,6 @@ static VLCMainWindow *sharedInstance = nil;
defer:flag];
});
[[[VLCMain sharedInstance] playlist] updateTogglePlaylistState];
return sharedInstance;
}
......@@ -171,6 +169,13 @@ static VLCMainWindow *sharedInstance = nil;
[[o_search_fld cell] setPlaceholderString: _NS("Search")];
[[o_search_fld cell] accessibilitySetOverrideValue:_NS("Enter a term to search the playlist. Results will be selected in the table.") forAttribute:NSAccessibilityDescriptionAttribute];
[o_search_fld setToolTip: _NS("Search in Playlist")];
VLCPlaylist *playlist = [[VLCMain sharedInstance] playlist];
playlist.outlineView = o_outline_view;
playlist.playlistHeaderView = [o_outline_view headerView];
[o_outline_view setDelegate:playlist];
[o_outline_view setDataSource:playlist];
[o_dropzone_btn setTitle: _NS("Open media...")];
[[o_dropzone_btn cell] accessibilitySetOverrideValue:_NS("Click to open an advanced dialog to select the media to play. You can also drop files here to play.") forAttribute:NSAccessibilityDescriptionAttribute];
......@@ -973,6 +978,11 @@ static VLCMainWindow *sharedInstance = nil;
return [NSString stringWithFormat:@" — %@",[formatter stringFromDate:date]];
}
- (IBAction)searchItem:(id)sender
{
[[[[VLCMain sharedInstance] playlist] model] searchUpdate:[o_search_fld stringValue]];
}
#pragma mark -
#pragma mark Side Bar Data handling
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
......
......@@ -68,7 +68,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{
IBOutlet VLCMainWindow *o_mainwindow; /* VLCMainWindow */
IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
}
@property (readonly) VLCVoutWindowController* voutController;
......
......@@ -80,9 +80,10 @@ int OpenIntf (vlc_object_t *p_this)
msg_Dbg(p_intf, "Starting macosx interface");
[VLCApplication sharedApplication];
[[VLCMain sharedInstance] setIntf: p_intf];
[NSBundle loadNibNamed:@"MainMenu" owner:[[VLCMain sharedInstance] mainMenu]];
[VLCVoutWindowController sharedInstance];
return VLC_SUCCESS;
......@@ -155,6 +156,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCCoreInteraction *_coreinteraction;
ResumeDialogController *_resume_dialog;
VLCInputManager *_input_manager;
VLCPlaylist *_playlist;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */
}
......@@ -218,14 +220,11 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{
_playlist = [[VLCPlaylist alloc] init];
[NSBundle loadNibNamed:@"MainWindow" owner:self];
[[self mainWindow] makeKeyAndOrderFront:nil];
_open = [[VLCOpen alloc] init];
_mainmenu = [[VLCMainMenu alloc] init];
[NSBundle loadNibNamed:@"MainMenu" owner:_mainmenu];
[NSBundle loadNibNamed:@"MainWindow" owner:[VLCMain sharedInstance]];
[[[VLCMain sharedInstance] mainWindow] makeKeyAndOrderFront:nil];
_coreinteraction = [VLCCoreInteraction sharedInstance];
playlist_t * p_playlist = pl_Get(VLCIntf);
......@@ -314,7 +313,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
* the callbacks are registered.
*/
[_input_manager inputThreadChanged];
[o_playlist playbackModeUpdated];
[_playlist playbackModeUpdated];
// respect playlist-autostart
// note that PLAYLIST_PLAY will not stop any playback if already started
......@@ -567,7 +566,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
- (VLCPlaylist *)playlist
{
return o_playlist;
return _playlist;
}
- (VLCCoreDialogProvider *)coreDialogProvider
......
/*****************************************************************************
* playlist.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2012 VLC authors and VideoLAN
* Copyright (C) 2002-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
......@@ -37,34 +37,21 @@
* VLCPlaylist interface
*****************************************************************************/
@interface VLCPlaylist : NSObject<NSOutlineViewDataSource, NSOutlineViewDelegate>
{
IBOutlet VLCPlaylistView* o_outline_view;
IBOutlet id o_controller;
IBOutlet id o_btn_playlist;
IBOutlet id o_playlist_view;
IBOutlet id o_search_field;
IBOutlet id o_mi_save_playlist;
IBOutlet id o_ctx_menu;
IBOutlet id o_mi_play;
IBOutlet id o_mi_delete;
IBOutlet id o_mi_info;
IBOutlet id o_mi_preparse;
IBOutlet id o_mi_revealInFinder;
IBOutlet id o_mi_dl_cover_art;
IBOutlet id o_mi_selectall;
IBOutlet id o_mi_sort_name;
IBOutlet id o_mi_sort_author;
IBOutlet id o_mi_recursive_expand;
IBOutlet id o_save_accessory_view;
IBOutlet id o_save_accessory_popup;
IBOutlet id o_save_accessory_text;
IBOutlet id o_playlist_header;
}
@property (readwrite, weak) IBOutlet NSMenu *playlistMenu;
@property (readwrite, weak) IBOutlet NSMenuItem *playPlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *deletePlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *infoPlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *preparsePlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *revealInFinderPlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *downloadCoverArtPlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *selectAllPlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *sortNamePlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *sortAuthorPlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *recursiveExpandPlaylistMenuItem;
@property (nonatomic, readwrite, weak) VLCPlaylistView *outlineView;
@property (nonatomic, readwrite, weak) NSTableHeaderView *playlistHeaderView;
- (PLModel *)model;
......@@ -72,8 +59,6 @@
- (NSMenu *)menuForEvent:(NSEvent *)o_event;
- (IBAction)searchItem:(id)sender;
- (void)playlistUpdated;
- (void)playbackModeUpdated;
- (void)updateTogglePlaylistState;
......@@ -91,7 +76,6 @@
- (IBAction)revealItemInFinder:(id)sender;
- (IBAction)preparseItem:(id)sender;
- (IBAction)downloadCoverArt:(id)sender;
- (IBAction)savePlaylist:(id)sender;
- (IBAction)deleteItem:(id)sender;
- (IBAction)selectAll:(id)sender;
- (IBAction)sortNodeByName:(id)sender;
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment