]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/open.m
macosx: Repack module_config_t.
[vlc] / modules / gui / macosx / open.m
index 9c944b974fee36890cd0a5b66178bb9acf230578..6f7d4b84b4d085e02f81b1105332b0916bf6420d 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * open.m: Open dialogues for VLC's MacOS X port
  *****************************************************************************
- * Copyright (C) 2002-2011 the VideoLAN team
+ * Copyright (C) 2002-2012 VLC authors and VideoLAN
  * $Id$
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <sys/param.h>                                    /* for MAXPATHLEN */
-#include <string.h>
+#import <stdlib.h>                                      /* malloc(), free() */
+#import <sys/param.h>                                    /* for MAXPATHLEN */
 
-#include <paths.h>
-#include <IOKit/IOKitLib.h>
-#include <IOKit/IOBSD.h>
-#include <IOKit/storage/IOMedia.h>
-#include <IOKit/storage/IOCDMedia.h>
-#include <IOKit/storage/IODVDMedia.h>
+#import "CompatibilityFixes.h"
+
+#import <paths.h>
+#import <IOKit/IOBSD.h>
+#import <IOKit/storage/IOMedia.h>
+#import <IOKit/storage/IOCDMedia.h>
+#import <IOKit/storage/IODVDMedia.h>
+#import <IOKit/storage/IOBDMedia.h>
+#import <Cocoa/Cocoa.h>
+#import <QTKit/QTKit.h>
 
 #import "intf.h"
 #import "playlist.h"
 #import "output.h"
 #import "eyetv.h"
 
-#include <vlc_url.h>
+#import <vlc_url.h>
 
+NSArray *qtkvideoDevices;
+NSArray *qtkaudioDevices;
 #define setEyeTVUnconnected \
-[o_capture_lbl setStringValue: _NS("No device connected")]; \
-[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.")]; \
+[o_capture_lbl setStringValue: _NS("No device is selected")]; \
+[o_capture_long_lbl setStringValue: _NS("No device is selected.\n\nChoose available device in above pull-down menu.\n")]; \
 [o_capture_lbl displayIfNeeded]; \
 [o_capture_long_lbl displayIfNeeded]; \
 [self showCaptureView: o_capture_label_view]
 
-
-/*****************************************************************************
- * GetEjectableMediaOfClass
- *****************************************************************************/
-NSArray *GetEjectableMediaOfClass( const char *psz_class )
+struct display_info_t
 {
-    io_object_t next_media;
-    mach_port_t master_port;
-    kern_return_t kern_result;
-    NSArray *o_devices = nil;
-    NSMutableArray *p_list = nil;
-    io_iterator_t media_iterator;
-    CFMutableDictionaryRef classes_to_match;
-
-    kern_result = IOMasterPort( MACH_PORT_NULL, &master_port );
-    if( kern_result != KERN_SUCCESS )
-    {
-        return( nil );
-    }
-    classes_to_match = IOServiceMatching( psz_class );
-    if( classes_to_match == NULL )
-    {
-        return( nil );
-    }
-    CFDictionarySetValue( classes_to_match, CFSTR( kIOMediaEjectableKey ),
-                          kCFBooleanTrue );
-    kern_result = IOServiceGetMatchingServices( master_port, classes_to_match,
-                                                &media_iterator );
-    if( kern_result != KERN_SUCCESS )
-    {
-        return( nil );
-    }
-
-    p_list = [NSMutableArray arrayWithCapacity: 1];
-    next_media = IOIteratorNext( media_iterator );
-    if( next_media )
-    {
-        char psz_buf[0x32];
-        size_t dev_path_length;
-        CFTypeRef str_bsd_path;
-        do
-        {
-            str_bsd_path = IORegistryEntryCreateCFProperty( next_media,
-                                                            CFSTR( kIOBSDNameKey ),
-                                                            kCFAllocatorDefault,
-                                                            0 );
-            if( str_bsd_path == NULL )
-            {
-                IOObjectRelease( next_media );
-                continue;
-            }
-            snprintf( psz_buf, sizeof(psz_buf), "%s%c", _PATH_DEV, 'r' );
-            dev_path_length = strlen( psz_buf );
-            if( CFStringGetCString( str_bsd_path,
-                                    (char*)&psz_buf + dev_path_length,
-                                    sizeof(psz_buf) - dev_path_length,
-                                    kCFStringEncodingASCII ) )
-            {
-                [p_list addObject: [NSString stringWithUTF8String: psz_buf]];
-            }
-            CFRelease( str_bsd_path );
-            IOObjectRelease( next_media );
-        } while( ( next_media = IOIteratorNext( media_iterator ) ) );
-    }
-    IOObjectRelease( media_iterator );
-
-    o_devices = [NSArray arrayWithArray: p_list];
-
-    return( o_devices );
-}
+    CGRect rect;
+    CGDirectDisplayID id;
+};
 
 /*****************************************************************************
  * VLCOpen implementation
  *****************************************************************************/
 @implementation VLCOpen
 
+#pragma mark -
+#pragma mark Init
+
 static VLCOpen *_o_sharedMainInstance = nil;
 
 + (VLCOpen *)sharedInstance
@@ -156,19 +88,38 @@ static VLCOpen *_o_sharedMainInstance = nil;
         _o_sharedMainInstance = [super init];
         p_intf = VLCIntf;
     }
