]> git.sesse.net Git - vlc/blob - modules/gui/macosx/open.m
* Brought the new options system to the OSX gui.
[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.36 2003/07/27 23:05:41 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 #include "output.h"
44
45 /*****************************************************************************
46  * GetEjectableMediaOfClass 
47  *****************************************************************************/
48 NSArray *GetEjectableMediaOfClass( const char *psz_class )
49 {
50     io_object_t next_media;
51     mach_port_t master_port;
52     kern_return_t kern_result;
53     NSArray *o_devices = nil;
54     NSMutableArray *p_list = nil;
55     io_iterator_t media_iterator;
56     CFMutableDictionaryRef classes_to_match;
57
58     kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
59     if( kern_result != KERN_SUCCESS )
60     {
61         return( nil );
62     }
63     
64     classes_to_match = IOServiceMatching( psz_class );
65     if( classes_to_match == NULL )
66     {
67         return( nil );
68     }
69     
70     CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectable ), 
71                           kCFBooleanTrue );
72     
73     kern_result = IOServiceGetMatchingServices( master_port, classes_to_match, 
74                                                 &media_iterator );
75     if( kern_result != KERN_SUCCESS )
76     {
77         return( nil );
78     }
79
80     p_list = [NSMutableArray arrayWithCapacity: 1];
81     
82     next_media = IOIteratorNext( media_iterator );
83     if( next_media != NULL )
84     {
85         char psz_buf[0x32];
86         size_t dev_path_length;
87         CFTypeRef str_bsd_path;
88     
89         do
90         {
91             str_bsd_path = IORegistryEntryCreateCFProperty( next_media,
92                                                             CFSTR( kIOBSDName ),
93                                                             kCFAllocatorDefault,
94                                                             0 );
95             if( str_bsd_path == NULL )
96             {
97                 IOObjectRelease( next_media );
98                 continue;
99             }
100             
101             snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
102             dev_path_length = strlen( psz_buf );
103             
104             if( CFStringGetCString( str_bsd_path,
105                                     (char*)&psz_buf + dev_path_length,
106                                     sizeof(psz_buf) - dev_path_length,
107                                     kCFStringEncodingASCII ) )
108             {
109                 [p_list addObject: [NSString stringWithCString: psz_buf]];
110             }
111             
112             CFRelease( str_bsd_path );
113             
114             IOObjectRelease( next_media );
115         
116         } while( ( next_media = IOIteratorNext( media_iterator ) ) != NULL );
117     }
118     
119     IOObjectRelease( media_iterator );
120
121     o_devices = [NSArray arrayWithArray: p_list];
122
123     return( o_devices );
124 }
125
126 /*****************************************************************************
127  * VLCOpen implementation 
128  *****************************************************************************/
129 @implementation VLCOpen
130
131 - (void)awakeFromNib
132 {
133     intf_thread_t * p_intf = [NSApp getIntf];
134
135     [o_panel setTitle: _NS("Open Source")];
136     [o_mrl_lbl setTitle: _NS("Media Resource Locator (MRL)")];
137     [o_ckbox_enqueue setTitle: _NS("Only enqueue in playlist, do not play")];
138
139     [o_btn_ok setTitle: _NS("OK")];
140     [o_btn_cancel setTitle: _NS("Cancel")];
141
142     [[o_tabview tabViewItemAtIndex: 0] setLabel: _NS("File")];
143     [[o_tabview tabViewItemAtIndex: 1] setLabel: _NS("Disc")];
144     [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
145
146     [o_file_btn_browse setTitle: _NS("Browse...")];
147     [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
148
149     [o_disc_device_lbl setStringValue: _NS("Device name")];
150     [o_disc_title_lbl setStringValue: _NS("Title")];
151     [o_disc_chapter_lbl setStringValue: _NS("Chapter")];
152     [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
153     [o_disc_dvd_menus setTitle: _NS("Use DVD menus")];
154
155     [[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
156     [[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
157     [[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")];
158     [[o_disc_type cellAtRow:3 column:0] setTitle: _NS("Audio CD")];
159
160     [o_net_udp_port_lbl setStringValue: _NS("Port")];
161     [o_net_udpm_addr_lbl setStringValue: _NS("Address")];
162     [o_net_udpm_port_lbl setStringValue: _NS("Port")];
163     [o_net_http_url_lbl setStringValue: _NS("URL")];
164
165     [[o_net_mode cellAtRow:0 column:0] setTitle: _NS("UDP/RTP")];
166     [[o_net_mode cellAtRow:1 column:0] setTitle: _NS("UDP/RTP Multicast")];
167     [[o_net_mode cellAtRow:2 column:0] setTitle: _NS("HTTP/FTP/MMS")];
168
169     [o_net_udp_port setIntValue: config_GetInt( p_intf, "server-port" )];
170     [o_net_udp_port_stp setIntValue: config_GetInt( p_intf, "server-port" )];
171
172     [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
173     [o_file_sub_btn_settings setTitle: _NS("Settings...")];
174     [o_file_sub_btn_browse setTitle: _NS("Browse...")];
175     [o_file_sub_override setTitle: _NS("Override")];
176     [o_file_sub_delay_lbl setStringValue: _NS("delay")];
177     [o_file_sub_delay_stp setEnabled: NO];
178     [o_file_sub_fps_lbl setStringValue: _NS("fps")];
179     [o_file_sub_fps_stp setEnabled: NO];
180     [o_file_sub_ok_btn setStringValue: _NS("OK")];
181     
182     [[NSNotificationCenter defaultCenter] addObserver: self
183         selector: @selector(openFilePathChanged:)
184         name: NSControlTextDidChangeNotification
185         object: o_file_path];
186
187     [[NSNotificationCenter defaultCenter] addObserver: self
188         selector: @selector(openDiscInfoChanged:)
189         name: NSControlTextDidChangeNotification
190         object: o_disc_device];
191     [[NSNotificationCenter defaultCenter] addObserver: self
192         selector: @selector(openDiscInfoChanged:)
193         name: NSControlTextDidChangeNotification
194         object: o_disc_title];
195     [[NSNotificationCenter defaultCenter] addObserver: self
196         selector: @selector(openDiscInfoChanged:)
197         name: NSControlTextDidChangeNotification
198         object: o_disc_chapter];
199     [[NSNotificationCenter defaultCenter] addObserver: self
200         selector: @selector(openDiscInfoChanged:)
201         name: NSControlTextDidChangeNotification
202         object: o_disc_videots_folder];
203
204     [[NSNotificationCenter defaultCenter] addObserver: self
205         selector: @selector(openNetInfoChanged:)
206         name: NSControlTextDidChangeNotification
207         object: o_net_udp_port];
208     [[NSNotificationCenter defaultCenter] addObserver: self
209         selector: @selector(openNetInfoChanged:)
210         name: NSControlTextDidChangeNotification
211         object: o_net_udpm_addr];
212     [[NSNotificationCenter defaultCenter] addObserver: self
213         selector: @selector(openNetInfoChanged:)
214         name: NSControlTextDidChangeNotification
215         object: o_net_udpm_port];
216     [[NSNotificationCenter defaultCenter] addObserver: self
217         selector: @selector(openNetInfoChanged:)
218         name: NSControlTextDidChangeNotification
219         object: o_net_http_url];
220 }
221
222 - (void)openTarget:(int)i_type
223 {
224     int i_result;
225
226     [o_tabview selectTabViewItemAtIndex: i_type];
227     [o_file_sub_ckbox setState: NSOffState];
228     
229     i_result = [NSApp runModalForWindow: o_panel];
230     [o_panel close];
231
232     if( i_result )
233     {
234         intf_thread_t * p_intf = [NSApp getIntf];
235
236         NSMutableDictionary *o_dic;
237         NSMutableArray *o_options = [NSMutableArray array];
238         BOOL b_enq = [o_ckbox_enqueue state] == NSOnState ? YES : NO;
239         o_dic = [NSMutableDictionary dictionaryWithObject: [o_mrl stringValue] forKey: @"ITEM_URL"];
240         
241         if( [o_file_sub_ckbox state] == NSOnState )
242         {
243             [o_options addObject: [NSString stringWithFormat: @"sub-file=%s", [[o_file_sub_path stringValue] UTF8String]]];
244             if( [o_file_sub_override state] == NSOnState )
245             {
246                 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
247                 [o_options addObject: [NSString stringWithFormat: @"sub-fps=%f", [o_file_sub_fps floatValue]]];
248             }
249         }
250         if( [o_output_ckbox state] == NSOnState )
251         {
252             [o_options addObject: [NSString stringWithFormat: @"sout=%@", [(VLCOutput *)o_sout_options getMRL]]];
253         }
254         [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
255         [o_playlist appendArray: [NSArray arrayWithObject: o_dic] 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 if ( [o_type isEqualToString: _NS("Audio CD")])
389         {
390             psz_class = kIOCDMediaClass;
391             o_disc = o_type;
392             b_menus = 0; b_title_chapter = 0;
393             [o_disc_dvd_menus setState: FALSE];
394         }
395         else
396         {
397             psz_class = kIODVDMediaClass;
398             o_disc = o_type;
399             b_menus = 1;
400         }
401     
402         o_devices = GetEjectableMediaOfClass( psz_class );
403         if ( o_devices != nil )
404         {
405             int i_devices = [o_devices count];
406         
407             if ( i_devices )
408             {
409                 int i;
410         
411                 for( i = 0; i < i_devices; i++ )
412                 {
413                     [o_disc_device 
414                         addItemWithObjectValue: [o_devices objectAtIndex: i]];
415                 }
416
417                 [o_disc_device selectItemAtIndex: 0];
418             }
419             else
420             {
421                 [o_disc_device setStringValue: 
422                     [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
423             }
424         }
425     }
426
427     [o_disc_device setEnabled: b_device];
428     [o_disc_title setEnabled: b_title_chapter];
429     [o_disc_title_stp setEnabled: b_title_chapter];
430     [o_disc_chapter setEnabled: b_title_chapter];
431     [o_disc_chapter_stp setEnabled: b_title_chapter];
432     [o_disc_videots_folder setEnabled: !b_device];
433     [o_disc_videots_btn_browse setEnabled: !b_device];
434     [o_disc_dvd_menus setEnabled: b_menus];
435
436     [self openDiscInfoChanged: nil];
437 }
438
439 - (IBAction)openDiscStepperChanged:(id)sender
440 {
441     int i_tag = [sender tag];
442
443     if( i_tag == 0 )
444     {
445         [o_disc_title setIntValue: [o_disc_title_stp intValue]];
446     }
447     else if( i_tag == 1 )
448     {
449         [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
450     }
451
452     [self openDiscInfoChanged: nil];
453 }
454
455 - (void)openDiscInfoChanged:(NSNotification *)o_notification
456 {
457     NSString *o_type;
458     NSString *o_device;
459     NSString *o_videots;
460     NSString *o_mrl_string;
461     int i_title, i_chapter;
462     vlc_bool_t b_menus;
463
464     o_type = [[o_disc_type selectedCell] title];
465     o_device = [o_disc_device stringValue];
466     i_title = [o_disc_title intValue];
467     i_chapter = [o_disc_chapter intValue];
468     o_videots = [o_disc_videots_folder stringValue];
469     b_menus = [o_disc_dvd_menus state];
470
471     if ( [o_type isEqualToString: _NS("VCD")] )
472     {
473         if ( [o_device isEqualToString:
474                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
475             o_device = @"";
476         o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i,%i",
477                         o_device, i_title, i_chapter]; 
478     }
479     else if ( [o_type isEqualToString: _NS("Audio CD")] )
480     {
481         if ( [o_device isEqualToString:
482                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
483             o_device = @"";
484         o_mrl_string = [NSString stringWithFormat: @"cdda://%@",
485                         o_device]; 
486     }
487     else if ( [o_type isEqualToString: _NS("DVD")] )
488     {
489         if ( [o_device isEqualToString:
490                 [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
491             o_device = @"";
492         if ( b_menus )
493             o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
494                             o_device]; 
495         else
496             o_mrl_string = [NSString stringWithFormat: @"dvdold://%@@%i,%i",
497                             o_device, i_title, i_chapter]; 
498     }
499     else /* VIDEO_TS folder */
500     {
501         if ( b_menus )
502             o_mrl_string = [NSString stringWithFormat: @"dvdplay://%@",
503                             o_videots]; 
504         else
505             o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i,%i",
506                             o_videots, i_title, i_chapter]; 
507     }
508
509     [o_mrl setStringValue: o_mrl_string]; 
510 }
511
512 - (IBAction)openDiscMenusChanged:(id)sender
513 {
514     [self openDiscInfoChanged: nil];
515     [self openDiscTypeChanged: nil];
516 }
517
518 - (IBAction)openVTSBrowse:(id)sender
519 {
520     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
521
522     [o_open_panel setAllowsMultipleSelection: NO];
523     [o_open_panel setCanChooseFiles: NO];
524     [o_open_panel setCanChooseDirectories: YES];
525     [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
526     [o_open_panel setPrompt: _NS("Open")];
527
528     if( [o_open_panel runModalForDirectory: nil
529             file: nil types: nil] == NSOKButton )
530     {
531         NSString *o_dirname = [[o_open_panel filenames] objectAtIndex: 0];
532         [o_disc_videots_folder setStringValue: o_dirname];
533         [self openDiscInfoChanged: nil];
534     }
535 }
536
537 - (IBAction)openNetModeChanged:(id)sender
538 {
539     NSString *o_mode;
540     BOOL b_udp = FALSE;
541     BOOL b_udpm = FALSE;
542     BOOL b_http = FALSE;
543
544     o_mode = [[o_net_mode selectedCell] title];
545
546     if( [o_mode isEqualToString: _NS("UDP/RTP")] ) b_udp = TRUE;   
547     else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) b_udpm = TRUE;
548     else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] ) b_http = TRUE;
549
550     [o_net_udp_port setEnabled: b_udp];
551     [o_net_udp_port_stp setEnabled: b_udp];
552     [o_net_udpm_addr setEnabled: b_udpm];
553     [o_net_udpm_port setEnabled: b_udpm];
554     [o_net_udpm_port_stp setEnabled: b_udpm];
555     [o_net_http_url setEnabled: b_http];
556
557     [self openNetInfoChanged: nil];
558 }
559
560 - (IBAction)openNetStepperChanged:(id)sender
561 {
562     int i_tag = [sender tag];
563
564     if( i_tag == 0 )
565     {
566         [o_net_udp_port setIntValue: [o_net_udp_port_stp intValue]];
567     }
568     else if( i_tag == 1 )
569     {
570         [o_net_udpm_port setIntValue: [o_net_udpm_port_stp intValue]];
571     }
572
573     [self openNetInfoChanged: nil];
574 }
575
576 - (void)openNetInfoChanged:(NSNotification *)o_notification
577 {
578     NSString *o_mode;
579     NSString *o_mrl_string = [NSString string];
580     intf_thread_t * p_intf = [NSApp getIntf];
581
582     o_mode = [[o_net_mode selectedCell] title];
583
584     if( [o_mode isEqualToString: _NS("UDP/RTP")] )
585     {
586         int i_port = [o_net_udp_port intValue];
587
588         o_mrl_string = [NSString stringWithString: @"udp://"]; 
589
590         if( i_port != config_GetInt( p_intf, "server-port" ) )
591         {
592             o_mrl_string = 
593                 [o_mrl_string stringByAppendingFormat: @"@:%i", i_port]; 
594         } 
595     }
596     else if( [o_mode isEqualToString: _NS("UDP/RTP Multicast")] ) 
597     {
598         NSString *o_addr = [o_net_udpm_addr stringValue];
599         int i_port = [o_net_udpm_port intValue];
600
601         o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr]; 
602
603         if( i_port != config_GetInt( p_intf, "server-port" ) )
604         {
605             o_mrl_string = 
606                 [o_mrl_string stringByAppendingFormat: @":%i", i_port]; 
607         } 
608     }
609     else if( [o_mode isEqualToString: _NS("HTTP/FTP/MMS")] )
610     {
611         NSString *o_url = [o_net_http_url stringValue];
612
613         if ( ![o_url hasPrefix:@"http:"] && ![o_url hasPrefix:@"ftp:"]
614               && ![o_url hasPrefix:@"mms"] )
615             o_mrl_string = [NSString stringWithFormat: @"http://%@", o_url];
616         else
617             o_mrl_string = o_url;
618     }
619
620     [o_mrl setStringValue: o_mrl_string];
621 }
622
623 - (IBAction)openFile:(id)sender
624 {
625     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
626     int i;
627     
628     [o_open_panel setAllowsMultipleSelection: YES];
629     [o_open_panel setCanChooseDirectories: YES];
630     [o_open_panel setTitle: _NS("Open File")];
631     [o_open_panel setPrompt: _NS("Open")];
632     
633     if( [o_open_panel runModalForDirectory: nil
634             file: nil types: nil] == NSOKButton )
635     {
636         NSArray *o_array = [NSArray array];
637         NSArray *o_values = [[o_open_panel filenames]
638                 sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
639
640         for( i = 0; i < [o_values count]; i++)
641         {
642             NSDictionary *o_dic;
643             o_dic = [NSDictionary dictionaryWithObject:[o_values objectAtIndex:i] forKey:@"ITEM_URL"];
644             o_array = [o_array arrayByAddingObject: o_dic];
645         }
646         [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
647     }
648 }
649
650 - (IBAction)subsChanged:(id)sender
651 {
652     if ([o_file_sub_ckbox state] == NSOnState)
653     {
654         [o_file_sub_btn_settings setEnabled:YES];
655     }
656     else
657     {
658         [o_file_sub_btn_settings setEnabled:NO];
659     }
660 }
661
662 - (IBAction)subSettings:(id)sender
663 {
664     [NSApp beginSheet: o_file_sub_sheet
665         modalForWindow: [sender window]
666         modalDelegate: self
667         didEndSelector: NULL
668         contextInfo: nil];
669 }
670
671 - (IBAction)subFileBrowse:(id)sender
672 {
673     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
674     
675     [o_open_panel setAllowsMultipleSelection: NO];
676     [o_open_panel setTitle: _NS("Open File")];
677     [o_open_panel setPrompt: _NS("Open")];
678
679     if( [o_open_panel runModalForDirectory: nil 
680             file: nil types: nil] == NSOKButton )
681     {
682         NSString *o_filename = [[o_open_panel filenames] objectAtIndex: 0];
683         [o_file_sub_path setStringValue: o_filename];
684     }
685 }
686
687 - (IBAction)subOverride:(id)sender
688 {
689     BOOL b_state = [o_file_sub_override state];
690     [o_file_sub_delay setEnabled: b_state];
691     [o_file_sub_delay_stp setEnabled: b_state];
692     [o_file_sub_fps setEnabled: b_state];
693     [o_file_sub_fps_stp setEnabled: b_state];
694 }
695
696 - (IBAction)subDelayStepperChanged:(id)sender
697 {
698     [o_file_sub_delay setIntValue: [o_file_sub_delay_stp intValue]];
699 }
700
701 - (IBAction)subFpsStepperChanged:(id)sender;
702 {
703     [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
704 }
705
706 - (IBAction)subCloseSheet:(id)sender
707 {
708     [o_file_sub_sheet orderOut:sender];
709     [NSApp endSheet: o_file_sub_sheet];
710 }
711
712 - (IBAction)panelCancel:(id)sender
713 {
714     [NSApp stopModalWithCode: 0];
715 }
716
717 - (IBAction)panelOk:(id)sender
718 {
719     if( [[o_mrl stringValue] length] )
720     {
721         [NSApp stopModalWithCode: 1];
722     }
723     else
724     {
725         NSBeep();
726     }
727 }
728
729 @end