]> git.sesse.net Git - vlc/blob - projects/macosx/vlc_app/Sources/VLCController.m
Move the Mac OS X framework plus the yet to be finished VLC.app to projects/macosx...
[vlc] / projects / 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$
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 <VLCKit/VLCKit.h>
26
27 #import "VLCController.h" 
28 #import "VLCAppAdditions.h" 
29 #import "VLCValueTransformer.h" 
30
31 @interface VLCController ()
32 @property (readwrite,retain) NSArray * categories;
33 @end
34
35 /******************************************************************************
36  * VLCBrowsableVideoView
37  */
38 @implementation VLCController
39 @synthesize categories;
40
41 - (void)awakeFromNib
42 {
43     /***********************************
44      * Register our bindings value transformer
45      */
46     VLCFloat10000FoldTransformer *float100fold;
47     float100fold = [[[VLCFloat10000FoldTransformer alloc] init] autorelease];
48     [NSValueTransformer setValueTransformer:(id)float100fold forName:@"Float10000FoldTransformer"];
49     VLCNonNilAsBoolTransformer *nonNilAsBool;
50     nonNilAsBool = [[[VLCNonNilAsBoolTransformer alloc] init] autorelease];
51     [NSValueTransformer setValueTransformer:(id)nonNilAsBool forName:@"NonNilAsBoolTransformer"];
52     VLCURLToRepresentedFileNameTransformer *urlToRepresentedFileName;
53     urlToRepresentedFileName = [[[VLCURLToRepresentedFileNameTransformer alloc] init] autorelease];
54     [NSValueTransformer setValueTransformer:(id)urlToRepresentedFileName forName:@"URLToRepresentedFileNameTransformer"];
55
56     /***********************************
57      * categories: Main content
58      */
59     NSArray * mediaDiscoverers = [NSArray arrayWithObjects:
60         [[[VLCMediaDiscoverer alloc] initWithName:@"shoutcasttv"] autorelease],
61         [[[VLCMediaDiscoverer alloc] initWithName:@"shoutcast"] autorelease],
62         [[[VLCMediaDiscoverer alloc] initWithName:@"sap"] autorelease], nil];
63
64     NSArray * playlists = [NSMutableArray arrayWithObjects:[VLCMedia mediaAsNodeWithName:@"Default Playlist"], nil];
65
66     NSDictionary * playlistsAsDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:
67                                 [@"Playlists" uppercaseString], @"descriptionInCategoriesList",
68                                 @"Playlists", @"descriptionInVideoView",
69                                 [NSNumber numberWithBool:NO], @"selectableInCategoriesList",
70                                 playlists, @"childrenInCategoriesList",
71                                 playlists, @"childrenInVideoView",
72                                 nil];
73
74     self.categories = [NSArray arrayWithObjects:
75                     [NSMutableDictionary dictionaryWithObjectsAndKeys:
76                         [@"Service Discovery" uppercaseString], @"descriptionInCategoriesList",
77                         @"Service Discovery", @"descriptionInVideoView",
78                         [NSNumber numberWithBool:NO], @"selectableInCategoriesList",
79                         mediaDiscoverers, @"childrenInCategoriesList",
80                         mediaDiscoverers, @"childrenInVideoView",
81                         nil],
82                     playlistsAsDictionary,
83                     nil];
84
85     /* Execution will continue in applicationDidFinishLaunching */
86     [NSApp setDelegate:self];
87 }
88
89 - (void)newMainWindow:(id)sender
90 {
91     if (![NSBundle loadNibNamed:@"MainWindow" owner:self])
92     {
93         NSLog(@"Warning! Could not load MainWindow file.\n");
94     }
95     /* We are done. Should be on screen if Visible at launch time is checked */
96 }
97
98 - (void)addPlaylist:(id)sender
99 {
100     // TODO
101     NSLog(@"unimplemented!");
102 }
103
104 @end
105
106 @implementation VLCController (NSAppDelegate)
107 - (void)applicationDidFinishLaunching:(NSNotification *)notification
108 {
109     [self newMainWindow: self];
110 }
111 @end