Commit 9d6eca0c authored by Pierre d'Herbemont's avatar Pierre d'Herbemont

MacOSX/VLC_app: Better naming scheme for the different UI elements.

parent 7036039b
......@@ -7,7 +7,7 @@
<dict>
<key>ACTIONS</key>
<dict>
<key>detailListItemDoubleClicked</key>
<key>mediaListViewItemDoubleClicked</key>
<string>id</string>
<key>newMainWindow</key>
<string>id</string>
......@@ -18,15 +18,15 @@
<string>ObjC</string>
<key>OUTLETS</key>
<dict>
<key>categoryList</key>
<key>categoriesListView</key>
<string>id</string>
<key>detailItemFetchedStatus</key>
<key>mediaListItemFetchedStatus</key>
<string>id</string>
<key>detailItemsCount</key>
<key>mediaListItemsCount</key>
<string>id</string>
<key>detailList</key>
<key>mediaListView</key>
<string>id</string>
<key>detailSearchField</key>
<key>mediaListSearchField</key>
<string>id</string>
<key>fillScreenButton</key>
<string>id</string>
......
......@@ -28,9 +28,9 @@
/******************************************************************************
* VLCMediaDiscoverer (MasterViewBindings)
* VLCMediaDiscoverer (CategoriesListBindings)
*/
@implementation VLCMediaDiscoverer (MasterViewBindings)
@implementation VLCMediaDiscoverer (CategoriesListBindings)
+(void)initialize
{
[VLCMediaDiscoverer setKeys:[NSArray arrayWithObject:@"running"] triggerChangeNotificationsForDependentKey:@"currentlyFetchingItems"];
......@@ -43,7 +43,7 @@
if( !dict )
{
dict = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSSet setWithObject:@"discoveredMedia.flatAspect"], @"childrenInMasterViewForDetailView",
[NSSet setWithObject:@"discoveredMedia.flatAspect"], @"childrenInCategoriesListForDetailView",
nil] retain];
}
return [dict objectForKey: key];
......@@ -62,24 +62,24 @@
return sdImage;
}
/* MasterView specific bindings */
- (NSArray *)childrenInMasterView
/* CategoriesList specific bindings */
- (NSArray *)childrenInCategoriesList
{
return nil;
}
- (NSString *)descriptionInMasterView
- (NSString *)descriptionInCategoriesList
{
return [self localizedName];
}
- (VLCMediaListAspect *)childrenInMasterViewForDetailView
- (VLCMediaListAspect *)childrenInCategoriesListForDetailView
{
return [[self discoveredMedia] flatAspect];
}
- (BOOL)editableInMasterView
- (BOOL)editableInCategoriesList
{
return NO;
}
- (BOOL)selectableInMasterView
- (BOOL)selectableInCategoriesList
{
return YES;
}
......@@ -113,9 +113,9 @@
if( !dict )
{
dict = [[NSDictionary dictionaryWithObjectsAndKeys:
[NSSet setWithObject:@"subitems.hierarchicalNodeAspect.media"], @"childrenInMasterView",
[NSSet setWithObject:@"metaDictionary.title"], @"descriptionInMasterView",
[NSSet setWithObject:@"subitems.flatAspect"], @"childrenInMasterViewForDetailView",
[NSSet setWithObject:@"subitems.hierarchicalNodeAspect.media"], @"childrenInCategoriesList",
[NSSet setWithObject:@"metaDictionary.title"], @"descriptionInCategoriesList",
[NSSet setWithObject:@"subitems.flatAspect"], @"childrenInCategoriesListForDetailView",
[NSSet setWithObject:@"metaDictionary.title"], @"descriptionInVideoView",
[NSSet setWithObject:@"state"], @"stateAsImage",
nil] retain];
......@@ -123,28 +123,28 @@
return [dict objectForKey: key];
}
/* MasterView specific bindings */
- (NSArray *)childrenInMasterView
/* CategoriesList specific bindings */
- (NSArray *)childrenInCategoriesList
{
return [[[self subitems] hierarchicalNodeAspect] valueForKeyPath:@"media"];
}
- (void)setDescriptionInMasterView:(NSString *)description
- (void)setDescriptionInCategoriesList:(NSString *)description
{
NSLog(@"unimplemented: meta edition");
}
- (NSString *)descriptionInMasterView
- (NSString *)descriptionInCategoriesList
{
return [[self metaDictionary] objectForKey:@"title"];
}
- (VLCMediaListAspect *)childrenInMasterViewForDetailView
- (VLCMediaListAspect *)childrenInCategoriesListForDetailView
{
return [[self subitems] flatAspect];
}
- (BOOL)editableInMasterView
- (BOOL)editableInCategoriesList
{
return YES;
}
- (BOOL)selectableInMasterView
- (BOOL)selectableInCategoriesList
{
return YES;
}
......@@ -170,7 +170,7 @@
return [[self metaDictionary] objectForKey:@"title"];
}
/* DetailList specific bindings */
/* mediaListView specific bindings */
- (NSImage *)stateAsImage
{
static NSImage * playing = nil;
......
......@@ -25,26 +25,14 @@
#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;
NSArray * categories;
}
@property (readonly, retain) NSArray * arrayOfMasters;
@property (readonly, retain) NSArray * arrayOfVideoViewMasters;
@property (readonly, retain) NSArray * categories;
- (void)newMainWindow:(id)sender;
- (void)addPlaylist:(id)sender;
@end
......@@ -29,16 +29,14 @@
#import "VLCValueTransformer.h"
@interface VLCController ()
@property (readwrite,retain) NSArray * arrayOfMasters;
@property (readwrite,retain) NSArray * arrayOfVideoViewMasters;
@property (readwrite,retain) NSArray * categories;
@end
/******************************************************************************
* VLCBrowsableVideoView
*/
@implementation VLCController
@synthesize arrayOfMasters;
@synthesize arrayOfVideoViewMasters;
@synthesize categories;
- (void)awakeFromNib
{
......@@ -53,54 +51,39 @@
[NSValueTransformer setValueTransformer:(id)nonNilAsBool forName:@"NonNilAsBoolTransformer"];
/***********************************
* arrayOfMasters: MasterView OutlineView content
* categories: Main content
*/
NSArray * arrayOfMediaDiscoverer = [NSArray arrayWithObjects:
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];
arrayOfPlaylists = [NSMutableArray arrayWithObjects:[VLCMedia mediaAsNodeWithName:@"Default Playlist"], nil];
NSArray * playlists = [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",
NSDictionary * playlistsAsDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
[@"Playlists" uppercaseString], @"descriptionInCategoriesList",
@"Playlists", @"descriptionInVideoView",
[NSNumber numberWithBool:NO], @"selectableInCategoriesList",
playlists, @"childrenInCategoriesList",
playlists, @"childrenInVideoView",
nil];
self.arrayOfMasters = [NSArray arrayWithObjects:
self.categories = [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" uppercaseString], @"descriptionInCategoriesList",
@"Service Discovery", @"descriptionInVideoView",
arrayOfMediaDiscoverer, @"childrenInVideoView",
[NSNumber numberWithBool:NO], @"selectableInCategoriesList",
mediaDiscoverers, @"childrenInCategoriesList",
mediaDiscoverers, @"childrenInVideoView",
nil],
playlists,
playlistsAsDictionary,
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])
......@@ -117,3 +100,10 @@
}
@end
@implementation VLCController (NSAppDelegate)
- (void)applicationDidFinishLaunching:(NSNotification *)notification
{
[self newMainWindow: self];
}
@end
......@@ -26,15 +26,16 @@
#import "VLCController.h"
#import "VLCMediaArrayController.h"
#import "VLCAppAdditions.h"
#import "VLCBrowsableVideoView.h"
@interface VLCMainWindow : NSWindow {
/* IB elements */
IBOutlet id detailItemFetchedStatus;
IBOutlet id detailItemsCount;
IBOutlet id detailSearchField;
IBOutlet id mediaListItemFetchedStatus;
IBOutlet id mediaListItemsCount;
IBOutlet id mediaListSearchField;
IBOutlet NSOutlineView * categoryList;
IBOutlet NSTableView * detailList;
IBOutlet NSOutlineView * categoriesListView;
IBOutlet NSTableView * mediaListView;
IBOutlet VLCBrowsableVideoView * videoView;
IBOutlet id fillScreenButton;
......@@ -57,7 +58,7 @@
IBOutlet VLCController * controller; /* This is a VLCController binded to the File's Owner of the nib */
/* Controllers */
NSTreeController * treeController;
NSTreeController * categoriesTreeController;
VLCMediaArrayController * mediaArrayController;
/* Window state */
......
......@@ -29,9 +29,9 @@
#import "VLCAppAdditions.h"
/******************************************************************************
* VLCMainWindow (MasterViewDataSource)
* VLCMainWindow (CategoriesListDelegate)
*/
@implementation VLCMainWindow (MasterViewDelegate)
@implementation VLCMainWindow (CategoriesListDelegate)
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
{
return [[item representedObject] isKindOfClass:[NSDictionary class]];
......@@ -46,7 +46,10 @@
}
@end
@implementation VLCMainWindow (MasterViewDataSource)
/******************************************************************************
* VLCMainWindow (CategoriesListDataSource)
*/
@implementation VLCMainWindow (CategoriesListDataSource)
/* Drag and drop */
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index
{
......@@ -113,21 +116,21 @@
mediaPlayer = [[VLCMediaPlayer alloc] initWithVideoView:videoView];
/***********************************
* MasterView OutlineView content
* CategoriesList OutlineView content
*/
/* treeController */
treeController = [[NSTreeController alloc] init];
[treeController setContent:controller.arrayOfMasters];
/* categoriesTreeController */
categoriesTreeController = [[NSTreeController alloc] init];
[categoriesTreeController setContent:controller.categories];
[treeController setChildrenKeyPath:@"childrenInMasterView"];
//[treeController bind:@"contentArray" toObject:controller withKeyPath:@"arrayOfMasters" options:nil];
[categoriesTreeController setChildrenKeyPath:@"childrenInCategoriesList"];
//[categoriesTreeController bind:@"contentArray" toObject:controller withKeyPath:@"arrayOfMasters" options:nil];
/* Bind the "name" table column */
tableColumn = [categoryList tableColumnWithIdentifier:@"name"];
[tableColumn bind:@"value" toObject: treeController withKeyPath:@"arrangedObjects.descriptionInMasterView" options:nil];
tableColumn = [categoriesListView tableColumnWithIdentifier:@"name"];
[tableColumn bind:@"value" toObject: categoriesTreeController withKeyPath:@"arrangedObjects.descriptionInCategoriesList" options:nil];
[tableColumn setEditable:YES];
/* FIXME: this doesn't work obviously. */
[tableColumn bind:@"editable" toObject: treeController withKeyPath:@"arrangedObjects.editableInMasterView" options:nil];
[tableColumn bind:@"editable" toObject: categoriesTreeController withKeyPath:@"arrangedObjects.editableInCategoriesList" options:nil];
/* Use an ImageAndTextCell in the "name" table column */
ImageAndTextCell * cell = [[ImageAndTextCell alloc] init];
......@@ -137,52 +140,52 @@
[tableColumn setDataCell:cell];
/* Other setup */
[categoryList setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
[categoryList setDelegate:self];
[categoriesListView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
[categoriesListView setDelegate:self];
[categoryList registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, @"VLCMediaURLType", nil]];
[categoryList setDataSource: self];
[categoriesListView registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, @"VLCMediaURLType", nil]];
[categoriesListView setDataSource: self];
/***********************************
* detailList setup
* mediaListView setup
*/
mediaArrayController = [[VLCMediaArrayController alloc] init];
/* 1- Drag and drop */
[detailList registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, nil]];
[detailList setDataSource:mediaArrayController];
[mediaListView registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, NSURLPboardType, nil]];
[mediaListView setDataSource:mediaArrayController];
/* 2- Double click */
[detailList setTarget:self];
[detailList setDoubleAction:@selector(detailListItemDoubleClicked:)];
[mediaListView setTarget:self];
[mediaListView setDoubleAction:@selector(mediaListViewItemDoubleClicked:)];
/* 3- binding for "title" column */
tableColumn = [detailList tableColumnWithIdentifier:@"title"];
tableColumn = [mediaListView tableColumnWithIdentifier:@"title"];
[tableColumn bind:@"value" toObject: mediaArrayController withKeyPath:@"arrangedObjects.metaDictionary.title" options:nil];
/* 4- binding for "state" column */
tableColumn = [detailList tableColumnWithIdentifier:@"state"];
tableColumn = [mediaListView tableColumnWithIdentifier:@"state"];
[tableColumn bind:@"value" toObject: mediaArrayController withKeyPath:@"arrangedObjects.stateAsImage" options:nil];
/* 5- Search & Predicate */
NSMutableDictionary * bindingOptions = [NSMutableDictionary dictionary];
[bindingOptions setObject:@"metaDictionary.title contains[c] $value" forKey:NSPredicateFormatBindingOption];
[bindingOptions setObject:@"No Title" forKey:NSDisplayNameBindingOption];
[detailSearchField bind:@"predicate" toObject: mediaArrayController withKeyPath:@"filterPredicate" options:bindingOptions];
[mediaListSearchField bind:@"predicate" toObject: mediaArrayController withKeyPath:@"filterPredicate" options:bindingOptions];
/* 6- Bind the @"contentArray" and contentMediaList of the mediaArrayController */
[mediaArrayController bind:@"contentArray" toObject:treeController withKeyPath:@"selection.childrenInMasterViewForDetailView.media" options:nil];
[mediaArrayController bind:@"contentMediaList" toObject:treeController withKeyPath:@"selection.childrenInMasterViewForDetailView.parentMediaList" options:nil];
[mediaArrayController bind:@"contentArray" toObject:categoriesTreeController withKeyPath:@"selection.childrenInCategoriesListForDetailView.media" options:nil];
[mediaArrayController bind:@"contentMediaList" toObject:categoriesTreeController withKeyPath:@"selection.childrenInCategoriesListForDetailView.parentMediaList" options:nil];
/* 7- Aspect */
[detailList setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
[detailList setAllowsTypeSelect:YES];
[mediaListView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
[mediaListView setAllowsTypeSelect:YES];
/***********************************
* videoView setup
*/
[videoView setItemsTree:controller.arrayOfVideoViewMasters];
[videoView setItemsTree:controller.categories];
[videoView setNodeKeyPath:@"childrenInVideoView"];
[videoView setContentKeyPath:@"descriptionInVideoView"];
[videoView setTarget:self];
......@@ -193,8 +196,8 @@
* Other interface element setup
*/
[detailItemsCount bind:@"displayPatternValue1" toObject:mediaArrayController withKeyPath:@"arrangedObjects.@count" options:[NSDictionary dictionaryWithObject:@"%{value1}@ items" forKey:NSDisplayPatternBindingOption]];
[detailItemFetchedStatus bind:@"animate" toObject:treeController withKeyPath:@"selection.currentlyFetchingItems" options:[NSDictionary dictionaryWithObject:@"%{value1}@ items" forKey:NSDisplayPatternBindingOption]];
[mediaListItemsCount bind:@"displayPatternValue1" toObject:mediaArrayController withKeyPath:@"arrangedObjects.@count" options:[NSDictionary dictionaryWithObject:@"%{value1}@ items" forKey:NSDisplayPatternBindingOption]];
[mediaListItemFetchedStatus bind:@"animate" toObject:categoriesTreeController withKeyPath:@"selection.currentlyFetchingItems" options:[NSDictionary dictionaryWithObject:@"%{value1}@ items" forKey:NSDisplayPatternBindingOption]];
[fillScreenButton bind:@"value" toObject:videoView withKeyPath:@"fillScreen" options: [NSDictionary dictionaryWithObject:NSNegateBooleanTransformerName forKey:NSValueTransformerNameBindingOption]];
[fullScreenButton bind:@"value" toObject:videoView withKeyPath:@"fullScreen" options: nil];
......@@ -213,8 +216,8 @@
[navigatorViewToggleButton bind:@"value" toObject:self withKeyPath:@"navigatorViewVisible" options: nil];
/* Playlist buttons */
[removePlaylistButton bind:@"enabled" toObject:treeController withKeyPath:@"selection.editableInMasterView" options: nil];
[removePlaylistButton setTarget:treeController];
[removePlaylistButton bind:@"enabled" toObject:categoriesTreeController withKeyPath:@"selection.editableInCategoriesList" options: nil];
[removePlaylistButton setTarget:categoriesTreeController];
[removePlaylistButton setAction:@selector(remove:)];
[addPlaylistButton setTarget:controller];
[addPlaylistButton setAction:@selector(addPlaylist:)];
......@@ -222,20 +225,20 @@
[mainSplitView setDelegate:self];
/* Last minute setup */
[categoryList expandItem:nil expandChildren:YES];
[categoryList selectRowIndexes:[NSIndexSet indexSetWithIndex:[categoryList numberOfRows] > 0 ? [categoryList numberOfRows]-1 : 0] byExtendingSelection:NO];
[categoriesListView expandItem:nil expandChildren:YES];
[categoriesListView selectRowIndexes:[NSIndexSet indexSetWithIndex:[categoriesListView numberOfRows] > 0 ? [categoriesListView numberOfRows]-1 : 0] byExtendingSelection:NO];
}
- (void)dealloc
{
[navigatorView release];
[mediaPlayer release];
[treeController release];
[categoriesTreeController release];
[mediaArrayController release];
[super dealloc];
}
- (void)detailListItemDoubleClicked:(id)sender
- (void)mediaListViewItemDoubleClicked:(id)sender
{
[mediaPlayer setMedia:[[mediaArrayController selectedObjects] objectAtIndex:0]];
[mediaPlayer play];
......
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