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

Remove vlc_app. Unfinished, and doesn't belong here.

parent 32ef2433
Binary files a/projects/macosx/vlc_app/English.lproj/InfoPlist.strings and /dev/null differ Binary files a/projects/macosx/vlc_app/English.lproj/InfoPlist.strings and /dev/null differ
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBClasses</key>
<array>
<dict>
<key>CLASS</key>
<string>NSView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSResponder</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>addPlaylist</key>
<string>id</string>
<key>mediaListViewItemDoubleClicked</key>
<string>id</string>
<key>newMainWindow</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>VLCController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>categoriesListView</key>
<string>id</string>
<key>fillScreenButton</key>
<string>id</string>
<key>mediaListItemFetchedStatus</key>
<string>id</string>
<key>mediaListItemsCount</key>
<string>id</string>
<key>mediaListSearchField</key>
<string>id</string>
<key>mediaListView</key>
<string>id</string>
<key>videoView</key>
<string>VLCBrowsableVideoView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>ACTIONS</key>
<dict>
<key>mediaListViewItemDoubleClicked</key>
<string>id</string>
<key>videoViewItemClicked</key>
<string>id</string>
</dict>
<key>CLASS</key>
<string>VLCMainWindowController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>addPlaylistButton</key>
<string>NSButton</string>
<key>categoriesListView</key>
<string>NSOutlineView</string>
<key>categoriesTreeController</key>
<string>NSTreeController</string>
<key>controller</key>
<string>VLCController</string>
<key>mainSplitView</key>
<string>VLCOneSplitView</string>
<key>mediaArrayController</key>
<string>VLCMediaArrayController</string>
<key>mediaListView</key>
<string>NSTableView</string>
<key>mediaPlayer</key>
<string>VLCMediaPlayer</string>
<key>mediaPlayerBackwardPrevButton</key>
<string>NSButton</string>
<key>mediaPlayerForwardNextButton</key>
<string>NSButton</string>
<key>mediaPlayerPlayPauseStopButton</key>
<string>NSButton</string>
<key>removePlaylistButton</key>
<string>NSButton</string>
<key>toolbarMediaAudioVolume</key>
<string>NSView</string>
<key>toolbarMediaControl</key>
<string>NSView</string>
<key>toolbarMediaDescription</key>
<string>NSView</string>
<key>videoView</key>
<string>VLCBrowsableVideoView</string>
</dict>
<key>SUPERCLASS</key>
<string>NSWindowController</string>
</dict>
<dict>
<key>CLASS</key>
<string>FirstResponder</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSObject</string>
</dict>
<dict>
<key>CLASS</key>
<string>VLCOneSplitView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSSplitView</string>
</dict>
<dict>
<key>CLASS</key>
<string>VLCMediaArrayController</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSArrayController</string>
</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>mainWindowController</key>
<string>VLCMainWindowController</string>
<key>selectedObject</key>
<string>id</string>
<key>target</key>
<string>id</string>
</dict>
<key>SUPERCLASS</key>
<string>VLCVideoView</string>
</dict>
<dict>
<key>CLASS</key>
<string>VLCVideoView</string>
<key>LANGUAGE</key>
<string>ObjC</string>
<key>SUPERCLASS</key>
<string>NSView</string>
</dict>
<dict>
<key>CLASS</key>
<string>VLCMediaPlayer</string>
<key>LANGUAGE</key>
<string>ObjC</string>
</dict>
</array>
<key>IBVersion</key>
<string>1</string>
</dict>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IBFramework Version</key>
<string>629</string>
<key>IBOldestOS</key>
<integer>5</integer>
<key>IBOpenObjects</key>
<array/>
<key>IBSystem Version</key>
<string>9B18</string>
<key>targetFramework</key>
<string>IBCocoaFramework</string>
</dict>
</plist>
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>org.videolan.vlc</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
/*****************************************************************************
* AppleRemote.h
* AppleRemote
* $Id$
*
* Created by Martin Kahr on 11.03.06 under a MIT-style license.
* Copyright (c) 2006 martinkahr.com. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*
*****************************************************************************
*
* Note that changes made by any members or contributors of the VideoLAN team
* (i.e. changes that were checked in exclusively into one of VideoLAN's source code
* repositories) are licensed under the GNU General Public License version 2,
* or (at your option) any later version.
* Thus, the following statements apply to our changes:
*
* Copyright (C) 2006-2007 the VideoLAN team
* Authors: Eric Petit <titer@m0k.org>
* Felix 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>
#import <mach/mach.h>
#import <mach/mach_error.h>
#import <IOKit/IOKitLib.h>
#import <IOKit/IOCFPlugIn.h>
#import <IOKit/hid/IOHIDLib.h>
#import <IOKit/hid/IOHIDKeys.h>
enum AppleRemoteEventIdentifier
{
kRemoteButtonVolume_Plus =1<<1,
kRemoteButtonVolume_Minus =1<<2,
kRemoteButtonMenu =1<<3,
kRemoteButtonPlay =1<<4,
kRemoteButtonRight =1<<5,
kRemoteButtonLeft =1<<6,
kRemoteButtonRight_Hold =1<<7,
kRemoteButtonLeft_Hold =1<<8,
kRemoteButtonMenu_Hold =1<<9,
kRemoteButtonPlay_Sleep =1<<10,
kRemoteControl_Switched =1<<11,
kRemoteButtonVolume_Plus_Hold =1<<12,
kRemoteButtonVolume_Minus_Hold =1<<13
};
typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
/* Encapsulates usage of the apple remote control
This class is implemented as a singleton as there is exactly one remote per machine (until now)
The class is not thread safe
*/
@interface AppleRemote : NSObject {
IOHIDDeviceInterface** hidDeviceInterface;
IOHIDQueueInterface** queue;
NSMutableArray* allCookies;
NSMutableDictionary* cookieToButtonMapping;
BOOL openInExclusiveMode;
BOOL simulatePlusMinusHold;
BOOL processesBacklog;
/* state for simulating plus/minus hold */
BOOL lastEventSimulatedHold;
AppleRemoteEventIdentifier lastPlusMinusEvent;
NSTimeInterval lastPlusMinusEventTime;
int remoteId;
unsigned int clickCountEnabledButtons;
NSTimeInterval maxClickTimeDifference;
NSTimeInterval lastClickCountEventTime;
AppleRemoteEventIdentifier lastClickCountEvent;
unsigned int eventClickCount;
IBOutlet id delegate;
}
- (int) remoteId;
- (BOOL) isRemoteAvailable;
- (BOOL) isListeningToRemote;
- (void) setListeningToRemote: (BOOL) value;
- (BOOL) isOpenInExclusiveMode;
- (void) setOpenInExclusiveMode: (BOOL) value;
/* click counting makes it possible to recognize if the user has pressed a button repeatedly
* click counting does delay each event as it has to wait if there is another event (second click)
* therefore there is a slight time difference (maximumClickCountTimeDifference) between a single click
* of the user and the call of your delegate method
* click counting can be enabled individually for specific buttons. Use the property clickCountEnableButtons
* to set the buttons for which click counting shall be enabled */
- (BOOL) clickCountingEnabled;
- (void) setClickCountingEnabled: (BOOL) value;
- (unsigned int) clickCountEnabledButtons;
- (void) setClickCountEnabledButtons: (unsigned int)value;
/* the maximum time difference till which clicks are recognized as multi clicks */
- (NSTimeInterval) maximumClickCountTimeDifference;
- (void) setMaximumClickCountTimeDifference: (NSTimeInterval) timeDiff;
/* When your application needs to much time on the main thread when processing an event other events
* may already be received which are put on a backlog. As soon as your main thread
* has some spare time this backlog is processed and may flood your delegate with calls.
* Backlog processing is turned off by default. */
- (BOOL) processesBacklog;
- (void) setProcessesBacklog: (BOOL) value;
/* Sets an NSApplication delegate which starts listening when application is becoming active
* and stops listening when application resigns being active.
* If an NSApplication delegate has been already set all method calls will be forwarded to this delegate, too. */
- (BOOL) listeningOnAppActivate;
- (void) setListeningOnAppActivate: (BOOL) value;
/* Simulating plus/minus hold does deactivate sending of individual requests for plus/minus pressed down/released.
* Instead special hold events are being triggered when the user is pressing and holding plus/minus for a small period.
* With simulating enabled the plus/minus buttons do behave as the left/right buttons */
- (BOOL) simulatesPlusMinusHold;
- (void) setSimulatesPlusMinusHold: (BOOL) value;
/* Delegates are not retained */
- (void) setDelegate: (id) delegate;
- (id) delegate;
- (IBAction) startListening: (id) sender;
- (IBAction) stopListening: (id) sender;
@end
@interface AppleRemote (Singleton)
+ (AppleRemote*) sharedRemote;
@end
/* Method definitions for the delegate of the AppleRemote class */
@interface NSObject(NSAppleRemoteDelegate)
- (void) appleRemoteButton: (AppleRemoteEventIdentifier)buttonIdentifier pressedDown: (BOOL) pressedDown clickCount: (unsigned int) count;
@end
@interface AppleRemote (PrivateMethods)
- (void) setRemoteId: (int) aValue;
- (NSDictionary*) cookieToButtonMapping;
- (IOHIDQueueInterface**) queue;
- (IOHIDDeviceInterface**) hidDeviceInterface;
- (void) handleEventWithCookieString: (NSString*) cookieString sumOfValues: (SInt32) sumOfValues;
@end
@interface AppleRemote (IOKitMethods)
- (io_object_t) findAppleRemoteDevice;
- (IOHIDDeviceInterface**) createInterfaceForDevice: (io_object_t) hidDevice;
- (BOOL) initializeCookies;
- (BOOL) openDevice;
@end
/* A NSApplication delegate which is used to activate and deactivate listening to the remote control
* dependent on the activation state of your application.
* All events are delegated to the original NSApplication delegate if necessary */
@interface AppleRemoteApplicationDelegate : NSObject {
id applicationDelegate;
}
- (id) initWithApplicationDelegate: (id) delegate;
- (id) applicationDelegate;
@end
This diff is collapsed.
/*****************************************************************************
* 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>
* Felix Kühne <fkuehne at videolan dot org>
* Jérôme Decoodt <djc 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>
/*****************************************************************************
* NSIndexPath (VLCAppAddition)
*****************************************************************************/
@interface NSIndexPath (VLCAppAddition)
- (NSIndexPath *)indexPathByRemovingFirstIndex;
- (NSUInteger)lastIndex;
@end
/*****************************************************************************
* NSArray (VLCAppAddition)
*****************************************************************************/
@interface NSArray (VLCAppAddition)
- (id)objectAtIndexPath:(NSIndexPath *)path withNodeKeyPath:(NSString *)nodeKeyPath;
@end
/*****************************************************************************
* NSView (VLCAppAdditions)
*****************************************************************************/
@interface NSView (VLCAppAdditions)
- (void)moveSubviewsToVisible;
@end
/*****************************************************************************
* VLCOneSplitView
*
* Missing functionality to a one-split view
*****************************************************************************/
@interface VLCOneSplitView : NSSplitView
{
}
- (float)sliderPosition;
- (void)setSliderPosition:(float)newPosition;
@end
/*****************************************************************************
* NSScreen (VLCAdditions)
*
* Missing extension to NSScreen
*****************************************************************************/
@interface NSScreen (VLCAdditions)
+ (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID;
- (BOOL)isMainScreen;
- (BOOL)isScreen: (NSScreen*)screen;
- (CGDirectDisplayID)displayID;
- (void)blackoutOtherScreens;
+ (void)unblackoutScreens;
@end
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow (Used only when needing setCanBecomeKeyWindow)
*****************************************************************************/
@interface VLCWindow : NSWindow
{
BOOL canBecomeKeyWindow;
BOOL isset_canBecomeKeyWindow;
}
- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey;
@end
/*****************************************************************************
* VLCImageCustomizedSlider
*
* Slider personalized by backgroundImage and knobImage
*****************************************************************************/
@interface VLCImageCustomizedSlider : NSSlider
{
NSImage * knobImage;
NSImage * backgroundImage;
}
@property (retain) NSImage * knobImage;
@property (retain) NSImage * backgroundImage;
- (void)drawKnobInRect: (NSRect)knobRect;
- (void)drawBackgroundInRect: (NSRect)knobRect;
- (void)drawRect: (NSRect)rect;
@end
/*****************************************************************************
* NSImageView (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@interface NSImageView (VLCAppAdditions)
- (BOOL)mouseDownCanMoveWindow;
@end
/*****************************************************************************
* NSImage (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@interface NSImage (VLCAppAdditions)
- (CGImageRef)CGImage;
@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>
* Felix Kühne <fkuehne at videolan dot org>
* Jérôme Decoodt <djc 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 "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
- (CGFloat)dividerThickness
{
return 1.;
}
- (void)drawDividerInRect:(NSRect)aRect
{
[self lockFocus];
[[NSColor blackColor] set];
NSRectFill(aRect);
[self unlockFocus];
}
- (float)sliderPosition
{
NSSize size = [[[self subviews] objectAtIndex:0] frame].size;
return [self isVertical] ? size.width : 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
/*****************************************************************************
* NSScreen (VLCAdditions)
*
* Missing extension to NSScreen
*****************************************************************************/
@implementation NSScreen (VLCAdditions)
static NSMutableArray *blackoutWindows = NULL;
+ (void)load
{
/* init our fake object attribute */
blackoutWindows = [[NSMutableArray alloc] initWithCapacity:1];
}
+ (NSScreen *)screenWithDisplayID: (CGDirectDisplayID)displayID
{
int i;
for( i = 0; i < [[NSScreen screens] count]; i++ )
{
NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
if([screen displayID] == displayID)
return screen;
}
return nil;
}
- (BOOL)isMainScreen
{
return ([self displayID] == [[[NSScreen screens] objectAtIndex:0] displayID]);
}
- (BOOL)isScreen: (NSScreen*)screen
{
return ([self displayID] == [screen displayID]);
}
- (CGDirectDisplayID)displayID
{
return (CGDirectDisplayID)_screenNumber;
}
- (void)blackoutOtherScreens
{
unsigned int i;
/* Free our previous blackout window (follow blackoutWindow alloc strategy) */
[blackoutWindows makeObjectsPerformSelector:@selector(close)];
[blackoutWindows removeAllObjects];
for(i = 0; i < [[NSScreen screens] count]; i++)
{
NSScreen *screen = [[NSScreen screens] objectAtIndex: i];
VLCWindow *blackoutWindow;
NSRect screen_rect;
if([self isScreen: screen])
continue;
screen_rect = [screen frame];
screen_rect.origin.x = screen_rect.origin.y = 0.0f;
/* blackoutWindow alloc strategy
- The NSMutableArray blackoutWindows has the blackoutWindow references
- blackoutOtherDisplays is responsible for alloc/releasing its Windows
*/
blackoutWindow = [[VLCWindow alloc] initWithContentRect: screen_rect styleMask: NSBorderlessWindowMask
backing: NSBackingStoreBuffered defer: NO screen: screen];
[blackoutWindow setBackgroundColor:[NSColor blackColor]];
[blackoutWindow setLevel: NSFloatingWindowLevel]; /* Disappear when Expose is triggered */
[blackoutWindow orderFront: self];
[blackoutWindows addObject: blackoutWindow];
[blackoutWindow release];
}
}
+ (void)unblackoutScreens
{
unsigned int i;
for(i = 0; i < [blackoutWindows count]; i++)
{
VLCWindow *blackoutWindow = [blackoutWindows objectAtIndex: i];
[blackoutWindow close];
}
}
@end
/*****************************************************************************
* VLCWindow
*
* Missing extension to NSWindow
*****************************************************************************/
@implementation VLCWindow
- (id)initWithContentRect:(NSRect)contentRect styleMask:(unsigned int)styleMask
backing:(NSBackingStoreType)backingType defer:(BOOL)flag
{
self = [super initWithContentRect:contentRect styleMask:styleMask backing:backingType defer:flag];
if( self )
isset_canBecomeKeyWindow = NO;
return self;
}
- (void)setCanBecomeKeyWindow: (BOOL)canBecomeKey
{
isset_canBecomeKeyWindow = YES;
canBecomeKeyWindow = canBecomeKey;
}
- (BOOL)canBecomeKeyWindow
{
if(isset_canBecomeKeyWindow)
return canBecomeKeyWindow;
return [super canBecomeKeyWindow];
}
@end
/*****************************************************************************
* VLCImageCustomizedSlider
*
* Slider personalized by backgroundImage and knobImage
*****************************************************************************/
@implementation VLCImageCustomizedSlider
@synthesize backgroundImage;
@synthesize knobImage;
- (id)initWithFrame:(NSRect)frame
{
if(self = [super initWithFrame:frame])
{
knobImage = nil;
backgroundImage = nil;
}
return self;
}
- (void)dealloc
{
[knobImage release];
[knobImage release];
[super dealloc];
}
- (void)drawKnobInRect:(NSRect) knobRect
{
NSRect imageRect;
imageRect.size = [self.knobImage size];
imageRect.origin.x = 0;
imageRect.origin.y = 0;
knobRect.origin.x += (knobRect.size.width - imageRect.size.width) / 2;
knobRect.origin.y += (knobRect.size.width - imageRect.size.width) / 2;
knobRect.size.width = imageRect.size.width;
knobRect.size.height = imageRect.size.height;
[self.knobImage drawInRect:knobRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1];
}
- (void)drawBackgroundInRect:(NSRect) drawRect
{
NSRect imageRect = drawRect;
imageRect.origin.y += ([self.backgroundImage size].height - [self bounds].size.height ) / 2;
[self.backgroundImage drawInRect:drawRect fromRect:imageRect operation:NSCompositeSourceOver fraction:1];
}
- (void)drawRect:(NSRect)rect
{
/* Draw default to make sure the slider behaves correctly */
[[NSGraphicsContext currentContext] saveGraphicsState];
NSRectClip(NSZeroRect);
[super drawRect:rect];
[[NSGraphicsContext currentContext] restoreGraphicsState];
if( self.backgroundImage )
[self drawBackgroundInRect: rect];
if( self.knobImage )
{
NSRect knobRect = [[self cell] knobRectFlipped:NO];
[[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
[self drawKnobInRect: knobRect];
}
}
@end
/*****************************************************************************
* NSImageView (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@implementation NSImageView (VLCAppAdditions)
- (BOOL)mouseDownCanMoveWindow
{
return YES;
}
@end
/*****************************************************************************
* NSImage (VLCAppAdditions)
*
* Make the image view move the window by mouse down by default
*****************************************************************************/
@implementation NSImage (VLCAppAdditions)
- (CGImageRef)CGImage
{
return [[NSBitmapImageRep imageRepWithData:[NSBitmapImageRep TIFFRepresentationOfImageRepsInArray: [self representations]]] CGImage];
}
@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 <VLCKit/VLCKit.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 (CategoriesListBindings)
*/
@implementation VLCMediaDiscoverer (CategoriesListBindings)
+ (NSSet *)keyPathsForValuesAffectingCurrentlyFetchingItems
{
return [NSSet setWithObject:@"running"];
}
+ (NSSet *)keyPathsForValuesAffectingChildrenInCategoriesListForDetailView
{
return [NSSet setWithObject:@"discoveredMedia.flatAspect"];
}
/* General shortcuts */
- (BOOL)currentlyFetchingItems
{
return [self isRunning];
}
- (NSImage *)image
{
static NSImage * sdImage = nil;
if( !sdImage )
sdImage = [[NSImage imageNamed:@"applications-internet.png"] retain];
return sdImage;
}
/* CategoriesList specific bindings */
- (NSArray *)childrenInCategoriesList
{
return nil;
}
- (NSString *)descriptionInCategoriesList
{
return [self localizedName];
}
- (VLCMediaListAspect *)childrenInCategoriesListForDetailView
{
return [[self discoveredMedia] flatAspect];
}
- (BOOL)editableInCategoriesList
{
return NO;
}
- (BOOL)selectableInCategoriesList
{
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 *)keyPathsForValuesAffectingChildrenInCategoriesList
{
return [NSSet setWithObject:@"subitems.hierarchicalNodeAspect.media"];
}
+ (NSSet *)keyPathsForValuesAffectingDescriptionInCategoriesList
{
return [NSSet setWithObject:@"metaDictionary.title"];
}
+ (NSSet *)keyPathsForValuesAffectingChildrenInCategoriesListForDetailView
{
return [NSSet setWithObject:@"subitems.flatAspect"];
}
+ (NSSet *)keyPathsForValuesAffectingChildrenInDescriptionInVideoView
{
return [NSSet setWithObject:@"metaDictionary.title"];
}
+ (NSSet *)keyPathsForValuesAffectingStateAsImage
{
return [NSSet setWithObject:@"state"];
}
/* CategoriesList specific bindings */
- (NSArray *)childrenInCategoriesList
{
return [[[self subitems] hierarchicalNodeAspect] valueForKeyPath:@"media"];
}
- (void)setDescriptionInCategoriesList:(NSString *)description
{
NSLog(@"unimplemented: meta edition");
}
- (NSString *)descriptionInCategoriesList
{
return [[self metaDictionary] objectForKey:@"title"];
}
- (VLCMediaListAspect *)childrenInCategoriesListForDetailView
{
return [[self subitems] flatAspect];
}
- (BOOL)editableInCategoriesList
{
return YES;
}
- (BOOL)selectableInCategoriesList
{
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"];
}
/* mediaListView 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)
+ (NSSet *)keyPathsForValuesAffectingDescription
{
return [NSSet setWithObjects:@"playing", @"media", nil];
}
+ (NSSet *)keyPathsForValuesAffectingStateAsButtonImage
{
return [NSSet setWithObjects:@"state", @"playing", @"canPause", nil];
}
+ (NSSet *)keyPathsForValuesAffectingStateAsButtonAlternateImage
{
return [NSSet setWithObjects:@"state", @"playing", @"canPause", nil];
}
+ (NSSet *)keyPathsForValuesAffectingStateAsFullScreenButtonImage
{
return [NSSet setWithObjects:@"state", @"playing", @"canPause", nil];
}
+ (NSSet *)keyPathsForValuesAffectingStateAsFullScreenButtonAlternateImage
{
return [NSSet setWithObjects:@"state", @"playing", @"canPause", nil];
}
- (NSString *)description
{
if([self media])
return [self valueForKeyPath:@"media.metaDictionary.title"];
else
return @"VLC Media Player";
}
- (NSImage *)stateAsButtonImage
{
if([self state] == VLCMediaPlayerStatePlaying && [self canPause])
return [NSImage imageNamed:@"pause.png"];
else if( [self state] == VLCMediaPlayerStatePlaying )
return [NSImage imageNamed:@"stop.png"];
else
return [NSImage imageNamed:@"play.png"];
}
- (NSImage *)stateAsButtonAlternateImage
{
if([self state] == VLCMediaPlayerStatePlaying && [self canPause])
return [NSImage imageNamed:@"pause_blue.png"];
else if( [self state] == VLCMediaPlayerStatePlaying )
return [NSImage imageNamed:@"stop_blue.png"];
else
return [NSImage imageNamed:@"play_blue.png"];
}
- (NSImage *)stateAsFullScreenButtonImage
{
if([self state] == VLCMediaPlayerStatePlaying && [self canPause])
return [NSImage imageNamed:@"fs_pause.png"];
else if( [self state] == VLCMediaPlayerStatePlaying )
return [NSImage imageNamed:@"fs_stop.png"];
else
return [NSImage imageNamed:@"fs_play.png"];
}
- (NSImage *)stateAsFullScreenButtonAlternateImage
{
if([self state] == VLCMediaPlayerStatePlaying && [self canPause])
return [NSImage imageNamed:@"fs_pause_highlight.png"];
else if( [self state] == VLCMediaPlayerStatePlaying )
return [NSImage imageNamed:@"fs_stop_highlight.png"];
else
return [NSImage imageNamed:@"fs_play_highlight.png"];
}
@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 <VLCKit/VLCKit.h>
#import "VLCAppAdditions.h"
@class VLCMainWindowController;
@class VLCMediaListLayer;
@interface VLCBrowsableVideoView : NSView {
BOOL menuDisplayed;
NSArray * itemsTree;
NSRange displayedItems;
NSInteger selectedIndex;
CALayer * selectionLayer;
CALayer * backLayer;
CALayer * menuLayer;
NSIndexPath * selectedPath;
NSString * nodeKeyPath;
NSString * contentKeyPath;
id selectedObject;
BOOL fullScreen;
/* Actions on non-node items*/
id target;
SEL action;
/* FullScreenTransition */
VLCWindow * fullScreenWindow;
NSViewAnimation * fullScreenAnim1;
NSViewAnimation * fullScreenAnim2;
NSView * tempFullScreenView;
IBOutlet VLCMainWindowController * mainWindowController;
VLCVideoLayer * videoLayer;
VLCMediaListLayer * mediaListLayer;
}
/* 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;
@property (readwrite) BOOL fullScreen;
@property (readonly) BOOL hasVideo;
@property (readonly) VLCVideoLayer * videoLayer;
/* 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;
- (IBAction)backToMediaListView:(id)sender;
@end
/*****************************************************************************
* VLCController.h: VLC.app main controller
*****************************************************************************
* 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 <VLCKit/VLCKit.h>
@class VLCMainWindow;
@interface VLCController : NSObject
{
NSArray * categories;
}
@property (readonly, retain) NSArray * categories;
- (void)newMainWindow:(id)sender;
- (void)addPlaylist:(id)sender;
@end
/*****************************************************************************
* VLCController.m: VLC.app main controller
*****************************************************************************
* 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 <VLCKit/VLCKit.h>
#import "VLCController.h"
#import "VLCAppAdditions.h"
#import "VLCValueTransformer.h"
@interface VLCController ()
@property (readwrite,retain) NSArray * categories;
@end
/******************************************************************************
* VLCBrowsableVideoView
*/
@implementation VLCController
@synthesize categories;
- (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"];
VLCURLToRepresentedFileNameTransformer *urlToRepresentedFileName;
urlToRepresentedFileName = [[[VLCURLToRepresentedFileNameTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:(id)urlToRepresentedFileName forName:@"URLToRepresentedFileNameTransformer"];
VLCSelectionIndexToDescriptionTransformer *indexToDescription;
indexToDescription = [[[VLCSelectionIndexToDescriptionTransformer alloc] init] autorelease];
[NSValueTransformer setValueTransformer:(id)indexToDescription forName:@"SelectionIndexToDescriptionTransformer"];
/***********************************
* categories: Main content
*/
NSArray * mediaDiscoverers = [NSArray arrayWithObjects:
[[[VLCMediaDiscoverer alloc] initWithName:@"shoutcasttv"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"shoutcast"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease],
[[[VLCMediaDiscoverer alloc] initWithName:@"freebox"] autorelease], nil];
self.categories = [NSArray arrayWithObjects:
[NSMutableDictionary dictionaryWithObjectsAndKeys:
[@"Service Discovery" uppercaseString], @"descriptionInCategoriesList",
@"Service Discovery", @"descriptionInVideoView",
[NSNumber numberWithBool:NO], @"selectableInCategoriesList",
mediaDiscoverers, @"childrenInCategoriesList",
mediaDiscoverers, @"childrenInVideoView",
nil],
[VLCMedia mediaAsNodeWithName:@"Playlist"],
nil];
/* Execution will continue in applicationDidFinishLaunching */
[NSApp setDelegate: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
{
// TODO
NSLog(@"unimplemented!");
}
@end
@implementation VLCController (NSAppDelegate)
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
[self newMainWindow: self];
}
@end
/*****************************************************************************
* VLCExceptionHandler.h: VLCExceptionHandler implementation
*****************************************************************************
* 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 VLCExceptionHandler : NSObject {
}
- (void)printStackTrace:(NSException *)e;
@end
/*****************************************************************************
* VLCExceptionHandler.m: VLCExceptionHandler implementation
*****************************************************************************
* 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 "VLCExceptionHandler.h"
#import <ExceptionHandling/ExceptionHandling.h>
@implementation VLCExceptionHandler
+ (void)load
{
[[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];
NSLog(@"*** Exception Handled! %@: %@", [exception name], [exception reason]);
int ret = NSRunCriticalAlertPanel(@"Exception not handled!",
[NSString stringWithFormat:@"%@: %@\n\nBack trace has been printed to Console.\n\nWe will now wait for debugger connection...\n",
[exception name], [exception reason]],
@"Quit", @"Wait Debugger", nil);
if( ret == NSOKButton )
{
[NSApp terminate:self];
}
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
/*****************************************************************************
* VLCFullScreenControllerWindow.m: class that allow media controlling in
* fullscreen (with the mouse)
*****************************************************************************
* 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 <VLCKit/VLCKit.h>
#import "VLCAppAdditions.h"
#import "VLCMainWindowController.h"
@interface VLCFullScreenControllerWindow : NSPanel
{
/* IBOutlets */
IBOutlet VLCImageCustomizedSlider * volumeSlider;
IBOutlet VLCImageCustomizedSlider * mediaPositionSlider;
IBOutlet NSButton * mediaPlayerForwardNextButton;
IBOutlet NSButton * mediaPlayerBackwardPrevButton;
IBOutlet NSButton * mediaPlayerPlayPauseStopButton;
IBOutlet id fillScreenButton;
IBOutlet id fullScreenButton;
IBOutlet NSTextField * mediaReadingProgressText;
IBOutlet NSTextField * mediaDescriptionText;
NSTimer * hideWindowTimer;
NSTrackingArea * videoViewTrackingArea;
BOOL active;
/* Owner */
IBOutlet VLCMainWindowController * mainWindowController;
/* Draging the window using its content */
NSPoint mouseClic;
}
@end
/*****************************************************************************
* VLCMainWindow.h: VLCMainWindow implementation
*****************************************************************************
* 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 VLCMainWindow : NSWindow {
}
@end
/*****************************************************************************
* VLCMainWindow.m: VLCMainWindow implementation
*****************************************************************************
* 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 "VLCMainWindow.h"
/******************************************************************************
* VLCMainWindow
*/
@implementation VLCMainWindow
@end
/*****************************************************************************
* VLCMainWindowController.h: VLCMainWindowController implementation
*****************************************************************************
* 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 "VLCController.h"
#import "VLCMediaArrayController.h"
#import "VLCAppAdditions.h"
#import "VLCBrowsableVideoView.h"
#import "VLCMainWindow.h"
@interface VLCMainWindowController : NSWindowController
{
IBOutlet VLCOneSplitView * mainSplitView;
/* Media List */
IBOutlet NSTableView * mediaListView;
/* Categories List */
IBOutlet NSOutlineView * categoriesListView;
IBOutlet NSButton * addPlaylistButton;
IBOutlet NSButton * removePlaylistButton;
/* Toolbar control buttons */
IBOutlet NSButton * mediaPlayerForwardNextButton;
IBOutlet NSButton * mediaPlayerBackwardPrevButton;
IBOutlet NSButton * mediaPlayerPlayPauseStopButton;
/* Toolbar */
IBOutlet NSView * toolbarMediaAudioVolume;
IBOutlet NSView * toolbarMediaDescription;
IBOutlet NSView * toolbarMediaControl;
/* Video */
IBOutlet VLCBrowsableVideoView * videoView;
/* Controllers */
NSTreeController * categoriesTreeController;
IBOutlet VLCMediaArrayController * mediaArrayController;
IBOutlet VLCMediaPlayer * mediaPlayer;
IBOutlet VLCController * controller; /* This is a VLCController binded to the File's Owner of the nib */
/* States */
float navigatorViewWidth;
}
@property BOOL navigatorViewVisible;
- (void)setNavigatorViewVisible:(BOOL)wantsVisible animate:(BOOL)animate;
@property (readonly) VLCMediaPlayer * mediaPlayer;
@property (readonly) VLCBrowsableVideoView * videoView;
@property (readonly) VLCMediaArrayController * mediaArrayController;
@property (readonly) NSTreeController * categoriesTreeController;
- (IBAction)mediaListViewItemDoubleClicked:(id)sender;
- (void)videoViewItemClicked:(id)sender;
@end
/*****************************************************************************
* 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 <VLCKit/VLCKit.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] || op == NSTableViewDropOn ? 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];
if( !droppedItems )
droppedItems = [[info draggingPasteboard] propertyListForType:NSURLPboardType];
NSAssert( contentMediaList, @"No contentMediaList" );
for (i = 0; i < [droppedItems count]; i++)
{
NSString * filename = [droppedItems objectAtIndex:i];
VLCMedia *media = [VLCMedia mediaWithPath:filename];
[contentMediaList lock];
[contentMediaList insertMedia:media atIndex:row];
[contentMediaList unlock];
}
return YES;
}
- (BOOL)tableView:(NSTableView *)aTableView writeRowsWithIndexes:(NSIndexSet *)rowIndexes toPasteboard:(NSPasteboard *)pboard
{
NSMutableArray *array = [NSMutableArray arrayWithCapacity:[rowIndexes count]];
int i = [rowIndexes firstIndex];
do {
[array addObject:[[contentMediaList mediaAtIndex:i] url]];
} while ((i = [rowIndexes indexGreaterThanIndex:i]) != NSNotFound);
[pboard declareTypes:[NSArray arrayWithObject:@"VLCMediaURLType"] owner:self];
[pboard setPropertyList:array forType:@"VLCMediaURLType"];
return YES;
}
@end
//
// VLCMediaLayer.h
// VLC
//
// Created by Pierre d'Herbemont on 1/14/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <VLCKit/VLCKit.h>
@interface VLCMediaLayer : CALayer {
BOOL displayFullInformation;
VLCMedia * media;
CATextLayer * titleLayer;
CATextLayer * artistLayer;
CATextLayer * genreLayer;
CALayer * artworkLayer;
}
+ (id)layerWithMedia:(VLCMedia *)media;
@property (assign) BOOL displayFullInformation;
@property (retain,readonly) VLCMedia * media;
@property (retain,readonly) CATextLayer * titleLayer;
@property (retain,readonly) CATextLayer * artistLayer;
@property (retain,readonly) CATextLayer * genreLayer;
@property (retain,readonly) CALayer * artworkLayer;
@end
This diff is collapsed.
//
// VLCMediaListLayer.h
// VLC
//
// Created by Pierre d'Herbemont on 1/14/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import <Cocoa/Cocoa.h>
#import <QuartzCore/QuartzCore.h>
#import <VLCKit/VLCKit.h>
#import "VLCMediaLayer.h"
#import "VLCMediaArrayController.h"
@interface VLCMediaListLayer : CALayer {
NSArray * content;
NSUInteger selectedIndex;
VLCMediaLayer * previousLayer;
VLCMediaLayer * selectedLayer;
VLCMediaLayer * nextLayer;
VLCMediaArrayController * controller;
}
+ (id)layer;
+ (id)layerWithMediaArrayController:(VLCMediaArrayController *)aController;
@property (retain,readwrite) NSArray * content;
@property (readwrite) NSUInteger selectedIndex;
@property (retain,readwrite) VLCMediaArrayController * controller;
@end
This diff is collapsed.
/*****************************************************************************
* 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
@interface VLCURLToRepresentedFileNameTransformer : NSValueTransformer {
}
@end
@interface VLCSelectionIndexToDescriptionTransformer : 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
@implementation VLCURLToRepresentedFileNameTransformer
+ (Class)transformedValueClass
{
return [NSURL class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (NSString *)transformedValue:(id)value
{
if( ![value isKindOfClass:[NSURL class]] || ![value isFileURL] )
return @"";
return [value path];
}
@end
@implementation VLCSelectionIndexToDescriptionTransformer
+ (Class)transformedValueClass
{
return [NSNumber class];
}
+ (BOOL)allowsReverseTransformation
{
return NO;
}
- (NSString *)transformedValue:(id)value
{
if( ![value isKindOfClass:[NSNumber class]])
return @"";
return [value intValue] == NSNotFound ? @"" : [NSString stringWithFormat:@"%@ of ", value];
}
@end
This diff is collapsed.
//
// Prefix header for all source files of the 'VLC' target in the 'VLC' project
//
#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
//
// main.m
// VLC
//
// Created by Pierre d'Herbemont on 11/08/07.
// Copyright __MyCompanyName__ 2007. All rights reserved.
//
#import <Cocoa/Cocoa.h>
int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **) argv);
}
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