Commit a708b862 authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/VLC_app: Initial import. Big playlist still causes memory and cpu high...

MacOSX/VLC_app: Initial import. Big playlist still causes memory and cpu high load. Interface is ugly. Miss many functionality. But code is light. Supports multiple player. Fullscreen a-la frontrow interface (yet a bit ugly).
parent 7ea9b1c2
...@@ -5,14 +5,13 @@ ...@@ -5,14 +5,13 @@
<key>IBClasses</key> <key>IBClasses</key>
<array> <array>
<dict> <dict>
<key>CLASS</key> <key>ACTIONS</key>
<string>VLCCategoryOutlineView</string> <dict>
<key>LANGUAGE</key> <key>detailListItemDoubleClicked</key>
<string>ObjC</string> <string>id</string>
<key>SUPERCLASS</key> <key>newMainWindow</key>
<string>NSOutlineView</string> <string>id</string>
</dict> </dict>
<dict>
<key>CLASS</key> <key>CLASS</key>
<string>VLCController</string> <string>VLCController</string>
<key>LANGUAGE</key> <key>LANGUAGE</key>
...@@ -21,12 +20,18 @@ ...@@ -21,12 +20,18 @@
<dict> <dict>
<key>categoryList</key> <key>categoryList</key>
<string>id</string> <string>id</string>
<key>detailItemFetchedStatus</key>
<string>id</string>
<key>detailItemsCount</key>
<string>id</string>
<key>detailList</key> <key>detailList</key>
<string>id</string> <string>id</string>
<key>detailSearchField</key> <key>detailSearchField</key>
<string>id</string> <string>id</string>
<key>videoView</key> <key>fillScreenButton</key>
<string>id</string> <string>id</string>
<key>videoView</key>
<string>VLCBrowsableVideoView</string>
</dict> </dict>
<key>SUPERCLASS</key> <key>SUPERCLASS</key>
<string>NSObject</string> <string>NSObject</string>
...@@ -39,6 +44,28 @@ ...@@ -39,6 +44,28 @@
<key>SUPERCLASS</key> <key>SUPERCLASS</key>
<string>NSObject</string> <string>NSObject</string>
</dict> </dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>moveDown</key>
<string>id</string>
<key>moveUp</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>VLCBrowsableVideoView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>selectedObject</key>
<string>id</string>
<key>target</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>VLCVideoView</string>
</dict>
<dict> <dict>
<key>CLASS</key> <key>CLASS</key>
<string>VLCVideoView</string> <string>VLCVideoView</string>
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<integer>5</integer> <integer>5</integer>
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>253</integer> <integer>81</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>9B18</string> <string>9B18</string>
......
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>CFBundleDevelopmentRegion</key> <key>CFBundleDevelopmentRegion</key>
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string></string> <string></string>
<key>CFBundleIdentifier</key> <key>CFBundleIdentifier</key>
<string>com.yourcompany.VLC</string> <string>org.videolan.vlc</string>
<key>CFBundleInfoDictionaryVersion</key> <key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string> <string>6.0</string>
<key>CFBundleName</key> <key>CFBundleName</key>
......
/*****************************************************************************
* ImageAndTextCell.h: Helpful cell to display an image and a text.
* Borrowed from Apple's sample code for most part.
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
@interface ImageAndTextCell : NSTextFieldCell {
NSString *imageKeyPath;
id representedObject;
}
/* Will be set at creation time */
@property (copy) NSString * imageKeyPath;
/* Will be set through an outlineView delegate. Represent an object that respond
* to the imageKeyPath. Text is displayed through the usual super class
* @"value" bindings */
@property (retain) id representedObject;
@end
/*****************************************************************************
* ImageAndTextCell.h: Helpful cell to display an image and a text.
* Borrowed from Apple's sample code for most part.
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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 "ImageAndTextCell.h"
@implementation ImageAndTextCell
@synthesize imageKeyPath;
@synthesize representedObject;
- (id)init {
if (self = [super init]) {
[self setLineBreakMode:NSLineBreakByTruncatingTail];
[self setSelectable:YES];
}
return self;
}
- (void)dealloc {
[imageKeyPath release];
[super dealloc];
}
- (id)copyWithZone:(NSZone *)zone {
ImageAndTextCell *cell = (ImageAndTextCell *)[super copyWithZone:zone];
cell->imageKeyPath = [imageKeyPath copy];
cell->representedObject = [representedObject retain];
return cell;
}
- (NSImage *)cellImage
{
return imageKeyPath ? [[self representedObject] valueForKeyPath: imageKeyPath] : nil;
}
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent {
NSRect textFrame, imageFrame;
NSImage * image = [self cellImage];
NSDivideRect (aRect, &imageFrame, &textFrame, 6 + [image size].width, NSMinXEdge);
[super editWithFrame: textFrame inView: controlView editor:textObj delegate:anObject event: theEvent];
}
- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(NSInteger)selStart length:(NSInteger)selLength {
NSRect textFrame, imageFrame;
NSImage * image = [self cellImage];
NSDivideRect (aRect, &imageFrame, &textFrame, 6 + [image size].width, NSMinXEdge);
[super selectWithFrame: textFrame inView: controlView editor:textObj delegate:anObject start:selStart length:selLength];
}
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSImage * image = [self cellImage];
if (image != nil) {
NSRect imageFrame;
NSSize imageSize = [image size];
NSDivideRect(cellFrame, &imageFrame, &cellFrame, 6 + imageSize.width, NSMinXEdge);
if ([self drawsBackground]) {
[[self backgroundColor] set];
NSRectFill(imageFrame);
}
imageFrame.origin.x += 3;
imageFrame.size = imageSize;
if ([controlView isFlipped])
imageFrame.origin.y += ceil((cellFrame.size.height + imageFrame.size.height) / 2);
else
imageFrame.origin.y += ceil((cellFrame.size.height - imageFrame.size.height) / 2);
[image compositeToPoint:imageFrame.origin operation:NSCompositeSourceOver];
}
[super drawWithFrame:cellFrame inView:controlView];
}
- (NSSize)cellSize {
NSImage * image = [self cellImage];
NSSize cellSize = [super cellSize];
cellSize.width += (image ? [image size].width : 0) + 6;
return cellSize;
}
- (NSUInteger)hitTestForEvent:(NSEvent *)event inRect:(NSRect)cellFrame ofView:(NSView *)controlView {
NSPoint point = [controlView convertPoint:[event locationInWindow] fromView:nil];
NSImage * image = [self cellImage];
// If we have an image, we need to see if the user clicked on the image portion.
if (image != nil) {
// This code closely mimics drawWithFrame:inView:
NSSize imageSize = [image size];
NSRect imageFrame;
NSDivideRect(cellFrame, &imageFrame, &cellFrame, 6 + imageSize.width, NSMinXEdge);
imageFrame.origin.x += 3;
imageFrame.size = imageSize;
// If the point is in the image rect, then it is a content hit
if (NSMouseInRect(point, imageFrame, [controlView isFlipped])) {
// We consider this just a content area. It is not trackable, nor it it editable text. If it was, we would or in the additional items.
// By returning the correct parts, we allow NSTableView to correctly begin an edit when the text portion is clicked on.
return NSCellHitContentArea;
}
}
// At this point, the cellFrame has been modified to exclude the portion for the image. Let the superclass handle the hit testing at this point.
return [super hitTestForEvent:event inRect:cellFrame ofView:controlView];
}
@end
/*****************************************************************************
* VLCAppAdditions.m: Helpful additions to NS* classes
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
@interface NSIndexPath (VLCAppAddition)
- (NSIndexPath *)indexPathByRemovingFirstIndex;
- (NSUInteger)lastIndex;
@end
@interface NSArray (VLCAppAddition)
- (id)objectAtIndexPath:(NSIndexPath *)path withNodeKeyPath:(NSString *)nodeKeyPath;
@end
@interface NSView (VLCAppAdditions)
- (void)moveSubviewsToVisible;
@end
/* Split view that supports slider animation */
@interface VLCOneSplitView : NSSplitView
- (float)sliderPosition;
- (void)setSliderPosition:(float)newPosition;
@end
\ No newline at end of file
/*****************************************************************************
* VLCAppAdditions.m: Helpful additions to NS* classes
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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 "VLCAppAdditions.h"
#import <QuartzCore/QuartzCore.h>
@implementation NSIndexPath (VLCAppAddition)
- (NSIndexPath *)indexPathByRemovingFirstIndex
{
if( [self length] <= 1 )
return [[[NSIndexPath alloc] init] autorelease];
NSIndexPath * ret;
NSUInteger * ints = malloc(sizeof(NSUInteger)*[self length]);
if( !ints ) return nil;
[self getIndexes:ints];
ret = [NSIndexPath indexPathWithIndexes:ints+1 length:[self length]-1];
free(ints);
return ret;
}
- (NSUInteger)lastIndex
{
if(![self length])
return 0;
return [self indexAtPosition:[self length]-1];
}
@end
@implementation NSArray (VLCAppAddition)
- (id)objectAtIndexPath:(NSIndexPath *)path withNodeKeyPath:(NSString *)nodeKeyPath
{
if( ![path length] || !nodeKeyPath )
return self;
id object = [self objectAtIndex:[path indexAtPosition:0]];
id subarray = [object valueForKeyPath:nodeKeyPath];
if([path length] == 1)
return subarray ? subarray : object;
if(!subarray)
return object;
return [subarray objectAtIndexPath:[path indexPathByRemovingFirstIndex] withNodeKeyPath:nodeKeyPath];
}
@end
@implementation NSView (VLCAppAdditions)
- (void)moveSubviewsToVisible
{
for(NSView * view in [self subviews])
{
if( ([view autoresizingMask] & NSViewHeightSizable) &&
!NSContainsRect([view frame], [self bounds]) )
{
NSRect newFrame = NSIntersectionRect( [self bounds], [view frame] );
if( !NSIsEmptyRect(newFrame) )
[view setFrame:NSIntersectionRect( [self bounds], [view frame] )];
}
}
}
@end
/* Split view that supports slider animation */
@implementation VLCOneSplitView
- (float)sliderPosition
{
return [[[self subviews] objectAtIndex:0] frame].size.height;
}
- (void)setSliderPosition:(float)newPosition
{
[self setPosition:newPosition ofDividerAtIndex:0];
}
+ (id)defaultAnimationForKey:(NSString *)key
{
if([key isEqualToString:@"sliderPosition"])
{
return [CABasicAnimation animation];
}
return [super defaultAnimationForKey: key];
}
@end
/*****************************************************************************
* VLCAppBindings.m: Helpful addition code related to bindings uses
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
#import <VLC/VLC.h>
/* We do implement some category functions,
* But we don't publicise them, as they should
* only be used with bindings. */
@interface VLCMediaDiscoverer (VLCAppBindings)
@end
@interface VLCMedia (VLCAppBindings)
@end
@interface VLCMediaPlayer (VLCAppBindings)
@end
/*****************************************************************************
* VLCAppBindings.m: Helpful addition code related to bindings uses
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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 "VLCAppBindings.h"
/* This is globally a big hack to ease binding uses */
/******************************************************************************
* VLCMediaDiscoverer (MasterViewBindings)
*/
@implementation VLCMediaDiscoverer (MasterViewBindings)
+(void)initialize
{
[VLCMediaDiscoverer setKeys:[NSArray arrayWithObject:@"running"] triggerChangeNotificationsForDependentKey:@"currentlyFetchingItems"];
}
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
{
/* Thanks to Julien Robert, we'll have some nice auto triggered KVO event from here */
static NSDictionary * dict = nil;
if( !dict )
{
dict = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSSet setWithObject:@"discoveredMedia.flatAspect"], @"childrenInMasterViewForDetailView",
nil] retain];
}
return [dict objectForKey: key];
}
/* General shortcuts */
- (BOOL)currentlyFetchingItems
{
return [self isRunning];
}
- (NSImage *)image
{
static NSImage * sdImage = nil;
if( !sdImage )
sdImage = [[NSImage imageNamed:@"applications-internet.png"] retain];
return sdImage;
}
/* MasterView specific bindings */
- (NSArray *)childrenInMasterView
{
return nil;
}
- (NSString *)descriptionInMasterView
{
return [self localizedName];
}
- (VLCMediaListAspect *)childrenInMasterViewForDetailView
{
return [[self discoveredMedia] flatAspect];
}
- (BOOL)editableInMasterView
{
return NO;
}
- (BOOL)selectableInMasterView
{
return YES;
}
/* VideoView specific bindings */
- (NSArray *)childrenInVideoView
{
return [[[self discoveredMedia] flatAspect] valueForKeyPath:@"media"];
}
- (NSString *)descriptionInVideoView
{
return [self localizedName];
}
- (BOOL)isLeaf
{
return YES;
}
@end
/******************************************************************************
* VLCMedia (VLCAppBindings)
*/
@implementation VLCMedia (VLCAppBindings)
+ (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key
{
/* Thanks to Julien Robert, we'll have some nice auto triggered KVO event from here */
static NSDictionary * dict = nil;
if( !dict )
{
dict = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSSet setWithObject:@"subitems.hierarchicalNodeAspect.media"], @"childrenInMasterView",
[NSSet setWithObject:@"metaDictionary.title"], @"descriptionInMasterView",
[NSSet setWithObject:@"subitems.flatAspect"], @"childrenInMasterViewForDetailView",
[NSSet setWithObject:@"metaDictionary.title"], @"descriptionInVideoView",
[NSSet setWithObject:@"state"], @"stateAsImage",
nil] retain];
}
return [dict objectForKey: key];
}
/* MasterView specific bindings */
- (NSArray *)childrenInMasterView
{
return [[[self subitems] hierarchicalNodeAspect] valueForKeyPath:@"media"];
}
- (void)setDescriptionInMasterView:(NSString *)description
{
NSLog(@"unimplemented: meta edition");
}
- (NSString *)descriptionInMasterView
{
return [[self metaDictionary] objectForKey:@"title"];
}
- (VLCMediaListAspect *)childrenInMasterViewForDetailView
{
return [[self subitems] flatAspect];
}
- (BOOL)editableInMasterView
{
return YES;
}
- (BOOL)selectableInMasterView
{
return YES;
}
- (BOOL)currentlyFetchingItems
{
return NO;
}
- (NSImage *)image
{
static NSImage * playlistImage = nil;
if( !playlistImage )
playlistImage = [[NSImage imageNamed:@"type_playlist.png"] retain];
return playlistImage;
}
/* VideoView specific bindings */
- (NSArray *)childrenInVideoView
{
return [[[self subitems] flatAspect] valueForKeyPath:@"media"];
}
- (NSString *)descriptionInVideoView
{
return [[self metaDictionary] objectForKey:@"title"];
}
/* DetailList specific bindings */
- (NSImage *)stateAsImage
{
static NSImage * playing = nil;
static NSImage * error = nil;
if(!playing)
playing = [[NSImage imageNamed:@"volume_high.png"] retain];
if(!error)
error = [[NSImage imageNamed:@"dialog-error.png"] retain];
if( [self state] == VLCMediaStatePlaying )
return playing;
else if( [self state] == VLCMediaStateBuffering )
return playing;
else if( [self state] == VLCMediaStateError )
return error;
return nil;
}
@end
@implementation VLCMediaPlayer (VLCAppBindings)
+ (void)initialize
{
[self setKeys:[NSArray arrayWithObjects:@"playing", @"media", nil] triggerChangeNotificationsForDependentKey:@"description"];
}
- (NSString *)description
{
if([self media])
return [self valueForKeyPath:@"media.metaDictionary.title"];
else
return @"VLC Media Player";
}
@end
/*****************************************************************************
* VLCBrowsableVideoView.h: VideoView subclasses that allow fullscreen
* browsing
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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 <QuartzCore/QuartzCore.h>
#import <VLC/VLC.h>
@interface VLCBrowsableVideoView : VLCVideoView {
BOOL menuDisplayed;
NSArray * itemsTree;
NSRange displayedItems;
NSInteger selectedIndex;
CALayer * selectionLayer;
CALayer * backLayer;
CALayer * menuLayer;
NSIndexPath * selectedPath;
NSString * nodeKeyPath;
NSString * contentKeyPath;
id selectedObject;
/* Actions on non-node items*/
id target;
SEL action;
}
/* Binds an nsarray to that property. But don't forget the set the access keys. */
@property (retain) NSArray * itemsTree;
@property (copy) NSString * nodeKeyPath;
@property (copy) NSString * contentKeyPath;
@property (readonly, retain) id selectedObject;
/* Set up a specific action to do, on items that don't have node.
* action first argument is the browsableVideoView. You can get the selected object,
* with -selectedObject */
@property (retain) id target;
@property SEL action;
- (void)toggleMenu;
- (void)displayMenu;
- (void)hideMenu;
@end
This diff is collapsed.
/*****************************************************************************
* VLCController.h: VLC.app main controller
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCController.h 21565 2007-08-29 21:10:20Z pdherbemont $
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
#import <VLC/VLC.h>
#import "VLCMediaArrayController.h"
#import "VLCBrowsableVideoView.h"
@class VLCMainWindow;
#define VLCPanic( ex ) __VLCPanic( ex, __FUNCTION__, __FILE__, __LINE__ )
static inline void __VLCPanic( const char * str, const char * function, const char * file, int line_number )
{
NSRunCriticalAlertPanel( @"Error", [NSString stringWithFormat:@"The following error was encountered: %s (%s:%d %s)", str, file, line_number, function], @"Quit", nil, nil );
exit( -1 );
}
@interface VLCController : NSObject
{
NSMutableArray * arrayOfPlaylists;
NSArray * arrayOfMasters;
NSArray * arrayOfVideoViewMasters;
}
@property (readonly, retain) NSArray * arrayOfMasters;
@property (readonly, retain) NSArray * arrayOfVideoViewMasters;
- (void)newMainWindow:(id)sender;
@end
/*****************************************************************************
* VLCController.m: VLC.app main controller
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCController.m 23286 2007-11-23 21:40:20Z pdherbemont $
*
* Authors: Pierre d'Herbemont <pdherbemont # 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 <VLC/VLC.h>
#import "VLCController.h"
#import "VLCAppAdditions.h"
#import "VLCValueTransformer.h"
@interface VLCController ()
@property (readwrite,retain) NSArray * arrayOfMasters;
@property (readwrite,retain) NSArray * arrayOfVideoViewMasters;
@end
/******************************************************************************
* VLCBrowsableVideoView
*/
@implementation VLCController
@synthesize arrayOfMasters;
@synthesize arrayOfVideoViewMasters;
- (void)awakeFromNib
{
/***********************************
* Register our bindings value transformer
*/
VLCFloat10000FoldTransformer *float100fold;
float100fold = [[[VLCFloat10000FoldTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:(id)float100fold forName:@"Float10000FoldTransformer"];
VLCNonNilAsBoolTransformer *nonNilAsBool;
nonNilAsBool = [[[VLCNonNilAsBoolTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:(id)nonNilAsBool forName:@"NonNilAsBoolTransformer"];
/***********************************
* arrayOfMasters: MasterView OutlineView content
*/
NSArray * arrayOfMediaDiscoverer = [NSArray arrayWithObjects:
[[[VLCMediaDiscoverer alloc] initWithName:@"shoutcasttv"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"shoutcast"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"freebox"] autorelease], nil];
arrayOfPlaylists = [NSMutableArray arrayWithObjects:[VLCMedia mediaAsNodeWithName:@"Default Playlist"], nil];
NSDictionary * playlists = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[@"Playlists" uppercaseString], @"descriptionInMasterView",
[@"Playlists" uppercaseString], @"descriptionInVideoView",
[NSNumber numberWithBool:NO], @"selectableInMasterView",
arrayOfPlaylists, @"childrenInMasterView",
arrayOfPlaylists, @"childrenInVideoView",
nil];
self.arrayOfMasters = [NSArray arrayWithObjects:
[NSMutableDictionary dictionaryWithObjectsAndKeys:
[@"Service Discovery" uppercaseString], @"descriptionInMasterView",
[NSNumber numberWithBool:NO], @"selectableInMasterView",
arrayOfMediaDiscoverer, @"childrenInMasterView",
nil],
playlists,
nil];
/***********************************
* videoView setup
*/
self.arrayOfVideoViewMasters = [NSArray arrayWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"Service Discovery", @"descriptionInVideoView",
arrayOfMediaDiscoverer, @"childrenInVideoView",
nil],
playlists,
nil];
/* Execution will continue in applicationDidFinishLaunching */
[NSApp setDelegate:self];
}
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
[self newMainWindow: self];
}
- (void)newMainWindow:(id)sender
{
if (![NSBundle loadNibNamed:@"MainWindow" owner:self])
{
NSLog(@"Warning! Could not load MainWindow file.\n");
}
/* We are done. Should be on screen if Visible at launch time is checked */
}
- (void)addPlaylist:(id)sender
{
[[arrayOfMasters mutableArrayValueForKey:@"[0].childrenInMasterView"] addObject:[VLCMedia mediaAsNodeWithName:@"Untitled Playlist"]];
}
@end
@implementation VLCController (ExceptionHandlerDelegating)
@end
/*****************************************************************************
* VLCExceptionHandler.h: VLCExceptionHandler implementation
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCController.h 21565 2007-08-29 21:10:20Z pdherbemont $
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
@interface VLCExceptionHandler : NSObject {
}
- (void)printStackTrace:(NSException *)e;
@end
/*****************************************************************************
* VLCExceptionHandler.m: VLCExceptionHandler implementation
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCController.h 21565 2007-08-29 21:10:20Z pdherbemont $
*
* Authors: Pierre d'Herbemont <pdherbemont # 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 "VLCExceptionHandler.h"
#import <ExceptionHandling/ExceptionHandling.h>
@implementation VLCExceptionHandler
+ (void)initialize
{
[[NSExceptionHandler defaultExceptionHandler] setDelegate:[[VLCExceptionHandler alloc] init]];
[[NSExceptionHandler defaultExceptionHandler] setExceptionHandlingMask:
0xffff /* Catch all */ ];
[[NSExceptionHandler defaultExceptionHandler] setExceptionHangingMask:
NSHangOnUncaughtExceptionMask|
NSHangOnUncaughtSystemExceptionMask|
NSHangOnUncaughtRuntimeErrorMask|
NSHangOnTopLevelExceptionMask|
NSHangOnOtherExceptionMask];
}
/* From Apple's guide on exception */
- (BOOL)exceptionHandler:(NSExceptionHandler *)sender shouldLogException:(NSException *)exception mask:(unsigned int)aMask
{
[self printStackTrace:exception];
return YES;
}
- (void)printStackTrace:(NSException *)e
{
NSString *stack = [[e userInfo] objectForKey:NSStackTraceKey];
if (!stack)
{
NSLog(@"No stack trace available.");
return;
}
NSTask *ls = [[NSTask alloc] init];
NSString *pid = [[NSNumber numberWithInt:[[NSProcessInfo processInfo] processIdentifier]] stringValue];
NSMutableArray *args = [NSMutableArray arrayWithCapacity:20];
[args addObject:@"-p"];
[args addObject:pid];
[args addObjectsFromArray:[stack componentsSeparatedByString:@" "]];
/* Note: function addresses are separated by double spaces, not a single space. */
[ls setLaunchPath:@"/usr/bin/atos"];
[ls setArguments:args];
[ls launch];
[ls release];
}
@end
/*****************************************************************************
* VLCMainWindow.h: VLCMainWindow implementation
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id: VLCController.h 21565 2007-08-29 21:10:20Z pdherbemont $
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
#import "VLCController.h"
#import "VLCMediaArrayController.h"
@interface VLCMainWindow : NSWindow {
/* IB elements */
IBOutlet id detailItemFetchedStatus;
IBOutlet id detailItemsCount;
IBOutlet id detailSearchField;
IBOutlet NSOutlineView * categoryList;
IBOutlet NSTableView * detailList;
IBOutlet VLCBrowsableVideoView * videoView;
IBOutlet id fillScreenButton;
IBOutlet id fullScreenButton;
IBOutlet NSSlider * mediaReadingProgressSlider;
IBOutlet NSTextField * mediaReadingProgressText;
IBOutlet NSTextField * mediaDescriptionText;
IBOutlet id navigatorViewToggleButton;
IBOutlet NSSplitView * mainSplitView;
IBOutlet NSView * navigatorView;
IBOutlet NSView * videoPlayerAndControlView;
IBOutlet NSView * controlView;
IBOutlet NSButton * addPlaylistButton;
IBOutlet NSButton * removePlaylistButton;
VLCMediaPlayer * mediaPlayer;
IBOutlet VLCController * controller; /* This is a VLCController binded to the File's Owner of the nib */
/* Controllers */
NSTreeController * treeController;
VLCMediaArrayController * mediaArrayController;
/* Window state */
CGFloat navigatorHeight;
}
@property BOOL navigatorViewVisible;
@end
This diff is collapsed.
/*****************************************************************************
* VLCMediaArrayController.h: NSArrayController subclass specific to media
* list.
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
#import <VLC/VLC.h>
@interface VLCMediaArrayController : NSArrayController
{
VLCMediaList * contentMediaList;
}
/* Usually set through a bindings. Contents is provided by the
* super class contentArray bindings. This is useful to
* get the media list ability to be read-write. */
@property (retain) VLCMediaList * contentMediaList;
@end
/*****************************************************************************
* VLCMediaArrayController.m: NSArrayController subclass specific to media
* list.
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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 "VLCMediaArrayController.h"
@implementation VLCMediaArrayController
@synthesize contentMediaList;
@end
/******************************************************************************
* VLCMediaArrayController (NSTableViewDataSource)
*/
@implementation VLCMediaArrayController (NSTableViewDataSource)
/* Dummy implementation, because that seems to be needed */
- (int)numberOfRowsInTableView:(NSTableView *)tableView
{
return 0;
}
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
return nil;
}
/* Implement drag and drop */
- (NSDragOperation)tableView:(NSTableView*)tv validateDrop:(id <NSDraggingInfo>)info
proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op
{
return [contentMediaList isReadOnly] ? NSDragOperationNone : NSDragOperationGeneric;
}
- (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
row:(int)row dropOperation:(NSTableViewDropOperation)operation
{
int i;
row = 0;
NSArray *droppedItems = [[info draggingPasteboard] propertyListForType:NSFilenamesPboardType];
for (i = 0; i < [droppedItems count]; i++)
{
NSString * filename = [droppedItems objectAtIndex:i];
VLCMedia *media = [VLCMedia mediaWithPath:filename];
[contentMediaList lock];
[contentMediaList insertMedia:media atIndex:[contentMediaList count] > 0 ? [contentMediaList count]-1 : 0];
[contentMediaList unlock];
}
return YES;
}
@end
/*****************************************************************************
* VLCValueTransformer.m: NSValueTransformer subclasses
*****************************************************************************
* Copyright (C) 2007 Pierre d'Herbemont
* Copyright (C) 2007 the VideoLAN team
* $Id$
*
* Authors: Pierre d'Herbemont <pdherbemont # 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>
@interface VLCFloat10000FoldTransformer : NSValueTransformer {
}
@end
@interface VLCNonNilAsBoolTransformer : NSValueTransformer {
}
@end
//
// VLCValueTransformer.m
// VLC
//
// Created by Pierre d'Herbemont on 12/29/07.
// Copyright 2007 __MyCompanyName__. All rights reserved.
//
#import "VLCValueTransformer.h"
@implementation VLCFloat10000FoldTransformer
+ (Class)transformedValueClass
{
return [NSNumber class];
}
+ (BOOL)allowsReverseTransformation
{
return YES;
}
- (id)transformedValue:(id)value
{
if( !value ) return nil;
if(![value respondsToSelector: @selector(floatValue)])
{
[NSException raise: NSInternalInconsistencyException
format: @"Value (%@) does not respond to -floatValue.",
[value class]];
return nil;
}
return [NSNumber numberWithFloat: [value floatValue]*10000.];
}
- (id)reverseTransformedValue:(id)value
{
if( !value ) return nil;
if(![value respondsToSelector: @selector(floatValue)])
{
[NSException raise: NSInternalInconsistencyException
format: @"Value (%@) does not respond to -floatValue.",
[value class]];
return nil;
}
return [NSNumber numberWithFloat: [value floatValue]/10000.];
}
@end
@implementation VLCNonNilAsBoolTransformer
+ (Class)transformedValueClass
{
return [NSObject class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (NSNumber *)transformedValue:(id)value
{
return [NSNumber numberWithBool: !!value];
}
@end
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