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

extra/MacOSX/VLC_app: Initial import of a wanna-be VLC.app application that...

extra/MacOSX/VLC_app: Initial import of a wanna-be VLC.app application that use the framework. Not really valuable for now.
parent b5763548
B/* Localized versions of Info.plist keys */ B/* Localized versions of Info.plist keys */
{
IBClasses = (
{CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = NSSegmentedControl; LANGUAGE = ObjC; SUPERCLASS = NSControl; },
{CLASS = VLCCategoryListDataSource; LANGUAGE = ObjC; SUPERCLASS = NSObject; },
{CLASS = VLCCategoryOutlineView; LANGUAGE = ObjC; SUPERCLASS = NSOutlineView; },
{
CLASS = VLCController;
LANGUAGE = ObjC;
OUTLETS = {categoryList = id; detailList = id; detailSearchField = id; videoView = id; };
SUPERCLASS = NSObject;
},
{CLASS = VLCVideoView; LANGUAGE = ObjC; SUPERCLASS = NSView; }
);
IBVersion = 1;
}
\ No newline at end of file
<?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">
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>269 541 530 314 0 0 1680 1028 </string>
<key>IBEditorPositions</key>
<dict>
<key>29</key>
<string>141 525 338 44 0 0 1680 1028 </string>
</dict>
<key>IBFramework Version</key>
<string>446.1</string>
<key>IBOpenObjects</key>
<array>
<integer>21</integer>
<integer>29</integer>
</array>
<key>IBSystem Version</key>
<string>8R218</string>
</dict>
</plist>
<?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">
<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>com.yourcompany.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>
This diff is collapsed.
/*****************************************************************************
* VLCCategoryCell.h: VLC.app custom cell
* Most of the code here from Colloquy (GPL v2)
*****************************************************************************
* 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 VLCCategoryCell : NSImageCell {
@private
NSImage *_statusImage;
NSImage *_altImage;
NSString *_mainText;
NSString *_infoText;
NSLineBreakMode _lineBreakMode;
unsigned _statusNumber;
unsigned _importantStatusNumber;
BOOL _boldAndWhiteOnHighlight;
BOOL _selectable;
}
- (void) setStatusImage:(NSImage *) image;
- (NSImage *) statusImage;
- (void) setHighlightedImage:(NSImage *) image;
- (NSImage *) highlightedImage;
- (void) setMainText:(NSString *) text;
- (NSString *) mainText;
- (void) setInformationText:(NSString *) text;
- (NSString *) informationText;
- (void) setLineBreakMode:(NSLineBreakMode) mode;
- (NSLineBreakMode) lineBreakMode;
- (void) setBoldAndWhiteOnHighlight:(BOOL) boldAndWhite;
- (BOOL) boldAndWhiteOnHighlight;
- (void) setStatusNumber:(unsigned) number;
- (unsigned) statusNumber;
- (void) setImportantStatusNumber:(unsigned) number;
- (unsigned) importantStatusNumber;
@end
This diff is collapsed.
/*****************************************************************************
* VLCCategoryListDataSource.h: VLC.app custom outline view
*****************************************************************************
* 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 VLCCategoryListDataSource : NSObject
{
NSArray * mainCategories;
}
@end
/*****************************************************************************
* VLCCategoryListDataSource.h: VLC.app custom outline view
*****************************************************************************
* 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 <VLC/VLC.h>
#import "VLCCategoryListDataSource.h"
@implementation VLCCategoryListDataSource
- (id)init
{
if( self = [super init] )
{
/* No need to release, cause we keep it around forever */
mainCategories = [[NSArray arrayWithObjects: [VLCMediaLibrary sharedMediaLibrary],
@"Services Discovery",
@"Playlists", nil] retain];
}
return self;
}
- (id)outlineView:(NSOutlineView *)aOutlineView child:(int)index ofItem:(id)item
{
if( !item )
{
return [mainCategories objectAtIndex: index];
}
if ([item isKindOfClass: [NSString class]])
{
if([item isEqualToString: @"Services Discovery"])
return [[[VLCServicesDiscoverer sharedDiscoverer] services] objectAtIndex: index];
if([item isEqualToString: @"Playlists"])
return [[[[VLCMediaLibrary sharedMediaLibrary] playlists] objectAtIndex: index] retain]; /* XXX: this is a leak, but this code needs rework */
}
if ([item isKindOfClass: [VLCMediaLibrary class]])
return nil;
#if 0
if ([item isKindOfClass: [VLCMediaDiscoverer class]])
{
return nil;
}
#endif
if ([item isKindOfClass: [VLCPlaylist class]])
{
return [[[item sublists] objectAtIndex: index] retain]; /* XXX: this is a leak, but this code needs rework */
}
return nil;
}
- (BOOL)outlineView:(NSOutlineView *)aOutlineView isItemExpandable:(id)item
{
if (!item)
return YES;
if ([item isKindOfClass: [NSString class]])
{
if([item isEqualToString: @"Services Discovery"])
return YES;
if([item isEqualToString: @"Playlists"])
return YES;
}
if ([item isKindOfClass: [VLCMediaLibrary class]])
return NO;
if ([item isKindOfClass: [VLCPlaylist class]])
{
return [[item sublists] count] > 0;
}
return NO;
}
- (int)outlineView:(NSOutlineView *)aOutlineView numberOfChildrenOfItem:(id)item
{
if (!item)
return [mainCategories count];
if ([item isKindOfClass: [NSString class]])
{
if([item isEqualToString: @"Playlists"])
return [[[VLCMediaLibrary sharedMediaLibrary] playlists] count];
if([item isEqualToString: @"Services Discovery"])
return [[[VLCServicesDiscoverer sharedDiscoverer] services] count];
}
if ([item isKindOfClass: [VLCPlaylist class]])
return [[item playlists] count];
return 0;
}
- (id)outlineView:(NSOutlineView *)aOutlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
if (!item)
return nil;
if( [[tableColumn identifier] isEqualToString:@"name"] )
{
if ( [item isKindOfClass: [NSString class]] )
return item;
if ( [item isKindOfClass: [VLCPlaylist class]])
return [[[item providerMedia] metaInformation] objectForKey:VLCMetaInformationTitle];
if ( [item isKindOfClass: [VLCMediaDiscoverer class]])
return [item localizedName];
if ( [item isKindOfClass: [VLCMediaLibrary class]])
return @"Library";
}
else if ( [item isKindOfClass: [NSString class]] && [[tableColumn identifier] isEqualToString:@"icon"])
return nil;
return nil;
}
@end
@implementation VLCCategoryListDataSource (OutlineViewDelegating)
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
{
if ([item isKindOfClass: [NSString class]])
{
if([item isEqualToString: @"Library"])
return YES;
if([item isEqualToString: @"Services Discovery"])
return NO;
if([item isEqualToString: @"Playlists"])
return NO;
}
return YES;
}
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
if ([item isKindOfClass: [VLCMediaDiscoverer class]])
[cell setImage: [NSImage imageNamed:@"vlc_stream_16px"]];
else
[cell setImage: nil];
}
@end
/*****************************************************************************
* VLCCategoryOutlineView.h: VLC.app custom outline view
*****************************************************************************
* 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 VLCCategoryOutlineView : NSOutlineView
{
BOOL enableAnimation;
NSMutableDictionary *allAnimatingItemsDict;
int animations;
NSSize animationHedgeFactor;
BOOL disableExpansionAnimation;
}
@end
/*****************************************************************************
* VLCCategoryOutlineView.h: VLC.app custom outline view
* Most of the code here from Colloquy (GPL v2)
*****************************************************************************
* Copyright (C) 2007 Colloquy team (no copyright on original file)
* 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 "VLCCategoryOutlineView.h"
/* Taken from colloquy (GPL v2) */
static void gradientInterpolate( void *info, float const *inData, float *outData )
{
static float light[4] = { 0.67843137, 0.73333333, 0.81568627, 1. };
static float dark[4] = { 0.59607843, 0.66666667, 0.76862745, 1. };
float a = inData[0];
int i = 0;
for( i = 0; i < 4; i++ )
outData[i] = ( 1. - a ) * dark[i] + a * light[i];
}
@implementation VLCCategoryOutlineView
- (NSColor *) _highlightColorForCell:(NSCell *)aCell
{
/* return nil to prevent normal selection drawing*/
return nil;
}
- (void) _highlightRow:(int) row clipRect:(NSRect) clipRect
{
NSRect highlight = [self rectOfRow:row];
struct CGFunctionCallbacks callbacks = { 0, gradientInterpolate, NULL };
CGFunctionRef function = CGFunctionCreate( NULL, 1, NULL, 4, NULL, &callbacks );
CGColorSpaceRef cspace = CGColorSpaceCreateDeviceRGB();
CGShadingRef shading = CGShadingCreateAxial( cspace, CGPointMake( NSMinX( highlight ), NSMaxY( highlight ) ), CGPointMake( NSMinX( highlight ), NSMinY( highlight ) ), function, false, false );
CGContextDrawShading( [[NSGraphicsContext currentContext] graphicsPort], shading );
CGShadingRelease( shading );
CGColorSpaceRelease( cspace );
CGFunctionRelease( function );
static NSColor *rowBottomLine = nil;
if( ! rowBottomLine )
rowBottomLine = [[NSColor colorWithCalibratedRed:( 140. / 255. ) green:( 152. / 255. ) blue:( 176. / 255. ) alpha:1.] retain];
[rowBottomLine set];
NSRect bottomLine = NSMakeRect( NSMinX( highlight ), NSMaxY( highlight ) - 1., NSWidth( highlight ), 1. );
NSRectFill( bottomLine );
}
@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>
#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
{
IBOutlet id categoryList;
IBOutlet id detailList;
IBOutlet id videoView;
IBOutlet id detailSearchField;
}
@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.
*****************************************************************************/
/* this code needs rework, but it does nice thing */
#import <VLC/VLC.h>
#import "VLCController.h"
#import "VLCCategoryCell.h"
NSArrayController * treeController;
VLCPlaylist * currentPlaylist;
@implementation VLCController
- (void)awakeFromNib
{
[NSApp setDelegate:self];
[detailList setTarget:self];
[detailList setDoubleAction:@selector(detailListItemDoubleClicked:)];
[detailList setDataSource: [[VLCPlaylistDataSource alloc] initWithPlaylist:nil videoView:videoView]];
[detailList registerForDraggedTypes: [NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, nil]];
[categoryList setTarget:self];
[categoryList setAction:@selector(categoryListItemClicked:)];
[[[categoryList tableColumns] objectAtIndex:0] setDataCell:[[[VLCCategoryCell alloc] init] autorelease]];
}
- (void)detailListItemDoubleClicked:(id)sender
{
if( [sender isKindOfClass:[NSTableView class]] && [sender selectedRow] >= 0)
{
[videoView setPlaylist: currentPlaylist];
[videoView playMedia: [[treeController selectedObjects] objectAtIndex: 0]];
}
}
- (void)categoryListItemClicked:(id)sender
{
VLCPlaylist * aPlaylist;
id selectedItem = [sender itemAtRow:[sender selectedRow]];
if([selectedItem isKindOfClass:[VLCMediaLibrary class]])
aPlaylist = [selectedItem allMedia];
else if([selectedItem isKindOfClass:[VLCMediaDiscoverer class]])
aPlaylist = [selectedItem playlist];
else if([selectedItem isKindOfClass:[VLCPlaylist class]])
aPlaylist = [selectedItem flatPlaylist];
else
{
return;
}
currentPlaylist= aPlaylist;
treeController = [[NSArrayController alloc] init]; /* XXX: We leak */
//[treeController setAutomaticallyPreparesContent: YES];
[[detailList dataSource] release];
NSLog(@"currentPlaylist %@", currentPlaylist);
[detailList setDataSource: [[VLCPlaylistDataSource alloc] initWithPlaylist:aPlaylist videoView:videoView]];
//[treeController setContent: [[VLCMediaLibrary sharedMediaLibrary] allMedia]];
[treeController bind:@"contentArray" toObject: aPlaylist
withKeyPath:@"items" options:nil];
NSTableColumn *tableColumn;
NSMutableDictionary *bindingOptions = [NSMutableDictionary dictionary];
[bindingOptions setObject:@"metaInformation.title contains[c] $value" forKey:NSPredicateFormatBindingOption];
[bindingOptions setObject:@"No Title" forKey:NSDisplayNameBindingOption];
[detailSearchField bind:@"predicate" toObject: treeController
withKeyPath:@"filterPredicate" options:bindingOptions];
//[treeController setChildrenKeyPath:@"subitems.items"];
[bindingOptions removeAllObjects];
[bindingOptions setObject:@"Search" forKey:@"NSNullPlaceholder"];
/* binding for "title" column */
tableColumn = [detailList tableColumnWithIdentifier:@"title"];
[tableColumn bind:@"value" toObject: treeController
withKeyPath:@"arrangedObjects.metaInformation.title" options:bindingOptions];
}
@end
@implementation VLCController (NSAppDelegating)
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[self categoryListItemClicked: categoryList];
}
@end
//
// 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