+
     return _o_sharedMainInstance;
 }
 
 - (void)dealloc
 {
+    [o_specialMediaFolders release];
+    [o_opticalDevices release];
     if( o_file_slave_path )
         [o_file_slave_path release];
+    [o_mrl release];
+    if (o_sub_path)
+        [o_sub_path release];
+    [o_currentOpticalMediaIconView release];
+    [o_currentOpticalMediaView release];
+    int i;
+    for( i = 0; i < [o_displayInfos count]; i ++ )
+    {
+        NSValue *v = [o_displayInfos objectAtIndex:i];
+        free( [v pointerValue] );
+    }
+    [o_displayInfos removeAllObjects];
+    [o_displayInfos release];
+
     [super dealloc];
 }
 
 - (void)awakeFromNib
 {
+    if (OSX_LION)
+        [o_panel setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
+
     [o_panel setTitle: _NS("Open Source")];
     [o_mrl_lbl setStringValue: _NS("Media Resource Locator (MRL)")];
 
@@ -180,22 +131,51 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [[o_tabview tabViewItemAtIndex: 2] setLabel: _NS("Network")];
     [[o_tabview tabViewItemAtIndex: 3] setLabel: _NS("Capture")];
 
+    [o_file_name setStringValue: @""];
+    [o_file_name_stub setStringValue: _NS("Choose a file")];
+    [o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
     [o_file_btn_browse setTitle: _NS("Browse...")];
     [o_file_stream setTitle: _NS("Treat as a pipe rather than as a file")];
+    [o_file_stream setHidden: NO];
     [o_file_slave_ckbox setTitle: _NS("Play another media synchronously")];
     [o_file_slave_select_btn setTitle: _NS("Choose...")];
-    [o_file_slave_filename_txt setStringValue: @""];
-
-    [o_disc_device_lbl setStringValue: _NS("Device name")];
-    [o_disc_title_lbl setStringValue: _NS("Title")];
-    [o_disc_chapter_lbl setStringValue: _NS("Chapter")];
-    [o_disc_videots_btn_browse setTitle: _NS("Browse...")];
-    [o_disc_dvd_menus setTitle: _NS("No DVD menus")];
-
-    [[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")];
-    [[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")];
-    [[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")];
-    [[o_disc_type cellAtRow:3 column:0] setTitle: _NS("Audio CD")];
+    [o_file_slave_filename_lbl setStringValue: @""];
+    [o_file_slave_icon_well setImage: NULL];
+    [o_file_subtitles_filename_lbl setStringValue: @""];
+    [o_file_subtitles_icon_well setImage: NULL];
+    [o_file_custom_timing_ckb setTitle: _NS("Custom playback")];
+    [o_file_starttime_lbl setStringValue: _NS("Start time")];
+    [o_file_starttime_fld setStringValue: @""];
+    [o_file_stoptime_lbl setStringValue: _NS("Stop time")];
+    [o_file_stoptime_fld setStringValue: @""];
+
+    [o_disc_selector_pop removeAllItems];
+    [o_disc_selector_pop setHidden: NO];
+    NSString *o_videots = _NS("Open VIDEO_TS folder");
+    NSString *o_bdmv = _NS("Open BDMV folder");
+    [o_disc_nodisc_lbl setStringValue: _NS("Insert Disc")];
+    [o_disc_nodisc_videots_btn setTitle: o_videots];
+    [o_disc_nodisc_bdmv_btn setTitle: o_bdmv];
+    [o_disc_audiocd_lbl setStringValue: _NS("Audio CD")];
+    [o_disc_audiocd_trackcount_lbl setStringValue: @""];
+    [o_disc_audiocd_videots_btn setTitle: o_videots];
+    [o_disc_audiocd_bdmv_btn setTitle: o_bdmv];
+    [o_disc_dvd_lbl setStringValue: @""];
+    [o_disc_dvd_disablemenus_btn setTitle: _NS("Disable DVD menus")];
+    [o_disc_dvd_videots_btn setTitle: o_videots];
+    [o_disc_dvd_bdmv_btn setTitle: o_bdmv];
+    [o_disc_dvdwomenus_lbl setStringValue: @""];
+    [o_disc_dvdwomenus_enablemenus_btn setTitle: _NS("Enable DVD menus")];
+    [o_disc_dvdwomenus_videots_btn setTitle: o_videots];
+    [o_disc_dvdwomenus_bdmv_btn setTitle: o_bdmv];
+    [o_disc_dvdwomenus_title_lbl setStringValue: _NS("Title")];
+    [o_disc_dvdwomenus_chapter_lbl setStringValue: _NS("Chapter")];
+    [o_disc_vcd_title_lbl setStringValue: _NS("Title")];
+    [o_disc_vcd_chapter_lbl setStringValue: _NS("Chapter")];
+    [o_disc_vcd_videots_btn setTitle: o_videots];
+    [o_disc_vcd_bdmv_btn setTitle: o_bdmv];
+    [o_disc_bd_videots_btn setTitle: o_videots];
+    [o_disc_bd_bdmv_btn setTitle: o_bdmv];
 
     [o_net_udp_port_lbl setStringValue: _NS("Port")];
     [o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
@@ -219,12 +199,13 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_eyetv_chn_bgbar setUsesThreadedAnimation: YES];
 
     [o_capture_mode_pop removeAllItems];
-    [o_capture_mode_pop addItemWithTitle: @"iSight"];
+    [o_capture_mode_pop addItemWithTitle: _NS("Video Device")];
+    [o_capture_mode_pop addItemWithTitle: _NS("Audio Device")];
     [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
     [o_capture_mode_pop addItemWithTitle: @"EyeTV"];
-    [o_screen_lbl setStringValue: _NS("Screen Capture Input")];
-    [o_screen_long_lbl setStringValue: _NS("This facility allows you to process your screen's output.")];
+    [o_screen_long_lbl setStringValue: _NS("This input allows you to save, stream or display your current screen contents.")];
     [o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
+    [o_screen_screen_lbl setStringValue: _NS("Screen:")];
     [o_screen_left_lbl setStringValue: _NS("Subscreen left:")];
     [o_screen_top_lbl setStringValue: _NS("Subscreen top:")];
     [o_screen_width_lbl setStringValue: _NS("Subscreen width:")];
@@ -238,30 +219,63 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_eyetv_noInstanceLong_lbl setStringValue: _NS("VLC could not connect to EyeTV.\nMake sure that you installed VLC's EyeTV plugin.")];
     [o_eyetv_launchEyeTV_btn setTitle: _NS("Launch EyeTV now")];
     [o_eyetv_getPlugin_btn setTitle: _NS("Download Plugin")];
+    [o_qtk_long_lbl setStringValue: _NS("This input allows you to process input signals from QuickTime-compatible video devices.\nSimultaneous live Audio input is not supported.")];
+    [o_capture_width_lbl setStringValue: _NS("Image width:")];
+    [o_capture_height_lbl setStringValue: _NS("Image height:")];
 
-    [self setSubPanel];
+    [self qtkvideoDevices];
+    [o_qtk_device_pop removeAllItems];
+    msg_Dbg( VLCIntf, "Found %lu video capture devices", [qtkvideoDevices count] );
 
-    [[NSNotificationCenter defaultCenter] addObserver: self
-        selector: @selector(openFilePathChanged:)
-        name: NSControlTextDidChangeNotification
-        object: o_file_path];
+    if([qtkvideoDevices count] >= 1)
+    {
+        if (!qtk_currdevice_uid) {
+            qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID]
+                                                                stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+        }
+        NSUInteger deviceCount = [qtkvideoDevices count];
+        for(int ivideo = 0; ivideo < deviceCount; ivideo++){
+            QTCaptureDevice *qtk_device;
+            qtk_device = [qtkvideoDevices objectAtIndex:ivideo];
+            [o_qtk_device_pop addItemWithTitle: [qtk_device localizedDisplayName]];
+            if([[[qtk_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtk_currdevice_uid]){
+                [o_qtk_device_pop selectItemAtIndex:ivideo];
+            }
+        }
+    }
+    else
+    {
+        [o_qtk_device_pop addItemWithTitle: _NS("None")];
+        [qtk_currdevice_uid release];
+    }
 
-    [[NSNotificationCenter defaultCenter] addObserver: self
-        selector: @selector(openDiscInfoChanged:)
-        name: NSControlTextDidChangeNotification
-        object: o_disc_device];
-    [[NSNotificationCenter defaultCenter] addObserver: self
-        selector: @selector(openDiscInfoChanged:)
-        name: NSControlTextDidChangeNotification
-        object: o_disc_title];
-    [[NSNotificationCenter defaultCenter] addObserver: self
-        selector: @selector(openDiscInfoChanged:)
-        name: NSControlTextDidChangeNotification
-        object: o_disc_chapter];
-    [[NSNotificationCenter defaultCenter] addObserver: self
-        selector: @selector(openDiscInfoChanged:)
-        name: NSControlTextDidChangeNotification
-        object: o_disc_videots_folder];
+    [self qtkaudioDevices];
+    [o_qtkaudio_device_pop removeAllItems];
+    msg_Dbg( VLCIntf, "Found %lu audio capture devices", [qtkaudioDevices count] );
+
+    if([qtkaudioDevices count] >= 1)
+    {
+        if (!qtkaudio_currdevice_uid) {
+            qtkaudio_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeSound] uniqueID]
+                                  stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+        }
+        NSUInteger deviceCount = [qtkaudioDevices count];
+        for(int iaudio = 0; iaudio < deviceCount; iaudio++){
+            QTCaptureDevice *qtkaudio_device;
+            qtkaudio_device = [qtkaudioDevices objectAtIndex:iaudio];
+            [o_qtkaudio_device_pop addItemWithTitle: [qtkaudio_device localizedDisplayName]];
+            if([[[qtkaudio_device uniqueID]stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] isEqualToString:qtkaudio_currdevice_uid]){
+                [o_qtkaudio_device_pop selectItemAtIndex:iaudio];
+            }
+        }
+    }
+    else
+    {
+        [o_qtkaudio_device_pop addItemWithTitle: _NS("None")];
+        [qtkaudio_currdevice_uid release];
+    }
+
+    [self setSubPanel];
 
     [[NSNotificationCenter defaultCenter] addObserver: self
         selector: @selector(openNetInfoChanged:)
@@ -296,6 +310,37 @@ static VLCOpen *_o_sharedMainInstance = nil;
                                              selector: @selector(textFieldWasClicked:)
                                                  name: @"VLCOpenTextFieldWasClicked"
                                                object: nil];
+
+    /* we want to be notified about removed or added media */
+    o_specialMediaFolders = [[NSMutableArray alloc] init];
+    o_opticalDevices = [[NSMutableArray alloc] init];
+    o_displayInfos = [[NSMutableArray alloc] init];
+    NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
+
+    [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
+    [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
+    [self performSelector:@selector(scanOpticalMedia:) withObject:nil afterDelay:2.0];
+    [self performSelector:@selector(qtkChanged:) withObject:nil afterDelay:2.5];
+    [self performSelector:@selector(qtkAudioChanged:) withObject:nil afterDelay:3.0];
+
+    [self setMRL: @""];
+}
+
+- (void)setMRL:(NSString *)newMRL
+{
+    [o_mrl release];
+    o_mrl = newMRL;
+    [o_mrl retain];
+    [o_mrl_fld setStringValue: newMRL];
+    if ([o_mrl length] > 0)
+        [o_btn_ok setEnabled: YES];
+    else
+        [o_btn_ok setEnabled: NO];
+}
+
+- (NSString *)MRL
+{
+    return o_mrl;
 }
 
 - (void)setSubPanel
@@ -304,9 +349,12 @@ static VLCOpen *_o_sharedMainInstance = nil;
     module_config_t * p_item;
 
     [o_file_sub_ckbox setTitle: _NS("Load subtitles file:")];
-    [o_file_sub_btn_settings setTitle: _NS("Settings...")];
+    [o_file_sub_path_lbl setStringValue: _NS("Choose a file")];
+    [o_file_sub_path_lbl setHidden: NO];
+    [o_file_sub_path_fld setStringValue: @""];
+    [o_file_sub_btn_settings setTitle: _NS("Choose...")];
     [o_file_sub_btn_browse setTitle: _NS("Browse...")];
-    [o_file_sub_override setTitle: _NS("Override parametters")];
+    [o_file_sub_override setTitle: _NS("Override parameters")];
     [o_file_sub_delay_lbl setStringValue: _NS("Delay")];
     [o_file_sub_delay_stp setEnabled: NO];
     [o_file_sub_fps_lbl setStringValue: _NS("FPS")];
@@ -325,11 +373,11 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     if( p_item )
     {
-        for( i_index = 0; p_item->ppsz_list && p_item->ppsz_list[i_index];
+        for( i_index = 0; p_item->list.psz && p_item->list.psz[i_index];
              i_index++ )
         {
             [o_file_sub_encoding_pop addItemWithTitle:
-                [NSString stringWithUTF8String: p_item->ppsz_list[i_index]]];
+                [NSString stringWithUTF8String: p_item->list.psz[i_index]]];
         }
         [o_file_sub_encoding_pop selectItemWithTitle:
                 [NSString stringWithUTF8String: p_item->value.psz]];
@@ -339,11 +387,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     if ( p_item )
     {
-        for ( i_index = 0; i_index < p_item->i_list; i_index++ )
+        for ( i_index = 0; i_index < p_item->list_count; i_index++ )
         {
             [o_file_sub_align_pop addItemWithTitle:
-                [NSString stringWithUTF8String:
-                p_item->ppsz_list_text[i_index]]];
+             _NS(p_item->list_text[i_index])];
         }
         [o_file_sub_align_pop selectItemAtIndex: p_item->value.i];
     }
@@ -352,12 +399,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     if ( p_item )
     {
-        for ( i_index = 0; i_index < p_item->i_list; i_index++ )
+        for ( i_index = 0; i_index < p_item->list_count; i_index++ )
         {
-            [o_file_sub_size_pop addItemWithTitle:
-                [NSString stringWithUTF8String:
-                p_item->ppsz_list_text[i_index]]];
-            if ( p_item->value.i == p_item->pi_list[i_index] )
+            [o_file_sub_size_pop addItemWithTitle: _NS(p_item->list_text[i_index])];
+            if ( p_item->value.i == p_item->list.i[i_index] )
             {
                 [o_file_sub_size_pop selectItemAtIndex: i_index];
             }
@@ -373,7 +418,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
     [o_tabview selectTabViewItemAtIndex: i_type];
     [o_file_sub_ckbox setState: NSOffState];
+
     i_result = [NSApp runModalForWindow: o_panel];
     [o_panel close];
 
@@ -381,14 +426,13 @@ static VLCOpen *_o_sharedMainInstance = nil;
     {
         NSMutableDictionary *o_dic;
         NSMutableArray *o_options = [NSMutableArray array];
-        unsigned int i;
 
-        o_dic = [NSMutableDictionary dictionaryWithObject: [o_mrl stringValue] forKey: @"ITEM_URL"];
+        o_dic = [NSMutableDictionary dictionaryWithObject: [self MRL] forKey: @"ITEM_URL"];
         if( [o_file_sub_ckbox state] == NSOnState )
         {
             module_config_t * p_item;
 
-            [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", [o_file_sub_path stringValue]]];
+            [o_options addObject: [NSString stringWithFormat: @"sub-file=%@", o_sub_path]];
             if( [o_file_sub_override state] == NSOnState )
             {
                 [o_options addObject: [NSString stringWithFormat: @"sub-delay=%i", (int)( [o_file_sub_delay intValue] * 10 )]];
@@ -398,7 +442,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
                     @"subsdec-encoding=%@",
                     [o_file_sub_encoding_pop titleOfSelectedItem]]];
             [o_options addObject: [NSString stringWithFormat:
-                    @"subsdec-align=%i",
+                    @"subsdec-align=%li",
                     [o_file_sub_align_pop indexOfSelectedItem]]];
 
             p_item = config_FindConfig( VLC_OBJECT(p_intf),
@@ -408,15 +452,36 @@ static VLCOpen *_o_sharedMainInstance = nil;
             {
                 [o_options addObject: [NSString stringWithFormat:
                     @"freetype-rel-fontsize=%i",
-                    p_item->pi_list[[o_file_sub_size_pop indexOfSelectedItem]]]];
+                    p_item->list.i[[o_file_sub_size_pop indexOfSelectedItem]]]];
             }
         }
+        NSArray * components = [[o_file_starttime_fld stringValue] componentsSeparatedByString:@":"];
+        NSUInteger componentCount = [components count];
+        NSInteger tempValue;
+        if( componentCount == 1 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] );
+        else if( componentCount == 2 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue] );
+        else if( componentCount == 3 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue] );
+        if (tempValue > 0)
+            [o_options addObject: [NSString stringWithFormat:@"start-time=%li", tempValue]];
+        components = [[o_file_stoptime_fld stringValue] componentsSeparatedByString:@":"];
+        componentCount = [components count];
+        if( componentCount == 1 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] );
+        else if( componentCount == 2 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 60 + [[components objectAtIndex:1] intValue] );
+        else if( componentCount == 3 )
+            tempValue = 1000000 * ( [[components objectAtIndex:0] intValue] * 3600 + [[components objectAtIndex:1] intValue] * 60 + [[components objectAtIndex:2] intValue] );
+        if (tempValue > 0)
+            [o_options addObject: [NSString stringWithFormat:@"stop-time=%li", tempValue]];
         if( [o_output_ckbox state] == NSOnState )
         {
-            for (i = 0 ; i < [[o_sout_options mrl] count] ; i++)
+            NSUInteger count = [[o_sout_options mrl] count];
+            for (NSUInteger i = 0 ; i < count ; i++)
             {
-                [o_options addObject: [NSString stringWithString:
-                      [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
+                [o_options addObject: [NSString stringWithString: [[(VLCOutput *)o_sout_options mrl] objectAtIndex: i]]];
             }
         }
         if( [o_file_slave_ckbox state] && o_file_slave_path )
@@ -424,7 +489,13 @@ static VLCOpen *_o_sharedMainInstance = nil;
         if( [[[o_tabview selectedTabViewItem] label] isEqualToString: _NS("Capture")] )
         {
             if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
+            {
+                int selected_index = [o_screen_screen_pop indexOfSelectedItem];
+                NSValue *v = [o_displayInfos objectAtIndex:selected_index];
+                struct display_info_t *item = ( struct display_info_t * )[v pointerValue];
+
                 [o_options addObject: [NSString stringWithFormat: @"screen-fps=%f", [o_screen_fps_fld floatValue]]];
+                [o_options addObject: [NSString stringWithFormat: @"screen-display-id=%i", item->id]];
                 [o_options addObject: [NSString stringWithFormat: @"screen-left=%i", [o_screen_left_fld intValue]]];
                 [o_options addObject: [NSString stringWithFormat: @"screen-top=%i", [o_screen_top_fld intValue]]];
                 [o_options addObject: [NSString stringWithFormat: @"screen-width=%i", [o_screen_width_fld intValue]]];
@@ -433,17 +504,66 @@ static VLCOpen *_o_sharedMainInstance = nil;
                     [o_options addObject: @"screen-follow-mouse"];
                 else
                     [o_options addObject: @"no-screen-follow-mouse"];
+            }
+            else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Video Device")] )
+            {
+                [o_options addObject: [NSString stringWithFormat: @"qtcapture-width=%i", [o_capture_width_fld intValue]]];
+                [o_options addObject: [NSString stringWithFormat: @"qtcapture-height=%i", [o_capture_height_fld intValue]]];
+            }
         }
 
         /* apply the options to our item(s) */
         [o_dic setObject: (NSArray *)[o_options copy] forKey: @"ITEM_OPTIONS"];
         if( b_autoplay )
-            [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
+            [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:NO];
         else
-            [o_playlist appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
+            [[[VLCMain sharedInstance] playlist] appendArray: [NSArray arrayWithObject: o_dic] atPos: -1 enqueue:YES];
+    }
+}
+
+- (IBAction)screenChanged:(id)sender
+{
+    int selected_index = [o_screen_screen_pop indexOfSelectedItem];
+    if( selected_index >= [o_displayInfos count] ) return;
+
+    NSValue *v = [o_displayInfos objectAtIndex:selected_index];
+    struct display_info_t *item = ( struct display_info_t * )[v pointerValue];
+
+    [o_screen_left_stp setMaxValue: item->rect.size.width];
+    [o_screen_top_stp setMaxValue: item->rect.size.height];
+    [o_screen_width_stp setMaxValue: item->rect.size.width];
+    [o_screen_height_stp setMaxValue: item->rect.size.height];
+}
+
+- (IBAction)qtkChanged:(id)sender
+{
+    NSInteger i_selectedDevice = [o_qtk_device_pop indexOfSelectedItem];
+    if( [qtkvideoDevices count] >= 1 )
+    {
+        NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex: 0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
+
+        [o_capture_width_fld setIntValue: [sizes sizeValue].width];
+        [o_capture_height_fld setIntValue: [sizes sizeValue].height];
+        [o_capture_width_stp setIntValue: [o_capture_width_fld intValue]];
+        [o_capture_height_stp setIntValue: [o_capture_height_fld intValue]];
+        qtk_currdevice_uid = [[(QTCaptureDevice *)[qtkvideoDevices objectAtIndex:i_selectedDevice] uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+        [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
+    }
+}
+
+- (IBAction)qtkAudioChanged:(id)sender
+{
+    NSInteger i_selectedDevice = [o_qtkaudio_device_pop indexOfSelectedItem];
+    if( [qtkaudioDevices count] >= 1 )
+    {
+        qtkaudio_currdevice_uid = [[(QTCaptureDevice *)[qtkaudioDevices objectAtIndex:i_selectedDevice] uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+        [self setMRL:[NSString stringWithFormat:@"qtsound://%@", qtkaudio_currdevice_uid]];
     }
 }
 
+#pragma mark -
+#pragma mark Main Actions
+
 - (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
 {
     NSString *o_label = [o_tvi label];
@@ -454,7 +574,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     }
     else if( [o_label isEqualToString: _NS("Disc")] )
     {
-        [self openDiscTypeChanged: nil];
+        [self scanOpticalMedia: nil];
     }
     else if( [o_label isEqualToString: _NS("Network")] )
     {
@@ -493,41 +613,12 @@ static VLCOpen *_o_sharedMainInstance = nil;
         o_win_rect.size.height = o_win_rect.size.height + o_view_rect.size.height;
     }
 
-    [o_panel setFrame: o_win_rect display:YES animate: YES];
-    [o_panel displayIfNeeded];
+    [[o_panel animator] setFrame: o_win_rect display:YES];
+//    [o_panel displayIfNeeded];
     if( [o_mrl_btn state] == NSOnState )
         [[o_panel contentView] addSubview: o_mrl_view];
 }
 
-- (IBAction)inputSlaveAction:(id)sender
-{
-    if( sender == o_file_slave_ckbox )
-        [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
-    else
-    {
-        NSOpenPanel *o_open_panel;
-        o_open_panel = [NSOpenPanel openPanel];
-        [o_open_panel setCanChooseFiles: YES];
-        [o_open_panel setCanChooseDirectories: NO];
-        if( [o_open_panel runModal] == NSOKButton )
-        {
-            if( o_file_slave_path )
-                [o_file_slave_path release];
-            o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
-            [o_file_slave_path retain];
-        }
-        else
-            [o_file_slave_filename_txt setStringValue: @""];
-    }
-    if( o_file_slave_path )
-    {
-        NSFileWrapper *o_file_wrapper;
-        o_file_wrapper = [[NSFileWrapper alloc] initWithPath: o_file_slave_path];
-        [o_file_slave_filename_txt setStringValue: [NSString stringWithFormat: @"\"%@\"", [o_file_wrapper preferredFilename]]];
-        [o_file_wrapper release];
-    }
-}
-
 - (void)openFileGeneric
 {
     [self openFilePathChanged: nil];
@@ -536,7 +627,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (void)openDisc
 {
-    [self openDiscTypeChanged: nil];
+    [o_specialMediaFolders removeAllObjects];
+    [o_opticalDevices removeAllObjects];
+    [self scanOpticalMedia: nil];
     [self openTarget: 1];
 }
 
@@ -549,40 +642,96 @@ static VLCOpen *_o_sharedMainInstance = nil;
 - (void)openCapture
 {
     [self openCaptureModeChanged: nil];
-    [self showCaptureView: o_capture_label_view];
     [self openTarget: 3];
 }
 
-- (void)openFilePathChanged:(NSNotification *)o_notification
+- (void)openFile
 {
-    NSString *o_filename = [o_file_path stringValue];
-    bool b_stream = [o_file_stream state];
-    BOOL b_dir = NO;
+    NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
+    b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
 
-    [[NSFileManager defaultManager] fileExistsAtPath:o_filename isDirectory:&b_dir];
+    [o_open_panel setAllowsMultipleSelection: YES];
+    [o_open_panel setCanChooseDirectories: YES];
+    [o_open_panel setTitle: _NS("Open File")];
+    [o_open_panel setPrompt: _NS("Open")];
 
-    char *psz_uri = make_URI([o_filename UTF8String], "file");
-    if( !psz_uri ) return;
+    if( [o_open_panel runModal] == NSOKButton )
+    {
+        NSArray * o_urls = [o_open_panel URLs];
+        NSUInteger count = [o_urls count];
+        NSMutableArray *o_values = [NSMutableArray arrayWithCapacity:count];
+        NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
+        for( NSUInteger i = 0; i < count; i++ )
+        {
+            [o_values addObject: [[o_urls objectAtIndex: i] path]];
+        }
+        [o_values sortUsingSelector:@selector(caseInsensitiveCompare:)];
 
-    NSMutableString *o_mrl_string = [NSMutableString stringWithUTF8String: psz_uri ];
-    NSRange offile = [o_mrl_string rangeOfString:@"file"];
-    free( psz_uri );
+        for( NSUInteger i = 0; i < count; i++ )
+        {
+            NSDictionary *o_dic;
+            char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], "file");
+            if( !psz_uri )
+                continue;
+
+            o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
 
-    if( b_dir )
+            free( psz_uri );
+
+            [o_array addObject: o_dic];
+        }
+        if( b_autoplay )
+            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:NO];
+        else
+            [[[VLCMain sharedInstance] playlist] appendArray: o_array atPos: -1 enqueue:YES];
+    }
+}
+
+#pragma mark -
+#pragma mark File Panel
+
+- (void)openFilePathChanged:(NSNotification *)o_notification
+{
+    if ( o_file_path && [o_file_path length] > 0 )
     {
-        [o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
+        bool b_stream = [o_file_stream state];
+        BOOL b_dir = NO;
+
+        [[NSFileManager defaultManager] fileExistsAtPath:o_file_path isDirectory:&b_dir];
+
+        char *psz_uri = make_URI([o_file_path UTF8String], "file");
+        if( !psz_uri ) return;
+
+        NSMutableString *o_mrl_string = [NSMutableString stringWithUTF8String: psz_uri ];
+        NSRange offile = [o_mrl_string rangeOfString:@"file"];
+        free( psz_uri );
+
+        if( b_dir )
+            [o_mrl_string replaceCharactersInRange:offile withString: @"directory"];
+        else if( b_stream )
+            [o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
+
+        [o_file_name setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_path]];
+        [o_file_name_stub setHidden: YES];
+        [o_file_stream setHidden: NO];
+        [o_file_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_path]];
+        [o_file_icon_well setHidden: NO];
+        [self setMRL: o_mrl_string];
     }
-    else if( b_stream )
+    else
     {
-        [o_mrl_string replaceCharactersInRange:offile withString: @"stream"];
+        [o_file_name setStringValue: @""];
+        [o_file_name_stub setHidden: NO];
+        [o_file_stream setHidden: YES];
+        [o_file_icon_well setImage: [NSImage imageNamed:@"generic"]];
+        [self setMRL: @""];
     }
-    [o_mrl setStringValue: o_mrl_string];
 }
 
 - (IBAction)openFileBrowse:(id)sender
 {
     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
+
     [o_open_panel setAllowsMultipleSelection: NO];
     [o_open_panel setCanChooseDirectories: YES];
     [o_open_panel setTitle: _NS("Open File")];
@@ -603,8 +752,10 @@ static VLCOpen *_o_sharedMainInstance = nil;
 {
     if (returnCode == NSFileHandlingPanelOKButton)
     {
-        NSString *o_filename = [[[sheet URLs] objectAtIndex: 0] path];
-        [o_file_path setStringValue: o_filename];
+        if( o_file_path )
+            [o_file_path release];
+        o_file_path = [[[sheet URLs] objectAtIndex: 0] path];
+        [o_file_path retain];
         [self openFilePathChanged: nil];
     }
 }
@@ -614,179 +765,383 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [self openFilePathChanged: nil];
 }
 
-- (IBAction)openDiscTypeChanged:(id)sender
+- (IBAction)inputSlaveAction:(id)sender
 {
-    NSString *o_type;
-    BOOL b_device, b_no_menus, b_title_chapter;
-    [o_disc_device removeAllItems];
-    b_title_chapter = ![o_disc_dvd_menus state];
-    o_type = [[o_disc_type selectedCell] title];
-
-    if ( [o_type isEqualToString: _NS("VIDEO_TS folder")] )
+    if( sender == o_file_slave_ckbox )
+        [o_file_slave_select_btn setEnabled: [o_file_slave_ckbox state]];
+    else
     {
-        b_device = NO; b_no_menus = YES;
+        NSOpenPanel *o_open_panel;
+        o_open_panel = [NSOpenPanel openPanel];
+        [o_open_panel setCanChooseFiles: YES];
+        [o_open_panel setCanChooseDirectories: NO];
+        if( [o_open_panel runModal] == NSOKButton )
+        {
+            if( o_file_slave_path )
+                [o_file_slave_path release];
+            o_file_slave_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+            [o_file_slave_path retain];
+        }
+    }
+    if( o_file_slave_path && [o_file_slave_ckbox state] == NSOnState)
+    {
+        [o_file_slave_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_file_slave_path]];
+        [o_file_slave_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: o_file_slave_path]];
     }
     else
     {
-        NSArray *o_devices;
-        NSString *o_disc;
-        const char *psz_class = NULL;
-        b_device = YES;
+        [o_file_slave_filename_lbl setStringValue: @""];
+        [o_file_slave_icon_well setImage: NULL];
+    }
+}
 
-        if ( [o_type isEqualToString: _NS("VCD")] )
-        {
-            psz_class = kIOCDMediaClass;
-            o_disc = o_type;
-            b_no_menus = NO; b_title_chapter = YES;
-               }
-        else if ( [o_type isEqualToString: _NS("Audio CD")])
-        {
-            psz_class = kIOCDMediaClass;
-            o_disc = o_type;
-            b_no_menus = NO; b_title_chapter = NO;
+- (IBAction)fileTimeCustomization:(id)sender
+{
+    BOOL b_value = [o_file_custom_timing_ckb state];
+    [o_file_starttime_fld setEnabled: b_value];
+    [o_file_starttime_lbl setEnabled: b_value];
+    [o_file_stoptime_fld setEnabled: b_value];
+    [o_file_stoptime_lbl setEnabled: b_value];
+}
+
+#pragma mark -
+#pragma mark Optical Media Panel
+
+- (void)showOpticalMediaView: theView withIcon:(NSImage *)icon
+{
+    NSRect o_view_rect;
+    o_view_rect = [theView frame];
+    [theView setFrame: NSMakeRect( 233, 0, o_view_rect.size.width, o_view_rect.size.height)];
+    [theView setAutoresizesSubviews: YES];
+    if (o_currentOpticalMediaView)
+    {
+        [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] replaceSubview: o_currentOpticalMediaView with: theView];
+        [o_currentOpticalMediaView release];
+    }
+    else
+        [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] addSubview: theView];
+    o_currentOpticalMediaView = theView;
+    [o_currentOpticalMediaView retain];
+
+    NSImageView *imageView;
+    imageView = [[NSImageView alloc] init];
+    [imageView setFrame: NSMakeRect( 53, 61, 128, 128 )];
+    [icon setSize: NSMakeSize(128,128)];
+    [imageView setImage: icon];
+    if (o_currentOpticalMediaIconView)
+    {
+        [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] replaceSubview: o_currentOpticalMediaIconView with: imageView];
+        [o_currentOpticalMediaIconView release];
+    }
+    else
+         [[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] animator] addSubview: imageView];
+    o_currentOpticalMediaIconView = imageView;
+    [o_currentOpticalMediaIconView retain];
+    [o_currentOpticalMediaView setNeedsDisplay: YES];
+    [o_currentOpticalMediaIconView setNeedsDisplay: YES];
+    [[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] setNeedsDisplay: YES];
+    [[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] displayIfNeeded];
+}
+
+- (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
+{
+    OSStatus err;
+    FSRef ref;
+    FSVolumeRefNum actualVolume;
+    err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
+
+    // get a FSVolumeRefNum from mountPath
+    if ( noErr == err ) {
+        FSCatalogInfo   catalogInfo;
+        err = FSGetCatalogInfo ( &ref,
+                                kFSCatInfoVolume,
+                                &catalogInfo,
+                                NULL,
+                                NULL,
+                                NULL
+                                );
+        if ( noErr == err ) {
+            actualVolume = catalogInfo.volume;
         }
-        else
-        {
-            psz_class = kIODVDMediaClass;
-            o_disc = o_type;
-            b_no_menus = YES;
+    }
+
+    GetVolParmsInfoBuffer volumeParms;
+    err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
+    if ( noErr == err )
+    {
+        NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
+        return [NSString stringWithFormat:@"/dev/r%@", bsdName];
+    }
+
+    return @"";
+}
+
+- (char *)getVolumeTypeFromMountPath:(NSString *)mountPath
+{
+    OSStatus err;
+    FSRef ref;
+    FSVolumeRefNum actualVolume;
+    err = FSPathMakeRef ( (const UInt8 *) [mountPath fileSystemRepresentation], &ref, NULL );
+
+    // get a FSVolumeRefNum from mountPath
+    if ( noErr == err ) {
+        FSCatalogInfo   catalogInfo;
+        err = FSGetCatalogInfo ( &ref,
+                                kFSCatInfoVolume,
+                                &catalogInfo,
+                                NULL,
+                                NULL,
+                                NULL
+                                );
+        if ( noErr == err ) {
+            actualVolume = catalogInfo.volume;
         }
-        o_devices = GetEjectableMediaOfClass( psz_class );
-        if ( o_devices != nil )
+    }
+
+    GetVolParmsInfoBuffer volumeParms;
+    err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
+
+    CFMutableDictionaryRef matchingDict;
+    io_service_t service;
+
+    matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
+    service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
+
+    char *returnValue;
+    if (IO_OBJECT_NULL != service) {
+        if (IOObjectConformsTo(service, kIOCDMediaClass)) {
+            returnValue = kVLCMediaAudioCD;
+        }
+        else if(IOObjectConformsTo(service, kIODVDMediaClass))
+            returnValue = kVLCMediaDVD;
+        else if(IOObjectConformsTo(service, kIOBDMediaClass))
+            returnValue = kVLCMediaBD;
+        else
         {
-            int i_devices = [o_devices count];
-            if ( i_devices )
+            if ([mountPath rangeOfString:@"VIDEO_TS" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
+                returnValue = kVLCMediaVideoTSFolder;
+            else if ([mountPath rangeOfString:@"BDMV" options:NSCaseInsensitiveSearch | NSBackwardsSearch].location != NSNotFound)
+                returnValue = kVLCMediaBDMVFolder;
+            else
             {
-                               for( int i = 0; i < i_devices; i++ )
+                // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
+                NSFileManager * fm = [[NSFileManager alloc] init];
+
+                NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
+                for (int i = 0; i < [dirContents count]; i++)
                 {
-                    [o_disc_device
-                        addItemWithObjectValue: [o_devices objectAtIndex: i]];
+                    NSString *currentFile = [dirContents objectAtIndex:i];
+                    NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
+
+                    BOOL isDir;
+                    if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
+                    {
+                        if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaSVCD;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaVCD;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaBDMVFolder;
+                            break;
+                        }
+                        if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame)
+                        {
+                            returnValue = kVLCMediaVideoTSFolder;
+                            break;
+                        }
+                    }
                 }
 
-                [o_disc_device selectItemAtIndex: 0];
-            }
-            else
-            {
-                [o_disc_device setStringValue:
-                    [NSString stringWithFormat: _NS("No %@s found"), o_disc]];
+                [fm release];
+
+                if(!returnValue)
+                    returnValue = kVLCMediaVideoTSFolder;
             }
         }
-    }
-
-    [o_disc_device setEnabled: b_device];
-    [o_disc_title setEnabled: b_title_chapter];
-    [o_disc_title_stp setEnabled: b_title_chapter];
-    [o_disc_chapter setEnabled: b_title_chapter];
-    [o_disc_chapter_stp setEnabled: b_title_chapter];
-    [o_disc_videots_folder setEnabled: !b_device];
-    [o_disc_videots_btn_browse setEnabled: !b_device];
-    [o_disc_dvd_menus setEnabled: b_no_menus];
 
-    [self openDiscInfoChanged: nil];
+        IOObjectRelease(service);
+    }
+    return returnValue;
 }
 
-- (IBAction)openDiscStepperChanged:(id)sender
+- (void)showOpticalAtPath: (NSString *)o_opticalDevicePath
 {
-    int i_tag = [sender tag];
+    NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
 
-    if( i_tag == 0 )
+    char *diskType = [self getVolumeTypeFromMountPath:o_opticalDevicePath];
+
+    if (diskType == kVLCMediaDVD || diskType == kVLCMediaVideoTSFolder)
     {
-        [o_disc_title setIntValue: [o_disc_title_stp intValue]];
+        [o_disc_dvd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_opticalDevicePath]];
+        [o_disc_dvdwomenus_lbl setStringValue: [o_disc_dvd_lbl stringValue]];
+        NSString *pathToOpen;
+        if (diskType == kVLCMediaVideoTSFolder)
+            pathToOpen = o_opticalDevicePath;
+        else
+            pathToOpen = [self getBSDNodeFromMountPath: o_opticalDevicePath];
+        if (!b_nodvdmenus) {
+            [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", pathToOpen]];
+            [self showOpticalMediaView: o_disc_dvd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: o_opticalDevicePath]];
+        } else {
+            [self setMRL: [NSString stringWithFormat: @"dvdread://%@#%i:%i-", pathToOpen, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
+            [self showOpticalMediaView: o_disc_dvdwomenus_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: o_opticalDevicePath]];
+        }
     }
-    else if( i_tag == 1 )
+    else if (diskType == kVLCMediaAudioCD)
     {
-        [o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]];
+        [o_disc_audiocd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
+        [o_disc_audiocd_trackcount_lbl setStringValue: [NSString stringWithFormat:_NS("%i tracks"), [[[NSFileManager defaultManager] subpathsOfDirectoryAtPath: o_opticalDevicePath error:NULL] count] - 1]]; // minus .TOC.plist
+        [self showOpticalMediaView: o_disc_audiocd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: o_opticalDevicePath]];
+        [self setMRL: [NSString stringWithFormat: @"cdda://%@", [self getBSDNodeFromMountPath: o_opticalDevicePath]]];
     }
-
-    [self openDiscInfoChanged: nil];
-}
-
-- (void)openDiscInfoChanged:(NSNotification *)o_notification
-{
-    NSString *o_type;
-    NSString *o_device;
-    NSString *o_videots;
-    NSString *o_mrl_string;
-    int i_title, i_chapter;
-    BOOL b_no_menus;
-
-    o_type = [[o_disc_type selectedCell] title];
-    o_device = [o_disc_device stringValue];
-    i_title = [o_disc_title intValue];
-    i_chapter = [o_disc_chapter intValue];
-    o_videots = [o_disc_videots_folder stringValue];
-    b_no_menus = [o_disc_dvd_menus state];
-
-    if ( [o_type isEqualToString: _NS("VCD")] )
+    else if (diskType == kVLCMediaVCD)
     {
-        if ( [o_device isEqualToString:
-                [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
-            o_device = @"";
-        o_mrl_string = [NSString stringWithFormat: @"vcd://%@@%i:%i",
-                        o_device, i_title, i_chapter];
+        [o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
+        [self showOpticalMediaView: o_disc_vcd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: o_opticalDevicePath]];
+        [self setMRL: [NSString stringWithFormat: @"vcd://%@#%i:%i", [self getBSDNodeFromMountPath: o_opticalDevicePath], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
     }
-    else if ( [o_type isEqualToString: _NS("Audio CD")] )
+    else if (diskType == kVLCMediaSVCD)
     {
-        if ( [o_device isEqualToString:
-                [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
-            o_device = @"";
-        o_mrl_string = [NSString stringWithFormat: @"cdda://%@",
-                        o_device];
+        [o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
+        [self showOpticalMediaView: o_disc_vcd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: o_opticalDevicePath]];
+        [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath: o_opticalDevicePath], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
     }
-    else if ( [o_type isEqualToString: _NS("DVD")] )
+    else if (diskType == kVLCMediaBD || diskType == kVLCMediaBDMVFolder)
     {
-        if ( [o_device isEqualToString:
-                [NSString stringWithFormat: _NS("No %@s found"), o_type]] )
-            o_device = @"";
-        if ( b_no_menus )
-            o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i-",
-                            o_device, i_title, i_chapter];
-        else
-                       o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
-                            o_device];
-            
+        [o_disc_bd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath: o_opticalDevicePath]];
+        [self showOpticalMediaView: o_disc_bd_view withIcon: [[NSWorkspace sharedWorkspace] iconForFile: o_opticalDevicePath]];
+        [self setMRL: [NSString stringWithFormat: @"bluray://%@", o_opticalDevicePath]];
     }
-    else /* VIDEO_TS folder */
+    else
     {
-        if ( b_no_menus )
-            o_mrl_string = [NSString stringWithFormat: @"dvdread://%@@%i:%i",
-                            o_videots, i_title, i_chapter];
-        else
-                       o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@",
-                            o_videots];            
+        msg_Warn( VLCIntf, "unknown disk type, no idea what to display" );
+        [self showOpticalMediaView: o_disc_nodisc_view withIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
     }
 
-    [o_mrl setStringValue: o_mrl_string];
+    [o_pool release];
+}
+
+- (void)showSelectedOpticalDisc
+{
+    NSString *o_opticalDevicePath = [o_opticalDevices objectAtIndex:[o_disc_selector_pop indexOfSelectedItem]];
+    [NSThread detachNewThreadSelector:@selector(showOpticalAtPath:) toTarget:self withObject:o_opticalDevicePath];
+}
+
+- (void)scanOpticalMedia:(NSNotification *)o_notification
+{
+    [o_opticalDevices removeAllObjects];
+    [o_disc_selector_pop removeAllItems];
+    [o_opticalDevices addObjectsFromArray: [[NSWorkspace sharedWorkspace] mountedRemovableMedia]];
+    [o_opticalDevices addObjectsFromArray: o_specialMediaFolders];
+    if ([o_opticalDevices count] > 0) {
+        NSUInteger deviceCount = [o_opticalDevices count];
+        for (NSUInteger i = 0; i < deviceCount ; i++)
+            [o_disc_selector_pop addItemWithTitle: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: i]]];
+
+        if ([o_disc_selector_pop numberOfItems] <= 1)
+            [o_disc_selector_pop setHidden: YES];
+        else
+            [o_disc_selector_pop setHidden: NO];
+
+        // select newly added media folder
+        if (o_notification && [[o_notification name] isEqualToString:@"VLCNewMediaFolderNotification"])
+            [o_disc_selector_pop selectItemAtIndex: [[o_disc_selector_pop itemArray] count] - 1];
+
+        [self showSelectedOpticalDisc];
+    }
+    else
+    {
+        msg_Dbg( VLCIntf, "no optical media found" );
+        [o_disc_selector_pop setHidden: YES];
+        [self showOpticalMediaView: o_disc_nodisc_view withIcon: [NSImage imageNamed: @"NSApplicationIcon"]];
+    }
 }
 
-- (IBAction)openDiscMenusChanged:(id)sender
+- (IBAction)discSelectorChanged:(id)sender
 {
-    [self openDiscInfoChanged: nil];
-    [self openDiscTypeChanged: nil];
+    [self showSelectedOpticalDisc];
 }
 
-- (IBAction)openVTSBrowse:(id)sender
+- (IBAction)openSpecialMediaFolder:(id)sender
 {
+    /* this is currently for VIDEO_TS and BDMV folders */
     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
 
     [o_open_panel setAllowsMultipleSelection: NO];
     [o_open_panel setCanChooseFiles: NO];
     [o_open_panel setCanChooseDirectories: YES];
-    [o_open_panel setTitle: _NS("Open VIDEO_TS Directory")];
+    [o_open_panel setTitle: [sender title]];
     [o_open_panel setPrompt: _NS("Open")];
 
-    if( [o_open_panel runModal] == NSOKButton )
+    if ([o_open_panel runModal] == NSOKButton)
     {
-        NSString *o_dirname = [[[o_open_panel URLs] objectAtIndex: 0] path];
-        [o_disc_videots_folder setStringValue: o_dirname];
-        [self openDiscInfoChanged: nil];
+        NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+        if ([o_path length] > 0 )
+        {
+            [o_specialMediaFolders addObject: o_path];
+            [self scanOpticalMedia: [NSNotification notificationWithName:@"VLCNewMediaFolderNotification" object:nil]];
+        }
     }
 }
 
+- (IBAction)dvdreadOptionChanged:(id)sender
+{
+    NSString *o_device_path = [o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]];
+    char *diskType = [self getVolumeTypeFromMountPath:o_device_path];
+
+    NSString *pathToOpen;
+    if (diskType == kVLCMediaVideoTSFolder)
+        pathToOpen = o_device_path;
+    else
+        pathToOpen = [self getBSDNodeFromMountPath: o_device_path];
+
+    if (sender == o_disc_dvdwomenus_enablemenus_btn) {
+        b_nodvdmenus = NO;
+        [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", pathToOpen]];
+        [self showOpticalMediaView: o_disc_dvd_view withIcon: [o_currentOpticalMediaIconView image]];
+        return;
+    }
+    if (sender == o_disc_dvd_disablemenus_btn) {
+        b_nodvdmenus = YES;
+        [self showOpticalMediaView: o_disc_dvdwomenus_view withIcon: [o_currentOpticalMediaIconView image]];
+    }
+
+    if (sender == o_disc_dvdwomenus_title)
+        [o_disc_dvdwomenus_title_stp setIntValue: [o_disc_dvdwomenus_title intValue]];
+    if (sender == o_disc_dvdwomenus_title_stp)
+        [o_disc_dvdwomenus_title setIntValue: [o_disc_dvdwomenus_title_stp intValue]];
+    if (sender == o_disc_dvdwomenus_chapter)
+        [o_disc_dvdwomenus_chapter_stp setIntValue: [o_disc_dvdwomenus_chapter intValue]];
+    if (sender == o_disc_dvdwomenus_chapter_stp)
+        [o_disc_dvdwomenus_chapter setIntValue: [o_disc_dvdwomenus_chapter_stp intValue]];
+
+    [self setMRL: [NSString stringWithFormat: @"dvdread://%@#%i:%i-", pathToOpen, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
+}
+
+- (IBAction)vcdOptionChanged:(id)sender
+{
+    if (sender == o_disc_vcd_title)
+        [o_disc_vcd_title_stp setIntValue: [o_disc_vcd_title intValue]];
+    if (sender == o_disc_vcd_title_stp)
+        [o_disc_vcd_title setIntValue: [o_disc_vcd_title_stp intValue]];
+    if (sender == o_disc_vcd_chapter)
+        [o_disc_vcd_chapter_stp setIntValue: [o_disc_vcd_chapter intValue]];
+    if (sender == o_disc_vcd_chapter_stp)
+        [o_disc_vcd_chapter setIntValue: [o_disc_vcd_chapter_stp intValue]];
+
+    [self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
+}
+
+#pragma mark -
+#pragma mark Network Panel
+
 - (void)textFieldWasClicked:(NSNotification *)o_notification
 {
     if( [o_notification object] == o_net_udp_port )
@@ -851,9 +1206,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
             int i_port = [o_net_udp_port intValue];
 
             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
-                o_mrl_string = [NSString stringWithString: @"udp://"];
+                o_mrl_string = @"udp://";
             else
-                o_mrl_string = [NSString stringWithString: @"rtp://"];
+                o_mrl_string = @"rtp://";
 
             if( i_port != config_GetInt( p_intf, "server-port" ) )
             {
@@ -882,7 +1237,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     {
         o_mrl_string = [o_net_http_url stringValue];
     }
-    [o_mrl setStringValue: o_mrl_string];
+    [self setMRL: o_mrl_string];
 }
 
 - (IBAction)openNetUDPButtonAction:(id)sender
@@ -907,11 +1262,11 @@ static VLCOpen *_o_sharedMainInstance = nil;
         if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
         {
             int i_port = [o_net_udp_port intValue];
-            
+
             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
-                o_mrl_string = [NSString stringWithString: @"udp://"];
+                o_mrl_string = @"udp://";
             else
-                o_mrl_string = [NSString stringWithString: @"rtp://"];
+                o_mrl_string = @"rtp://";
 
             if( i_port != config_GetInt( p_intf, "server-port" ) )
             {
@@ -923,7 +1278,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
         {
             NSString *o_addr = [o_net_udpm_addr stringValue];
             int i_port = [o_net_udpm_port intValue];
-            
+
             if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
                 o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
             else
@@ -935,64 +1290,31 @@ static VLCOpen *_o_sharedMainInstance = nil;
                 [o_mrl_string stringByAppendingFormat: @":%i", i_port];
             }
         }
-        [o_mrl setStringValue: o_mrl_string];
+        [self setMRL: o_mrl_string];
         [o_net_http_url setStringValue: o_mrl_string];
         [o_net_udp_panel orderOut: sender];
         [NSApp endSheet: o_net_udp_panel];
     }
 }
-    
-- (void)openFile
-{
-    NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
-    int i;
-    b_autoplay = config_GetInt( VLCIntf, "macosx-autoplay" );
-    [o_open_panel setAllowsMultipleSelection: YES];
-    [o_open_panel setCanChooseDirectories: YES];
-    [o_open_panel setTitle: _NS("Open File")];
-    [o_open_panel setPrompt: _NS("Open")];
-    if( [o_open_panel runModal] == NSOKButton )
-    {
-        NSArray *o_array = [NSArray array];
-        NSArray *o_values = [[o_open_panel URLs]
-                sortedArrayUsingSelector:@selector(caseInsensitiveCompare:)];
-
-        for( i = 0; i < (int)[o_values count]; i++)
-        {
-            NSDictionary *o_dic;
-            char *psz_uri = make_URI([[[o_values objectAtIndex:i] path] UTF8String], "file");
-            if( !psz_uri )
-                continue;
-
-            o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
 
-            free( psz_uri );
-
-            o_array = [o_array arrayByAddingObject: o_dic];
-        }
-        if( b_autoplay )
-            [o_playlist appendArray: o_array atPos: -1 enqueue:NO];
-        else
-            [o_playlist appendArray: o_array atPos: -1 enqueue:YES];
-    }
-}
+#pragma mark -
+#pragma mark Capture Panel
 
 - (void)showCaptureView: theView
 {
     NSRect o_view_rect;
     o_view_rect = [theView frame];
-    if( o_currentCaptureView )
+    [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
+    [theView setAutoresizesSubviews: YES];
+    if (o_currentCaptureView)
     {
-        [o_currentCaptureView removeFromSuperviewWithoutNeedingDisplay];
+        [[[[o_tabview tabViewItemAtIndex: 3] view] animator] replaceSubview: o_currentCaptureView with: theView];
         [o_currentCaptureView release];
     }
-    [theView setFrame: NSMakeRect( 0, -10, o_view_rect.size.width, o_view_rect.size.height)];
-    [theView setNeedsDisplay: YES];
-    [theView setAutoresizesSubviews: YES];
-    [[[o_tabview tabViewItemAtIndex: 3] view] addSubview: theView];
-    [theView displayIfNeeded];
+    else
+    {
+        [[[[o_tabview tabViewItemAtIndex: 3] view] animator] addSubview: theView];
+    }
     o_currentCaptureView = theView;
     [o_currentCaptureView retain];
 }
@@ -1015,36 +1337,83 @@ static VLCOpen *_o_sharedMainInstance = nil;
         }
         else
             [self showCaptureView: o_eyetv_notLaunched_view];
-        [o_mrl setStringValue: @""];
-    } 
+        [self setMRL: @""];
+    }
     else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Screen")] )
     {
         [self showCaptureView: o_screen_view];
-        [o_mrl setStringValue: @"screen://"];
+        [self setMRL: @"screen://"];
         [o_screen_height_fld setIntValue: config_GetInt( p_intf, "screen-height" )];
         [o_screen_width_fld setIntValue: config_GetInt( p_intf, "screen-width" )];
         [o_screen_fps_fld setFloatValue: config_GetFloat( p_intf, "screen-fps" )];
         [o_screen_left_fld setIntValue: config_GetInt( p_intf, "screen-left" )];
         [o_screen_top_fld setIntValue: config_GetInt( p_intf, "screen-top" )];
         [o_screen_follow_mouse_ckb setIntValue: config_GetInt( p_intf, "screen-follow-mouse" )];
+
+        int screen_index = config_GetInt( p_intf, "screen-index" );
+        int display_id = config_GetInt( p_intf, "screen-display-id" );
+        unsigned int i, displayCount = 0;
+        CGLError returnedError;
+        struct display_info_t *item;
+        NSValue *v;
+
+        returnedError = CGGetOnlineDisplayList( 0, NULL, &displayCount );
+        if( !returnedError )
+        {
+            CGDirectDisplayID *ids;
+            ids = ( CGDirectDisplayID * )malloc( displayCount * sizeof( CGDirectDisplayID ) );
+            returnedError = CGGetOnlineDisplayList( displayCount, ids, &displayCount );
+            if( !returnedError )
+            {
+                for( i = 0; i < [o_displayInfos count]; i ++ )
+                {
+                    v = [o_displayInfos objectAtIndex:i];
+                    free( [v pointerValue] );
+                }
+                [o_displayInfos removeAllObjects];
+                [o_screen_screen_pop removeAllItems];
+                for( i = 0; i < displayCount; i ++ )
+                {
+                    item = ( struct display_info_t * )malloc( sizeof( struct display_info_t ) );
+                    item->id = ids[i];
+                    item->rect = CGDisplayBounds( item->id );
+                    [o_screen_screen_pop addItemWithTitle: [NSString stringWithFormat:@"Screen %d (%dx%d)", i + 1, (int)item->rect.size.width, (int)item->rect.size.height]];
+                    v = [NSValue valueWithPointer:item];
+                    [o_displayInfos addObject:v];
+                    if( i == 0 || display_id == item->id || screen_index - 1 == i )
+                    {
+                        [o_screen_screen_pop selectItemAtIndex: i];
+                        [o_screen_left_stp setMaxValue: item->rect.size.width];
+                        [o_screen_top_stp setMaxValue: item->rect.size.height];
+                        [o_screen_width_stp setMaxValue: item->rect.size.width];
+                        [o_screen_height_stp setMaxValue: item->rect.size.height];
+                    }
+                }
+            }
+            free( ids );
+        }
     }
-    else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: @"iSight"] )
+    else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Video Device")] )
     {
-        [o_capture_lbl setStringValue: _NS("iSight Capture Input")];
-        [o_capture_long_lbl setStringValue: _NS("This facility allows you to process your iSight's input signal.\n\nNo settings are available in this version, so you will be provided a 640px*480px raw video stream.\n\nLive Audio input is not supported.")];
-        [o_capture_lbl displayIfNeeded];
-        [o_capture_long_lbl displayIfNeeded];
-        
-        [self showCaptureView: o_capture_label_view];
-        [o_mrl setStringValue: @"qtcapture://"];
+        [self showCaptureView: o_qtk_view];
+        if ([o_capture_width_fld intValue] <= 0)
+            [self qtkChanged:nil];
+
+        if(!qtk_currdevice_uid)
+            [self setMRL: @""];
+        else
+            [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
     }
-}
+    else if( [[[o_capture_mode_pop selectedItem] title] isEqualToString: _NS("Audio Device")] )
+    {
+        [self showCaptureView: o_qtkaudio_view];
+        [self qtkAudioChanged:nil];
 
-- (IBAction)screenStepperChanged:(id)sender
-{
-    [o_screen_fps_fld setFloatValue: [o_screen_fps_stp floatValue]];
-    [o_panel makeFirstResponder: o_screen_fps_fld];
-    [o_mrl setStringValue: @"screen://"];
+        if(!qtkaudio_currdevice_uid)
+            [self setMRL: @""];
+        else
+            [self setMRL:[NSString stringWithFormat:@"qtsound://%@", qtkaudio_currdevice_uid]];
+    }
 }
 
 - (void)screenFPSfieldChanged:(NSNotification *)o_notification
@@ -1052,7 +1421,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_screen_fps_stp setFloatValue: [o_screen_fps_fld floatValue]];
     if( [[o_screen_fps_fld stringValue] isEqualToString: @""] )
         [o_screen_fps_fld setFloatValue: 1.0];
-    [o_mrl setStringValue: @"screen://"];
+    [self setMRL: @"screen://"];
 }
 
 - (IBAction)eyetvSwitchChannel:(id)sender
@@ -1061,19 +1430,19 @@ static VLCOpen *_o_sharedMainInstance = nil;
     {
         int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: YES];
         [o_eyetv_channels_pop selectItemWithTag:chanNum];
-        [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+        [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
     }
     else if( sender == o_eyetv_previousProgram_btn )
     {
         int chanNum = [[[VLCMain sharedInstance] eyeTVController] switchChannelUp: NO];
         [o_eyetv_channels_pop selectItemWithTag:chanNum];
-        [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+        [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
     }
     else if( sender == o_eyetv_channels_pop )
     {
         int chanNum = [[sender selectedItem] tag];
         [[[VLCMain sharedInstance] eyeTVController] selectChannel:chanNum];
-        [o_mrl setStringValue: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
+        [self setMRL: [NSString stringWithFormat:@"eyetv:// :eyetv-channel=%d", chanNum]];
     }
     else
         msg_Err( VLCIntf, "eyetvSwitchChannel sent by unknown object" );
@@ -1116,9 +1485,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
         msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
         setEyeTVUnconnected;
     }
-    else
-        msg_Warn( VLCIntf, "unknown external notify '%s' received", [[o_notification name] UTF8String] );
-}    
+}
 
 /* little helper method, since this code needs to be run by multiple objects */
 - (void)setupChannelInfo
@@ -1129,7 +1496,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_eyetv_chn_bgbar animate: self];
     [o_eyetv_chn_status_txt setStringValue: _NS("Retrieving Channel Info...")];
     [o_eyetv_chn_status_txt setHidden: NO];
+
     /* retrieve info */
     NSEnumerator *channels = [[[VLCMain sharedInstance] eyeTVController] allChannels];
     int x = -2;
@@ -1139,7 +1506,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [[[o_eyetv_channels_pop menu] addItemWithTitle: _NS("S-Video input")
                                                action: nil
                                         keyEquivalent: @""] setTag:x++];
-    if( channels ) 
+    if( channels )
     {
         NSString *channel;
         [[o_eyetv_channels_pop menu] addItem: [NSMenuItem separatorItem]];
@@ -1154,21 +1521,30 @@ static VLCOpen *_o_sharedMainInstance = nil;
         /* make Tuner the default */
         [o_eyetv_channels_pop selectItemWithTag:[[[VLCMain sharedInstance] eyeTVController] currentChannel]];
     }
+
     /* clean up GUI */
     [o_eyetv_chn_bgbar setHidden: YES];
     [o_eyetv_chn_status_txt setHidden: YES];
 }
 
+#pragma mark -
+#pragma mark Subtitle Settings
+
 - (IBAction)subsChanged:(id)sender
 {
     if ([o_file_sub_ckbox state] == NSOnState)
     {
         [o_file_sub_btn_settings setEnabled:YES];
+        if (o_sub_path) {
+            [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_sub_path]];
+            [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile:o_sub_path]];
+        }
     }
     else
     {
         [o_file_sub_btn_settings setEnabled:NO];
+        [o_file_subtitles_filename_lbl setStringValue: @""];
+        [o_file_subtitles_icon_well setImage: NULL];
     }
 }
 
@@ -1183,22 +1559,36 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (IBAction)subCloseSheet:(id)sender
 {
+    [self subsChanged: nil];
     [o_file_sub_sheet orderOut:sender];
     [NSApp endSheet: o_file_sub_sheet];
 }
-    
+
 - (IBAction)subFileBrowse:(id)sender
 {
     NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
+
     [o_open_panel setAllowsMultipleSelection: NO];
     [o_open_panel setTitle: _NS("Open File")];
     [o_open_panel setPrompt: _NS("Open")];
 
     if( [o_open_panel runModal] == NSOKButton )
     {
-        NSString *o_filename = [[[o_open_panel URLs] objectAtIndex: 0] path];
-        [o_file_sub_path setStringValue: o_filename];
+        o_sub_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
+        [o_sub_path retain];
+        [o_file_subtitles_filename_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:o_sub_path]];
+        [o_file_sub_path_fld setStringValue: [o_file_subtitles_filename_lbl stringValue]];
+        [o_file_sub_path_lbl setHidden: YES];
+        [o_file_subtitles_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile:o_sub_path]];
+        [o_file_sub_icon_view setImage: [o_file_subtitles_icon_well image]];
+    }
+    else
+    {
+        [o_file_sub_path_lbl setHidden: NO];
+        [o_file_sub_path_fld setStringValue:@""];
+        [o_file_subtitles_filename_lbl setStringValue:@""];
+        [o_file_subtitles_icon_well setImage: nil];
+        [o_file_sub_icon_view setImage: nil];
     }
 }
 
@@ -1221,6 +1611,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
     [o_file_sub_fps setFloatValue: [o_file_sub_fps_stp floatValue]];
 }
 
+#pragma mark -
+#pragma mark Miscellaneous
+
 - (IBAction)panelCancel:(id)sender
 {
     [NSApp stopModalWithCode: 0];
@@ -1228,14 +1621,36 @@ static VLCOpen *_o_sharedMainInstance = nil;
 
 - (IBAction)panelOk:(id)sender
 {
-    if( [[o_mrl stringValue] length] )
-    {
+    if( [[self MRL] length] )
         [NSApp stopModalWithCode: 1];
-    }
     else
-    {
         NSBeep();
-    }
+}
+
+- (NSArray *)qtkvideoDevices
+{
+    if ( !qtkvideoDevices )
+        [self qtkrefreshVideoDevices];
+    return qtkvideoDevices;
+}
+
+- (void)qtkrefreshVideoDevices
+{
+    [qtkvideoDevices release];
+    qtkvideoDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeVideo] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
+}
+
+- (NSArray *)qtkaudioDevices
+{
+    if ( !qtkaudioDevices )
+        [self qtkrefreshAudioDevices];
+    return qtkaudioDevices;
+}
+
+- (void)qtkrefreshAudioDevices
+{
+    [qtkaudioDevices release];
+    qtkaudioDevices = [[[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeSound] arrayByAddingObjectsFromArray:[QTCaptureDevice inputDevicesWithMediaType:QTMediaTypeMuxed]] retain];
 }
 
 @end