Commit 721aa357 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: re-written the 'Open Disc' tab in the open panel

it automatically detects inserted disks and their type, so type selector by the user is no longer needed, which allows a much cleaner GUI
parent e6f62b35
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -24,8 +24,6 @@ ...@@ -24,8 +24,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/ *****************************************************************************/
NSArray *GetEjectableMediaOfClass( const char *psz_class );
/***************************************************************************** /*****************************************************************************
* Intf_Open interface * Intf_Open interface
*****************************************************************************/ *****************************************************************************/
...@@ -57,18 +55,53 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class ); ...@@ -57,18 +55,53 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class );
IBOutlet id o_file_slave_filename_txt; IBOutlet id o_file_slave_filename_txt;
/* open disc */ /* open disc */
IBOutlet id o_disc_type; IBOutlet id o_disc_icon_well;
IBOutlet id o_disc_device; IBOutlet id o_disc_selector_pop;
IBOutlet id o_disc_device_lbl;
IBOutlet id o_disc_title; IBOutlet id o_disc_nodisc_view;
IBOutlet id o_disc_title_lbl; IBOutlet id o_disc_nodisc_lbl;
IBOutlet id o_disc_title_stp; IBOutlet id o_disc_nodisc_videots_btn;
IBOutlet id o_disc_chapter; IBOutlet id o_disc_nodisc_bdmv_btn;
IBOutlet id o_disc_chapter_lbl;
IBOutlet id o_disc_chapter_stp; IBOutlet id o_disc_audiocd_view;
IBOutlet id o_disc_videots_folder; IBOutlet id o_disc_audiocd_lbl;
IBOutlet id o_disc_videots_btn_browse; IBOutlet id o_disc_audiocd_trackcount_lbl;
IBOutlet id o_disc_dvd_menus; IBOutlet id o_disc_audiocd_videots_btn;
IBOutlet id o_disc_audiocd_bdmv_btn;
IBOutlet id o_disc_dvd_view;
IBOutlet id o_disc_dvd_lbl;
IBOutlet id o_disc_dvd_disablemenus_btn;
IBOutlet id o_disc_dvd_videots_btn;
IBOutlet id o_disc_dvd_bdmv_btn;
IBOutlet id o_disc_dvdwomenus_view;
IBOutlet id o_disc_dvdwomenus_lbl;
IBOutlet id o_disc_dvdwomenus_enablemenus_btn;
IBOutlet id o_disc_dvdwomenus_videots_btn;
IBOutlet id o_disc_dvdwomenus_bdmv_btn;
IBOutlet id o_disc_dvdwomenus_title;
IBOutlet id o_disc_dvdwomenus_title_lbl;
IBOutlet id o_disc_dvdwomenus_title_stp;
IBOutlet id o_disc_dvdwomenus_chapter;
IBOutlet id o_disc_dvdwomenus_chapter_lbl;
IBOutlet id o_disc_dvdwomenus_chapter_stp;
IBOutlet id o_disc_vcd_view;
IBOutlet id o_disc_vcd_lbl;
IBOutlet id o_disc_vcd_videots_btn;
IBOutlet id o_disc_vcd_bdmv_btn;
IBOutlet id o_disc_vcd_title;
IBOutlet id o_disc_vcd_title_lbl;
IBOutlet id o_disc_vcd_title_stp;
IBOutlet id o_disc_vcd_chapter;
IBOutlet id o_disc_vcd_chapter_lbl;
IBOutlet id o_disc_vcd_chapter_stp;
IBOutlet id o_disc_bd_view;
IBOutlet id o_disc_bd_lbl;
IBOutlet id o_disc_bd_videots_btn;
IBOutlet id o_disc_bd_bdmv_btn;
/* open network */ /* open network */
IBOutlet id o_net_http_url; IBOutlet id o_net_http_url;
...@@ -170,6 +203,10 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class ); ...@@ -170,6 +203,10 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class );
NSString *qtk_currdevice_uid; NSString *qtk_currdevice_uid;
BOOL b_autoplay; BOOL b_autoplay;
BOOL b_nodvdmenus;
id o_currentOpticalMediaView;
NSMutableArray *o_opticalDevices;
NSMutableArray *o_specialMediaFolders;
id o_currentCaptureView; id o_currentCaptureView;
NSString *o_file_slave_path; NSString *o_file_slave_path;
NSString *o_mrl; NSString *o_mrl;
...@@ -198,11 +235,11 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class ); ...@@ -198,11 +235,11 @@ NSArray *GetEjectableMediaOfClass( const char *psz_class );
- (IBAction)openFileStreamChanged:(id)sender; - (IBAction)openFileStreamChanged:(id)sender;
- (void)openDisc; - (void)openDisc;
- (IBAction)openDiscTypeChanged:(id)sender; - (void)scanOpticalMedia:(NSNotification *)o_notification;
- (IBAction)openDiscStepperChanged:(id)sender; - (IBAction)discSelectorChanged:(id)sender;
- (void)openDiscInfoChanged:(NSNotification *)o_notification; - (IBAction)openSpecialMediaFolder:(id)sender;
- (IBAction)openDiscMenusChanged:(id)sender; - (IBAction)dvdreadOptionChanged:(id)sender;
- (IBAction)openVTSBrowse:(id)sender; - (IBAction)vcdOptionChanged:(id)sender;
- (void)openNet; - (void)openNet;
- (IBAction)openNetModeChanged:(id)sender; - (IBAction)openNetModeChanged:(id)sender;
......
...@@ -28,19 +28,17 @@ ...@@ -28,19 +28,17 @@
/***************************************************************************** /*****************************************************************************
* Preamble * Preamble
*****************************************************************************/ *****************************************************************************/
#include <stdlib.h> /* malloc(), free() */ #import <stdlib.h> /* malloc(), free() */
#include <sys/param.h> /* for MAXPATHLEN */ #import <sys/param.h> /* for MAXPATHLEN */
#include <string.h>
#import <paths.h>
#include <paths.h> #import <IOKit/IOBSD.h>
#include <IOKit/IOKitLib.h> #import <IOKit/storage/IOMedia.h>
#include <IOKit/IOBSD.h> #import <IOKit/storage/IOCDMedia.h>
#include <IOKit/storage/IOMedia.h> #import <IOKit/storage/IODVDMedia.h>
#include <IOKit/storage/IOCDMedia.h> #import <IOKit/storage/IOBDMedia.h>
#include <IOKit/storage/IODVDMedia.h>
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
#import <QTKit/QTKit.h> #import <QTKit/QTKit.h>
#import <Foundation/NSobject.h>
#import "intf.h" #import "intf.h"
#import "playlist.h" #import "playlist.h"
...@@ -48,7 +46,7 @@ ...@@ -48,7 +46,7 @@
#import "output.h" #import "output.h"
#import "eyetv.h" #import "eyetv.h"
#include <vlc_url.h> #import <vlc_url.h>
NSArray *qtkvideoDevices; NSArray *qtkvideoDevices;
#define setEyeTVUnconnected \ #define setEyeTVUnconnected \
...@@ -58,86 +56,15 @@ NSArray *qtkvideoDevices; ...@@ -58,86 +56,15 @@ NSArray *qtkvideoDevices;
[o_capture_long_lbl displayIfNeeded]; \ [o_capture_long_lbl displayIfNeeded]; \
[self showCaptureView: o_capture_label_view] [self showCaptureView: o_capture_label_view]
/***************************************************************************** #define kVLCMediaAudioCD "AudioCD"
* GetEjectableMediaOfClass #define kVLCMediaDVD "DVD"
*****************************************************************************/ #define kVLCMediaVCD "VCD"
NSArray *GetEjectableMediaOfClass( const char *psz_class ) #define kVLCMediaSVCD "SVCD"
{ #define kVLCMediaBD "Bluray"
io_object_t next_media; #define kVLCMediaVideoTSFolder "VIDEO_TS"
mach_port_t master_port; #define kVLCMediaBDMVFolder "BDMV"
kern_return_t kern_result; #define kVLCMediaUnknown "Unknown"
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 );
}
/***************************************************************************** /*****************************************************************************
* VLCOpen implementation * VLCOpen implementation
...@@ -165,6 +92,8 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -165,6 +92,8 @@ static VLCOpen *_o_sharedMainInstance = nil;
- (void)dealloc - (void)dealloc
{ {
[o_specialMediaFolders release];
[o_opticalDevices release];
if( o_file_slave_path ) if( o_file_slave_path )
[o_file_slave_path release]; [o_file_slave_path release];
[o_mrl release]; [o_mrl release];
...@@ -190,16 +119,33 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -190,16 +119,33 @@ static VLCOpen *_o_sharedMainInstance = nil;
[o_file_slave_select_btn setTitle: _NS("Choose...")]; [o_file_slave_select_btn setTitle: _NS("Choose...")];
[o_file_slave_filename_txt setStringValue: @""]; [o_file_slave_filename_txt setStringValue: @""];
[o_disc_device_lbl setStringValue: _NS("Device name")]; [o_disc_selector_pop removeAllItems];
[o_disc_title_lbl setStringValue: _NS("Title")]; [o_disc_selector_pop setHidden: NO];
[o_disc_chapter_lbl setStringValue: _NS("Chapter")]; NSString *o_videots = _NS("Open VIDEO_TS folder");
[o_disc_videots_btn_browse setTitle: _NS("Browse...")]; NSString *o_bdmv = _NS("Open BDMV folder");
[o_disc_dvd_menus setTitle: _NS("No DVD menus")]; [o_disc_nodisc_lbl setStringValue: _NS("Insert Disc")];
[o_disc_nodisc_videots_btn setTitle: o_videots];
[[o_disc_type cellAtRow:0 column:0] setTitle: _NS("VIDEO_TS folder")]; [o_disc_nodisc_bdmv_btn setTitle: o_bdmv];
[[o_disc_type cellAtRow:1 column:0] setTitle: _NS("DVD")]; [o_disc_audiocd_lbl setStringValue: _NS("Audio CD")];
[[o_disc_type cellAtRow:2 column:0] setTitle: _NS("VCD")]; [o_disc_audiocd_trackcount_lbl setStringValue: @""];
[[o_disc_type cellAtRow:3 column:0] setTitle: _NS("Audio CD")]; [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_udp_port_lbl setStringValue: _NS("Port")];
[o_net_udpm_addr_lbl setStringValue: _NS("IP Address")]; [o_net_udpm_addr_lbl setStringValue: _NS("IP Address")];
...@@ -271,23 +217,6 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -271,23 +217,6 @@ static VLCOpen *_o_sharedMainInstance = nil;
name: NSControlTextDidChangeNotification name: NSControlTextDidChangeNotification
object: o_file_path]; object: o_file_path];
[[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];
[[NSNotificationCenter defaultCenter] addObserver: self [[NSNotificationCenter defaultCenter] addObserver: self
selector: @selector(openNetInfoChanged:) selector: @selector(openNetInfoChanged:)
name: NSControlTextDidChangeNotification name: NSControlTextDidChangeNotification
...@@ -322,6 +251,15 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -322,6 +251,15 @@ static VLCOpen *_o_sharedMainInstance = nil;
name: @"VLCOpenTextFieldWasClicked" name: @"VLCOpenTextFieldWasClicked"
object: nil]; object: nil];
/* we want to be notified about removed or added media */
o_specialMediaFolders = [[NSMutableArray alloc] init];
o_opticalDevices = [[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];
[[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidRenameVolumeNotification object:nil];
[self scanOpticalMedia:nil];
[self setMRL: @""]; [self setMRL: @""];
} }
...@@ -507,7 +445,7 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -507,7 +445,7 @@ static VLCOpen *_o_sharedMainInstance = nil;
} }
else if( [o_label isEqualToString: _NS("Disc")] ) else if( [o_label isEqualToString: _NS("Disc")] )
{ {
[self openDiscTypeChanged: nil]; [self scanOpticalMedia: nil];
} }
else if( [o_label isEqualToString: _NS("Network")] ) else if( [o_label isEqualToString: _NS("Network")] )
{ {
...@@ -589,7 +527,9 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -589,7 +527,9 @@ static VLCOpen *_o_sharedMainInstance = nil;
- (void)openDisc - (void)openDisc
{ {
[self openDiscTypeChanged: nil]; [o_specialMediaFolders removeAllObjects];
[o_opticalDevices removeAllObjects];
[self scanOpticalMedia: nil];
[self openTarget: 1]; [self openTarget: 1];
} }
...@@ -669,185 +609,286 @@ static VLCOpen *_o_sharedMainInstance = nil; ...@@ -669,185 +609,286 @@ static VLCOpen *_o_sharedMainInstance = nil;
[self openFilePathChanged: nil]; [self openFilePathChanged: nil];
} }
- (IBAction)openDiscTypeChanged:(id)sender - (void)showOpticalMediaView: theView
{ {
NSString *o_type; NSRect o_view_rect;
BOOL b_device, b_no_menus, b_title_chapter; o_view_rect = [theView frame];
if( o_currentOpticalMediaView )
[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")] )
{
b_device = NO; b_no_menus = YES;
}
else
{
NSArray *o_devices;
NSString *o_disc;
const char *psz_class = NULL;
b_device = YES;
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;
}
else
{ {
psz_class = kIODVDMediaClass; [o_currentOpticalMediaView removeFromSuperviewWithoutNeedingDisplay];
o_disc = o_type; [o_currentOpticalMediaView release];
b_no_menus = YES;
} }
[theView setFrame: NSMakeRect( 233, 0, o_view_rect.size.width, o_view_rect.size.height)];
[theView setNeedsDisplay: YES];
[theView setAutoresizesSubviews: YES];
[[[o_tabview tabViewItemAtIndex: [o_tabview indexOfTabViewItemWithIdentifier:@"optical"]] view] addSubview: theView];
[theView displayIfNeeded];
o_currentOpticalMediaView = theView;
[o_currentOpticalMediaView retain];
}
o_devices = GetEjectableMediaOfClass( psz_class ); - (NSString *) getBSDNodeFromMountPath:(NSString *)mountPath
if ( o_devices != nil ) {
{ OSStatus err;
int i_devices = [o_devices count]; 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;
}
}
GetVolParmsInfoBuffer volumeParms;
err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
if ( noErr != err ) {
msg_Err( p_intf, "error retrieving volume params, bailing out" );
return @"";
}
NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
return [NSString stringWithFormat:@"/dev/r%@", bsdName];
}
if ( i_devices ) - (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;
}
}
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
{ {
for( int i = 0; i < i_devices; i++ ) if ([mountPath rangeOfString:@"VIDEO_TS"].location != NSNotFound)
returnValue = kVLCMediaVideoTSFolder;
else if ([mountPath rangeOfString:@"BDMV"].location != NSNotFound)
returnValue = kVLCMediaBDMVFolder;
else
{ {
[o_disc_device NSArray * topLevelItems;
addItemWithObjectValue: [o_devices objectAtIndex: i]]; topLevelItems = [[NSFileManager defaultManager] subpathsOfDirectoryAtPath: mountPath error: NULL];
for (int i = 0; i < [topLevelItems count]; i++) {
if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
returnValue = kVLCMediaSVCD;
break;
} }
if([[topLevelItems objectAtIndex:i] rangeOfString:@"VCD"].location != NSNotFound) {
[o_disc_device selectItemAtIndex: 0]; returnValue = kVLCMediaVCD;
break;
} }
else
{
[o_disc_device setStringValue:
[NSString stringWithFormat: _NS("No %@s found"), o_disc]];
} }
if(!returnValue)
returnValue = kVLCMediaUnknown;
} }
} }
[o_disc_device setEnabled: b_device]; IOObjectRelease(service);
[o_disc_title setEnabled: b_title_chapter]; }
[o_disc_title_stp setEnabled: b_title_chapter]; return returnValue;
[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];
} }
- (IBAction)openDiscStepperChanged:(id)sender - (void)showOpticalAtIndex: (NSNumber *)n_index
{ {
int i_tag = [sender tag]; NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
if( i_tag == 0 ) unsigned int index = [n_index intValue];
char *diskType = [self getVolumeTypeFromMountPath:[o_opticalDevices objectAtIndex: index]];
if (diskType == kVLCMediaDVD || diskType == kVLCMediaVideoTSFolder)
{ {
[o_disc_title setIntValue: [o_disc_title_stp intValue]]; [o_disc_dvd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
[o_disc_dvdwomenus_lbl setStringValue: [o_disc_dvd_lbl stringValue]];
[o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
NSString *pathToOpen;
if (diskType == kVLCMediaVideoTSFolder)
pathToOpen = [o_opticalDevices objectAtIndex: index];
else
pathToOpen = [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]];
if (!b_nodvdmenus) {
[self setMRL: [NSString stringWithFormat: @"dvdnav://%@", pathToOpen]];
[self showOpticalMediaView: o_disc_dvd_view];
} 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];
} }
else if( i_tag == 1 ) }
else if (diskType == kVLCMediaAudioCD)
{
[o_disc_audiocd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
[o_disc_audiocd_trackcount_lbl setStringValue: [NSString stringWithFormat:_NS("%i tracks"), [[[NSFileManager defaultManager] subpathsOfDirectoryAtPath: [o_opticalDevices objectAtIndex: index] error:NULL] count] - 1]]; // minus .TOC.plist
[self showOpticalMediaView: o_disc_audiocd_view];
[o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
[self setMRL: [NSString stringWithFormat: @"cdda://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
}
else if (diskType == kVLCMediaVCD || diskType == kVLCMediaSVCD)
{ {
[o_disc_chapter setIntValue: [o_disc_chapter_stp intValue]]; [o_disc_vcd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
[self showOpticalMediaView: o_disc_vcd_view];
[o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
[self setMRL: [NSString stringWithFormat: @"vcd://%@@%i:%i", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]], [o_disc_vcd_title intValue], [o_disc_vcd_chapter intValue]]];
}
else if (diskType == kVLCMediaBD || diskType == kVLCMediaBDMVFolder)
{
[o_disc_bd_lbl setStringValue: [[NSFileManager defaultManager] displayNameAtPath:[o_opticalDevices objectAtIndex: index]]];
[self showOpticalMediaView: o_disc_bd_view];
[o_disc_icon_well setImage: [[NSWorkspace sharedWorkspace] iconForFile: [o_opticalDevices objectAtIndex: index]]];
if (diskType == kVLCMediaBD)
[self setMRL: [NSString stringWithFormat: @"bluray://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: index]]]];
else
[self setMRL: [NSString stringWithFormat: @"bluray://%@", [o_opticalDevices objectAtIndex: index]]];
}
else
{
msg_Warn( VLCIntf, "unknown disk type, no idea what to display" );
[o_disc_icon_well setImage: [NSImage imageNamed:@"NSApplicationIcon"]];
[self showOpticalMediaView: o_disc_nodisc_view];
} }
[self openDiscInfoChanged: nil]; [[o_disc_icon_well image] setSize: NSMakeSize(128,128)];
[o_pool release];
} }
- (void)openDiscInfoChanged:(NSNotification *)o_notification - (void)scanOpticalMedia:(NSNotification *)o_notification
{ {
NSString *o_type; [o_opticalDevices removeAllObjects];
NSString *o_device; [o_disc_selector_pop removeAllItems];
NSString *o_videots; [o_opticalDevices addObjectsFromArray: [[NSWorkspace sharedWorkspace] mountedRemovableMedia]];
NSString *o_mrl_string; if ([o_specialMediaFolders count] > 0)
int i_title, i_chapter; [o_opticalDevices addObjectsFromArray: o_specialMediaFolders];
BOOL b_no_menus; if ([o_opticalDevices count] > 0) {
for (int i = 0; i < [o_opticalDevices count] ; i++)
o_type = [[o_disc_type selectedCell] title]; [o_disc_selector_pop addItemWithTitle: [o_opticalDevices objectAtIndex: i]];
o_device = [o_disc_device stringValue];
i_title = [o_disc_title intValue]; if ([o_disc_selector_pop numberOfItems] <= 1)
i_chapter = [o_disc_chapter intValue]; [o_disc_selector_pop setHidden: YES];
o_videots = [o_disc_videots_folder stringValue];
b_no_menus = [o_disc_dvd_menus state];
if ( [o_type isEqualToString: _NS("VCD")] )
{
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];
}
else if ( [o_type isEqualToString: _NS("Audio CD")] )
{
if ( [o_device isEqualToString:
[NSString stringWithFormat: _NS("No %@s found"), o_type]] )
o_device = @"";
o_mrl_string = [NSString stringWithFormat: @"cdda://%@",
o_device];
}
else if ( [o_type isEqualToString: _NS("DVD")] )
{
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 else
o_mrl_string = [NSString stringWithFormat: @"dvdnav://%@", [o_disc_selector_pop setHidden: NO];
o_device];
} [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
else /* VIDEO_TS folder */
{
if ([o_videots length] > 0)
{
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];
} }
else else
o_mrl_string = @""; {
msg_Dbg( VLCIntf, "no optical media found" );
[o_disc_selector_pop setHidden: YES];
[o_disc_icon_well setImage: [NSImage imageNamed: @"NSApplicationIcon"]];
[self showOpticalMediaView: o_disc_nodisc_view];
} }
if ([o_device length] > 0)
[self setMRL: o_mrl_string];
else
[self setMRL: @""];
} }
- (IBAction)openDiscMenusChanged:(id)sender - (IBAction)discSelectorChanged:(id)sender
{ {
[self openDiscInfoChanged: nil]; [NSThread detachNewThreadSelector:@selector(showOpticalAtIndex:) toTarget:self withObject:[NSNumber numberWithInt:[o_disc_selector_pop indexOfSelectedItem]]];
[self openDiscTypeChanged: nil];
} }
- (IBAction)openVTSBrowse:(id)sender - (IBAction)openSpecialMediaFolder:(id)sender
{ {
/* this is currently for VIDEO_TS and BDMV folders */
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel]; NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
[o_open_panel setAllowsMultipleSelection: NO]; [o_open_panel setAllowsMultipleSelection: NO];
[o_open_panel setCanChooseFiles: NO]; [o_open_panel setCanChooseFiles: NO];
[o_open_panel setCanChooseDirectories: YES]; [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")]; [o_open_panel setPrompt: _NS("Open")];
if( [o_open_panel runModal] == NSOKButton ) if ([o_open_panel runModal] == NSOKButton)
{
NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
if ([o_path length] > 0 )
{
if ([o_path rangeOfString:@"VIDEO_TS"].location != NSNotFound || [o_path rangeOfString:@"BDMV"].location != NSNotFound)
{ {
NSString *o_dirname = [[[o_open_panel URLs] objectAtIndex: 0] path]; [o_specialMediaFolders addObject: o_path];
[o_disc_videots_folder setStringValue: o_dirname]; [self scanOpticalMedia: nil];
[self openDiscInfoChanged: nil]; }
else
msg_Dbg( VLCIntf, "chosen directory is no suitable special media folder" );
}
} }
} }
- (IBAction)dvdreadOptionChanged:(id)sender
{
if (sender == o_disc_dvdwomenus_enablemenus_btn) {
b_nodvdmenus = NO;
[self setMRL: [NSString stringWithFormat: @"dvdnav://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]]]];
[self showOpticalMediaView: o_disc_dvd_view];
return;
}
if (sender == o_disc_dvd_disablemenus_btn) {
b_nodvdmenus = YES;
[self showOpticalMediaView: o_disc_dvdwomenus_view];
}
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-", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]], [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]]];
}
- (void)textFieldWasClicked:(NSNotification *)o_notification - (void)textFieldWasClicked:(NSNotification *)o_notification
{ {
if( [o_notification object] == o_net_udp_port ) if( [o_notification object] == o_net_udp_port )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment