+ if( b_autoplay )
+ [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
+ else
+ [o_playlist appendArray: o_array atPos: -1 enqueue:YES];
+ }
+}
+
+- (void)showCaptureView: theView
+{
+ NSRect o_view_rect;
+ o_view_rect = [theView frame];
+ if( o_currentCaptureView )
+ {
+ [o_currentCaptureView removeFromSuperviewWithoutNeedingDisplay];
+ [o_currentCaptureView release];
+ }
+ [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
+ [theView setNeedsDisplay: YES];
+ [theView setAutoresizesSubviews: YES];
+ [[[o_tabview tabViewItemAtIndex: 3] view] addSubview: theView];
+ [theView displayIfNeeded];
+ o_currentCaptureView = theView;
+ [o_currentCaptureView retain];
+}
+
+- (IBAction)openCaptureModeChanged:(id)sender
+{
+ if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
+ {
+ if( [[[VLCMain sharedInstance] eyeTVController] isEyeTVrunning] == YES )
+ {
+ if( [[[VLCMain sharedInstance] eyeTVController] isDeviceConnected] == YES )
+ {
+ [self showCaptureView: o_eyetv_running_view];
+ [self setupChannelInfo];
+ }
+ else
+ {
+ setEyeTVUnconnected;
+ }
+ }
+ else
+ [self showCaptureView: o_eyetv_notLaunched_view];
+ [o_mrl setStringValue: @""];
+ }
+ else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
+ {
+ [self showCaptureView: o_screen_view];
+ [o_mrl setStringValue: @"screen://"];
+ [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
+ [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
+ [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
+ [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
+ [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
+ [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
+ }
+ else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"iSight"] )
+ {
+ [o_capture_lbl setStringValue: _NS("iSight Capture Input")];
+ [o_capture_long_lbl setStringValue: _NS("This facility allows you to process your iSight's input signal.\n\nNo settings are available in this version, so you will be provided a 640px*480px raw video stream.\n\nLive Audio input is not supported.")];
+ [o_capture_lbl displayIfNeeded];
+ [o_capture_long_lbl displayIfNeeded];
+
+ [self showCaptureView: o_capture_label_view];
+ [o_mrl setStringValue: @"qtcapture://"];
+ }
+}
+
+- (IBAction)screenStepperChanged:(id)sender
+{
+ [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
+ [o_panel makeFirstResponder: o_screen_fps_fld];
+ [o_mrl setStringValue: @"screen://"];
+}
+
+- (void)screenFPSfieldChanged:(NSNotification *)o_notification
+{
+ [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
+ if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
+ [o_screen_fps_fld setFloatValue: 1.0];
+ [o_mrl setStringValue: @"screen://"];
+}
+
+- (IBAction)eyetvSwitchChannel:(id)sender
+{
+ if( sender == o_eyetv_nextProgram_btn )
+ {
+ int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
+ [o_eyetv_channels_pop selectItemWithTag:chanNum];
+ [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+ }
+ else if( sender == o_eyetv_previousProgram_btn )
+ {
+ int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
+ [o_eyetv_channels_pop selectItemWithTag:chanNum];
+ [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+ }
+ else if( sender == o_eyetv_channels_pop )
+ {
+ int chanNum = [[sender selectedItem] tag];
+ [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
+ [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+ }
+ else
+ msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
+}
+
+- (IBAction)eyetvLaunch:(id)sender
+{
+ [[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
+}
+
+- (IBAction)eyetvGetPlugin:(id)sender
+{
+ [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
+}
+
+- (void)eyetvChanged:(NSNotification *)o_notification
+{
+ if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
+ {
+ msg_Dbg( VLCIntf, "eyetv device was added" );
+ [self showCaptureView: o_eyetv_running_view];
+ [self setupChannelInfo];
+ }
+ else if( [[o_notification name] isEqualToString: @"DeviceRemoved"] )
+ {
+ /* leave the channel selection like that,
+ * switch to our "no device" tab */
+ msg_Dbg( VLCIntf, "eyetv device was removed" );
+ setEyeTVUnconnected;
+ }
+ else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
+ {
+ /* switch to the "launch eyetv" tab */
+ msg_Dbg( VLCIntf, "eyetv was terminated" );
+ [self showCaptureView: o_eyetv_notLaunched_view];
+ }
+ else if( [[o_notification name] isEqualToString: @"PluginInit"] )
+ {
+ /* we got no device yet */
+ msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
+ setEyeTVUnconnected;
+ }
+ else
+ msg_Warn( VLCIntf, "unknown external notify '%s' received", [[o_notification name] UTF8String] );
+}
+
+/* little helper method, since this code needs to be run by multiple objects */
+- (void)setupChannelInfo
+{
+ /* set up channel selection */
+ [o_eyetv_channels_pop removeAllItems];
+ [o_eyetv_chn_bgbar setHidden: NO];
+ [o_eyetv_chn_bgbar animate: self];
+ [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
+ [o_eyetv_chn_status_txt setHidden: NO];
+
+ /* retrieve info */
+ NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
+ int x = -2;
+ [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
+ action: nil
+ keyEquivalent: @""] setTag:x++];
+ [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
+ action: nil
+ keyEquivalent: @""] setTag:x++];
+ if( channels )
+ {
+ NSString *channel;
+ [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
+ while( channel = [channels nextObject] )
+ {
+ /* we have to add items this way, because we accept duplicates
+ * additionally, we save a bit of time */
+ [[[o_eyetv_channels_pop menu] addItemWithTitle: channel
+ action: nil
+ keyEquivalent: @""] setTag:++x];
+ }
+ /* make Tuner the default */
+ [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] currentChannel]];