~ubuntu-branches/ubuntu/utopic/vlc/utopic

« back to all changes in this revision

Viewing changes to modules/gui/macosx/open.m

  • Committer: Package Import Robot
  • Author(s): Benjamin Drung
  • Date: 2012-07-21 17:52:21 UTC
  • mfrom: (1.1.48) (3.5.44 sid)
  • Revision ID: package-import@ubuntu.com-20120721175221-53m5pclzo992kawy
Tags: 2.0.3-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * open.m: Open dialogues for VLC's MacOS X port
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2002-2012 VLC authors and VideoLAN
5
 
 * $Id: b9fa3618fff62563e0852483d5c62d72d6ccd22d $
 
5
 * $Id: 028703a4fb7c4b476d1617e9a3c2321fcf28ab82 $
6
6
 *
7
7
 * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8
8
 *          Christophe Massiot <massiot@via.ecp.fr>
53
53
NSArray               *qtkvideoDevices;
54
54
#define setEyeTVUnconnected \
55
55
[o_capture_lbl setStringValue: _NS("No device is selected")]; \
56
 
[o_capture_long_lbl setStringValue: _NS("No device is selected.\n\nChoose available device in above pull-down menu\n.")]; \
 
56
[o_capture_long_lbl setStringValue: _NS("No device is selected.\n\nChoose available device in above pull-down menu.\n")]; \
57
57
[o_capture_lbl displayIfNeeded]; \
58
58
[o_capture_long_lbl displayIfNeeded]; \
59
59
[self showCaptureView: o_capture_label_view]
708
708
 
709
709
    GetVolParmsInfoBuffer volumeParms;
710
710
    err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
711
 
    if ( noErr != err ) {
712
 
        msg_Err( p_intf, "error retrieving volume params, bailing out" );
713
 
        return @"";
 
711
    if ( noErr == err )
 
712
    {
 
713
        NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
 
714
        return [NSString stringWithFormat:@"/dev/r%@", bsdName];
714
715
    }
715
716
 
716
 
    NSString *bsdName = [NSString stringWithUTF8String:(char *)volumeParms.vMDeviceID];
717
 
    return [NSString stringWithFormat:@"/dev/r%@", bsdName];
 
717
    return @"";
718
718
}
719
719
 
720
720
- (char *)getVolumeTypeFromMountPath:(NSString *)mountPath
767
767
            {
768
768
                // NSFileManager is not thread-safe, don't use defaultManager outside of the main thread
769
769
                NSFileManager * fm = [[NSFileManager alloc] init];
770
 
                NSArray * topLevelItems;
771
 
                topLevelItems = [fm subpathsOfDirectoryAtPath: mountPath error: NULL];
 
770
 
 
771
                NSArray *dirContents = [fm contentsOfDirectoryAtPath:mountPath error:nil];
 
772
                for (int i = 0; i < [dirContents count]; i++)
 
773
                {
 
774
                    NSString *currentFile = [dirContents objectAtIndex:i];
 
775
                    NSString *fullPath = [mountPath stringByAppendingPathComponent:currentFile];
 
776
 
 
777
                    BOOL isDir;
 
778
                    if ([fm fileExistsAtPath:fullPath isDirectory:&isDir] && isDir)
 
779
                    {
 
780
                        if ([currentFile caseInsensitiveCompare:@"SVCD"] == NSOrderedSame)
 
781
                        {
 
782
                            returnValue = kVLCMediaSVCD;
 
783
                            break;
 
784
                        }
 
785
                        if ([currentFile caseInsensitiveCompare:@"VCD"] == NSOrderedSame)
 
786
                        {
 
787
                            returnValue = kVLCMediaVCD;
 
788
                            break;
 
789
                        }
 
790
                        if ([currentFile caseInsensitiveCompare:@"BDMV"] == NSOrderedSame)
 
791
                        {
 
792
                            returnValue = kVLCMediaBDMVFolder;
 
793
                            break;
 
794
                        }
 
795
                        if ([currentFile caseInsensitiveCompare:@"VIDEO_TS"] == NSOrderedSame)
 
796
                        {
 
797
                            returnValue = kVLCMediaVideoTSFolder;
 
798
                            break;
 
799
                        }
 
800
                    }
 
801
                }
 
802
 
772
803
                [fm release];
773
804
 
774
 
                NSUInteger itemCount = [topLevelItems count];
775
 
                for (int i = 0; i < itemCount; i++) {
776
 
                    if([[topLevelItems objectAtIndex:i] rangeOfString:@"SVCD"].location != NSNotFound) {
777
 
                        returnValue = kVLCMediaSVCD;
778
 
                        break;
779
 
                    }
780
 
                    if([[topLevelItems objectAtIndex:i] rangeOfString:@"VCD"].location != NSNotFound) {
781
 
                        returnValue = kVLCMediaVCD;
782
 
                        break;
783
 
                    }
784
 
                }
785
805
                if(!returnValue)
786
806
                    returnValue = kVLCMediaVideoTSFolder;
787
807
            }
871
891
        else
872
892
            [o_disc_selector_pop setHidden: NO];
873
893
 
 
894
        // select newly added media folder
 
895
        if (o_notification && [[o_notification name] isEqualToString:@"VLCNewMediaFolderNotification"])
 
896
            [o_disc_selector_pop selectItemAtIndex: [[o_disc_selector_pop itemArray] count] - 1];
 
897
 
874
898
        [self showSelectedOpticalDisc];
875
899
    }
876
900
    else
903
927
        if ([o_path length] > 0 )
904
928
        {
905
929
            [o_specialMediaFolders addObject: o_path];
906
 
            [self scanOpticalMedia: nil];
 
930
            [self scanOpticalMedia: [NSNotification notificationWithName:@"VLCNewMediaFolderNotification" object:nil]];
907
931
        }
908
932
    }
909
933
}
910
934
 
911
935
- (IBAction)dvdreadOptionChanged:(id)sender
912
936
{
 
937
    NSString *o_device_path = [o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]];
 
938
    char *diskType = [self getVolumeTypeFromMountPath:o_device_path];
 
939
 
 
940
    NSString *pathToOpen;
 
941
    if (diskType == kVLCMediaVideoTSFolder)
 
942
        pathToOpen = o_device_path;
 
943
    else
 
944
        pathToOpen = [self getBSDNodeFromMountPath: o_device_path];
 
945
 
913
946
    if (sender == o_disc_dvdwomenus_enablemenus_btn) {
914
947
        b_nodvdmenus = NO;
915
 
        [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", [self getBSDNodeFromMountPath:[o_opticalDevices objectAtIndex: [o_disc_selector_pop indexOfSelectedItem]]]]];
 
948
        [self setMRL: [NSString stringWithFormat: @"dvdnav://%@", pathToOpen]];
916
949
        [self showOpticalMediaView: o_disc_dvd_view withIcon: [o_currentOpticalMediaIconView image]];
917
950
        return;
918
951
    }
930
963
    if (sender == o_disc_dvdwomenus_chapter_stp)
931
964
        [o_disc_dvdwomenus_chapter setIntValue: [o_disc_dvdwomenus_chapter_stp intValue]];
932
965
 
933
 
    [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]]];
 
966
    [self setMRL: [NSString stringWithFormat: @"dvdread://%@#%i:%i-", pathToOpen, [o_disc_dvdwomenus_title intValue], [o_disc_dvdwomenus_chapter intValue]]];
934
967
}
935
968
 
936
969
- (IBAction)vcdOptionChanged:(id)sender