]> git.sesse.net Git - vlc/blob - modules/gui/macosx/open.m
d125a22497d32041599dd3ffcd69dc3736a66f28
[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 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_eyetv_currentChannel_lbl setStringValue: _NS("Current channel:")];
221     [o_eyetv_previousProgram_btn setTitle: _NS("Previous Channel")];
222     [o_eyetv_nextProgram_btn setTitle: _NS("Next Channel")];
223     [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
224     [o_eyetv_noInstance_lbl setStringValue: _NS("EyeTV is not launched")];
225     [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
226     [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
227     [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
228
229     [self setSubPanel];
230
231     [[NSNotificationCenter defaultCenter] addObserver: self
232         selector: @selector(openFilePathChanged:)
233         name: NSControlTextDidChangeNotification
234         object: o_file_path];
235
236     [[NSNotificationCenter defaultCenter] addObserver: self
237         selector: @selector(openDiscInfoChanged:)
238         name: NSControlTextDidChangeNotification
239         object: o_disc_device];
240     [[NSNotificationCenter defaultCenter] addObserver: self
241         selector: @selector(openDiscInfoChanged:)
242         name: NSControlTextDidChangeNotification
243         object: o_disc_title];
244     [[NSNotificationCenter defaultCenter] addObserver: self
245         selector: @selector(openDiscInfoChanged:)
246         name: NSControlTextDidChangeNotification
247         object: o_disc_chapter];
248     [[NSNotificationCenter defaultCenter] addObserver: self
249         selector: @selector(openDiscInfoChanged:)
250         name: NSControlTextDidChangeNotification
251         object: o_disc_videots_folder];
252
253     [[NSNotificationCenter defaultCenter] addObserver: self
254         selector: @selector(openNetInfoChanged:)
255         name: NSControlTextDidChangeNotification
256         object: o_net_udp_port];
257     [[NSNotificationCenter defaultCenter] addObserver: self
258         selector: @selector(openNetInfoChanged:)
259         name: NSControlTextDidChangeNotification
260         object: o_net_udpm_addr];
261     [[NSNotificationCenter defaultCenter] addObserver: self
262         selector: @selector(openNetInfoChanged:)
263         name: NSControlTextDidChangeNotification
264         object: o_net_udpm_port];
265     [[NSNotificationCenter defaultCenter] addObserver: self
266         selector: @selector(openNetInfoChanged:)
267         name: NSControlTextDidChangeNotification
268         object: o_net_http_url];
269
270     [[NSDistributedNotificationCenter defaultCenter] addObserver: self
271                                                         selector: @selector(eyetvChanged:)
272                                                             name: NULL
273                                                           object: @"VLCEyeTVSupport"
274                                               suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
275
276     [[NSNotificationCenter defaultCenter] addObserver: self
277                                              selector: @selector(screenFPSfieldChanged:)
278                                                  name: NSControlTextDidChangeNotification
279                                                object: o_screen_fps_fld];
280
281     /* register clicks on text fields */
282     [[NSNotificationCenter defaultCenter] addObserver: self
283                                              selector: @selector(textFieldWasClicked:)
284                                                  name: @"VLCOpenTextFieldWasClicked"
285                                                object: nil];
286 }
287
288 - (void)setSubPanel
289 {
290     int i_index;
291     module_config_t * p_item;
292
293     [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
294     [o_file_sub_btn_settings setTitle: _NS("Settings...")];
295     [o_file_sub_btn_browse setTitle: _NS("Browse...")];
296     [o_file_sub_override setTitle: _NS("Override parametters")];
297     [o_file_sub_delay_lbl setStringValue: _NS("Delay")];
298     [o_file_sub_delay_stp setEnabled: NO];
299     [o_file_sub_fps_lbl setStringValue: _NS("FPS")];
300     [o_file_sub_fps_stp setEnabled: NO];
301     [o_file_sub_encoding_lbl setStringValue: _NS("Subtitles encoding")];
302     [o_file_sub_encoding_pop removeAllItems];
303     [o_file_sub_size_lbl setStringValue: _NS("Font size")];
304     [o_file_sub_size_pop removeAllItems];
305     [o_file_sub_align_lbl setStringValue: _NS("Subtitles alignment")];
306     [o_file_sub_align_pop removeAllItems];
307     [o_file_sub_ok_btn setStringValue: _NS("OK")];
308     [o_file_sub_font_box setTitle: _NS("Font Properties")];
309     [o_file_sub_file_box setTitle: _NS("Subtitle File")];
310
311     p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-encoding" );
312
313     if( p_item )
314     {
315         for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
316              i_index++ )
317         {
318             [o_file_sub_encoding_pop addItemWithTitle:
319                 [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
320         }
321         [o_file_sub_encoding_pop selectItemWithTitle:
322                 [NSString stringWithUTF8String: p_item->value.psz]];
323     }
324
325     p_item = config_FindConfig( VLC_OBJECT(p_intf), "subsdec-align" );
326
327     if ( p_item )
328     {
329         for ( i_index = 0; i_index < p_item->i_list; i_index++ )
330         {
331             [o_file_sub_align_pop addItemWithTitle:
332                 [NSString stringWithUTF8String:
333                 p_item->ppsz_list_text[i_index]]];
334         }
335         [o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
336     }
337
338     p_item = config_FindConfig( VLC_OBJECT(p_intf), "freetype-rel-fontsize" );
339
340     if ( p_item )
341     {
342         for ( i_index = 0; i_index < p_item->i_list; i_index++ )
343         {
344             [o_file_sub_size_pop addItemWithTitle:
345                 [NSString stringWithUTF8String:
346                 p_item->ppsz_list_text[i_index]]];
347             if ( p_item->value.i == p_item->pi_list[i_index] )
348             {
349                 [o_file_sub_size_pop selectItemAtIndex: i_index];
350             }
351         }
352     }
353 }
354
355 - (void)openTarget:(int)i_type
356 {
357     int i_result;
358
359     b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
360
361     [o_tabview selectTabViewItemAtIndex: i_type];
362     [o_file_sub_ckbox setState: NSOffState];
363  
364     i_result = [NSApp runModalForWindow: o_panel];
365     [o_panel close];
366
367     if( i_result )
368     {
369         NSMutableDictionary *o_dic;
370         NSMutableArray *o_options = [NSMutableArray array];
371         unsigned int i;
372
373         o_dic = [NSMutableDictionary dictionaryWithObject: [o_mrl stringValue] forKey: @"ITEM_URL"];
374         if( [o_file_sub_ckbox state] == NSOnState )
375         {
376             module_config_t * p_item;
377
378             [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", [o_file_sub_path stringValue]]];
379             if( [o_file_sub_override state] == NSOnState )
380             {
381                 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
382                 [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
383             }
384             [o_options addObject: [NSString stringWithFormat:
385                     @"subsdec-encoding=%@",
386                     [o_file_sub_encoding_pop titleOfSelectedItem]]];
387             [o_options addObject: [NSString stringWithFormat:
388                     @"subsdec-align=%i",
389                     [o_file_sub_align_pop indexOfSelectedItem]]];
390
391             p_item = config_FindConfig( VLC_OBJECT(p_intf),
392                                             "freetype-rel-fontsize" );
393
394             if ( p_item )
395             {
396                 [o_options addObject: [NSString stringWithFormat:
397                     @"freetype-rel-fontsize=%i",
398                     p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
399             }
400         }
401         if( [o_output_ckbox state] == NSOnState )
402         {
403             for (i = 0 ; i < [[o_sout_options getMRL] count] ; i++)
404             {
405                 [o_options addObject: [NSString stringWithString:
406                       [[(VLCOutput *)o_sout_options getMRL] objectAtIndex: i]]];
407             }
408         }
409         if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
410         {
411             if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
412                 [o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
413                 [o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
414                 [o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
415                 [o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
416                 [o_options addObject: [NSString stringWithFormat: @"screen-height=%i", [o_screen_height_fld intValue]]];
417                 if( [o_screen_follow_mouse_ckb intValue] == YES )
418                     [o_options addObject: @"screen-follow-mouse"];
419                 else
420                     [o_options addObject: @"no-screen-follow-mouse"];
421         }
422
423         /* apply the options to our item(s) */
424         [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
425         if( b_autoplay )
426             [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
427         else
428             [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
429     }
430 }
431
432 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
433 {
434     NSString *o_label = [o_tvi label];
435
436     if( [o_label isEqualToString: _NS("File")] )
437     {
438         [self openFilePathChanged: nil];
439     }
440     else if( [o_label isEqualToString: _NS("Disc")] )
441     {
442         [self openDiscTypeChanged: nil];
443     }
444     else if( [o_label isEqualToString: _NS("Network")] )
445     {
446         [self openNetInfoChanged: nil];
447     }
448     else if( [o_label isEqualToString: _NS("Capture")] )
449     {
450         [self openCaptureModeChanged: nil];
451     }
452 }
453
454 - (IBAction)expandMRLfieldAction:(id)sender
455 {
456     NSRect o_win_rect, o_view_rect;
457     o_win_rect = [o_panel frame];
458     o_view_rect = [o_mrl_view frame];
459
460     if( [o_mrl_btn state] == NSOffState )
461     {
462         /* we need to collaps, restore the panel size */
463         o_win_rect.size.height = o_win_rect.size.height - o_view_rect.size.height;
464         o_win_rect.origin.y = ( o_win_rect.origin.y + o_view_rect.size.height ) - o_view_rect.size.height;
465
466         /* remove the MRL view */
467         [o_mrl_view removeFromSuperviewWithoutNeedingDisplay];
468     } else {
469         /* we need to expand */
470         [o_mrl_view setFrame: NSMakeRect( 0,
471                                          [o_mrl_btn frame].origin.y,
472                                          o_view_rect.size.width,
473                                          o_view_rect.size.height )];
474         [o_mrl_view setNeedsDisplay: YES];
475         [o_mrl_view setAutoresizesSubviews: YES];
476
477         /* add the MRL view */
478         [[o_panel contentView] addSubview: o_mrl_view];
479         o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
480     }
481
482     [o_panel setFrame: o_win_rect display:YES animate: YES];
483     [o_panel displayIfNeeded];
484 }
485
486 - (void)openFileGeneric
487 {
488     [self openFilePathChanged: nil];
489     [self openTarget: 0];
490 }
491
492 - (void)openDisc
493 {
494     [self openDiscTypeChanged: nil];
495     [self openTarget: 1];
496 }
497
498 - (void)openNet
499 {
500     [self openNetInfoChanged: nil];
501     [self openTarget: 2];
502 }
503
504 - (void)openCapture
505 {
506     [self openCaptureModeChanged: nil];
507     [self showCaptureView: o_capture_label_view];
508     [self openTarget: 3];
509 }
510
511 - (void)openFilePathChanged:(NSNotification *)o_notification
512 {
513     NSString *o_mrl_string;
514     NSString *o_filename = [o_file_path stringValue];
515     NSString *o_ext = [o_filename pathExtension];
516     bool b_stream = [o_file_stream state];
517     BOOL b_dir = NO;
518  
519     [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
520
521     if( b_dir )
522     {
523         o_mrl_string = [NSString stringWithFormat: @"directory://%@/", o_filename];
524     }
525     else if( [o_ext isEqualToString: @"bin"] ||
526         [o_ext isEqualToString: @"cue"] ||
527         [o_ext isEqualToString: @"vob"] ||
528         [o_ext isEqualToString: @"iso"] )
529     {
530         o_mrl_string = o_filename;
531     }
532     else
533     {
534         o_mrl_string = [NSString stringWithFormat: @"%s://%@",
535                         b_stream ? "stream" : "file",
536                         o_filename];
537     }
538     [o_mrl setStringValue: o_mrl_string];
539 }
540
541 - (IBAction)openFileBrowse:(id)sender
542 {
543     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
544  
545     [o_open_panel setAllowsMultipleSelection: NO];
546     [o_open_panel setCanChooseDirectories: YES];
547     [o_open_panel setTitle: _NS("Open File")];
548     [o_open_panel setPrompt: _NS("Open")];
549
550     [o_open_panel beginSheetForDirectory:nil
551         file:nil
552         types:nil
553         modalForWindow:[sender window]
554         modalDelegate: self
555         didEndSelector: @selector(pathChosenInPanel:
556                         withReturn:
557                         contextInfo:)
558         contextInfo: nil];
559 }
560
561 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void  *)contextInfo
562 {
563     if (returnCode == NSFileHandlingPanelOKButton)
564     {
565         NSString *o_filename = [[sheet filenames] objectAtIndex: 0];
566         [o_file_path setStringValue: o_filename];
567         [self openFilePathChanged: nil];
568     }
569 }
570
571 - (IBAction)openFileStreamChanged:(id)sender
572 {
573     [self openFilePathChanged: nil];
574 }
575
576 - (IBAction)openDiscTypeChanged:(id)sender
577 {
578     NSString *o_type;
579     BOOL b_device, b_no_menus, b_title_chapter;
580  
581     [o_disc_device removeAllItems];
582     b_title_chapter = ![o_disc_dvd_menus state];
583  
584     o_type = [[o_disc_type selectedCell] title];
585
586     if ( [o_type isEqualToString: _NS("VIDEO_TS directory")] )
587     {
588         b_device = NO; b_no_menus = YES;
589     }
590     else
591     {
592         NSArray *o_devices;
593         NSString *o_disc;
594         const char *psz_class = NULL;
595         b_device = YES;
596
597         if ( [o_type isEqualToString: _NS("VCD")] )
598         {
599             psz_class = kIOCDMediaClass;
600             o_disc = o_type;
601             b_no_menus = NO; b_title_chapter = YES;
602                 }
603         else if ( [o_type isEqualToString: _NS("Audio CD")])
604         {
605             psz_class = kIOCDMediaClass;
606             o_disc = o_type;
607             b_no_menus = NO; b_title_chapter = NO;
608         }
609         else
610         {
611             psz_class = kIODVDMediaClass;
612             o_disc = o_type;
613             b_no_menus = YES;
614         }
615  
616         o_devices = GetEjectableMediaOfClass( psz_class );
617         if ( o_devices != nil )
618         {
619             int i_devices = [o_devices count];
620  
621             if ( i_devices )
622             {
623                                 for( int i = 0; i < i_devices; i++ )
624                 {
625                     [o_disc_device
626                         addItemWithObjectValue: [o_devices objectAtIndex: i]];
627                 }
628
629                 [o_disc_device selectItemAtIndex: 0];
630             }
631             else
632             {
633                 [o_disc_device setStringValue:
634                     [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
635             }
636         }
637     }
638
639     [o_disc_device setEnabled: b_device];
640     [o_disc_title setEnabled: b_title_chapter];
641     [o_disc_title_stp setEnabled: b_title_chapter];
642     [o_disc_chapter setEnabled: b_title_chapter];
643     [o_disc_chapter_stp setEnabled: b_title_chapter];
644     [o_disc_videots_folder setEnabled: !b_device];
645     [o_disc_videots_btn_browse setEnabled: !b_device];
646     [o_disc_dvd_menus setEnabled: b_no_menus];
647
648     [self openDiscInfoChanged: nil];
649 }
650
651 - (IBAction)openDiscStepperChanged:(id)sender
652 {
653     int i_tag = [sender tag];
654
655     if( i_tag == 0 )
656     {
657         [o_disc_title setIntValue: [o_disc_title_stp intValue]];
658     }
659     else if( i_tag == 1 )
660     {
661         [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
662     }
663
664     [self openDiscInfoChanged: nil];
665 }
666
667 - (void)openDiscInfoChanged:(NSNotification *)o_notification
668 {
669     NSString *o_type;
670     NSString *o_device;
671     NSString *o_videots;
672     NSString *o_mrl_string;
673     int i_title, i_chapter;
674     BOOL b_no_menus;
675
676     o_type = [[o_disc_type selectedCell] title];
677     o_device = [o_disc_device stringValue];
678     i_title = [o_disc_title intValue];
679     i_chapter = [o_disc_chapter intValue];
680     o_videots = [o_disc_videots_folder stringValue];
681     b_no_menus = [o_disc_dvd_menus state];
682
683     if ( [o_type isEqualToString: _NS("VCD")] )
684     {
685         if ( [o_device isEqualToString:
686                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
687             o_device = @"";
688         o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i:%i",
689                         o_device, i_title, i_chapter];
690     }
691     else if ( [o_type isEqualToString: _NS("Audio CD")] )
692     {
693         if ( [o_device isEqualToString:
694                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
695             o_device = @"";
696         o_mrl_string = [NSString stringWithFormat: @"cdda://%@",
697                         o_device];
698     }
699     else if ( [o_type isEqualToString: _NS("DVD")] )
700     {
701         if ( [o_device isEqualToString:
702                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
703             o_device = @"";
704         if ( b_no_menus )
705             o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i-",
706                             o_device, i_title, i_chapter];
707         else
708                         o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
709                             o_device];
710             
711     }
712     else /* VIDEO_TS folder */
713     {
714         if ( b_no_menus )
715             o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i",
716                             o_videots, i_title, i_chapter];
717         else
718                         o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
719                             o_videots];            
720     }
721
722     [o_mrl setStringValue: o_mrl_string];
723 }
724
725 - (IBAction)openDiscMenusChanged:(id)sender
726 {
727     [self openDiscInfoChanged: nil];
728     [self openDiscTypeChanged: nil];
729 }
730
731 - (IBAction)openVTSBrowse:(id)sender
732 {
733     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
734
735     [o_open_panel setAllowsMultipleSelection: NO];
736     [o_open_panel setCanChooseFiles: NO];
737     [o_open_panel setCanChooseDirectories: YES];
738     [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
739     [o_open_panel setPrompt: _NS("Open")];
740
741     if( [o_open_panel runModalForDirectory: nil
742             file: nil types: nil] == NSOKButton )
743     {
744         NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
745         [o_disc_videots_folder setStringValue: o_dirname];
746         [self openDiscInfoChanged: nil];
747     }
748 }
749
750 - (void)textFieldWasClicked:(NSNotification *)o_notification
751 {
752     if( [o_notification object] == o_net_udp_port )
753         [o_net_mode selectCellAtRow: 0 column: 0];
754     else if( [o_notification object] == o_net_udpm_addr ||
755              [o_notification object] == o_net_udpm_port )
756         [o_net_mode selectCellAtRow: 1 column: 0];
757     else
758         [o_net_mode selectCellAtRow: 2 column: 0];
759
760     [self openNetInfoChanged: nil];
761 }
762
763 - (IBAction)openNetModeChanged:(id)sender
764 {
765     if( sender == o_net_mode )
766     {
767         if( [[sender selectedCell] tag] == 0 )
768             [o_panel makeFirstResponder: o_net_udp_port];
769         else if ( [[sender selectedCell] tag] == 1 )
770             [o_panel makeFirstResponder: o_net_udpm_addr];
771         else
772             msg_Warn( p_intf, "Unknown sender tried to change UDP/RTP mode" );
773     }
774
775     [self openNetInfoChanged: nil];
776 }
777
778 - (IBAction)openNetStepperChanged:(id)sender
779 {
780     int i_tag = [sender tag];
781
782     if( i_tag == 0 )
783     {
784         [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
785         [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
786                                                             object: o_net_udp_port];
787         [o_panel makeFirstResponder: o_net_udp_port];
788     }
789     else if( i_tag == 1 )
790     {
791         [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
792         [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
793                                                             object: o_net_udpm_port];
794         [o_panel makeFirstResponder: o_net_udpm_port];
795     }
796
797     [self openNetInfoChanged: nil];
798 }
799
800 - (void)openNetInfoChanged:(NSNotification *)o_notification
801 {
802     NSString *o_mrl_string = [NSString string];
803
804     if( [o_net_udp_panel isVisible] )
805     {
806         NSString *o_mode;
807         o_mode = [[o_net_mode selectedCell] title];
808
809         if( [o_mode isEqualToString: _NS("Unicast")] )
810         {
811             int i_port = [o_net_udp_port intValue];
812
813             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
814                 o_mrl_string = [NSString stringWithString: @"udp://"];
815             else
816                 o_mrl_string = [NSString stringWithString: @"rtp://"];
817
818             if( i_port != config_GetInt( p_intf, "server-port" ) )
819             {
820                 o_mrl_string =
821                     [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
822             }
823         }
824         else if( [o_mode isEqualToString: _NS("Multicast")] )
825         {
826             NSString *o_addr = [o_net_udpm_addr stringValue];
827             int i_port = [o_net_udpm_port intValue];
828
829             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
830                 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
831             else
832                 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
833
834             if( i_port != config_GetInt( p_intf, "server-port" ) )
835             {
836                 o_mrl_string =
837                     [o_mrl_string stringByAppendingFormat: @":%i", i_port];
838             }
839         }
840     }
841     else
842     {
843         NSString *o_url = [o_net_http_url stringValue];
844
845         if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
846               && ![o_url hasPrefix:@"mms"] && ![o_url hasPrefix:@"rtsp"] )
847             o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
848         else
849             o_mrl_string = o_url;
850     }
851     [o_mrl setStringValue: o_mrl_string];
852 }
853
854 - (IBAction)openNetUDPButtonAction:(id)sender
855 {
856     if( sender == o_net_openUDP_btn )
857     {
858         [NSApp beginSheet: o_net_udp_panel
859            modalForWindow: o_panel
860             modalDelegate: self
861            didEndSelector: NULL
862               contextInfo: nil];
863         [self openNetInfoChanged: nil];
864     }
865     else if( sender == o_net_udp_cancel_btn )
866     {
867         [o_net_udp_panel orderOut: sender];
868         [NSApp endSheet: o_net_udp_panel];
869     }
870     else if( sender == o_net_udp_ok_btn )
871     {
872         NSString *o_mrl_string = [NSString string];
873         if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
874         {
875             int i_port = [o_net_udp_port intValue];
876             
877             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
878                 o_mrl_string = [NSString stringWithString: @"udp://"];
879             else
880                 o_mrl_string = [NSString stringWithString: @"rtp://"];
881
882             if( i_port != config_GetInt( p_intf, "server-port" ) )
883             {
884                 o_mrl_string =
885                 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port];
886             }
887         }
888         else if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Multicast")] )
889         {
890             NSString *o_addr = [o_net_udpm_addr stringValue];
891             int i_port = [o_net_udpm_port intValue];
892             
893             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
894                 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
895             else
896                 o_mrl_string = [NSString stringWithFormat: @"rtp://@%@", o_addr];
897
898             if( i_port != config_GetInt( p_intf, "server-port" ) )
899             {
900                 o_mrl_string =
901                 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
902             }
903         }
904         [o_mrl setStringValue: o_mrl_string];
905         [o_net_udp_panel orderOut: sender];
906         [NSApp endSheet: o_net_udp_panel];
907     }
908 }
909     
910 - (void)openFile
911 {
912     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
913     int i;
914     b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
915  
916     [o_open_panel setAllowsMultipleSelection: YES];
917     [o_open_panel setCanChooseDirectories: YES];
918     [o_open_panel setTitle: _NS("Open File")];
919     [o_open_panel setPrompt: _NS("Open")];
920  
921     if( [o_open_panel runModalForDirectory: nil
922             file: nil types: nil] == NSOKButton )
923     {
924         NSArray *o_array = [NSArray array];
925         NSArray *o_values = [[o_open_panel filenames]
926                 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
927
928         for( i = 0; i < (int)[o_values count]; i++)
929         {
930             NSDictionary *o_dic;
931             o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
932             o_array = [o_array arrayByAddingObject: o_dic];
933         }
934         if( b_autoplay )
935             [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
936         else
937             [o_playlist appendArray: o_array atPos: -1 enqueue:YES];
938     }
939 }
940
941 - (void)showCaptureView: theView
942 {
943     NSRect o_view_rect;
944     o_view_rect = [theView frame];
945     if( o_currentCaptureView )
946     {
947         [o_currentCaptureView removeFromSuperviewWithoutNeedingDisplay];
948         [o_currentCaptureView release];
949     }
950     [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
951     [theView setNeedsDisplay: YES];
952     [theView setAutoresizesSubviews: YES];
953     [[[o_tabview tabViewItemAtIndex: 3] view] addSubview: theView];
954     [theView displayIfNeeded];
955     o_currentCaptureView = theView;
956     [o_currentCaptureView retain];
957 }
958
959 - (IBAction)openCaptureModeChanged:(id)sender
960 {
961     if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"EyeTV"] )
962     {
963         if( [[[VLCMain sharedInstance] getEyeTVController] isEyeTVrunning] == YES )
964         {
965             if( [[[VLCMain sharedInstance] getEyeTVController] isDeviceConnected] == YES )
966             {
967                 [self showCaptureView: o_eyetv_running_view];
968                 [self setupChannelInfo];
969             }
970             else
971             {
972                 setEyeTVUnconnected;
973             }
974         }
975         else
976             [self showCaptureView: o_eyetv_notLaunched_view];
977         [o_mrl setStringValue: @""];
978     } 
979     else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
980     {
981         [self showCaptureView: o_screen_view];
982         [o_mrl setStringValue: @"screen://"];
983         [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
984         [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
985         [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
986         [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
987         [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
988         [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
989     }
990     else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"iSight"] )
991     {
992         [o_capture_lbl setStringValue: _NS("iSight Capture Input")];
993         [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.")];
994         [o_capture_lbl displayIfNeeded];
995         [o_capture_long_lbl displayIfNeeded];
996         
997         [self showCaptureView: o_capture_label_view];
998         [o_mrl setStringValue: @"qtcapture://"];
999     }
1000 }
1001
1002 - (IBAction)screenStepperChanged:(id)sender
1003 {
1004     [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
1005     [o_panel makeFirstResponder: o_screen_fps_fld];
1006     [o_mrl setStringValue: @"screen://"];
1007 }
1008
1009 - (void)screenFPSfieldChanged:(NSNotification *)o_notification
1010 {
1011     [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
1012     if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
1013         [o_screen_fps_fld setFloatValue: 1.0];
1014     [o_mrl setStringValue: @"screen://"];
1015 }
1016
1017 - (IBAction)eyetvSwitchChannel:(id)sender
1018 {
1019     if( sender == o_eyetv_nextProgram_btn )
1020     {
1021         int chanNum = [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: YES];
1022         [o_eyetv_channels_pop selectItemWithTag:chanNum];
1023         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1024     }
1025     else if( sender == o_eyetv_previousProgram_btn )
1026     {
1027         int chanNum = [[[VLCMain sharedInstance] getEyeTVController] switchChannelUp: NO];
1028         [o_eyetv_channels_pop selectItemWithTag:chanNum];
1029         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1030     }
1031     else if( sender == o_eyetv_channels_pop )
1032     {
1033         int chanNum = [[sender selectedItem] tag];
1034         [[[VLCMain sharedInstance] getEyeTVController] selectChannel:chanNum];
1035         [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
1036     }
1037     else
1038         msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
1039 }
1040
1041 - (IBAction)eyetvLaunch:(id)sender
1042 {
1043     [[[VLCMain sharedInstance] getEyeTVController] launchEyeTV];
1044 }
1045
1046 - (IBAction)eyetvGetPlugin:(id)sender
1047 {
1048     [[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: @"http://www.videolan.org/vlc/eyetv"]];
1049 }
1050
1051 - (void)eyetvChanged:(NSNotification *)o_notification
1052 {
1053     if( [[o_notification name] isEqualToString: @"DeviceAdded"] )
1054     {
1055         msg_Dbg( VLCIntf, "eyetv device was added" );
1056         [self showCaptureView: o_eyetv_running_view];
1057         [self setupChannelInfo];
1058     }
1059     else if( [[o_notification name] isEqualToString: @"DeviceRemoved"] )
1060     {
1061         /* leave the channel selection like that,
1062          * switch to our "no device" tab */
1063         msg_Dbg( VLCIntf, "eyetv device was removed" );
1064         setEyeTVUnconnected;
1065     }
1066     else if( [[o_notification name] isEqualToString: @"PluginQuit"] )
1067     {
1068         /* switch to the "launch eyetv" tab */
1069         msg_Dbg( VLCIntf, "eyetv was terminated" );
1070         [self showCaptureView: o_eyetv_notLaunched_view];
1071     }
1072     else if( [[o_notification name] isEqualToString: @"PluginInit"] )
1073     {
1074         /* we got no device yet */
1075         msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
1076         setEyeTVUnconnected;
1077     }
1078     else
1079         msg_Warn( VLCIntf, "unknown external notify '%s' received", [[o_notification name] UTF8String] );
1080 }    
1081
1082 /* little helper method, since this code needs to be run by multiple objects */
1083 - (void)setupChannelInfo
1084 {
1085     /* set up channel selection */
1086     [o_eyetv_channels_pop removeAllItems];
1087     [o_eyetv_chn_bgbar setHidden: NO];
1088     [o_eyetv_chn_bgbar animate: self];
1089     [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
1090     [o_eyetv_chn_status_txt setHidden: NO];
1091  
1092     /* retrieve info */
1093     NSEnumerator *channels = [[[VLCMain sharedInstance] getEyeTVController] allChannels];
1094     int x = -2;
1095     [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("Composite input")
1096                                                action: nil
1097                                         keyEquivalent: @""] setTag:x++];
1098     [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
1099                                                action: nil
1100                                         keyEquivalent: @""] setTag:x++];
1101     if( channels ) 
1102     {
1103         NSString *channel;
1104         [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
1105         while( channel = [channels nextObject] )
1106         {
1107             /* we have to add items this way, because we accept duplicates
1108              * additionally, we save a bit of time */
1109             [[[o_eyetv_channels_pop menu] addItemWithTitle: channel
1110                                                    action: nil
1111                                             keyEquivalent: @""] setTag:++x];
1112         }
1113         /* make Tuner the default */
1114         [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] getEyeTVController] currentChannel]];
1115     }
1116  
1117     /* clean up GUI */
1118     [o_eyetv_chn_bgbar setHidden: YES];
1119     [o_eyetv_chn_status_txt setHidden: YES];
1120 }
1121
1122 - (IBAction)subsChanged:(id)sender
1123 {
1124     if ([o_file_sub_ckbox state] == NSOnState)
1125     {
1126         [o_file_sub_btn_settings setEnabled:YES];
1127     }
1128     else
1129     {
1130         [o_file_sub_btn_settings setEnabled:NO];
1131     }
1132 }
1133
1134 - (IBAction)subSettings:(id)sender
1135 {
1136     [NSApp beginSheet: o_file_sub_sheet
1137         modalForWindow: [sender window]
1138         modalDelegate: self
1139         didEndSelector: NULL
1140         contextInfo: nil];
1141 }
1142
1143 - (IBAction)subCloseSheet:(id)sender
1144 {
1145     [o_file_sub_sheet orderOut:sender];
1146     [NSApp endSheet: o_file_sub_sheet];
1147 }
1148     
1149 - (IBAction)subFileBrowse:(id)sender
1150 {
1151     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1152  
1153     [o_open_panel setAllowsMultipleSelection: NO];
1154     [o_open_panel setTitle: _NS("Open File")];
1155     [o_open_panel setPrompt: _NS("Open")];
1156
1157     if( [o_open_panel runModalForDirectory: nil
1158             file: nil types: nil] == NSOKButton )
1159     {
1160         NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
1161         [o_file_sub_path setStringValue: o_filename];
1162     }
1163 }
1164
1165 - (IBAction)subOverride:(id)sender
1166 {
1167     BOOL b_state = [o_file_sub_override state];
1168     [o_file_sub_delay setEnabled: b_state];
1169     [o_file_sub_delay_stp setEnabled: b_state];
1170     [o_file_sub_fps setEnabled: b_state];
1171     [o_file_sub_fps_stp setEnabled: b_state];
1172 }
1173
1174 - (IBAction)subDelayStepperChanged:(id)sender
1175 {
1176     [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
1177 }
1178
1179 - (IBAction)subFpsStepperChanged:(id)sender;
1180 {
1181     [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
1182 }
1183
1184 - (IBAction)panelCancel:(id)sender
1185 {
1186     [NSApp stopModalWithCode: 0];
1187 }
1188
1189 - (IBAction)panelOk:(id)sender
1190 {
1191     if( [[o_mrl stringValue] length] )
1192     {
1193         [NSApp stopModalWithCode: 1];
1194     }
1195     else
1196     {
1197         NSBeep();
1198     }
1199 }
1200
1201 @end
1202
1203 @implementation VLCOpenTextField
1204
1205 - (void)mouseDown:(NSEvent *)theEvent
1206 {
1207     [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCOpenTextFieldWasClicked"
1208                                                         object: self];
1209     [super mouseDown: theEvent];
1210 }
1211
1212 @end