diff options
author | dynaflash <[email protected]> | 2007-08-27 05:08:38 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2007-08-27 05:08:38 +0000 |
commit | 285fdf0693de5c0b791345b51694d2e59246ed29 (patch) | |
tree | 9d054c682457e53e781e176374ddb7f6b99d14c6 /macosx | |
parent | b399b95c674157b268c56b11064ad4874fde0ec7 (diff) |
MacGui: Integrate HBDVDetector directly into Controller.mm and get rid of ScanController and its associated files.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@873 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.h | 12 | ||||
-rw-r--r-- | macosx/Controller.mm | 83 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/classes.nib | 27 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/keyedobjects.nib | bin | 136422 -> 134384 bytes | |||
-rw-r--r-- | macosx/HandBrake.xcodeproj/project.pbxproj | 8 | ||||
-rw-r--r-- | macosx/ScanController.h | 44 | ||||
-rw-r--r-- | macosx/ScanController.mm | 122 |
7 files changed, 81 insertions, 215 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index 233ef101c..2ef1144fb 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -11,7 +11,6 @@ #include "ChapterTitles.h" -#include "ScanController.h" #include "PictureController.h" #include "QueueController.h" #import "MVMenuButton.h" @@ -22,10 +21,6 @@ { IBOutlet NSWindow * fWindow; - /* Scan panel */ - IBOutlet ScanController * fScanController; - IBOutlet NSPanel * fScanPanel; - /* Picture panel */ IBOutlet PictureController * fPictureController; IBOutlet NSPanel * fPicturePanel; @@ -155,7 +150,7 @@ /* Chapters box */ IBOutlet NSButton * fCreateChapterMarkers; IBOutlet NSTableView * fChapterTable; - ChapterTitles * fChapterTitlesDelegate; + ChapterTitles * fChapterTitlesDelegate; /* Bottom */ IBOutlet NSButton * fPictureButton; @@ -256,7 +251,10 @@ - (void) enableUI: (bool) enable; - (IBAction) showNewScan: (id) sender; - (IBAction) showScanPanel: (id) sender; - +- (IBAction) browseSources: (id) sender; +- (void) browseSourcesDone: (NSOpenPanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo; + - (IBAction) titlePopUpChanged: (id) sender; - (IBAction) chapterPopUpChanged: (id) sender; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 18aa65d1c..11ff795f5 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -9,6 +9,12 @@ #include "lang.h" #import "HBOutputPanelController.h" #import "HBPreferencesController.h" +/* Added to integrate scanning into HBController */ +#include <IOKit/IOKitLib.h> +#include <IOKit/storage/IOMedia.h> +#include <IOKit/storage/IODVDMedia.h> +#include "HBDVDDetector.h" +#include "dvdread/dvd_reader.h" #define _(a) NSLocalizedString(a,NULL) @@ -77,7 +83,6 @@ static NSString* ChooseSourceIdentifier = @"Choose Source Item Identifie HBController *hbGrowlDelegate = [[HBController alloc] init]; [GrowlApplicationBridge setGrowlDelegate: hbGrowlDelegate]; /* Init others controllers */ - [fScanController SetHandle: fHandle]; [fPictureController SetHandle: fHandle]; [fQueueController SetHandle: fHandle]; @@ -665,11 +670,11 @@ list = hb_get_titles( fHandle ); { currentScanCount = checkScanCount; - [fScanController Cancel: NULL]; + //[fScanController Cancel: NULL]; [fScanIndicator setIndeterminate: NO]; [fScanIndicator setDoubleValue: 0.0]; [fScanIndicator setHidden: YES]; - [fScanController Cancel: NULL]; + //[fScanController Cancel: NULL]; /* Enable/Disable Menu Controls Accordingly */ [fMenuOpenSource setEnabled: YES]; [fMenuStartEncode setEnabled: YES]; @@ -712,7 +717,6 @@ list = hb_get_titles( fHandle ); [fScanIndicator setIndeterminate: NO]; [fScanIndicator setDoubleValue: 0.0]; [fScanIndicator setHidden: YES]; - [fScanController Cancel: NULL]; [self showNewScan: NULL]; break; } @@ -1145,11 +1149,76 @@ list = hb_get_titles( fHandle ); [fMenuPicturePanelShow setEnabled: NO]; [fMenuQueuePanelShow setEnabled: NO]; - - [fScanController Show]; - + [self browseSources:NULL]; +} + +- (void) browseSources: (id) sender +{ + NSOpenPanel * panel; + + panel = [NSOpenPanel openPanel]; + [panel setAllowsMultipleSelection: NO]; + [panel setCanChooseFiles: YES]; + [panel setCanChooseDirectories: YES ]; + NSString * sourceDirectory; + if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"]) + { + sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"]; + } + else + { + sourceDirectory = @"~/Desktop"; + sourceDirectory = [sourceDirectory stringByExpandingTildeInPath]; + } + [panel beginSheetForDirectory: sourceDirectory file: nil types: nil + modalForWindow: fWindow modalDelegate: self + didEndSelector: @selector( browseSourcesDone:returnCode:contextInfo: ) + contextInfo: nil]; +} + +- (void) browseSourcesDone: (NSOpenPanel *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo +{ + /* User selected a file to open */ + if( returnCode == NSOKButton ) + { + [fSrcDVD2Field setStringValue: _( @"Opening a new source ..." )]; + [fScanIndicator setHidden: NO]; + [fScanIndicator setIndeterminate: YES]; + [fScanIndicator startAnimation: nil]; + + /* we set the last source directory in the prefs here */ + NSString *sourceDirectory = [[[sheet filenames] objectAtIndex: 0] stringByDeletingLastPathComponent]; + [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"]; + + NSString *path = [[sheet filenames] objectAtIndex: 0]; + HBDVDDetector *detector = [HBDVDDetector detectorForPath:path]; + if( [detector isVideoDVD] ) + { + // The chosen path was actually on a DVD, so use the raw block + // device path instead. + path = [detector devicePath]; + } + + hb_scan( fHandle, [path UTF8String], 0 ); + } + else // User clicked Cancel in browse window + { + /* use the outlets to the main menu bar to determine what to + enable and disable */ + [fMenuOpenSource setEnabled: YES]; + /* if we have a title loaded up */ + if ([[fSrcDVD2Field stringValue] length] > 0) + { + [fMenuAddToQueue setEnabled: YES]; + [fMenuStartEncode setEnabled: YES]; + [fMenuPicturePanelShow setEnabled: YES]; + [fMenuQueuePanelShow setEnabled: YES]; + } + } } + - (IBAction) openMainWindow: (id) sender { [fWindow makeKeyAndOrderFront:nil]; diff --git a/macosx/English.lproj/MainMenu.nib/classes.nib b/macosx/English.lproj/MainMenu.nib/classes.nib index 0992f80b4..d19965038 100644 --- a/macosx/English.lproj/MainMenu.nib/classes.nib +++ b/macosx/English.lproj/MainMenu.nib/classes.nib @@ -301,33 +301,6 @@ LANGUAGE = ObjC; OUTLETS = {fScrollView = NSScrollView; fTaskView = NSView; }; SUPERCLASS = NSObject; - }, - { - CLASS = ScanController; - LANGUAGE = ObjC; - OUTLETS = { - fBrowseButton = NSButton; - fCancelButton = NSButton; - fDetectedCell = NSButtonCell; - fDetectedPopUp = NSPopUpButton; - fFolderCell = NSButtonCell; - fFolderField = NSTextField; - fIndicator = NSProgressIndicator; - fMainMenuAddToQueue = NSMenuItem; - fMainMenuOpenSource = NSMenuItem; - fMainMenuPauseEncode = NSMenuItem; - fMainMenuStartEncode = NSMenuItem; - fMainWindowSrcName = NSTextField; - fMatrix = NSMatrix; - fMenuPicturePanelShow = NSMenuItem; - fMenuQueuePanelShow = NSMenuItem; - fOpenButton = NSButton; - fPanel = NSPanel; - fSelectString = NSTextField; - fStatusField = NSTextField; - fWindow = NSWindow; - }; - SUPERCLASS = NSObject; } ); IBVersion = 1; diff --git a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib Binary files differindex 9ae4b2801..4f4eb4130 100644 --- a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib +++ b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib diff --git a/macosx/HandBrake.xcodeproj/project.pbxproj b/macosx/HandBrake.xcodeproj/project.pbxproj index 81f12911a..d2518dd23 100644 --- a/macosx/HandBrake.xcodeproj/project.pbxproj +++ b/macosx/HandBrake.xcodeproj/project.pbxproj @@ -87,7 +87,6 @@ 4D3ECC2709A4917000B2E45F /* WhiteBox.m in Sources */ = {isa = PBXBuildFile; fileRef = 4D3ECC2609A4917000B2E45F /* WhiteBox.m */; }; 4DD93F8F082036E8008E1322 /* Controller.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DF3C8CB052889CD00A80101 /* Controller.h */; }; 4DD93F90082036E8008E1322 /* PictureGLView.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D85758F052B78E300C39CA9 /* PictureGLView.h */; }; - 4DD93F91082036E8008E1322 /* ScanController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D86C74F07281F4E007BA979 /* ScanController.h */; }; 4DD93F92082036E8008E1322 /* PictureController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4D1FD381073D19CE00E46515 /* PictureController.h */; }; 4DD93F93082036E8008E1322 /* QueueController.h in Headers */ = {isa = PBXBuildFile; fileRef = 4DD27BA507C0065C0023D231 /* QueueController.h */; }; 4DD93F96082036E8008E1322 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = 29B97318FDCFA39411CA2CEA /* MainMenu.nib */; }; @@ -95,7 +94,6 @@ 4DD93F9A082036E8008E1322 /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.mm */; settings = {ATTRIBUTES = (); }; }; 4DD93F9B082036E8008E1322 /* Controller.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4DF3C8CC052889CD00A80101 /* Controller.mm */; }; 4DD93F9C082036E8008E1322 /* PictureGLView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D85758E052B78E300C39CA9 /* PictureGLView.mm */; }; - 4DD93F9D082036E8008E1322 /* ScanController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D86C74E07281F4E007BA979 /* ScanController.mm */; }; 4DD93F9E082036E8008E1322 /* PictureController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4D1FD382073D19CE00E46515 /* PictureController.mm */; }; 4DD93F9F082036E8008E1322 /* QueueController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4DD27BA607C0065C0023D231 /* QueueController.mm */; }; 4DD93FA2082036E8008E1322 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; @@ -236,8 +234,6 @@ 4D3ECC2609A4917000B2E45F /* WhiteBox.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = WhiteBox.m; sourceTree = "<group>"; }; 4D85758E052B78E300C39CA9 /* PictureGLView.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = PictureGLView.mm; sourceTree = "<group>"; }; 4D85758F052B78E300C39CA9 /* PictureGLView.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PictureGLView.h; sourceTree = "<group>"; }; - 4D86C74E07281F4E007BA979 /* ScanController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = ScanController.mm; sourceTree = "<group>"; }; - 4D86C74F07281F4E007BA979 /* ScanController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ScanController.h; sourceTree = "<group>"; }; 4DD27BA507C0065C0023D231 /* QueueController.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = QueueController.h; sourceTree = "<group>"; }; 4DD27BA607C0065C0023D231 /* QueueController.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = QueueController.mm; sourceTree = "<group>"; }; 4DDE9724052B7B2B00C39CA9 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = /System/Library/Frameworks/OpenGL.framework; sourceTree = "<absolute>"; }; @@ -450,8 +446,6 @@ 4D1FD382073D19CE00E46515 /* PictureController.mm */, 4DF3C8CB052889CD00A80101 /* Controller.h */, 4DF3C8CC052889CD00A80101 /* Controller.mm */, - 4D86C74E07281F4E007BA979 /* ScanController.mm */, - 4D86C74F07281F4E007BA979 /* ScanController.h */, 4D85758E052B78E300C39CA9 /* PictureGLView.mm */, 4D85758F052B78E300C39CA9 /* PictureGLView.h */, 4DD27BA507C0065C0023D231 /* QueueController.h */, @@ -526,7 +520,6 @@ A2DFC6750C6197C600E66E89 /* MVMenuButton.h in Headers */, 4DD93F8F082036E8008E1322 /* Controller.h in Headers */, 4DD93F90082036E8008E1322 /* PictureGLView.h in Headers */, - 4DD93F91082036E8008E1322 /* ScanController.h in Headers */, 4DD93F92082036E8008E1322 /* PictureController.h in Headers */, 4DD93F93082036E8008E1322 /* QueueController.h in Headers */, A2A1EC310C76C35E00827E0D /* HBDVDDetector.h in Headers */, @@ -799,7 +792,6 @@ 4DD93F9A082036E8008E1322 /* main.mm in Sources */, 4DD93F9B082036E8008E1322 /* Controller.mm in Sources */, 4DD93F9C082036E8008E1322 /* PictureGLView.mm in Sources */, - 4DD93F9D082036E8008E1322 /* ScanController.mm in Sources */, 4DD93F9E082036E8008E1322 /* PictureController.mm in Sources */, 4DD93F9F082036E8008E1322 /* QueueController.mm in Sources */, A2A1EC3A0C76C58400827E0D /* HBDVDDetector.m in Sources */, diff --git a/macosx/ScanController.h b/macosx/ScanController.h deleted file mode 100644 index 8c21b4909..000000000 --- a/macosx/ScanController.h +++ /dev/null @@ -1,44 +0,0 @@ -/* $Id: ScanController.h,v 1.4 2005/03/21 12:37:32 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ - -#include <Cocoa/Cocoa.h> - -#include "hb.h" -//@class DriveDetector; -@interface ScanController : NSObject -{ - hb_handle_t * fHandle; - hb_list_t * fList; - - IBOutlet NSWindow * fWindow; - IBOutlet NSPanel * fPanel; - - IBOutlet NSTextField * fStatusField; - IBOutlet NSProgressIndicator * fIndicator; - IBOutlet NSTextField * fMainWindowSrcName; - - /* Menu Items */ - /* File Menu */ - IBOutlet NSMenuItem * fMainMenuOpenSource; - IBOutlet NSMenuItem * fMainMenuAddToQueue; - IBOutlet NSMenuItem * fMainMenuStartEncode; - IBOutlet NSMenuItem * fMainMenuPauseEncode; - /* Window Menu */ - IBOutlet NSMenuItem * fMenuQueuePanelShow; - IBOutlet NSMenuItem * fMenuPicturePanelShow; - - -} - -- (void) SetHandle: (hb_handle_t *) handle; -- (void) Show; -- (IBAction) Browse: (id) sender; -- (IBAction) Cancel: (id) sender; -- (void) BrowseDone: (NSOpenPanel *) sheet - returnCode: (int) returnCode contextInfo: (void *) contextInfo; - - -@end diff --git a/macosx/ScanController.mm b/macosx/ScanController.mm deleted file mode 100644 index 01aa0026e..000000000 --- a/macosx/ScanController.mm +++ /dev/null @@ -1,122 +0,0 @@ -/* $Id: ScanController.mm,v 1.10 2005/04/27 21:05:24 titer Exp $ - - This file is part of the HandBrake source code. - Homepage: <http://handbrake.m0k.org/>. - It may be used under the terms of the GNU General Public License. */ -/* These are now called in DriveDetector.h -#include <paths.h> -#include <IOKit/IOKitLib.h> -#include <IOKit/IOBSD.h> -#include <IOKit/storage/IOMedia.h> -#include <IOKit/storage/IODVDMedia.h> -*/ - -#include <IOKit/IOKitLib.h> -#include <IOKit/storage/IOMedia.h> -#include <IOKit/storage/IODVDMedia.h> - -#include "HBDVDDetector.h" -#include "ScanController.h" - -#include "dvdread/dvd_reader.h" - -#define _(a) NSLocalizedString(a,nil) -#define INSERT_STRING @"Insert a DVD" - -@implementation ScanController - - - -- (void) SetHandle: (hb_handle_t *) handle -{ - fHandle = handle; -} - -- (void) Show -{ - - [self Browse: NULL]; -} - -- (void) Browse: (id) sender -{ - NSOpenPanel * panel; - - panel = [NSOpenPanel openPanel]; - [panel setAllowsMultipleSelection: NO]; - [panel setCanChooseFiles: YES]; - [panel setCanChooseDirectories: YES ]; - NSString * sourceDirectory; - if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"]) - { - sourceDirectory = [[NSUserDefaults standardUserDefaults] stringForKey:@"LastSourceDirectory"]; - } - else - { - sourceDirectory = @"~/Desktop"; - sourceDirectory = [sourceDirectory stringByExpandingTildeInPath]; - } - [panel beginSheetForDirectory: sourceDirectory file: nil types: nil - modalForWindow: fWindow modalDelegate: self - didEndSelector: @selector( BrowseDone:returnCode:contextInfo: ) - contextInfo: nil]; -} - -- (void) BrowseDone: (NSOpenPanel *) sheet - returnCode: (int) returnCode contextInfo: (void *) contextInfo -{ - /* User selected a file to open */ - if( returnCode == NSOKButton ) - { - [fStatusField setStringValue: _( @"Opening a new source ..." )]; - [fIndicator setHidden: NO]; - [fIndicator setIndeterminate: YES]; - [fIndicator startAnimation: nil]; - - - /* we set the last source directory in the prefs here */ - NSString *sourceDirectory = [[[sheet filenames] objectAtIndex: 0] stringByDeletingLastPathComponent]; - [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"]; - - - - NSString *path = [[sheet filenames] objectAtIndex: 0]; - HBDVDDetector *detector = [HBDVDDetector detectorForPath:path]; - if( [detector isVideoDVD] ) - { - // The chosen path was actually on a DVD, so use the raw block - // device path instead. - path = [detector devicePath]; - } - - hb_scan( fHandle, [path UTF8String], 0 ); - - [self Cancel: nil]; - } - else // User clicked Cancel in browse window - { - /* use the outlets to the main menu bar to determine what to - enable and disable */ - [fMainMenuOpenSource setEnabled: YES]; - /* if we have a title loaded up */ - if ([[fMainWindowSrcName stringValue] length] > 0) - { - [fMainMenuAddToQueue setEnabled: YES]; - [fMainMenuStartEncode setEnabled: YES]; - //[fMainMenuPauseEncode setEnabled: YES]; - [fMenuQueuePanelShow setEnabled: YES]; - [fMenuPicturePanelShow setEnabled: YES]; - } - [self Cancel: nil]; - } - - - -} - -- (IBAction) Cancel: (id) sender -{ - [NSApp endSheet:fPanel]; - [fPanel orderOut:self]; -} -@end |