MacOSX/VLC_app: Initial import. Big playlist still causes memory and cpu high load...
[vlc.git] / extras / MacOSX / VLC_app / Sources / VLCController.m
1 /*****************************************************************************
2  * VLCController.m: VLC.app main controller
3  *****************************************************************************
4  * Copyright (C) 2007 Pierre d'Herbemont
5  * Copyright (C) 2007 the VideoLAN team
6  * $Id: VLCController.m 23286 2007-11-23 21:40:20Z pdherbemont $
7  *
8  * Authors: Pierre d'Herbemont <pdherbemont # videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #import <VLC/VLC.h>
26
27 #import "VLCController.h" 
28 #import "VLCAppAdditions.h" 
29 #import "VLCValueTransformer.h" 
30
31 @interface VLCController ()
32 @property (readwrite,retain) NSArray * arrayOfMasters;
33 @property (readwrite,retain) NSArray * arrayOfVideoViewMasters;
34 @end
35
36 /******************************************************************************
37  * VLCBrowsableVideoView
38  */
39 @implementation VLCController
40 @synthesize arrayOfMasters;
41 @synthesize arrayOfVideoViewMasters;
42
43 - (void)awakeFromNib
44 {
45     /***********************************
46      * Register our bindings value transformer
47      */
48     VLCFloat10000FoldTransformer *float100fold;
49     float100fold = [[[VLCFloat10000FoldTransformer alloc] init] autorelease];
50     [NSValueTransformer setValueTransformer:(id)float100fold forName:@"Float10000FoldTransformer"];
51     VLCNonNilAsBoolTransformer *nonNilAsBool;
52     nonNilAsBool = [[[VLCNonNilAsBoolTransformer alloc] init] autorelease];
53     [NSValueTransformer setValueTransformer:(id)nonNilAsBool forName:@"NonNilAsBoolTransformer"];
54
55     /***********************************
56      * arrayOfMasters: MasterView OutlineView content
57      */
58     NSArray * arrayOfMediaDiscoverer = [NSArray arrayWithObjects:
59         [[[VLCMediaDiscoverer alloc] initWithName:@"shoutcasttv"] autorelease],
60         [[[VLCMediaDiscoverer alloc] initWithName:@"shoutcast"] autorelease],
61         [[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease],
62         [[[VLCMediaDiscoverer alloc] initWithName:@"freebox"] autorelease], nil];
63
64     arrayOfPlaylists = [NSMutableArray arrayWithObjects:[VLCMedia mediaAsNodeWithName:@"Default Playlist"], nil];
65
66     NSDictionary * playlists = [NSMutableDictionary dictionaryWithObjectsAndKeys:
67                                 [@"Playlists" uppercaseString], @"descriptionInMasterView",
68                                 [@"Playlists" uppercaseString], @"descriptionInVideoView",
69                                 [NSNumber numberWithBool:NO], @"selectableInMasterView",
70                                 arrayOfPlaylists, @"childrenInMasterView",
71                                 arrayOfPlaylists, @"childrenInVideoView",
72                                 nil];
73
74     self.arrayOfMasters = [NSArray arrayWithObjects:
75                     [NSMutableDictionary dictionaryWithObjectsAndKeys:
76                         [@"Service Discovery" uppercaseString], @"descriptionInMasterView",
77                         [NSNumber numberWithBool:NO], @"selectableInMasterView",
78                         arrayOfMediaDiscoverer, @"childrenInMasterView",
79                         nil],
80                     playlists,
81                     nil];
82     
83
84     /***********************************
85      * videoView setup
86      */
87     self.arrayOfVideoViewMasters = [NSArray arrayWithObjects:
88                     [NSDictionary dictionaryWithObjectsAndKeys:
89                         @"Service Discovery", @"descriptionInVideoView",
90                         arrayOfMediaDiscoverer, @"childrenInVideoView",
91                         nil],
92                     playlists,
93                     nil];
94
95     /* Execution will continue in applicationDidFinishLaunching */
96     [NSApp setDelegate:self];
97 }
98
99 - (void)applicationDidFinishLaunching:(NSNotification *)notification
100 {
101     [self newMainWindow: self];
102 }
103
104 - (void)newMainWindow:(id)sender
105 {
106     if (![NSBundle loadNibNamed:@"MainWindow" owner:self])
107     {
108         NSLog(@"Warning! Could not load MainWindow file.\n");
109     }
110     /* We are done. Should be on screen if Visible at launch time is checked */
111 }
112
113 - (void)addPlaylist:(id)sender
114 {
115     [[arrayOfMasters mutableArrayValueForKey:@"[0].childrenInMasterView"] addObject:[VLCMedia mediaAsNodeWithName:@"Untitled Playlist"]];
116 }
117
118 @end
119
120 @implementation VLCController (ExceptionHandlerDelegating)
121 @end