]> git.sesse.net Git - vlc/blob - modules/gui/macosx/open.m
* First set config variable, then add the files (and therefore potentially
[vlc] / modules / gui / macosx / open.m
1 /*****************************************************************************
2  * open.m: MacOS X plugin for vlc
3  *****************************************************************************
4  * Copyright (C) 2002-2003 VideoLAN
5  * $Id: open.m,v 1.33 2003/05/12 01:17:10 hartman Exp $
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  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either version 2 of the License, or
14  * (at your option) any later version.
15  * 
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /*****************************************************************************
27  * Preamble
28  *****************************************************************************/
29 #include <stdlib.h>                                      /* malloc(), free() */
30 #include <sys/param.h>                                    /* for MAXPATHLEN */
31 #include <string.h>
32
33 #include <paths.h>
34 #include <IOKit/IOKitLib.h>
35 #include <IOKit/IOBSD.h>
36 #include <IOKit/storage/IOMedia.h>
37 #include <IOKit/storage/IOCDMedia.h>
38 #include <IOKit/storage/IODVDMedia.h>
39
40 #include "intf.h"
41 #include "playlist.h"
42 #include "open.h"
43
44 /*****************************************************************************
45  * GetEjectableMediaOfClass 
46  *****************************************************************************/
47 NSArray *GetEjectableMediaOfClass( const char *psz_class )
48 {
49     io_object_t next_media;
50     mach_port_t master_port;
51     kern_return_t kern_result;
52     NSArray *o_devices = nil;
53     NSMutableArray *p_list = nil;
54     io_iterator_t media_iterator;
55     CFMutableDictionaryRef classes_to_match;
56
57     kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
58     if( kern_result != KERN_SUCCESS )
59     {
60         return( nil );
61     }
62     
63     classes_to_match = IOServiceMatching( psz_class );
64     if( classes_to_match == NULL )
65     {
66         return( nil );
67     }
68     
69     CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectable ), 
70                           kCFBooleanTrue );
71     
72     kern_result = IOServiceGetMatchingServices( master_port, classes_to_match, 
73                                                 &media_iterator );
74     if( kern_result != KERN_SUCCESS )
75     {
76         return( nil );
77     }
78
79     p_list = [NSMutableArray arrayWithCapacity: 1];
80     
81     next_media = IOIteratorNext( media_iterator );
82     if( next_media != NULL )
83     {
84         char psz_buf[0x32];
85         size_t dev_path_length;
86         CFTypeRef str_bsd_path;
87     
88         do
89         {
90             str_bsd_path = IORegistryEntryCreateCFProperty( next_media,
91                                                             CFSTR( kIOBSDName ),
92                                                             kCFAllocatorDefault,
93                                                             0 );
94             if( str_bsd_path == NULL )
95             {
96                 IOObjectRelease( next_media );
97                 continue;
98             }
99             
100             snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
101             dev_path_length = strlen( psz_buf );
102             
103             if( CFStringGetCString( str_bsd_path,
104                                     (char*)&psz_buf + dev_path_length,
105                                     sizeof(psz_buf) - dev_path_length,
106                                     kCFStringEncodingASCII ) )
107             {
108                 [p_list addObject: [NSString stringWithCString: psz_buf]];
109             }
110             
111             CFRelease( str_bsd_path );
112             
113             IOObjectRelease( next_media );
114         
115         } while( ( next_media = IOIteratorNext( media_iterator ) ) != NULL );
116     }
117     
118     IOObjectRelease( media_iterator );
119
120     o_devices = [NSArray arrayWithArray: p_list];
121
122     return( o_devices );
123 }
124
125 /*****************************************************************************
126  * VLCOpen implementation 
127  *****************************************************************************/
128 @implementation VLCOpen
129
130 - (void)awakeFromNib
131 {
132     intf_thread_t * p_intf = [NSApp getIntf];
133
134     [o_panel setTitle: _NS("Open Source")];
135     [o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
136     [o_ckbox_enqueue setTitle: _NS("Only enqueue in playlist, do not play")];
137
138     [o_btn_ok setTitle: _NS("OK")];
139     [o_btn_cancel setTitle: _NS("Cancel")];
140
141     [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
142     [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
143     [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
144
145     [o_file_btn_browse setTitle: _NS("Browse...")];
146     [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
147
148     [o_disc_device_lbl setStringValue: _NS("Device name")];
149     [o_disc_title_lbl setStringValue: _NS("Title")];
150     [o_disc_chapter_lbl setStringValue: _NS("Chapter")];
151     [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
152     [o_disc_dvd_menus setTitle: _NS("Use DVD menus")];
153
154     [[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
155     [[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
156     [[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")];
157
158     [o_net_udp_port_lbl setStringValue: _NS("Port")];
159     [o_net_udpm_addr_lbl setStringValue: _NS("Address")];
160     [o_net_udpm_port_lbl setStringValue: _NS("Port")];
161     [o_net_http_url_lbl setStringValue: _NS("URL")];
162
163     [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("UDP/RTP")];
164     [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("UDP/RTP Multicast")];
165     [[o_net_mode cellAtRow:2 column:0] setTitle: _NS("HTTP/FTP/MMS")];
166
167     [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
168     [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
169
170     [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
171     [o_file_sub_btn_settings setTitle: _NS("Settings...")];
172     [o_file_sub_btn_browse setTitle: _NS("Browse...")];
173     [o_file_sub_override setTitle: _NS("Override")];
174     [o_file_sub_delay_lbl setStringValue: _NS("delay")];
175     [o_file_sub_delay_stp setEnabled: NO];
176     [o_file_sub_fps_lbl setStringValue: _NS("fps")];
177     [o_file_sub_fps_stp setEnabled: NO];
178     [o_file_sub_ok_btn setStringValue: _NS("OK")];
179     
180     [[NSNotificationCenter defaultCenter] addObserver: self
181         selector: @selector(openFilePathChanged:)
182         name: NSControlTextDidChangeNotification
183         object: o_file_path];
184
185     [[NSNotificationCenter defaultCenter] addObserver: self
186         selector: @selector(openDiscInfoChanged:)
187         name: NSControlTextDidChangeNotification
188         object: o_disc_device];
189     [[NSNotificationCenter defaultCenter] addObserver: self
190         selector: @selector(openDiscInfoChanged:)
191         name: NSControlTextDidChangeNotification
192         object: o_disc_title];
193     [[NSNotificationCenter defaultCenter] addObserver: self
194         selector: @selector(openDiscInfoChanged:)
195         name: NSControlTextDidChangeNotification
196         object: o_disc_chapter];
197     [[NSNotificationCenter defaultCenter] addObserver: self
198         selector: @selector(openDiscInfoChanged:)
199         name: NSControlTextDidChangeNotification
200         object: o_disc_videots_folder];
201
202     [[NSNotificationCenter defaultCenter] addObserver: self
203         selector: @selector(openNetInfoChanged:)
204         name: NSControlTextDidChangeNotification
205         object: o_net_udp_port];
206     [[NSNotificationCenter defaultCenter] addObserver: self
207         selector: @selector(openNetInfoChanged:)
208         name: NSControlTextDidChangeNotification
209         object: o_net_udpm_addr];
210     [[NSNotificationCenter defaultCenter] addObserver: self
211         selector: @selector(openNetInfoChanged:)
212         name: NSControlTextDidChangeNotification
213         object: o_net_udpm_port];
214     [[NSNotificationCenter defaultCenter] addObserver: self
215         selector: @selector(openNetInfoChanged:)
216         name: NSControlTextDidChangeNotification
217         object: o_net_http_url];
218 }
219
220 - (void)openTarget:(int)i_type
221 {
222     int i_result;
223
224     [o_tabview selectTabViewItemAtIndex: i_type];
225     [o_file_sub_ckbox setState: NSOffState];
226     
227     i_result = [NSApp runModalForWindow: o_panel];
228     [o_panel close];
229
230     if( i_result )
231     {
232         intf_thread_t * p_intf = [NSApp getIntf];
233
234         NSString *o_source = [o_mrl stringValue];
235         BOOL b_enq = [o_ckbox_enqueue state] == NSOnState ? YES : NO;
236         NSString *subPath = [o_file_sub_path stringValue];
237         
238         if (([o_file_sub_ckbox state] == NSOnState) && !([subPath isEqualTo: @""]))
239         {
240             config_PutPsz( p_intf, "sub-file", strdup( [subPath cString] ) );
241             if ( [o_file_sub_override state] )
242             {
243                 config_PutInt( p_intf, "sub-delay", (int)( [o_file_sub_delay intValue] * 10 ) );
244                 config_PutFloat( p_intf, "sub-fps", [o_file_sub_fps floatValue] );
245             }
246         }
247         else
248         {
249             config_PutPsz( p_intf, "sub-file", "" );
250             config_PutInt( p_intf, "sub-delay", 0 );
251             config_PutFloat( p_intf, "sub-fps", 0.0 );
252         }
253         
254         [o_playlist appendArray: 
255             [NSArray arrayWithObject: o_source] atPos: -1 enqueue:b_enq];
256     }
257 }
258
259 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
260 {
261     NSString *o_label = [o_tvi label];
262
263     if( [o_label isEqualToString: _NS("File")] )
264     {
265         [self openFilePathChanged: nil];
266     }
267     else if( [o_label isEqualToString: _NS("Disc")] )
268     {
269         [self openDiscTypeChanged: nil];
270     }
271     else if( [o_label isEqualToString: _NS("Network")] )
272     {
273         [self openNetModeChanged: nil];
274     }  
275 }
276
277 - (IBAction)openFileGeneric:(id)sender
278 {
279     [self openFilePathChanged: nil];
280     [self openTarget: 0];
281 }
282
283 - (IBAction)openDisc:(id)sender
284 {
285     [self openDiscTypeChanged: nil];
286     [self openTarget: 1];
287 }
288
289 - (IBAction)openNet:(id)sender
290 {
291     [self openNetModeChanged: nil];
292     [self openTarget: 2];
293 }
294
295 - (void)openFilePathChanged:(NSNotification *)o_notification
296 {
297     NSString *o_mrl_string;
298     NSString *o_filename = [o_file_path stringValue];
299     NSString *o_ext = [o_filename pathExtension];
300     vlc_bool_t b_stream = [o_file_stream state];
301     BOOL b_dir = NO;
302     
303     [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
304
305     if( b_dir )
306     {
307         o_mrl_string = [NSString stringWithFormat: @"dir:%@", o_filename];
308     }
309     else if( [o_ext isEqualToString: @"bin"] ||
310         [o_ext isEqualToString: @"cue"] ||
311         [o_ext isEqualToString: @"vob"] ||
312         [o_ext isEqualToString: @"iso"] )
313     {
314         o_mrl_string = o_filename;
315     }
316     else
317     {
318         o_mrl_string = [NSString stringWithFormat: @"%s://%@",
319                         b_stream ? "stream" : "file",
320                         o_filename];
321     }
322     [o_mrl setStringValue: o_mrl_string]; 
323 }
324
325 - (IBAction)openFileBrowse:(id)sender
326 {
327     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
328     
329     [o_open_panel setAllowsMultipleSelection: NO];
330     [o_open_panel setCanChooseDirectories: YES];
331     [o_open_panel setTitle: _NS("Open File")];
332     [o_open_panel setPrompt: _NS("Open")];
333
334     [o_open_panel beginSheetForDirectory:nil
335         file:nil
336         types:nil
337         modalForWindow:[sender window]
338         modalDelegate: self
339         didEndSelector: @selector(pathChosenInPanel: 
340                         withReturn:
341                         contextInfo:)
342         contextInfo: nil];
343 }
344
345 - (void)pathChosenInPanel: (NSOpenPanel *) sheet withReturn:(int)returnCode contextInfo:(void  *)contextInfo
346 {
347     if (returnCode == NSFileHandlingPanelOKButton)
348     {
349         NSString *o_filename = [[sheet filenames] objectAtIndex: 0];
350         [o_file_path setStringValue: o_filename];
351         [self openFilePathChanged: nil];
352     }
353 }
354
355 - (IBAction)openFileStreamChanged:(id)sender
356 {
357     [self openFilePathChanged: nil];
358 }
359
360 - (IBAction)openDiscTypeChanged:(id)sender
361 {
362     NSString *o_type;
363     vlc_bool_t b_device, b_menus, b_title_chapter;
364     
365     [o_disc_device removeAllItems];
366     b_title_chapter = ![o_disc_dvd_menus state];
367     
368     o_type = [[o_disc_type selectedCell] title];
369
370     if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
371     {
372         b_device = 0; b_menus = 1;
373     }
374     else
375     {
376         NSArray *o_devices;
377         NSString *o_disc;
378         const char *psz_class = NULL;
379         b_device = 1;
380
381         if ( [o_type isEqualToString: _NS("VCD")] )
382         {
383             psz_class = kIOCDMediaClass;
384             o_disc = o_type;
385             b_menus = 0; b_title_chapter = 1;
386             [o_disc_dvd_menus setState: FALSE];
387         }
388         else
389         {
390             psz_class = kIODVDMediaClass;
391             o_disc = o_type;
392             b_menus = 1;
393         }
394     
395         o_devices = GetEjectableMediaOfClass( psz_class );
396         if ( o_devices != nil )
397         {
398             int i_devices = [o_devices count];
399         
400             if ( i_devices )
401             {
402                 int i;
403         
404                 for( i = 0; i < i_devices; i++ )
405                 {
406                     [o_disc_device 
407                         addItemWithObjectValue: [o_devices objectAtIndex: i]];
408                 }
409
410                 [o_disc_device selectItemAtIndex: 0];
411             }
412             else
413             {
414                 [o_disc_device setStringValue: 
415                     [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
416             }
417         }
418     }
419
420     [o_disc_device setEnabled: b_device];
421     [o_disc_title setEnabled: b_title_chapter];
422     [o_disc_title_stp setEnabled: b_title_chapter];
423     [o_disc_chapter setEnabled: b_title_chapter];
424     [o_disc_chapter_stp setEnabled: b_title_chapter];
425     [o_disc_videots_folder setEnabled: !b_device];
426     [o_disc_videots_btn_browse setEnabled: !b_device];
427     [o_disc_dvd_menus setEnabled: b_menus];
428
429     [self openDiscInfoChanged: nil];
430 }
431
432 - (IBAction)openDiscStepperChanged:(id)sender
433 {
434     int i_tag = [sender tag];
435
436     if( i_tag == 0 )
437     {
438         [o_disc_title setIntValue: [o_disc_title_stp intValue]];
439     }
440     else if( i_tag == 1 )
441     {
442         [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
443     }
444
445     [self openDiscInfoChanged: nil];
446 }
447
448 - (void)openDiscInfoChanged:(NSNotification *)o_notification
449 {
450     NSString *o_type;
451     NSString *o_device;
452     NSString *o_videots;
453     NSString *o_mrl_string;
454     int i_title, i_chapter;
455     vlc_bool_t b_menus;
456
457     o_type = [[o_disc_type selectedCell] title];
458     o_device = [o_disc_device stringValue];
459     i_title = [o_disc_title intValue];
460     i_chapter = [o_disc_chapter intValue];
461     o_videots = [o_disc_videots_folder stringValue];
462     b_menus = [o_disc_dvd_menus state];
463
464     if ( [o_type isEqualToString: _NS("VCD")] )
465     {
466         if ( [o_device isEqualToString:
467                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
468             o_device = @"";
469         o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i,%i",
470                         o_device, i_title, i_chapter]; 
471     }
472     else if ( [o_type isEqualToString: _NS("DVD")] )
473     {
474         if ( [o_device isEqualToString:
475                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
476             o_device = @"";
477         if ( b_menus )
478             o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
479                             o_device]; 
480         else
481             o_mrl_string = [NSString stringWithFormat: @"dvdold://%@@%i,%i",
482                             o_device, i_title, i_chapter]; 
483     }
484     else /* VIDEO_TS folder */
485     {
486         if ( b_menus )
487             o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
488                             o_videots]; 
489         else
490             o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i,%i",
491                             o_videots, i_title, i_chapter]; 
492     }
493
494     [o_mrl setStringValue: o_mrl_string]; 
495 }
496
497 - (IBAction)openDiscMenusChanged:(id)sender
498 {
499     [self openDiscInfoChanged: nil];
500     [self openDiscTypeChanged: nil];
501 }
502
503 - (IBAction)openVTSBrowse:(id)sender
504 {
505     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
506
507     [o_open_panel setAllowsMultipleSelection: NO];
508     [o_open_panel setCanChooseFiles: NO];
509     [o_open_panel setCanChooseDirectories: YES];
510     [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
511     [o_open_panel setPrompt: _NS("Open")];
512
513     if( [o_open_panel runModalForDirectory: nil
514             file: nil types: nil] == NSOKButton )
515     {
516         NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
517         [o_disc_videots_folder setStringValue: o_dirname];
518         [self openDiscInfoChanged: nil];
519     }
520 }
521
522 - (IBAction)openNetModeChanged:(id)sender
523 {
524     NSString *o_mode;
525     BOOL b_udp = FALSE;
526     BOOL b_udpm = FALSE;
527     BOOL b_http = FALSE;
528
529     o_mode = [[o_net_mode selectedCell] title];
530
531     if( [o_mode isEqualToString: _NS("UDP/RTP")] ) b_udp = TRUE;   
532     else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) b_udpm = TRUE;
533     else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] ) b_http = TRUE;
534
535     [o_net_udp_port setEnabled: b_udp];
536     [o_net_udp_port_stp setEnabled: b_udp];
537     [o_net_udpm_addr setEnabled: b_udpm];
538     [o_net_udpm_port setEnabled: b_udpm];
539     [o_net_udpm_port_stp setEnabled: b_udpm];
540     [o_net_http_url setEnabled: b_http];
541
542     [self openNetInfoChanged: nil];
543 }
544
545 - (IBAction)openNetStepperChanged:(id)sender
546 {
547     int i_tag = [sender tag];
548
549     if( i_tag == 0 )
550     {
551         [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
552     }
553     else if( i_tag == 1 )
554     {
555         [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
556     }
557
558     [self openNetInfoChanged: nil];
559 }
560
561 - (void)openNetInfoChanged:(NSNotification *)o_notification
562 {
563     NSString *o_mode;
564     NSString *o_mrl_string = [NSString string];
565     intf_thread_t * p_intf = [NSApp getIntf];
566
567     o_mode = [[o_net_mode selectedCell] title];
568
569     if( [o_mode isEqualToString: _NS("UDP/RTP")] )
570     {
571         int i_port = [o_net_udp_port intValue];
572
573         o_mrl_string = [NSString stringWithString: @"udp://"]; 
574
575         if( i_port != config_GetInt( p_intf, "server-port" ) )
576         {
577             o_mrl_string = 
578                 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port]; 
579         } 
580     }
581     else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) 
582     {
583         NSString *o_addr = [o_net_udpm_addr stringValue];
584         int i_port = [o_net_udpm_port intValue];
585
586         o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr]; 
587
588         if( i_port != config_GetInt( p_intf, "server-port" ) )
589         {
590             o_mrl_string = 
591                 [o_mrl_string stringByAppendingFormat: @":%i", i_port]; 
592         } 
593     }
594     else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] )
595     {
596         NSString *o_url = [o_net_http_url stringValue];
597
598         if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
599               && ![o_url hasPrefix:@"mms"] )
600             o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
601         else
602             o_mrl_string = o_url;
603     }
604
605     [o_mrl setStringValue: o_mrl_string];
606 }
607
608 - (IBAction)openFile:(id)sender
609 {
610     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
611     
612     [o_open_panel setAllowsMultipleSelection: YES];
613     [o_open_panel setCanChooseDirectories: YES];
614     [o_open_panel setTitle: _NS("Open File")];
615     [o_open_panel setPrompt: _NS("Open")];
616     
617     if( [o_open_panel runModalForDirectory: nil
618             file: nil types: nil] == NSOKButton )
619     {
620         intf_thread_t * p_intf = [NSApp getIntf];
621         config_PutPsz( p_intf, "sout", NULL );
622         
623         NSArray *o_values = [[o_open_panel filenames]
624                 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
625         
626         config_PutPsz( p_intf, "sub-file", "" );
627         config_PutInt( p_intf, "sub-delay", 0 );
628         config_PutFloat( p_intf, "sub-fps", 0.0 );
629         config_PutPsz( p_intf, "sout", "" );
630         
631         [o_playlist appendArray: o_values atPos: -1 enqueue:NO];
632     }
633 }
634
635 - (IBAction)subsChanged:(id)sender
636 {
637     if ([o_file_sub_ckbox state] == NSOnState)
638     {
639         [o_file_sub_btn_settings setEnabled:YES];
640     }
641     else
642     {
643         [o_file_sub_btn_settings setEnabled:NO];
644     }
645 }
646
647 - (IBAction)subSettings:(id)sender
648 {
649     [NSApp beginSheet: o_file_sub_sheet
650         modalForWindow: [sender window]
651         modalDelegate: self
652         didEndSelector: NULL
653         contextInfo: nil];
654 }
655
656 - (IBAction)subFileBrowse:(id)sender
657 {
658     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
659     
660     [o_open_panel setAllowsMultipleSelection: NO];
661     [o_open_panel setTitle: _NS("Open File")];
662     [o_open_panel setPrompt: _NS("Open")];
663
664     if( [o_open_panel runModalForDirectory: nil 
665             file: nil types: nil] == NSOKButton )
666     {
667         NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
668         [o_file_sub_path setStringValue: o_filename];
669     }
670 }
671
672 - (IBAction)subOverride:(id)sender
673 {
674     BOOL b_state = [o_file_sub_override state];
675     [o_file_sub_delay setEnabled: b_state];
676     [o_file_sub_delay_stp setEnabled: b_state];
677     [o_file_sub_fps setEnabled: b_state];
678     [o_file_sub_fps_stp setEnabled: b_state];
679 }
680
681 - (IBAction)subDelayStepperChanged:(id)sender
682 {
683     [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
684 }
685
686 - (IBAction)subFpsStepperChanged:(id)sender;
687 {
688     [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
689 }
690
691 - (IBAction)subCloseSheet:(id)sender
692 {
693     [o_file_sub_sheet orderOut:sender];
694     [NSApp endSheet: o_file_sub_sheet];
695 }
696
697 - (IBAction)panelCancel:(id)sender
698 {
699     [NSApp stopModalWithCode: 0];
700 }
701
702 - (IBAction)panelOk:(id)sender
703 {
704     if( [[o_mrl stringValue] length] )
705     {
706         [NSApp stopModalWithCode: 1];
707     }
708     else
709     {
710         NSBeep();
711     }
712 }
713
714 @end