+- (IBAction)eyetvSwitchChannel:(id)sender
+{
+ if( sender == o_eyetv_nextProgram_btn )
+ [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: YES];
+ else if( sender == o_eyetv_previousProgram_btn )
+ [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: NO];
+ else if( sender == o_eyetv_channels_pop )
+ [[[VLCMain sharedInstance] getEyeTVController] selectChannel:
+ [sender indexOfSelectedItem]];
+ else
+ msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
+}
+
+- (IBAction)eyetvLaunch:(id)sender
+{
+ [[[VLCMain sharedInstance] getEyeTVController] launchEyeTV];
+}
+
+- (void)eyetvChanged:(NSNotification *)o_notification
+{
+ if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
+ {
+ msg_Dbg( VLCIntf, "eyetv device was added" );
+ [o_eyetv_tabView selectTabViewItemWithIdentifier:@"eyetvup"];
+ [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" );
+ [o_eyetv_tabView selectTabViewItemWithIdentifier:@"nodevice"];
+ }
+ else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
+ {
+ /* switch to the "launch eyetv" tab */
+ msg_Dbg( VLCIntf, "eyetv was terminated" );
+ [o_eyetv_tabView selectTabViewItemWithIdentifier:@"noeyetv"];
+ }
+ else if( [[o_notification name] isEqualToString: @"PluginInit"] )
+ {
+ /* we got no device yet */
+ msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
+ [o_eyetv_tabView selectTabViewItemWithIdentifier:@"nodevice"];
+ }
+ 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 */
+ int x = 0;
+ int channelCount = ( [[[VLCMain sharedInstance] getEyeTVController] getNumberOfChannels] + 1 );
+ while( x != channelCount )
+ {
+ /* we have to add items this way, because we accept duplicates
+ * additionally, we save a bit of time */
+ [[o_eyetv_channels_pop menu] addItemWithTitle: [[[VLCMain sharedInstance] getEyeTVController] getNameOfChannel: x]
+ action: nil
+ keyEquivalent: @""];
+ x += 1;
+ }
+
+ /* clean up GUI */
+ [o_eyetv_chn_bgbar setHidden: YES];
+ [o_eyetv_chn_status_txt setHidden: YES];
+}
+