OSDN Git Service

MacGui: Integrate HBDVDetector directly into Controller.mm and get rid of ScanControl...
authordynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 27 Aug 2007 05:08:38 +0000 (05:08 +0000)
committerdynaflash <dynaflash@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Mon, 27 Aug 2007 05:08:38 +0000 (05:08 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@873 b64f7644-9d1e-0410-96f1-a4d463321fa5

macosx/Controller.h
macosx/Controller.mm
macosx/English.lproj/MainMenu.nib/classes.nib
macosx/English.lproj/MainMenu.nib/keyedobjects.nib
macosx/HandBrake.xcodeproj/project.pbxproj
macosx/ScanController.h [deleted file]
macosx/ScanController.mm [deleted file]

index 233ef10..2ef1144 100644 (file)
@@ -11,7 +11,6 @@
 
 
 #include "ChapterTitles.h"
-#include "ScanController.h"
 #include "PictureController.h"
 #include "QueueController.h"
 #import "MVMenuButton.h"
 {
     IBOutlet NSWindow            * fWindow;
        
-    /* Scan panel */
-       IBOutlet ScanController      * fScanController;
-    IBOutlet NSPanel             * fScanPanel;
-       
     /* Picture panel */
     IBOutlet PictureController   * fPictureController;
     IBOutlet NSPanel             * fPicturePanel;
     /* Chapters box */
     IBOutlet NSButton            * fCreateChapterMarkers;
     IBOutlet NSTableView         * fChapterTable;
-       ChapterTitles       * fChapterTitlesDelegate;
+       ChapterTitles                * fChapterTitlesDelegate;
        
     /* Bottom */
     IBOutlet NSButton            * fPictureButton;
 - (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;
 
index 18aa65d..11ff795 100644 (file)
@@ -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];
index 0992f80..d199650 100644 (file)
             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; 
index 9ae4b28..4f4eb41 100644 (file)
Binary files a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib and b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib differ
index 81f1291..d2518dd 100644 (file)
@@ -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 */; };
                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>"; };
                                4D1FD382073D19CE00E46515 /* PictureController.mm */,
                                4DF3C8CB052889CD00A80101 /* Controller.h */,
                                4DF3C8CC052889CD00A80101 /* Controller.mm */,
-                               4D86C74E07281F4E007BA979 /* ScanController.mm */,
-                               4D86C74F07281F4E007BA979 /* ScanController.h */,
                                4D85758E052B78E300C39CA9 /* PictureGLView.mm */,
                                4D85758F052B78E300C39CA9 /* PictureGLView.h */,
                                4DD27BA507C0065C0023D231 /* QueueController.h */,
                                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 */,
                                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 (file)
index 8c21b49..0000000
+++ /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 (file)
index 01aa002..0000000
+++ /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