Skip to content

Commit

Permalink
macosx: split playlist source file
Browse files Browse the repository at this point in the history
  • Loading branch information
fkuehne committed Jul 22, 2015
1 parent c169acf commit 896af42
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 92 deletions.
4 changes: 4 additions & 0 deletions extras/package/macosx/vlc.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1246,6 +1246,8 @@
7D8BB0B61830311300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/DebugMessageVisualizer.xib; sourceTree = "<group>"; };
7D8BB0B91830367200FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PlaylistMenu.xib; sourceTree = "<group>"; };
7D8BB0BF1830393300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/MainWindow.xib; sourceTree = "<group>"; };
7DA481221B5FC13700917FD7 /* playlistview.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = playlistview.h; path = ../../../modules/gui/macosx/playlistview.h; sourceTree = "<group>"; };
7DA481231B5FC13700917FD7 /* playlistview.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = playlistview.m; path = ../../../modules/gui/macosx/playlistview.m; sourceTree = "<group>"; };
7DB65D5218ABD6380053B874 /* AddonsWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AddonsWindowController.h; path = ../../../modules/gui/macosx/AddonsWindowController.h; sourceTree = SOURCE_ROOT; };
7DB65D5318ABD6380053B874 /* AddonsWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = AddonsWindowController.m; path = ../../../modules/gui/macosx/AddonsWindowController.m; sourceTree = SOURCE_ROOT; };
7DB65D5518ABD6490053B874 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/AddonManager.xib; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1860,6 +1862,8 @@
8E55FB800459B0FD00FB3317 /* output.m */,
8ED6C28303E2EB1C0059A3A7 /* playlist.h */,
8ED6C28403E2EB1C0059A3A7 /* playlist.m */,
7DA481221B5FC13700917FD7 /* playlistview.h */,
7DA481231B5FC13700917FD7 /* playlistview.m */,
8E49720006417F6800370C9F /* playlistinfo.h */,
8E49720106417F6800370C9F /* playlistinfo.m */,
7DF812F11B5599E40052293C /* PLItem.h */,
Expand Down
1 change: 1 addition & 0 deletions modules/gui/macosx/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ libmacosx_plugin_la_SOURCES = \
misc.h misc.m \
open.h open.m \
output.h output.m \
playlistview.h playlistview.m \
playlist.h playlist.m \
playlistinfo.h playlistinfo.m \
PLItem.h PLItem.m \
Expand Down
16 changes: 3 additions & 13 deletions modules/gui/macosx/playlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* Copyright (C) 2002-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <[email protected]>
* Derk-Jan Hartman <hartman at videolan dot org>
* Authors: Benjamin Pracht <bigben at videolab dot org>
* Felix Paul Kühne <fkuehne at videolan dot org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
*
* 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
Expand All @@ -25,17 +25,8 @@

#import "PXSourceList.h"
#import "PLModel.h"
#import "playlistview.h"

/*****************************************************************************
* VLCPlaylistView interface
*****************************************************************************/
@interface VLCPlaylistView : NSOutlineView

@end

/*****************************************************************************
* VLCPlaylist interface
*****************************************************************************/
@interface VLCPlaylist : NSObject<NSOutlineViewDelegate>

@property (readwrite, weak) IBOutlet NSMenu *playlistMenu;
Expand Down Expand Up @@ -71,7 +62,6 @@

- (void)deletionCompleted;


- (IBAction)playItem:(id)sender;
- (IBAction)revealItemInFinder:(id)sender;
- (IBAction)preparseItem:(id)sender;
Expand Down
86 changes: 7 additions & 79 deletions modules/gui/macosx/playlist.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* Copyright (C) 2002-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Jon Lech Johansen <[email protected]>
* Derk-Jan Hartman <hartman at videola/n dot org>
* Benjamin Pracht <bigben at videolab dot org>
* Authors: Derk-Jan Hartman <hartman at videola/n dot org>
* Benjamin Pracht <bigben at videolan dot org>
* Felix Paul Kühne <fkuehne at videolan dot org>
* David Fuhrmann <david dot fuhrmann at googlemail dot com>
*
* 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
Expand Down Expand Up @@ -112,74 +112,6 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
}
}

/*****************************************************************************
* VLCPlaylistView implementation
*****************************************************************************/
@implementation VLCPlaylistView

- (NSMenu *)menuForEvent:(NSEvent *)o_event
{
return([(VLCPlaylist *)[self delegate] menuForEvent: o_event]);
}

- (void)keyDown:(NSEvent *)o_event
{
unichar key = 0;

if ([[o_event characters] length])
key = [[o_event characters] characterAtIndex: 0];

switch(key) {
case NSDeleteCharacter:
case NSDeleteFunctionKey:
case NSDeleteCharFunctionKey:
case NSBackspaceCharacter:
[(VLCPlaylist *)[self delegate] deleteItem:self];
break;

case NSEnterCharacter:
case NSCarriageReturnCharacter:
[(VLCPlaylist *)[[VLCMain sharedInstance] playlist] playItem:nil];
break;

default:
[super keyDown: o_event];
break;
}
}

- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if (([self numberOfSelectedRows] >= 1 && [item action] == @selector(delete:)) || [item action] == @selector(selectAll:))
return YES;

return NO;
}

- (BOOL)acceptsFirstResponder
{
return YES;
}

- (BOOL)becomeFirstResponder
{
[self setNeedsDisplay:YES];
return YES;
}

- (BOOL)resignFirstResponder
{
[self setNeedsDisplay:YES];
return YES;
}

- (IBAction)delete:(id)sender
{
[[[VLCMain sharedInstance] playlist] deleteItem: sender];
}

@end

/*****************************************************************************
* An extension to NSOutlineView's interface to fix compilation warnings
* and let us access these 2 functions properly.
Expand All @@ -193,10 +125,6 @@ + (NSImage *)_defaultTableHeaderSortImage;
+ (NSImage *)_defaultTableHeaderReverseSortImage;
@end


/*****************************************************************************
* VLCPlaylist implementation
*****************************************************************************/
@interface VLCPlaylist ()
{
NSImage *_descendingSortingImage;
Expand Down Expand Up @@ -732,12 +660,12 @@ - (input_item_t *)createItem:(NSDictionary *)itemToCreateDict
if (optionsArray) {
NSUInteger count = [optionsArray count];
for (NSUInteger i = 0; i < count; i++)
input_item_AddOption(p_input, [o_options[i] UTF8String], VLC_INPUT_OPTION_TRUSTED);
input_item_AddOption(p_input, [optionsArray[i] UTF8String], VLC_INPUT_OPTION_TRUSTED);
}

/* Recent documents menu */
if (url != nil && (BOOL)config_GetInt(p_playlist, "macosx-recentitems") == YES)
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL: o_nsurl];
[[NSDocumentController sharedDocumentController] noteNewRecentDocumentURL:url];

return p_input;
}
Expand Down Expand Up @@ -866,9 +794,9 @@ - (void)outlineView:(NSOutlineView *)outlineView didClickTableColumn:(NSTableCol
b_isSortDescending = false;

if (b_isSortDescending)
i_type = ORDER_REVERSE;
type = ORDER_REVERSE;
else
i_type = ORDER_NORMAL;
type = ORDER_NORMAL;

[[self model] sortForColumn:identifier withMode:type];

Expand Down
29 changes: 29 additions & 0 deletions modules/gui/macosx/playlistview.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*****************************************************************************
* playlist.h: MacOS X interface module
*****************************************************************************
* Copyright (C) 2002-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Derk-Jan Hartman <hartman at videolan dot org>
* Felix Paul Kühne <fkuehne at videolan dot 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>

@interface VLCPlaylistView : NSOutlineView

@end
93 changes: 93 additions & 0 deletions modules/gui/macosx/playlistview.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*****************************************************************************
* playlistview.m: MacOS X interface module
*****************************************************************************
* Copyright (C) 2003-2015 VLC authors and VideoLAN
* $Id$
*
* Authors: Derk-Jan Hartman <hartman at videola/n dot org>
* Benjamin Pracht <bigben at videolab dot org>
* Felix Paul Kühne <fkuehne at videolan dot 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 "intf.h"
#import "playlistview.h"
#import "playlist.h"

@implementation VLCPlaylistView

- (NSMenu *)menuForEvent:(NSEvent *)event
{
return([(VLCPlaylist *)[self delegate] menuForEvent: event]);
}

- (void)keyDown:(NSEvent *)event
{
unichar key = 0;

if ([[event characters] length])
key = [[event characters] characterAtIndex: 0];

switch(key) {
case NSDeleteCharacter:
case NSDeleteFunctionKey:
case NSDeleteCharFunctionKey:
case NSBackspaceCharacter:
[(VLCPlaylist *)[self delegate] deleteItem:self];
break;

case NSEnterCharacter:
case NSCarriageReturnCharacter:
[(VLCPlaylist *)[[VLCMain sharedInstance] playlist] playItem:nil];
break;

default:
[super keyDown: event];
break;
}
}

- (BOOL)validateMenuItem:(NSMenuItem *)item
{
if (([self numberOfSelectedRows] >= 1 && [item action] == @selector(delete:)) || [item action] == @selector(selectAll:))
return YES;

return NO;
}

- (BOOL)acceptsFirstResponder
{
return YES;
}

- (BOOL)becomeFirstResponder
{
[self setNeedsDisplay:YES];
return YES;
}

- (BOOL)resignFirstResponder
{
[self setNeedsDisplay:YES];
return YES;
}

- (IBAction)delete:(id)sender
{
[[[VLCMain sharedInstance] playlist] deleteItem: sender];
}

@end
2 changes: 2 additions & 0 deletions po/POTFILES.in
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m
modules/gui/macosx/playlistinfo.h
modules/gui/macosx/playlistinfo.m
modules/gui/macosx/playlistview.h
modules/gui/macosx/playlistview.m
modules/gui/macosx/prefs.h
modules/gui/macosx/prefs.m
modules/gui/macosx/prefs_widgets.h
Expand Down

0 comments on commit 896af42

Please sign in to comment.