📄 open.m
字号:
int i_tag = [sender tag]; if( i_tag == 0 ) { [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]]; [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked" object: o_net_udp_port]; [o_panel makeFirstResponder: o_net_udp_port]; } else if( i_tag == 1 ) { [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]]; [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked" object: o_net_udpm_port]; [o_panel makeFirstResponder: o_net_udpm_port]; } [self openNetInfoChanged: nil];}- (void)openNetInfoChanged:(NSNotification *)o_notification{ NSString *o_mode; NSString *o_mrl_string = [NSString string]; intf_thread_t * p_intf = VLCIntf; o_mode = [[o_net_mode selectedCell] title]; if( [o_mode isEqualToString: _NS("UDP/RTP")] ) { int i_port = [o_net_udp_port intValue]; o_mrl_string = [NSString stringWithString: @"udp://"]; if( i_port != config_GetInt( p_intf, "server-port" ) ) { o_mrl_string = [o_mrl_string stringByAppendingFormat: @"@:%i", i_port]; } } else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) { NSString *o_addr = [o_net_udpm_addr stringValue]; int i_port = [o_net_udpm_port intValue]; o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr]; if( i_port != config_GetInt( p_intf, "server-port" ) ) { o_mrl_string = [o_mrl_string stringByAppendingFormat: @":%i", i_port]; } } else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS/RTSP")] ) { NSString *o_url = [o_net_http_url stringValue]; if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"] && ![o_url hasPrefix:@"mms"] && ![o_url hasPrefix:@"rtsp"] ) o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url]; else o_mrl_string = o_url; } [o_mrl setStringValue: o_mrl_string];}- (void)openFile{ NSOpenPanel *o_open_panel = [NSOpenPanel openPanel]; int i; b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" ); [o_open_panel setAllowsMultipleSelection: YES]; [o_open_panel setCanChooseDirectories: YES]; [o_open_panel setTitle: _NS("Open File")]; [o_open_panel setPrompt: _NS("Open")]; if( [o_open_panel runModalForDirectory: nil file: nil types: nil] == NSOKButton ) { NSArray *o_array = [NSArray array]; NSArray *o_values = [[o_open_panel filenames] sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)]; for( i = 0; i < (int)[o_values count]; i++) { NSDictionary *o_dic; o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"]; o_array = [o_array arrayByAddingObject: o_dic]; } 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] getEyeTVController] isEyeTVrunning] == YES ) { if( [[[VLCMain sharedInstance] getEyeTVController] 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: [NSString stringWithFormat:@"screen:// :screen-fps=%@", [o_screen_fps_fld stringValue]]]; } 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 setIntValue: [o_screen_fps_stp intValue]]; [o_panel makeFirstResponder: o_screen_fps_fld]; [o_mrl setStringValue: [NSString stringWithFormat:@"screen:// :screen-fps=%@", [o_screen_fps_fld stringValue]]];}- (void)screenFPSfieldChanged:(NSNotification *)o_notification{ [o_screen_fps_stp setIntValue: [o_screen_fps_fld intValue]]; if( [[o_screen_fps_fld stringValue] isEqualToString: @""] ) [o_screen_fps_fld setIntValue: 1]; [o_mrl setStringValue: [NSString stringWithFormat:@"screen:// :screen-fps=%i", [o_screen_fps_fld intValue]]];}- (IBAction)eyetvSwitchChannel:(id)sender{ if( sender == o_eyetv_nextProgram_btn ) { int chanNum = [[[VLCMain sharedInstance] getEyeTVController] 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] getEyeTVController] 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] getEyeTVController] 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] getEyeTVController] 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] getEyeTVController] 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] getEyeTVController] currentChannel]]; } /* clean up GUI */ [o_eyetv_chn_bgbar setHidden: YES]; [o_eyetv_chn_status_txt setHidden: YES];}- (IBAction)subsChanged:(id)sender{ if ([o_file_sub_ckbox state] == NSOnState) { [o_file_sub_btn_settings setEnabled:YES]; } else { [o_file_sub_btn_settings setEnabled:NO]; }}- (IBAction)subSettings:(id)sender{ [NSApp beginSheet: o_file_sub_sheet modalForWindow: [sender window] modalDelegate: self didEndSelector: NULL contextInfo: nil];}- (IBAction)subFileBrowse:(id)sender{ NSOpenPanel *o_open_panel = [NSOpenPanel openPanel]; [o_open_panel setAllowsMultipleSelection: NO]; [o_open_panel setTitle: _NS("Open File")]; [o_open_panel setPrompt: _NS("Open")]; if( [o_open_panel runModalForDirectory: nil file: nil types: nil] == NSOKButton ) { NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0]; [o_file_sub_path setStringValue: o_filename]; }}- (IBAction)subOverride:(id)sender{ BOOL b_state = [o_file_sub_override state]; [o_file_sub_delay setEnabled: b_state]; [o_file_sub_delay_stp setEnabled: b_state]; [o_file_sub_fps setEnabled: b_state]; [o_file_sub_fps_stp setEnabled: b_state];}- (IBAction)subDelayStepperChanged:(id)sender{ [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];}- (IBAction)subFpsStepperChanged:(id)sender;{ [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];}- (IBAction)subCloseSheet:(id)sender{ [o_file_sub_sheet orderOut:sender]; [NSApp endSheet: o_file_sub_sheet];}- (IBAction)panelCancel:(id)sender{ [NSApp stopModalWithCode: 0];}- (IBAction)panelOk:(id)sender{ if( [[o_mrl stringValue] length] ) { [NSApp stopModalWithCode: 1]; } else { NSBeep(); }}@end@implementation VLCOpenTextField- (void)mouseDown:(NSEvent *)theEvent{ [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked" object: self]; [super mouseDown: theEvent];}@end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -