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 @@ ...@@ -211,6 +211,10 @@
@property (readwrite, weak) IBOutlet NSStepper *specificTime_stepper; @property (readwrite, weak) IBOutlet NSStepper *specificTime_stepper;
@property (nonatomic) int jumpTimeValue; @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)releaseRepresentedObjects:(NSMenu *)the_menu;
- (void)setupMenus; - (void)setupMenus;
......
...@@ -1212,7 +1212,70 @@ ...@@ -1212,7 +1212,70 @@
- (IBAction)savePlaylist:(id)sender - (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 - (IBAction)revealItemInFinder:(id)sender
......
...@@ -53,6 +53,7 @@ typedef enum { ...@@ -53,6 +53,7 @@ typedef enum {
IBOutlet id o_search_fld; IBOutlet id o_search_fld;
IBOutlet id o_playlist_table; IBOutlet id o_playlist_table;
IBOutlet id o_outline_view;
IBOutlet id o_split_view; IBOutlet id o_split_view;
IBOutlet id o_left_split_view; IBOutlet id o_left_split_view;
IBOutlet id o_right_split_view; IBOutlet id o_right_split_view;
...@@ -97,6 +98,8 @@ typedef enum { ...@@ -97,6 +98,8 @@ typedef enum {
- (IBAction)removePodcast:(id)sender; - (IBAction)removePodcast:(id)sender;
- (IBAction)removePodcastWindowAction:(id)sender; - (IBAction)removePodcastWindowAction:(id)sender;
- (IBAction)searchItem:(id)sender;
- (void)windowResizedOrMoved:(NSNotification *)notification; - (void)windowResizedOrMoved:(NSNotification *)notification;
- (void)reloadSidebar; - (void)reloadSidebar;
......
...@@ -99,8 +99,6 @@ static VLCMainWindow *sharedInstance = nil; ...@@ -99,8 +99,6 @@ static VLCMainWindow *sharedInstance = nil;
defer:flag]; defer:flag];
}); });
[[[VLCMain sharedInstance] playlist] updateTogglePlaylistState];
return sharedInstance; return sharedInstance;
} }
...@@ -171,6 +169,13 @@ static VLCMainWindow *sharedInstance = nil; ...@@ -171,6 +169,13 @@ static VLCMainWindow *sharedInstance = nil;
[[o_search_fld cell] setPlaceholderString: _NS("Search")]; [[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 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 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]; [[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; ...@@ -973,6 +978,11 @@ static VLCMainWindow *sharedInstance = nil;
return [NSString stringWithFormat:@" — %@",[formatter stringFromDate:date]]; return [NSString stringWithFormat:@" — %@",[formatter stringFromDate:date]];
} }
- (IBAction)searchItem:(id)sender
{
[[[[VLCMain sharedInstance] playlist] model] searchUpdate:[o_search_fld stringValue]];
}
#pragma mark - #pragma mark -
#pragma mark Side Bar Data handling #pragma mark Side Bar Data handling
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */ /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
......
...@@ -68,7 +68,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -68,7 +68,6 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{ {
IBOutlet VLCMainWindow *o_mainwindow; /* VLCMainWindow */ IBOutlet VLCMainWindow *o_mainwindow; /* VLCMainWindow */
IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
} }
@property (readonly) VLCVoutWindowController* voutController; @property (readonly) VLCVoutWindowController* voutController;
......
...@@ -80,9 +80,10 @@ int OpenIntf (vlc_object_t *p_this) ...@@ -80,9 +80,10 @@ int OpenIntf (vlc_object_t *p_this)
msg_Dbg(p_intf, "Starting macosx interface"); msg_Dbg(p_intf, "Starting macosx interface");
[VLCApplication sharedApplication]; [VLCApplication sharedApplication];
[[VLCMain sharedInstance] setIntf: p_intf]; [[VLCMain sharedInstance] setIntf: p_intf];
[NSBundle loadNibNamed:@"MainMenu" owner:[[VLCMain sharedInstance] mainMenu]];
[VLCVoutWindowController sharedInstance]; [VLCVoutWindowController sharedInstance];
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -155,6 +156,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -155,6 +156,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCCoreInteraction *_coreinteraction; VLCCoreInteraction *_coreinteraction;
ResumeDialogController *_resume_dialog; ResumeDialogController *_resume_dialog;
VLCInputManager *_input_manager; VLCInputManager *_input_manager;
VLCPlaylist *_playlist;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */ 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, ...@@ -218,14 +220,11 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification - (void)applicationWillFinishLaunching:(NSNotification *)aNotification
{ {
_playlist = [[VLCPlaylist alloc] init];
[NSBundle loadNibNamed:@"MainWindow" owner:self];
[[self mainWindow] makeKeyAndOrderFront:nil];
_open = [[VLCOpen alloc] init]; _open = [[VLCOpen alloc] init];
_mainmenu = [[VLCMainMenu 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]; _coreinteraction = [VLCCoreInteraction sharedInstance];
playlist_t * p_playlist = pl_Get(VLCIntf); playlist_t * p_playlist = pl_Get(VLCIntf);
...@@ -314,7 +313,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -314,7 +313,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
* the callbacks are registered. * the callbacks are registered.
*/ */
[_input_manager inputThreadChanged]; [_input_manager inputThreadChanged];
[o_playlist playbackModeUpdated]; [_playlist playbackModeUpdated];
// respect playlist-autostart // respect playlist-autostart
// note that PLAYLIST_PLAY will not stop any playback if already started // 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, ...@@ -567,7 +566,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
- (VLCPlaylist *)playlist - (VLCPlaylist *)playlist
{ {
return o_playlist; return _playlist;
} }
- (VLCCoreDialogProvider *)coreDialogProvider - (VLCCoreDialogProvider *)coreDialogProvider
......
/***************************************************************************** /*****************************************************************************
* playlist.h: MacOS X interface module * playlist.h: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2012 VLC authors and VideoLAN * Copyright (C) 2002-2015 VLC authors and VideoLAN
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -37,34 +37,21 @@ ...@@ -37,34 +37,21 @@
* VLCPlaylist interface * VLCPlaylist interface
*****************************************************************************/ *****************************************************************************/
@interface VLCPlaylist : NSObject<NSOutlineViewDataSource, NSOutlineViewDelegate> @interface VLCPlaylist : NSObject<NSOutlineViewDataSource, NSOutlineViewDelegate>
{
IBOutlet VLCPlaylistView* o_outline_view; @property (readwrite, weak) IBOutlet NSMenu *playlistMenu;
@property (readwrite, weak) IBOutlet NSMenuItem *playPlaylistMenuItem;
IBOutlet id o_controller; @property (readwrite, weak) IBOutlet NSMenuItem *deletePlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *infoPlaylistMenuItem;
IBOutlet id o_btn_playlist; @property (readwrite, weak) IBOutlet NSMenuItem *preparsePlaylistMenuItem;
IBOutlet id o_playlist_view; @property (readwrite, weak) IBOutlet NSMenuItem *revealInFinderPlaylistMenuItem;
IBOutlet id o_search_field; @property (readwrite, weak) IBOutlet NSMenuItem *downloadCoverArtPlaylistMenuItem;
IBOutlet id o_mi_save_playlist; @property (readwrite, weak) IBOutlet NSMenuItem *selectAllPlaylistMenuItem;
IBOutlet id o_ctx_menu; @property (readwrite, weak) IBOutlet NSMenuItem *sortNamePlaylistMenuItem;
@property (readwrite, weak) IBOutlet NSMenuItem *sortAuthorPlaylistMenuItem;
IBOutlet id o_mi_play; @property (readwrite, weak) IBOutlet NSMenuItem *recursiveExpandPlaylistMenuItem;
IBOutlet id o_mi_delete;
IBOutlet id o_mi_info; @property (nonatomic, readwrite, weak) VLCPlaylistView *outlineView;
IBOutlet id o_mi_preparse; @property (nonatomic, readwrite, weak) NSTableHeaderView *playlistHeaderView;
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;
}
- (PLModel *)model; - (PLModel *)model;
...@@ -72,8 +59,6 @@ ...@@ -72,8 +59,6 @@
- (NSMenu *)menuForEvent:(NSEvent *)o_event; - (NSMenu *)menuForEvent:(NSEvent *)o_event;
- (IBAction)searchItem:(id)sender;
- (void)playlistUpdated; - (void)playlistUpdated;
- (void)playbackModeUpdated; - (void)playbackModeUpdated;
- (void)updateTogglePlaylistState; - (void)updateTogglePlaylistState;
...@@ -91,7 +76,6 @@ ...@@ -91,7 +76,6 @@
- (IBAction)revealItemInFinder:(id)sender; - (IBAction)revealItemInFinder:(id)sender;
- (IBAction)preparseItem:(id)sender; - (IBAction)preparseItem:(id)sender;
- (IBAction)downloadCoverArt:(id)sender; - (IBAction)downloadCoverArt:(id)sender;
- (IBAction)savePlaylist:(id)sender;
- (IBAction)deleteItem:(id)sender; - (IBAction)deleteItem:(id)sender;
- (IBAction)selectAll:(id)sender; - (IBAction)selectAll:(id)sender;
- (IBAction)sortNodeByName:(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