1 /*****************************************************************************
2 * intf_controller.m: MacOS X plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: intf_controller.m,v 1.10 2002/06/19 22:47:14 massiot Exp $
7 * Authors: Florian G. Pflug <fgp@phlo.org>
8 * Jon Lech Johansen <jon-vl@nanocrew.net>
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.
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.
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 #import <ApplicationServices/ApplicationServices.h>
31 #include "intf_controller.h"
33 @implementation Intf_Controller
35 /* Initialization & Event-Management */
39 NSString *pTitle = [NSString
40 stringWithCString: VOUT_TITLE " (Cocoa)"];
42 [o_window setTitle: pTitle];
48 NSAutoreleasePool *o_pool;
50 o_pool = [[NSAutoreleasePool alloc] init];
52 while( ![o_intf manage] )
54 if( [o_intf playlistPlaying] )
56 [o_time setStringValue: [o_intf getTimeAsString]];
58 if( f_slider == f_slider_old )
60 float f_updated = [o_intf getTimeAsFloat];
62 if( f_updated != f_slider )
64 if( [o_slider_lock tryLock] )
66 [o_timeslider setFloatValue: f_updated];
67 [o_slider_lock unlock];
73 [o_intf setTimeAsFloat: f_slider];
74 f_slider_old = f_slider;
77 UpdateSystemActivity( UsrActivity );
80 sleepDate = [NSDate dateWithTimeIntervalSinceNow: 0.5];
81 [NSThread sleepUntilDate: sleepDate];
98 /* send a dummy event to break out of the event loop */
99 pEvent = [NSEvent mouseEventWithType: NSLeftMouseDown
100 location: NSMakePoint( 1, 1 ) modifierFlags: 0
101 timestamp: 1 windowNumber: [[NSApp mainWindow] windowNumber]
102 context: [NSGraphicsContext currentContext] eventNumber: 1
103 clickCount: 1 pressure: 0.0];
104 [NSApp postEvent: pEvent atStart: YES];
107 /* NSApplication messages */
109 - (void)applicationWillFinishLaunching:(NSNotification *)o_notification
111 o_intf = [[Intf_VLCWrapper instance] retain];
112 o_vout = [[Vout_VLCWrapper instance] retain];
114 f_slider = f_slider_old = 0.0;
115 o_slider_lock = [[NSLock alloc] init];
117 [NSThread detachNewThreadSelector: @selector(manage)
118 toTarget: self withObject: nil];
121 - (BOOL)application:(NSApplication *)o_app openFile:(NSString *)o_filename
125 o_array = [NSArray arrayWithObject: o_filename];
126 [o_intf openFiles: o_array];
131 /* Functions attached to user interface */
133 - (IBAction)pause:(id)sender
135 [o_intf playlistPause];
138 - (IBAction)play:(id)sender
140 [o_intf playlistPlay];
143 - (IBAction)stop:(id)sender
145 [o_intf playlistStop];
148 - (IBAction)faster:(id)sender
153 - (IBAction)slower:(id)sender
158 - (IBAction)prev:(id)sender
160 [o_intf playlistPrev];
163 - (IBAction)next:(id)sender
165 [o_intf playlistNext];
168 - (IBAction)prevChannel:(id)sender
170 [o_intf channelPrev];
173 - (IBAction)nextChannel:(id)sender
175 [o_intf channelNext];
178 - (IBAction)loop:(id)sender
180 NSMenuItem * item = (NSMenuItem *)sender;
184 if( p_main->p_intf->p_sys->b_loop )
186 [item setState:NSOnState];
190 [item setState:NSOffState];
194 - (IBAction)deinterlace:(id)sender
196 NSMenuItem * item = (NSMenuItem *)sender;
198 if ( [item state] == NSOnState )
200 config_PutPszVariable( "filter", NULL );
201 [item setState:NSOffState];
205 config_PutPszVariable( "filter", "deinterlace:blend" );
206 [item setState:NSOnState];
210 - (IBAction)mute:(id)sender
212 NSMenuItem * item = (NSMenuItem *)sender;
216 if( p_main->p_intf->p_sys->b_mute )
218 [item setState:NSOnState];
222 [item setState:NSOffState];
226 - (IBAction)fullscreen:(id)sender
231 - (IBAction)eject:(id)sender
236 - (IBAction)maxvolume:(id)sender
241 - (IBAction)timesliderUpdate:(id)slider
243 switch( [[NSApp currentEvent] type] )
245 case NSLeftMouseDown:
246 [o_slider_lock tryLock];
250 f_slider = [o_timeslider floatValue];
251 [o_slider_lock unlock];
259 - (IBAction)quit:(id)sender
264 - (BOOL)validateMenuItem:(id)sender
266 NSMenuItem * o_item = (NSMenuItem *)sender;
267 int tag = [o_item tag];
269 if ( tag == 12 || tag == 13 )
271 if( !config_GetIntVariable( "network-channel" ) )
275 if ( tag == 12 && !p_main->p_intf->p_sys->i_channel )
286 @implementation Intf_PlaylistDS
290 if( [super init] == nil )
300 o_playlist = [[[Intf_VLCWrapper instance] playlistAsArray] retain];
303 - (int)numberOfRowsInTableView:(NSTableView*)o_table
306 return( [o_playlist count] );
309 - (id)tableView:(NSTableView *)o_table objectValueForTableColumn:(NSTableColumn*)o_column row:(int)i_row
311 return( [o_playlist objectAtIndex: i_row] );
314 - (void)tableView:(NSTableView *)o_table setObjectValue:o_value forTableColumn:(NSTableColumn *)o_column row:(int)i_index