]> git.sesse.net Git - vlc/blob - modules/gui/macosx/vlm.m
39d19c4423d113974ce3a7a6b6202b75050999d5
[vlc] / modules / gui / macosx / vlm.m
1 /*****************************************************************************
2  * vlm.m: VLM Configuration panel for Mac OS X
3  *****************************************************************************
4  * Copyright (c) 2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 #import "vlm.h"
25
26 #ifdef ENABLE_VLM
27
28 static NSString * VLCVLMToolbarIdentifier = @"Our VLM Toolbar Identifier";
29 static NSString * VLCVODToolbarIdentifier = @"VLM Item";
30 static NSString * VLCSchedToolbarIdentifier = @"Sched Item";
31 static NSString * VLCBcastToolbarIdentifier = @"Bcast Item";
32
33 @implementation VLCVLMController
34
35 static VLCVLMController *_o_sharedInstance = nil;
36
37 + (VLCVLMController *)sharedInstance
38 {
39     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
40 }
41
42 - (id)init
43 {
44     if( _o_sharedInstance )
45         [self dealloc];
46     else
47     {
48         _o_sharedInstance = [super init];
49     }
50
51     return _o_sharedInstance;
52 }
53
54 - (void)awakeFromNib
55 {
56     [self initStrings];
57     
58     /* setup the toolbar */
59     NSToolbar * o_vlm_toolbar = [[[NSToolbar alloc] initWithIdentifier: VLCVLMToolbarIdentifier] autorelease];
60     [o_vlm_toolbar setAllowsUserCustomization: NO];
61     [o_vlm_toolbar setAutosavesConfiguration: NO];
62     [o_vlm_toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
63     [o_vlm_toolbar setSizeMode: NSToolbarSizeModeRegular];
64     [o_vlm_toolbar setDelegate: self];
65     [o_vlm_win setToolbar: o_vlm_toolbar];
66 }
67
68 #define CreateToolbarItem( o_name, o_desc, o_img, sel ) \
69     o_toolbarItem = create_toolbar_item(o_itemIdent, o_name, o_desc, o_img, self, @selector(sel));
70 static inline NSToolbarItem *
71 create_toolbar_item( NSString * o_itemIdent, NSString * o_name, NSString * o_desc, NSString * o_img, id target, SEL selector )
72 {
73     NSToolbarItem *o_toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: o_itemIdent] autorelease]; \
74
75     [o_toolbarItem setLabel: o_name];
76     [o_toolbarItem setPaletteLabel: o_desc];
77
78     [o_toolbarItem setToolTip: o_desc];
79     [o_toolbarItem setImage: [NSImage imageNamed: o_img]];
80
81     [o_toolbarItem setTarget: target];
82     [o_toolbarItem setAction: selector];
83
84     [o_toolbarItem setEnabled: YES];
85     [o_toolbarItem setAutovalidates: YES];
86
87     return o_toolbarItem;
88 }
89
90 - (NSToolbarItem *) toolbar: (NSToolbar *)o_vlm_toolbar 
91       itemForItemIdentifier: (NSString *)o_itemIdent 
92   willBeInsertedIntoToolbar: (BOOL)b_willBeInserted
93 {
94     NSToolbarItem *o_toolbarItem = nil;
95
96     if( [o_itemIdent isEqual: VLCVODToolbarIdentifier] )
97     {
98         CreateToolbarItem( _NS("Video On Demand"), _NS("Video On Demand"), @"add_vod", addVOD );
99     }
100     else if( [o_itemIdent isEqual: VLCSchedToolbarIdentifier] )
101     {
102         CreateToolbarItem( _NS("Schedule"), _NS("Schedule"), @"add_schedule", addSched );
103     }
104     else if( [o_itemIdent isEqual: VLCBcastToolbarIdentifier] )
105     {
106         CreateToolbarItem( _NS("Broadcast"), _NS("Broadcast"), @"add_broadcast", addBcast );
107     }
108
109     return o_toolbarItem;
110 }
111
112 - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
113 {
114     return [NSArray arrayWithObjects: VLCBcastToolbarIdentifier, VLCSchedToolbarIdentifier, VLCVODToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
115 }
116
117 - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar
118 {
119     return [NSArray arrayWithObjects: VLCBcastToolbarIdentifier, VLCSchedToolbarIdentifier, VLCVODToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
120 }
121
122 - (void)initStrings
123 {
124     /* not implemented */
125 }
126
127 - (void)showVLMWindow
128 {
129     [o_vlm_win makeKeyAndOrderFront: self];
130 }
131
132 - (void)addBcast
133 {
134     [NSApp beginSheet: o_bcast_panel modalForWindow: o_vlm_win
135         modalDelegate: self didEndSelector: nil contextInfo: nil];
136 }
137
138 - (void)addVOD
139 {
140     [NSApp beginSheet: o_vod_panel modalForWindow: o_vlm_win
141         modalDelegate: self didEndSelector: nil contextInfo: nil];
142 }
143
144 - (void)addSched
145
146     [NSApp beginSheet: o_sched_panel modalForWindow: o_vlm_win
147          modalDelegate: self didEndSelector: nil contextInfo: nil];
148 }
149
150 - (IBAction)bcastButtonAction:(id)sender
151 {
152     [NSApp endSheet: o_bcast_panel];
153     [o_bcast_panel close];
154 }
155
156 - (IBAction)listDoubleClickAction:(id)sender
157 {
158 }
159
160 - (IBAction)schedButtonAction:(id)sender
161 {
162     [NSApp endSheet: o_sched_panel];
163     [o_sched_panel close];
164 }
165
166 - (IBAction)vodButtonAction:(id)sender
167 {
168     [NSApp endSheet: o_vod_panel];
169     [o_vod_panel close];
170 }
171
172 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
173 {
174     return 0;
175 }
176
177 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
178 {
179     return @"dummy";
180 }
181
182 @end
183
184 #endif