1 /* $Id: ScanController.mm,v 1.10 2005/04/27 21:05:24 titer Exp $
3 This file is part of the HandBrake source code.
4 Homepage: <http://handbrake.m0k.org/>.
5 It may be used under the terms of the GNU General Public License. */
6 /* These are now called in DriveDetector.h
8 #include <IOKit/IOKitLib.h>
9 #include <IOKit/IOBSD.h>
10 #include <IOKit/storage/IOMedia.h>
11 #include <IOKit/storage/IODVDMedia.h>
14 #include "ScanController.h"
15 #include "DriveDetector.h"
17 #define _(a) NSLocalizedString(a,nil)
18 #define INSERT_STRING @"Insert a DVD"
20 @implementation ScanController
24 - (void) SetHandle: (hb_handle_t *) handle
35 - (void) Browse: (id) sender
39 panel = [NSOpenPanel openPanel];
40 [panel setAllowsMultipleSelection: NO];
41 [panel setCanChooseFiles: YES];
42 [panel setCanChooseDirectories: YES ];
43 NSString * sourceDirectory;
44 if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"])
46 sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"];
50 sourceDirectory = @"~/Desktop";
51 sourceDirectory = [sourceDirectory stringByExpandingTildeInPath];
53 [panel beginSheetForDirectory: sourceDirectory file: nil types: nil
54 modalForWindow: fWindow modalDelegate: self
55 didEndSelector: @selector( BrowseDone:returnCode:contextInfo: )
59 - (void) BrowseDone: (NSOpenPanel *) sheet
60 returnCode: (int) returnCode contextInfo: (void *) contextInfo
62 /* User selected a file to open */
63 if( returnCode == NSOKButton )
65 [fStatusField setStringValue: _( @"Opening a new source ..." )];
66 [fIndicator setHidden: NO];
67 [fIndicator setIndeterminate: YES];
68 [fIndicator startAnimation: nil];
69 [fDriveDetector stop];
71 /* we set the last source directory in the prefs here */
72 NSString *sourceDirectory = [[[sheet filenames] objectAtIndex: 0] stringByDeletingLastPathComponent];
73 [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"];
75 hb_scan( fHandle, [[[sheet filenames] objectAtIndex: 0] UTF8String], 0 );
79 else // User clicked Cancel in browse window
91 - (IBAction) Cancel: (id) sender
93 [NSApp endSheet:fPanel];
94 [fPanel orderOut:self];