]> git.sesse.net Git - vlc/blob - modules/gui/macosx/open.m
macosx: Ignore attachment:// in Art uri for now.
[vlc] / modules / gui / macosx / open.m
1 /*****************************************************************************
2  * open.m: Open dialogues for VLC's MacOS X port
3  *****************************************************************************
4  * Copyright (C) 2002-2009 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8  *          Christophe Massiot <massiot@via.ecp.fr>
9  *          Derk-Jan Hartman <thedj@users.sourceforge.net>
10  *          Benjamin Pracht <bigben at videolan dot org>
11  *          Felix Paul Kühne <fkuehne at videolan dot org>
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  *****************************************************************************/
27
28 /*****************************************************************************
29  * Preamble
30  *****************************************************************************/
31 #include <stdlib.h>                                      /* malloc(), free() */
32 #include <sys/param.h>                                    /* for MAXPATHLEN */
33 #include <string.h>
34
35 #include <paths.h>
36 #include <IOKit/IOKitLib.h>
37 #include <IOKit/IOBSD.h>
38 #include <IOKit/storage/IOMedia.h>
39 #include <IOKit/storage/IOCDMedia.h>
40 #include <IOKit/storage/IODVDMedia.h>
41
42 #import "intf.h"
43 #import "playlist.h"
44 #import "open.h"
45 #import "output.h"
46 #import "eyetv.h"
47
48 #define setEyeTVUnconnected \
49 [o_capture_lbl setStringValue: _NS("No device connected")]; \
50 [o_capture_long_lbl setStringValue: _NS("VLC could not detect any EyeTV compatible device.\n\nCheck the device's connection, make sure that the latest EyeTV software is installed and try again.")]; \
51 [o_capture_lbl displayIfNeeded]; \
52 [o_capture_long_lbl displayIfNeeded]; \
53 [self showCaptureView: o_capture_label_view]
54
55
56 /*****************************************************************************
57  * GetEjectableMediaOfClass
58  *****************************************************************************/
59 NSArray *GetEjectableMediaOfClass( const char *psz_class )
60 {
61     io_object_t next_media;
62     mach_port_t master_port;
63     kern_return_t kern_result;
64     NSArray *o_devices = nil;
65     NSMutableArray *p_list = nil;
66     io_iterator_t media_iterator;
67     CFMutableDictionaryRef classes_to_match;
68
69     kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
70     if( kern_result != KERN_SUCCESS )
71     {
72         return( nil );
73     }
74  
75     classes_to_match = IOServiceMatching( psz_class );
76     if( classes_to_match == NULL )
77     {
78         return( nil );
79     }
80  
81     CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectableKey ),
82                           kCFBooleanTrue );
83  
84     kern_result = IOServiceGetMatchingServices( master_port, classes_to_match,
85                                                 &media_iterator );
86     if( kern_result != KERN_SUCCESS )
87     {
88         return( nil );
89     }
90
91     p_list = [NSMutableArray arrayWithCapacity: 1];
92  
93     next_media = IOIteratorNext( media_iterator );
94     if( next_media )
95     {
96         char psz_buf[0x32];
97         size_t dev_path_length;
98         CFTypeRef str_bsd_path;
99  
100         do
101         {
102             str_bsd_path = IORegistryEntryCreateCFProperty( next_media,
103                                                             CFSTR( kIOBSDNameKey ),
104                                                             kCFAllocatorDefault,
105                                                             0 );
106             if( str_bsd_path == NULL )
107             {
108                 IOObjectRelease( next_media );
109                 continue;
110             }
111  
112             snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
113             dev_path_length = strlen( psz_buf );
114  
115             if( CFStringGetCString( str_bsd_path,
116                                     (char*)&psz_buf + dev_path_length,
117                                     sizeof(psz_buf) - dev_path_length,
118                                     kCFStringEncodingASCII ) )
119             {
120                 [p_list addObject: [NSString stringWithUTF8String: psz_buf]];
121             }
122  
123             CFRelease( str_bsd_path );
124  
125             IOObjectRelease( next_media );
126  
127         } while( ( next_media = IOIteratorNext( media_iterator ) ) );
128     }
129  
130     IOObjectRelease( media_iterator );
131
132     o_devices = [NSArray arrayWithArray: p_list];
133
134     return( o_devices );
135 }
136
137 /*****************************************************************************
138  * VLCOpen implementation
139  *****************************************************************************/
140 @implementation VLCOpen
141
142 static VLCOpen *_o_sharedMainInstance = nil;
143
144 + (VLCOpen *)sharedInstance
145 {
146     return _o_sharedMainInstance ? _o_sharedMainInstance : [[self alloc] init];
147 }
148
149 - (id)init
150 {
151     if( _o_sharedMainInstance) {
152         [self dealloc];
153     } else {
154         _o_sharedMainInstance = [super init];
155         p_intf = VLCIntf;
156     }
157  
158     return _o_sharedMainInstance;
159 }
160
161 - (void)awakeFromNib
162 {
163     [o_panel setTitle: _NS("Open Source")];
164     [o_mrl_lbl setStringValue: _NS("Media Resource Locator (MRL)")];
165
166     [o_btn_ok setTitle: _NS("Open")];
167     [o_btn_cancel setTitle: _NS("Cancel")];
168
169     [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
170     [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
171     [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
172     [[o_tabview tabViewItemAtIndex: 3] setLabel: _NS("Capture")];
173
174     [o_file_btn_browse setTitle: _NS("Browse...")];
175     [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
176
177     [o_disc_device_lbl setStringValue: _NS("Device name")];
178     [o_disc_title_lbl setStringValue: _NS("Title")];
179     [o_disc_chapter_lbl setStringValue: _NS("Chapter")];
180     [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
181     [o_disc_dvd_menus setTitle: _NS("No DVD menus")];
182
183     [[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
184     [[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
185     [[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")];
186     [[o_disc_type cellAtRow:3 column:0] setTitle: _NS("Audio CD")];
187
188     [o_net_udp_port_lbl setStringValue: _NS("Port")];
189     [o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
190     [o_net_udpm_port_lbl setStringValue: _NS("Port")];
191     [o_net_http_url_lbl setStringValue: _NS("URL")];
192     [o_net_help_lbl setStringValue: _NS("To Open a usual network stream (HTTP, RTSP, MMS, FTP, etc.), just enter the URL in the field above. If you want to open a RTP or UDP stream, press the button below.")];
193     [o_net_help_udp_lbl setStringValue: _NS("If you want to open a multicast stream, enter the respective IP address given by the stream provider. In unicast mode, VLC will use your machine's IP automatically.\n\nTo open a stream using a different protocol, just press Cancel to close this sheet.")];
194     [o_net_udp_cancel_btn setTitle: _NS("Cancel")];
195     [o_net_udp_ok_btn setTitle: _NS("Open")];
196     [o_net_openUDP_btn setTitle: _NS("Open RTP/UDP Stream")];
197     [o_net_udp_mode_lbl setStringValue: _NS("Mode")];
198     [o_net_udp_protocol_lbl setStringValue: _NS("Protocol")];
199     [o_net_udp_address_lbl setStringValue: _NS("Address")];
200
201     [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("Unicast")];
202     [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("Multicast")];
203
204     [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
205     [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
206
207     [o_eyetv_chn_bgbar setUsesThreadedAnimation: YES];
208
209     [o_capture_mode_pop removeAllItems];
210     [o_capture_mode_pop addItemWithTitle: @"iSight"];
211     [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
212     [o_capture_mode_pop addItemWithTitle: @"EyeTV"];
213     [o_screen_lbl setStringValue: _NS("Screen Capture Input")];
214     [o_screen_long_lbl setStringValue: _NS("This facility allows you to process your screen's output.")];
215     [o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
216     [o_screen_left_lbl setStringValue: _NS("Subscreen left:")];
217     [o_screen_top_lbl setStringValue: _NS("Subscreen top:")];
218     [o_screen_width_lbl setStringValue: _NS("Subscreen width:")];
219     [o_screen_height_lbl setStringValue: _NS("Subscreen height:")];
220     [o_screen_follow_mouse_ckb setTitle: _NS("Follow the mouse")];
221     [o_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
222     [o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
223     [o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
224     [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
225     [o_eyetv_noInstance_lbl setStringValue: _NS("EyeTV is not launched")];
226     [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
227     [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
228     [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
229
230     [self setSubPanel];
231
232     [[NSNotificationCenter defaultCenter] addObserver: self
233         selector: @selector(openFilePathChanged:)
234         name: NSControlTextDidChangeNotification
235         object: o_file_path];
236
237     [[NSNotificationCenter defaultCenter] addObserver: self
238         selector: @selector(openDiscInfoChanged:)
239         name: NSControlTextDidChangeNotification
240         object: o_disc_device];
241     [[NSNotificationCenter defaultCenter] addObserver: self
242         selector: @selector(openDiscInfoChanged:)
243         name: NSControlTextDidChangeNotification
244         object: o_disc_title];
245     [[NSNotificationCenter defaultCenter] addObserver: self
246         selector: @selector(openDiscInfoChanged:)
247         name: NSControlTextDidChangeNotification
248         object: o_disc_chapter];
249     [[NSNotificationCenter defaultCenter] addObserver: self
250         selector: @selector(openDiscInfoChanged:)
251         name: NSControlTextDidChangeNotification
252         object: o_disc_videots_folder];
253
254     [[NSNotificationCenter defaultCenter] addObserver: self
255         selector: @selector(openNetInfoChanged:)
256         name: NSControlTextDidChangeNotification
257         object: o_net_udp_port];
258     [[NSNotificationCenter defaultCenter] addObserver: self
259         selector: @selector(openNetInfoChanged:)
260         name: NSControlTextDidChangeNotification
261         object: o_net_udpm_addr];
262     [[NSNotificationCenter defaultCenter] addObserver: self
263         selector: @selector(openNetInfoChanged:)
264         name: NSControlTextDidChangeNotification
265         object: o_net_udpm_port];
266     [[NSNotificationCenter defaultCenter] addObserver: self
267         selector: @selector(openNetInfoChanged:)
268         name: NSControlTextDidChangeNotification
269         object: o_net_http_url];
270
271     [[NSDistributedNotificationCenter defaultCenter] addObserver: self
272                                                         selector: @selector(eyetvChanged:)
273                                                             name: NULL
274                                                           object: @"VLCEyeTVSupport"
275                                               suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
276
277     [[NSNotificationCenter defaultCenter] addObserver: self
278                                              selector: @selector(screenFPSfieldChanged:)
279                                                  name: NSControlTextDidChangeNotification
280                                                object: o_screen_fps_fld];
281
282     /* register clicks on text fields */
283     [[NSNotificationCenter defaultCenter] addObserver: self
284                                              selector: @selector(textFieldWasClicked:)
285                                                  name: @"VLCOpenTextFieldWasClicked"
286                                                object: nil];
287 }
288
289 - (void)setSubPanel
290 {
291     int i_index;
292     module_config_t * p_item;
293
294     [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
295     [o_file_sub_btn_settings setTitle: _NS("Settings...")];
296     [o_file_sub_btn_browse setTitle: _NS("Browse...")];
297     [o_file_sub_override setTitle: _NS("Override parametters")];
298     [o_file_sub_delay_lbl setStringValue: _NS("Delay")];
299     [o_file_sub_delay_stp setEnabled: NO];
300     [o_file_sub_fps_lbl setStringValue: _NS("FPS")];
301     [o_file_sub_fps_stp setEnabled: NO];
302     [o_file_sub_encoding_lbl setStringValue: _NS("Subtitles encoding")];
303     [o_file_sub_encoding_pop removeAllItems];
304     [o_file_sub_size_lbl setStringValue: _NS("Font size")];
305     [o_file_sub_size_pop removeAllItems];
306     [o_file_sub_align_lbl setStringValue: _NS("Subtitles alignment")];
307     [o_file_sub_align_pop removeAllItems];
308     [o_file_sub_ok_btn setStringValue: _NS("OK")];
309     [o_file_sub_font_box setTitle: _NS("Font Properties")];
310     [o_file_sub_file_box setTitle: _NS("Subtitle File")];
311
312     p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
313
314     if( p_item )
315     {
316         for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
317              i_index++ )
318         {
319             [o_file_sub_encoding_pop addItemWithTitle:
320                 [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
321         }
322         [o_file_sub_encoding_pop selectItemWithTitle:
323                 [NSString stringWithUTF8String: p_item->value.psz]];
324     }
325
326     p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
327
328     if ( p_item )
329     {
330         for ( i_index = 0; i_index < p_item->i_list; i_index++ )
331         {
332             [o_file_sub_align_pop addItemWithTitle:
333                 [NSString stringWithUTF8String:
334                 p_item->ppsz_list_text[i_index]]];
335         }
336         [o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
337     }
338
339     p_item = config_FindConfig( VLC_OBJECT(p_intf), "freetype-rel-fontsize" );
340
341     if ( p_item )
342     {
343         for ( i_index = 0; i_index < p_item->i_list; i_index++ )
344         {
345             [o_file_sub_size_pop addItemWithTitle:
346                 [NSString stringWithUTF8String:
347                 p_item->ppsz_list_text[i_index]]];
348             if ( p_item->value.i == p_item->pi_list[i_index] )
349             {
350                 [o_file_sub_size_pop selectItemAtIndex: i_index];
351             }
352         }
353     }
354 }
355
356 - (void)openTarget:(int)i_type
357 {
358     int i_result;
359
360     b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
361
362     [o_tabview selectTabViewItemAtIndex: i_type];
363     [o_file_sub_ckbox setState: NSOffState];
364  
365     i_result = [NSApp runModalForWindow: o_panel];
366     [o_panel close];
367
368     if( i_result )
369     {
370         NSMutableDictionary *o_dic;
371         NSMutableArray *o_options = [NSMutableArray array];
372         unsigned int i;
373
374         o_dic = [NSMutableDictionary dictionaryWithObject: [o_mrl stringValue] forKey: @"ITEM_URL"];
375         if( [o_file_sub_ckbox state] == NSOnState )
376         {
377             module_config_t * p_item;
378
379             [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", [o_file_sub_path stringValue]]];
380             if( [o_file_sub_override state] == NSOnState )
381             {
382                 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
383                 [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
384             }
385             [o_options addObject: [NSString stringWithFormat:
386                     @"subsdec-encoding=%@",
387                     [o_file_sub_encoding_pop titleOfSelectedItem]]];
388             [o_options addObject: [NSString stringWithFormat:
389                     @"subsdec-align=%i",
390                     [o_file_sub_align_pop indexOfSelectedItem]]];
391
392             p_item = config_FindConfig( VLC_OBJECT(p_intf),
393                                             "freetype-rel-fontsize" );
394
395             if ( p_item )
396             {
397                 [o_options addObject: [NSString stringWithFormat:
398                     @"freetype-rel-fontsize=%i",
399                     p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
400             }
401         }
402         if( [o_output_ckbox state] == NSOnState )
403         {
404             for (i = 0 ; i < [[o_sout_options mrl] count] ; i++)
405             {
406                 [o_options addObject: [NSString stringWithString:
407                       [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
408             }
409         }
410         if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
411         {
412             if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
413                 [o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
414                 [o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
415                 [o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
416                 [o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
417                 [o_options addObject: [NSString stringWithFormat: @"screen-height=%i", [o_screen_height_fld intValue]]];
418                 if( [o_screen_follow_mouse_ckb intValue] == YES )
419                     [o_options addObject: @"screen-follow-mouse"];
420                 else
421                     [o_options addObject: @"no-screen-follow-mouse"];
422         }
423
424         /* apply the options to our item(s) */
425         [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
426         if( b_autoplay )
427             [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
428         else
429             [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
430     }
431 }
432
433 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
434 {
435     NSString *o_label = [o_tvi label];
436
437     if( [o_label isEqualToString: _NS("File")] )
438     {
439         [self openFilePathChanged: nil];
440     }
441     else if( [o_label isEqualToString: _NS("Disc")] )
442     {
443         [self openDiscTypeChanged: nil];
444     }
445     else if( [o_label isEqualToString: _NS("Network")] )
446     {
447         [self openNetInfoChanged: nil];
448     }
449     else if( [o_label isEqualToString: _NS("Capture")] )
450     {
451         [self openCaptureModeChanged: nil];
452     }
453 }
454
455 - (IBAction)expandMRLfieldAction:(id)sender
456 {
457     NSRect o_win_rect, o_view_rect;
458     o_win_rect = [o_panel frame];
459     o_view_rect = [o_mrl_view frame];
460
461     if( [o_mrl_btn state] == NSOffState )
462     {
463         /* we need to collaps, restore the panel size */
464         o_win_rect.size.height = o_win_rect.size.height - o_view_rect.size.height;
465         o_win_rect.origin.y = ( o_win_rect.origin.y + o_view_rect.size.height ) - o_view_rect.size.height;
466
467         /* remove the MRL view */
468         [o_mrl_view removeFromSuperviewWithoutNeedingDisplay];
469     } else {
470         /* we need to expand */
471         [o_mrl_view setFrame: NSMakeRect( 0,
472                                          [o_mrl_btn frame].origin.y,
473                                          o_view_rect.size.width,
474                                          o_view_rect.size.height )];
475         [o_mrl_view setNeedsDisplay: YES];
476         [o_mrl_view setAutoresizesSubviews: YES];
477
478         /* add the MRL view */
479         [[o_panel contentView] addSubview: o_mrl_view];
480         o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
481     }
482
483     [o_panel setFrame: o_win_rect display:YES animate: YES];
484     [o_panel displayIfNeeded];
485 }
486
487 - (void)openFileGeneric
488 {
489     [self openFilePathChanged: nil];
490     [self openTarget: 0];
491 }
492
493 - (void)openDisc
494 {
495     [self openDiscTypeChanged: nil];
496     [self openTarget: 1];
497 }
498
499 - (void)openNet
500 {
501     [self openNetInfoChanged: nil];
502     [self openTarget: 2];
503 }
504
505 - (void)openCapture
506 {
507     [self openCaptureModeChanged: nil];
508     [self showCaptureView: o_capture_label_view];
509     [self openTarget: 3];
510 }
511
512 - (void)openFilePathChanged:(NSNotification *)o_notification
513 {
514     NSString *o_mrl_string;
515     NSString *o_filename = [o_file_path stringValue];
516     NSString *o_ext = [o_filename pathExtension];
517     bool b_stream = [o_file_stream state];
518     BOOL b_dir = NO;
519  
520     [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
521
522     if( b_dir )
523     {
524         o_mrl_string = [NSString stringWithFormat: @"directory://%@/", o_filename];
525     }
526     else if( [o_ext isEqualToString: @"bin"] ||
527         [o_ext isEqualToString: @"cue"] ||
528         [o_ext isEqualToString: @"vob"] ||
529         [o_ext isEqualToString: @"iso"] )
530     {
531         o_mrl_string = o_filename;
532     }
533     else
534     {
535         o_mrl_string = [NSString stringWithFormat: @"%s://%@",
536                         b_stream ? "stream" : "file",
537                         o_filename];
538     }
539     [o_mrl setStringValue: o_mrl_string];
540 }
541
542 - (IBAction)openFileBrowse:(id)sender
543 {
544     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
545  
546     [o_open_panel setAllowsMultipleSelection: NO];
547     [o_open_panel setCanChooseDirectories: YES];
548     [o_open_panel setTitle: _NS("Open File")];
549     [o_open_panel setPrompt: _NS("Open")];
550
551     [o_open_panel beginSheetForDirectory:nil
552         file:nil
553         types:nil
554         modalForWindow:[sender window]
555         modalDelegate: self
556         didEndSelector: @selector(pathChosenInPanel:
557                         withReturn:
558                         contextInfo:)
559         contextInfo: nil];
560 }
561
562 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void  *)contextInfo
563 {
564     if (returnCode == NSFileHandlingPanelOKButton)
565     {
566         NSString *o_filename = [[sheet filenames] objectAtIndex: 0];
567         [o_file_path setStringValue: o_filename];
568         [self openFilePathChanged: nil];
569     }
570 }
571
572 - (IBAction)openFileStreamChanged:(id)sender
573 {
574     [self openFilePathChanged: nil];
575 }
576
577 - (IBAction)openDiscTypeChanged:(id)sender
578 {
579     NSString *o_type;
580     BOOL b_device, b_no_menus, b_title_chapter;
581  
582     [o_disc_device removeAllItems];
583     b_title_chapter = ![o_disc_dvd_menus state];
584  
585     o_type = [[o_disc_type selectedCell] title];
586
587     if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
588     {
589         b_device = NO; b_no_menus = YES;
590     }
591     else
592     {
593         NSArray *o_devices;
594         NSString *o_disc;
595         const char *psz_class = NULL;
596         b_device = YES;
597
598         if ( [o_type isEqualToString: _NS("VCD")] )
599         {
600             psz_class = kIOCDMediaClass;
601             o_disc = o_type;
602             b_no_menus = NO; b_title_chapter = YES;
603                 }
604         else if ( [o_type isEqualToString: _NS("Audio CD")])
605         {
606             psz_class = kIOCDMediaClass;
607             o_disc = o_type;
608             b_no_menus = NO; b_title_chapter = NO;
609         }
610         else
611         {
612             psz_class = kIODVDMediaClass;
613             o_disc = o_type;
614             b_no_menus = YES;
615         }
616  
617         o_devices = GetEjectableMediaOfClass( psz_class );
618         if ( o_devices != nil )
619         {
620             int i_devices = [o_devices count];
621  
622             if ( i_devices )
623             {
624                                 for( int i = 0; i < i_devices; i++ )
625                 {
626                     [o_disc_device
627                         addItemWithObjectValue: [o_devices objectAtIndex: i]];
628                 }
629
630                 [o_disc_device selectItemAtIndex: 0];
631             }
632             else
633             {
634                 [o_disc_device setStringValue:
635                     [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
636             }
637         }
638     }
639
640     [o_disc_device setEnabled: b_device];
641     [o_disc_title setEnabled: b_title_chapter];
642     [o_disc_title_stp setEnabled: b_title_chapter];
643     [o_disc_chapter setEnabled: b_title_chapter];
644     [o_disc_chapter_stp setEnabled: b_title_chapter];
645     [o_disc_videots_folder setEnabled: !b_device];
646     [o_disc_videots_btn_browse setEnabled: !b_device];
647     [o_disc_dvd_menus setEnabled: b_no_menus];
648
649     [self openDiscInfoChanged: nil];
650 }
651
652 - (IBAction)openDiscStepperChanged:(id)sender
653 {
654     int i_tag = [sender tag];
655
656     if( i_tag == 0 )
657     {
658         [o_disc_title setIntValue: [o_disc_title_stp intValue]];
659     }
660     else if( i_tag == 1 )
661     {
662         [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
663     }
664
665     [self openDiscInfoChanged: nil];
666 }
667
668 - (void)openDiscInfoChanged:(NSNotification *)o_notification
669 {
670     NSString *o_type;
671     NSString *o_device;
672     NSString *o_videots;
673     NSString *o_mrl_string;
674     int i_title, i_chapter;
675     BOOL b_no_menus;
676
677     o_type = [[o_disc_type selectedCell] title];
678     o_device = [o_disc_device stringValue];
679     i_title = [o_disc_title intValue];
680     i_chapter = [o_disc_chapter intValue];
681     o_videots = [o_disc_videots_folder stringValue];
682     b_no_menus = [o_disc_dvd_menus state];
683
684     if ( [o_type isEqualToString: _NS("VCD")] )
685     {
686         if ( [o_device isEqualToString:
687                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
688             o_device = @"";
689         o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i:%i",
690                         o_device, i_title, i_chapter];
691     }
692     else if ( [o_type isEqualToString: _NS("Audio CD")] )
693     {
694         if ( [o_device isEqualToString:
695                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
696             o_device = @"";
697         o_mrl_string = [NSString stringWithFormat: @"cdda://%@",
698                         o_device];
699     }
700     else if ( [o_type isEqualToString: _NS("DVD")] )
701     {
702         if ( [o_device isEqualToString:
703                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
704             o_device = @"";
705         if ( b_no_menus )
706             o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i-",
707                             o_device, i_title, i_chapter];
708         else
709                         o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
710                             o_device];
711             
712     }
713     else /* VIDEO_TS folder */
714     {
715         if ( b_no_menus )
716             o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i",
717                             o_videots, i_title, i_chapter];
718         else
719                         o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
720                             o_videots];            
721     }
722
723     [o_mrl setStringValue: o_mrl_string];
724 }
725
726 - (IBAction)openDiscMenusChanged:(id)sender
727 {
728     [self openDiscInfoChanged: nil];
729     [self openDiscTypeChanged: nil];
730 }
731
732 - (IBAction)openVTSBrowse:(id)sender
733 {
734     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
735
736     [o_open_panel setAllowsMultipleSelection: NO];
737     [o_open_panel setCanChooseFiles: NO];
738     [o_open_panel setCanChooseDirectories: YES];
739     [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
740     [o_open_panel setPrompt: _NS("Open")];
741
742     if( [o_open_panel runModalForDirectory: nil
743             file: nil types: nil] == NSOKButton )
744     {
745         NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
746         [o_disc_videots_folder setStringValue: o_dirname];
747         [self openDiscInfoChanged: nil];
748     }
749 }
750
751 - (void)textFieldWasClicked:(NSNotification *)o_notification
752 {
753     if( [o_notification object] == o_net_udp_port )
754         [o_net_mode selectCellAtRow: 0 column: 0];
755     else if( [o_notification object] == o_net_udpm_addr ||
756              [o_notification object] == o_net_udpm_port )
757         [o_net_mode selectCellAtRow: 1 column: 0];
758     else
759         [o_net_mode selectCellAtRow: 2 column: 0];
760
761     [self openNetInfoChanged: nil];
762 }
763
764 - (IBAction)openNetModeChanged:(id)sender
765 {
766     if( sender == o_net_mode )
767     {
768         if( [[sender selectedCell] tag] == 0 )
769             [o_panel makeFirstResponder: o_net_udp_port];
770         else if ( [[sender selectedCell] tag] == 1 )
771             [o_panel makeFirstResponder: o_net_udpm_addr];
772         else
773             msg_Warn( p_intf, "Unknown sender tried to change UDP/RTP mode" );
774     }
775
776     [self openNetInfoChanged: nil];
777 }
778
779 - (IBAction)openNetStepperChanged:(id)sender
780 {
781     int i_tag = [sender tag];
782
783     if( i_tag == 0 )
784     {
785         [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
786         [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
787                                                             object: o_net_udp_port];
788         [o_panel makeFirstResponder: o_net_udp_port];
789     }
790     else if( i_tag == 1 )
791     {
792         [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
793         [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
794                                                             object: o_net_udpm_port];
795         [o_panel makeFirstResponder: o_net_udpm_port];
796     }
797
798     [self openNetInfoChanged: nil];
799 }
800
801 - (void)openNetInfoChanged:(NSNotification *)o_notification
802 {
803     NSString *o_mrl_string = [NSString string];
804
805     if( [o_net_udp_panel isVisible] )
806     {
807         NSString *o_mode;
808         o_mode = [[o_net_mode selectedCell] title];
809
810         if( [o_mode isEqualToString: _NS("Unicast")] )
811         {
812             int i_port = [o_net_udp_port intValue];
813
814             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
815                 o_mrl_string = [NSString stringWithString: @"udp://"];
816             else
817                 o_mrl_string = [NSString stringWithString: @"rtp://"];
818
819             if( i_port != config_GetInt( p_intf, "server-port" ) )
820             {
821                 o_mrl_string =
822                     [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
823             }
824         }
825         else if( [o_mode isEqualToString: _NS("Multicast")] )
826         {
827             NSString *o_addr = [o_net_udpm_addr stringValue];
828             int i_port = [o_net_udpm_port intValue];
829
830             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
831                 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
832             else
833                 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
834
835             if( i_port != config_GetInt( p_intf, "server-port" ) )
836             {
837                 o_mrl_string =
838                     [o_mrl_string stringByAppendingFormat: @":%i", i_port];
839             }
840         }
841     }
842     else
843     {
844         NSString *o_url = [o_net_http_url stringValue];
845
846         if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
847               && ![o_url hasPrefix:@"mms"] && ![o_url hasPrefix:@"rtsp"] )
848             o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
849         else
850             o_mrl_string = o_url;
851     }
852     [o_mrl setStringValue: o_mrl_string];
853 }
854
855 - (IBAction)openNetUDPButtonAction:(id)sender
856 {
857     if( sender == o_net_openUDP_btn )
858     {
859         [NSApp beginSheet: o_net_udp_panel
860            modalForWindow: o_panel
861             modalDelegate: self
862            didEndSelector: NULL
863               contextInfo: nil];
864         [self openNetInfoChanged: nil];
865     }
866     else if( sender == o_net_udp_cancel_btn )
867     {
868         [o_net_udp_panel orderOut: sender];
869         [NSApp endSheet: o_net_udp_panel];
870     }
871     else if( sender == o_net_udp_ok_btn )
872     {
873         NSString *o_mrl_string = [NSString string];
874         if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
875         {
876             int i_port = [o_net_udp_port intValue];
877             
878             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
879                 o_mrl_string = [NSString stringWithString: @"udp://"];
880             else
881                 o_mrl_string = [NSString stringWithString: @"rtp://"];
882
883             if( i_port != config_GetInt( p_intf, "server-port" ) )
884             {
885                 o_mrl_string =
886                 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
887             }
888         }
889         else if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Multicast")] )
890         {
891             NSString *o_addr = [o_net_udpm_addr stringValue];
892             int i_port = [o_net_udpm_port intValue];
893             
894             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
895                 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
896             else
897                 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
898
899             if( i_port != config_GetInt( p_intf, "server-port" ) )
900             {
901                 o_mrl_string =
902                 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
903             }
904         }
905         [o_mrl setStringValue: o_mrl_string];
906         [o_net_http_url setStringValue: o_mrl_string];
907         [o_net_udp_panel orderOut: sender];
908         [NSApp endSheet: o_net_udp_panel];
909     }
910 }
911     
912 - (void)openFile
913 {
914     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
915     int i;
916     b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
917  
918     [o_open_panel setAllowsMultipleSelection: YES];
919     [o_open_panel setCanChooseDirectories: YES];
920     [o_open_panel setTitle: _NS("Open File")];
921     [o_open_panel setPrompt: _NS("Open")];
922  
923     if( [o_open_panel runModalForDirectory: nil
924             file: nil types: nil] == NSOKButton )
925     {
926         NSArray *o_array = [NSArray array];
927         NSArray *o_values = [[o_open_panel filenames]
928                 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
929
930         for( i = 0; i < (int)[o_values count]; i++)
931         {
932             NSDictionary *o_dic;
933             o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
934             o_array = [o_array arrayByAddingObject: o_dic];
935         }
936         if( b_autoplay )
937             [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
938         else
939             [o_playlist appendArray: o_array atPos: -1 enqueue:YES];
940     }
941 }
942
943 - (void)showCaptureView: theView
944 {
945     NSRect o_view_rect;
946     o_view_rect = [theView frame];
947     if( o_currentCaptureView )
948     {
949         [o_currentCaptureView removeFromSuperviewWithoutNeedingDisplay];
950         [o_currentCaptureView release];
951     }
952     [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
953     [theView setNeedsDisplay: YES];
954     [theView setAutoresizesSubviews: YES];
955     [[[o_tabview tabViewItemAtIndex: 3] view] addSubview: theView];
956     [theView displayIfNeeded];
957     o_currentCaptureView = theView;
958     [o_currentCaptureView retain];
959 }
960
961 - (IBAction)openCaptureModeChanged:(id)sender
962 {
963     if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
964     {
965         if( [[[VLCMain sharedInstance] eyeTVController] isEyeTVrunning] == YES )
966         {
967             if( [[[VLCMain sharedInstance] eyeTVController] isDeviceConnected] == YES )
968             {
969                 [self showCaptureView: o_eyetv_running_view];
970                 [self setupChannelInfo];
971             }
972             else
973             {
974                 setEyeTVUnconnected;
975             }
976         }
977         else
978             [self showCaptureView: o_eyetv_notLaunched_view];
979         [o_mrl setStringValue: @""];
980     } 
981     else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
982     {
983         [self showCaptureView: o_screen_view];
984         [o_mrl setStringValue: @"screen://"];
985         [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
986         [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
987         [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
988         [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
989         [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
990         [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
991     }
992     else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"iSight"] )
993     {
994         [o_capture_lbl setStringValue: _NS("iSight Capture Input")];
995         [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.")];
996         [o_capture_lbl displayIfNeeded];
997         [o_capture_long_lbl displayIfNeeded];
998         
999         [self showCaptureView: o_capture_label_view];
1000         [o_mrl setStringValue: @"qtcapture://"];
1001     }
1002 }
1003
1004 - (IBAction)screenStepperChanged:(id)sender
1005 {
1006     [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
1007     [o_panel makeFirstResponder: o_screen_fps_fld];
1008     [o_mrl setStringValue: @"screen://"];
1009 }
1010
1011 - (void)screenFPSfieldChanged:(NSNotification *)o_notification
1012 {
1013     [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
1014     if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
1015         [o_screen_fps_fld setFloatValue: 1.0];
1016     [o_mrl setStringValue: @"screen://"];
1017 }
1018
1019 - (IBAction)eyetvSwitchChannel:(id)sender
1020 {
1021     if( sender == o_eyetv_nextProgram_btn )
1022     {
1023         int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
1024         [o_eyetv_channels_pop selectItemWithTag:chanNum];
1025         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1026     }
1027     else if( sender == o_eyetv_previousProgram_btn )
1028     {
1029         int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
1030         [o_eyetv_channels_pop selectItemWithTag:chanNum];
1031         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1032     }
1033     else if( sender == o_eyetv_channels_pop )
1034     {
1035         int chanNum = [[sender selectedItem] tag];
1036         [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
1037         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1038     }
1039     else
1040         msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
1041 }
1042
1043 - (IBAction)eyetvLaunch:(id)sender
1044 {
1045     [[[VLCMain sharedInstance] eyeTVController] launchEyeTV];
1046 }
1047
1048 - (IBAction)eyetvGetPlugin:(id)sender
1049 {
1050     [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
1051 }
1052
1053 - (void)eyetvChanged:(NSNotification *)o_notification
1054 {
1055     if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
1056     {
1057         msg_Dbg( VLCIntf, "eyetv device was added" );
1058         [self showCaptureView: o_eyetv_running_view];
1059         [self setupChannelInfo];
1060     }
1061     else if( [[o_notification name] isEqualToString: @"DeviceRemoved"] )
1062     {
1063         /* leave the channel selection like that,
1064          * switch to our "no device" tab */
1065         msg_Dbg( VLCIntf, "eyetv device was removed" );
1066         setEyeTVUnconnected;
1067     }
1068     else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
1069     {
1070         /* switch to the "launch eyetv" tab */
1071         msg_Dbg( VLCIntf, "eyetv was terminated" );
1072         [self showCaptureView: o_eyetv_notLaunched_view];
1073     }
1074     else if( [[o_notification name] isEqualToString: @"PluginInit"] )
1075     {
1076         /* we got no device yet */
1077         msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
1078         setEyeTVUnconnected;
1079     }
1080     else
1081         msg_Warn( VLCIntf, "unknown external notify '%s' received", [[o_notification name] UTF8String] );
1082 }    
1083
1084 /* little helper method, since this code needs to be run by multiple objects */
1085 - (void)setupChannelInfo
1086 {
1087     /* set up channel selection */
1088     [o_eyetv_channels_pop removeAllItems];
1089     [o_eyetv_chn_bgbar setHidden: NO];
1090     [o_eyetv_chn_bgbar animate: self];
1091     [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
1092     [o_eyetv_chn_status_txt setHidden: NO];
1093  
1094     /* retrieve info */
1095     NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
1096     int x = -2;
1097     [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
1098                                                action: nil
1099                                         keyEquivalent: @""] setTag:x++];
1100     [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
1101                                                action: nil
1102                                         keyEquivalent: @""] setTag:x++];
1103     if( channels ) 
1104     {
1105         NSString *channel;
1106         [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
1107         while( channel = [channels nextObject] )
1108         {
1109             /* we have to add items this way, because we accept duplicates
1110              * additionally, we save a bit of time */
1111             [[[o_eyetv_channels_pop menu] addItemWithTitle: channel
1112                                                    action: nil
1113                                             keyEquivalent: @""] setTag:++x];
1114         }
1115         /* make Tuner the default */
1116         [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] currentChannel]];
1117     }
1118  
1119     /* clean up GUI */
1120     [o_eyetv_chn_bgbar setHidden: YES];
1121     [o_eyetv_chn_status_txt setHidden: YES];
1122 }
1123
1124 - (IBAction)subsChanged:(id)sender
1125 {
1126     if ([o_file_sub_ckbox state] == NSOnState)
1127     {
1128         [o_file_sub_btn_settings setEnabled:YES];
1129     }
1130     else
1131     {
1132         [o_file_sub_btn_settings setEnabled:NO];
1133     }
1134 }
1135
1136 - (IBAction)subSettings:(id)sender
1137 {
1138     [NSApp beginSheet: o_file_sub_sheet
1139         modalForWindow: [sender window]
1140         modalDelegate: self
1141         didEndSelector: NULL
1142         contextInfo: nil];
1143 }
1144
1145 - (IBAction)subCloseSheet:(id)sender
1146 {
1147     [o_file_sub_sheet orderOut:sender];
1148     [NSApp endSheet: o_file_sub_sheet];
1149 }
1150     
1151 - (IBAction)subFileBrowse:(id)sender
1152 {
1153     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1154  
1155     [o_open_panel setAllowsMultipleSelection: NO];
1156     [o_open_panel setTitle: _NS("Open File")];
1157     [o_open_panel setPrompt: _NS("Open")];
1158
1159     if( [o_open_panel runModalForDirectory: nil
1160             file: nil types: nil] == NSOKButton )
1161     {
1162         NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
1163         [o_file_sub_path setStringValue: o_filename];
1164     }
1165 }
1166
1167 - (IBAction)subOverride:(id)sender
1168 {
1169     BOOL b_state = [o_file_sub_override state];
1170     [o_file_sub_delay setEnabled: b_state];
1171     [o_file_sub_delay_stp setEnabled: b_state];
1172     [o_file_sub_fps setEnabled: b_state];
1173     [o_file_sub_fps_stp setEnabled: b_state];
1174 }
1175
1176 - (IBAction)subDelayStepperChanged:(id)sender
1177 {
1178     [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
1179 }
1180
1181 - (IBAction)subFpsStepperChanged:(id)sender;
1182 {
1183     [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
1184 }
1185
1186 - (IBAction)panelCancel:(id)sender
1187 {
1188     [NSApp stopModalWithCode: 0];
1189 }
1190
1191 - (IBAction)panelOk:(id)sender
1192 {
1193     if( [[o_mrl stringValue] length] )
1194     {
1195         [NSApp stopModalWithCode: 1];
1196     }
1197     else
1198     {
1199         NSBeep();
1200     }
1201 }
1202
1203 @end
1204
1205 @implementation VLCOpenTextField
1206
1207 - (void)mouseDown:(NSEvent *)theEvent
1208 {
1209     [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
1210                                                         object: self];
1211     [super mouseDown: theEvent];
1212 }
1213
1214 @end