1 /*****************************************************************************
2 * vlm.m: VLM Configuration panel for Mac OS X
3 *****************************************************************************
4 * Copyright (c) 2008 the VideoLAN team
7 * Authors: Felix Paul Kühne <fkuehne at videolan dot org>
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.
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.
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 *****************************************************************************/
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";
33 @implementation VLCVLMController
35 static VLCVLMController *_o_sharedInstance = nil;
37 + (VLCVLMController *)sharedInstance
39 return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
44 if( _o_sharedInstance )
48 _o_sharedInstance = [super init];
51 return _o_sharedInstance;
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];
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 )
73 NSToolbarItem *o_toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: o_itemIdent] autorelease]; \
75 [o_toolbarItem setLabel: o_name];
76 [o_toolbarItem setPaletteLabel: o_desc];
78 [o_toolbarItem setToolTip: o_desc];
79 [o_toolbarItem setImage: [NSImage imageNamed: o_img]];
81 [o_toolbarItem setTarget: target];
82 [o_toolbarItem setAction: selector];
84 [o_toolbarItem setEnabled: YES];
85 [o_toolbarItem setAutovalidates: YES];
90 - (NSToolbarItem *) toolbar: (NSToolbar *)o_vlm_toolbar
91 itemForItemIdentifier: (NSString *)o_itemIdent
92 willBeInsertedIntoToolbar: (BOOL)b_willBeInserted
94 NSToolbarItem *o_toolbarItem = nil;
96 if( [o_itemIdent isEqual: VLCVODToolbarIdentifier] )
98 CreateToolbarItem( _NS("Video On Demand"), _NS("Video On Demand"), @"add_vod", addVOD );
100 else if( [o_itemIdent isEqual: VLCSchedToolbarIdentifier] )
102 CreateToolbarItem( _NS("Schedule"), _NS("Schedule"), @"add_schedule", addSched );
104 else if( [o_itemIdent isEqual: VLCBcastToolbarIdentifier] )
106 CreateToolbarItem( _NS("Broadcast"), _NS("Broadcast"), @"add_broadcast", addBcast );
109 return o_toolbarItem;
112 - (NSArray *)toolbarDefaultItemIdentifiers: (NSToolbar *)toolbar
114 return [NSArray arrayWithObjects: VLCBcastToolbarIdentifier, VLCSchedToolbarIdentifier, VLCVODToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
117 - (NSArray *)toolbarAllowedItemIdentifiers: (NSToolbar *)toolbar
119 return [NSArray arrayWithObjects: VLCBcastToolbarIdentifier, VLCSchedToolbarIdentifier, VLCVODToolbarIdentifier, NSToolbarFlexibleSpaceItemIdentifier, nil];
124 /* not implemented */
127 - (void)showVLMWindow
129 [o_vlm_win makeKeyAndOrderFront: self];
134 [NSApp beginSheet: o_bcast_panel modalForWindow: o_vlm_win
135 modalDelegate: self didEndSelector: nil contextInfo: nil];
140 [NSApp beginSheet: o_vod_panel modalForWindow: o_vlm_win
141 modalDelegate: self didEndSelector: nil contextInfo: nil];
146 [NSApp beginSheet: o_sched_panel modalForWindow: o_vlm_win
147 modalDelegate: self didEndSelector: nil contextInfo: nil];
150 - (IBAction)bcastButtonAction:(id)sender
152 [NSApp endSheet: o_bcast_panel];
153 [o_bcast_panel close];
156 - (IBAction)listDoubleClickAction:(id)sender
160 - (IBAction)schedButtonAction:(id)sender
162 [NSApp endSheet: o_sched_panel];
163 [o_sched_panel close];
166 - (IBAction)vodButtonAction:(id)sender
168 [NSApp endSheet: o_vod_panel];
172 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
177 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex