diff options
author | handbrake <[email protected]> | 2006-01-14 12:56:59 +0000 |
---|---|---|
committer | handbrake <[email protected]> | 2006-01-14 12:56:59 +0000 |
commit | 452f36599a1ea52f3bd42361b534594568c428fd (patch) | |
tree | 7f53f79212cf524f0a13ed5ee2250992f21eabcb /macosx | |
parent | a9a84221af31ca7d11d1aa182d8b152270203f9f (diff) |
HandBrake 0.4
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@5 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.h (renamed from macosx/HBController.h) | 52 | ||||
-rw-r--r-- | macosx/Controller.mm (renamed from macosx/HBController.mm) | 363 | ||||
-rw-r--r-- | macosx/English.lproj/InfoPlist.strings | bin | 488 -> 488 bytes | |||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/classes.nib | 38 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/info.nib | 18 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/objects.nib | bin | 14905 -> 17820 bytes | |||
-rw-r--r-- | macosx/HandBrake.pbproj/project.pbxproj | 53 | ||||
-rw-r--r-- | macosx/PictureGLView.h | 2 | ||||
-rw-r--r-- | macosx/PictureGLView.mm | 2 | ||||
-rw-r--r-- | macosx/TargetSizeField.h | 23 | ||||
-rw-r--r-- | macosx/TargetSizeField.mm | 64 |
11 files changed, 490 insertions, 125 deletions
diff --git a/macosx/HBController.h b/macosx/Controller.h index 2e3339c74..4759a1d5b 100644 --- a/macosx/HBController.h +++ b/macosx/Controller.h @@ -1,4 +1,4 @@ -/* $Id: HBController.h,v 1.19 2003/10/06 21:13:45 titer Exp $ +/* $Id: Controller.h,v 1.6 2003/10/13 23:09:56 titer Exp $ This file is part of the HandBrake source code. Homepage: <http://beos.titer.org/handbrake/>. @@ -6,14 +6,19 @@ #include <Cocoa/Cocoa.h> -#include "Manager.h" +#include "Common.h" #include "PictureGLView.h" +#include "TargetSizeField.h" @interface HBController : NSObject { + bool fDie; + IBOutlet NSWindow * fWindow; + /* Scan view */ + uint64_t fLastDVDDetection; IBOutlet NSView * fScanView; IBOutlet NSMatrix * fScanMatrix; IBOutlet NSPopUpButton * fDVDPopUp; @@ -23,25 +28,44 @@ IBOutlet NSProgressIndicator * fScanProgress; IBOutlet NSButton * fScanButton; + IBOutlet NSView * fTempView; + + /* Rip view */ IBOutlet NSView * fRipView; + + /* Video box */ IBOutlet NSPopUpButton * fTitlePopUp; - IBOutlet NSPopUpButton * fAudioPopUp; - IBOutlet NSTextField * fVideoField; - IBOutlet NSStepper * fVideoStepper; - IBOutlet NSTextField * fAudioField; - IBOutlet NSStepper * fAudioStepper; + IBOutlet NSPopUpButton * fVideoCodecPopUp; + IBOutlet NSMatrix * fVideoMatrix; + IBOutlet NSTextField * fCustomBitrateField; + IBOutlet HBTargetSizeField * fTargetSizeField; IBOutlet NSButton * fTwoPassCheck; IBOutlet NSButton * fCropButton; + + /* Audio box */ + IBOutlet NSPopUpButton * fLanguagePopUp; + IBOutlet NSPopUpButton * fSecondaryLanguagePopUp; + IBOutlet NSPopUpButton * fAudioCodecPopUp; + IBOutlet NSPopUpButton * fAudioBitratePopUp; + + /* Destination box */ + IBOutlet NSPopUpButton * fFileFormatPopUp; IBOutlet NSTextField * fFileField; - IBOutlet NSButton * fRipBrowseButton; + IBOutlet NSButton * fFileBrowseButton; + + /* Bottom */ IBOutlet NSTextField * fRipStatusField; + IBOutlet NSTextField * fRipInfoField; IBOutlet NSProgressIndicator * fRipProgress; IBOutlet NSButton * fSuspendButton; IBOutlet NSButton * fRipButton; + + /* "Done" alert panel */ IBOutlet NSPanel * fDonePanel; + /* Crop & resize panel */ IBOutlet NSPanel * fPicturePanel; - IBOutlet PictureGLView * fPictureGLView; + IBOutlet HBPictureGLView * fPictureGLView; IBOutlet NSTextField * fWidthField; IBOutlet NSStepper * fWidthStepper; IBOutlet NSButton * fDeinterlaceCheck; @@ -56,22 +80,28 @@ IBOutlet NSTextField * fInfoField; int fPicture; - IBOutlet NSView * fBlankView; HBManager * fManager; HBList * fTitleList; } +- (IBAction) ScanMatrixChanged: (id) sender; - (IBAction) BrowseDVD: (id) sender; - (void) BrowseDVDDone: (NSOpenPanel *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo; - (IBAction) Scan: (id) sender; +- (IBAction) TitlePopUpChanged: (id) sender; +- (IBAction) VideoMatrixChanged: (id) sender; +- (IBAction) AudioPopUpChanged: (id) sender; - (IBAction) BrowseFile: (id) sender; - (void) BrowseFileDone: (NSSavePanel *) sheet returnCode: (int) returnCode contextInfo: (void *) contextInfo; - (IBAction) ShowPicturePanel: (id) sender; - (IBAction) ClosePanel: (id) sender; - (IBAction) Rip: (id) sender; +- (void) OverwriteAlertDone: (NSWindow *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo; +- (void) _Rip; - (IBAction) Cancel: (id) sender; - (IBAction) Suspend: (id) sender; - (IBAction) Resume: (id) sender; @@ -82,7 +112,5 @@ - (void) UpdateIntf: (NSTimer *) timer; - (void) DetectDrives; -- (void) ScanEnableIntf: (id) sender; -- (void) UpdatePopUp: (id) sender; @end diff --git a/macosx/HBController.mm b/macosx/Controller.mm index f46d0221a..402d721fa 100644 --- a/macosx/HBController.mm +++ b/macosx/Controller.mm @@ -1,4 +1,4 @@ -/* $Id: HBController.mm,v 1.24 2003/10/06 21:13:45 titer Exp $ +/* $Id: Controller.mm,v 1.10 2003/10/13 23:09:56 titer Exp $ This file is part of the HandBrake source code. Homepage: <http://beos.titer.org/handbrake/>. @@ -10,7 +10,7 @@ #include <IOKit/storage/IOMedia.h> #include <IOKit/storage/IODVDMedia.h> -#include "HBController.h" +#include "Controller.h" #include "Manager.h" @implementation HBController @@ -21,15 +21,17 @@ fManager = new HBManager( true ); /* Update the GUI every 1/10 sec */ + fDie = false; [NSTimer scheduledTimerWithTimeInterval: 0.1 target: self selector: @selector( UpdateIntf: ) - userInfo: nil repeats: FALSE]; + userInfo: nil repeats: YES]; } - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app { /* Clean up */ + fDie = true; delete fManager; return NSTerminateNow; @@ -37,17 +39,21 @@ - (void) awakeFromNib { - [[fScanMatrix cellAtRow: 0 column: 0] - setAction: @selector( ScanEnableIntf: )]; - [[fScanMatrix cellAtRow: 0 column: 0] setTarget: self]; - [[fScanMatrix cellAtRow: 1 column: 0] - setAction: @selector( ScanEnableIntf: )]; - [[fScanMatrix cellAtRow: 1 column: 0] setTarget: self]; + [fDVDPopUp removeAllItems]; [fScanProgress setStyle: NSProgressIndicatorSpinningStyle]; [fScanProgress setDisplayedWhenStopped: NO]; - [fRipProgress setIndeterminate: NO]; - [fTitlePopUp removeAllItems]; - [fAudioPopUp removeAllItems]; + [fAudioBitratePopUp removeAllItems]; + [fAudioBitratePopUp addItemWithTitle: @"32"]; + [fAudioBitratePopUp addItemWithTitle: @"64"]; + [fAudioBitratePopUp addItemWithTitle: @"96"]; + [fAudioBitratePopUp addItemWithTitle: @"128"]; + [fAudioBitratePopUp addItemWithTitle: @"160"]; + [fAudioBitratePopUp addItemWithTitle: @"192"]; + [fAudioBitratePopUp addItemWithTitle: @"224"]; + [fAudioBitratePopUp addItemWithTitle: @"256"]; + [fAudioBitratePopUp addItemWithTitle: @"288"]; + [fAudioBitratePopUp addItemWithTitle: @"320"]; + [fAudioBitratePopUp selectItemWithTitle: @"128"]; char string[1024]; memset( string, 0, 1024 ); snprintf( string, 1024, "%s/Desktop/Movie.avi", getenv( "HOME" ) ); @@ -59,11 +65,9 @@ [fWindow center]; /* Detect DVD drives */ + fLastDVDDetection = GetDate(); [self DetectDrives]; - [self ScanEnableIntf: self]; - - /* Init a blank view, used in window resizing animation */ - fBlankView = [[NSView alloc] init]; + [self ScanMatrixChanged: self]; } - (BOOL) windowShouldClose: (id) sender @@ -98,6 +102,21 @@ } } +- (IBAction) VideoMatrixChanged: (id) sender; +{ + if( ![fVideoMatrix selectedRow] ) + { + [fCustomBitrateField setEnabled: YES]; + [fTargetSizeField setEnabled: NO]; + } + else + { + [fCustomBitrateField setEnabled: NO]; + [fTargetSizeField setEnabled: YES]; + [fTargetSizeField UpdateBitrate]; + } +} + - (IBAction) BrowseFile: (id) sender { /* Open a panel to let the user choose and update the text field */ @@ -188,15 +207,12 @@ /* XXX */ newSize.width = 762 /*fPicturePanelSize.width*/ + title->fOutWidthMax - 720; - newSize.height = 754 /*fPicturePanelSize.height*/ + + newSize.height = 740 /*fPicturePanelSize.height*/ + title->fOutHeightMax - 576; [fPicturePanel setContentSize: newSize]; - [NSApp beginSheet: fPicturePanel - modalForWindow: fWindow - modalDelegate: nil - didEndSelector: nil - contextInfo: nil]; + [NSApp beginSheet: fPicturePanel modalForWindow: fWindow + modalDelegate: nil didEndSelector: nil contextInfo: nil]; [NSApp runModalForWindow: fPicturePanel]; [NSApp endSheet: fPicturePanel]; [fPicturePanel orderOut: self]; @@ -216,19 +232,78 @@ return; } + if( [fCustomBitrateField intValue] < 256 ) + { + NSBeginCriticalAlertSheet( @"Invalid video bitrate", @"Ooops", + nil, nil, fWindow, self, nil, nil, nil, + @"Video bitrate is too low !" ); + return; + } + if( [fCustomBitrateField intValue] > 8192 ) + { + NSBeginCriticalAlertSheet( @"Invalid video bitrate", @"Ooops", + nil, nil, fWindow, self, nil, nil, nil, + @"Video bitrate is too high !" ); + return; + } + if( [fLanguagePopUp indexOfSelectedItem] == + [fSecondaryLanguagePopUp indexOfSelectedItem] ) + { + NSBeginCriticalAlertSheet( @"Invalid secondary language", + @"Ooops", nil, nil, fWindow, self, nil, nil, nil, + @"Do you _really_ want to encode the same audio track twice?" ); + return; + } + + FILE * file; + if( ( file = fopen( [[fFileField stringValue] cString], "r" ) ) ) + { + fclose( file ); + NSBeginCriticalAlertSheet( @"File already exists", + @"Nooo", @"Yes, go ahead!", nil, fWindow, self, + @selector( OverwriteAlertDone:returnCode:contextInfo: ), + nil, nil, + [NSString stringWithFormat: @"Do you want to overwrite %s ?", + [[fFileField stringValue] cString]] ); + return; + } + + [self _Rip]; +} + +- (void) OverwriteAlertDone: (NSWindow *) sheet + returnCode: (int) returnCode contextInfo: (void *) contextInfo +{ + if( returnCode == NSAlertAlternateReturn ) + { + [self _Rip]; + } +} + +- (void) _Rip +{ /* Get the specified title & audio track(s) */ HBTitle * title = (HBTitle*) fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); - HBAudio * audio = (HBAudio*) - title->fAudioList->ItemAt( [fAudioPopUp indexOfSelectedItem] ); + HBAudio * audio1 = (HBAudio*) + title->fAudioList->ItemAt( [fLanguagePopUp indexOfSelectedItem] ); + HBAudio * audio2 = (HBAudio*) + title->fAudioList->ItemAt( [fSecondaryLanguagePopUp + indexOfSelectedItem] ); /* Use user settings */ - title->fBitrate = [fVideoStepper intValue]; - audio->fOutBitrate = [fAudioStepper intValue]; - title->fTwoPass = ( [fTwoPassCheck state] == NSOnState ); + title->fBitrate = [fCustomBitrateField intValue]; + title->fTwoPass = ( [fTwoPassCheck state] == NSOnState ); + audio1->fOutBitrate = [[fAudioBitratePopUp titleOfSelectedItem] + intValue]; + if( audio2 ) + { + audio2->fOutBitrate = + [[fAudioBitratePopUp titleOfSelectedItem] intValue]; + } /* Let libhb do the job */ - fManager->StartRip( title, audio, NULL, + fManager->StartRip( title, audio1, audio2, (char*) [[fFileField stringValue] cString] ); } @@ -303,6 +378,20 @@ - (void) UpdateIntf: (NSTimer *) timer { + if( fDie ) + { + [timer invalidate]; + return; + } + + /* Update DVD popup */ + if( [fWindow contentView] == fScanView && + GetDate() > fLastDVDDetection + 2000000 ) + { + [self DetectDrives]; + fLastDVDDetection = GetDate(); + } + /* Ask libhb about what's happening now */ if( fManager->NeedUpdate() ) { @@ -343,7 +432,7 @@ case HB_MODE_INVALID_VOLUME: { [fScanMatrix setEnabled: YES]; - [self ScanEnableIntf: self]; + [self ScanMatrixChanged: self]; [fScanProgress stopAnimation: self]; [fScanButton setEnabled: YES]; @@ -358,7 +447,7 @@ /* Show a temporary empty view while the window resizing animation */ - [fWindow setContentView: fBlankView ]; + [fWindow setContentView: fTempView ]; /* Actually resize it */ NSRect newFrame; @@ -376,6 +465,7 @@ [fWindow setContentView: fRipView ]; [fSuspendButton setEnabled: NO]; + [fTitlePopUp removeAllItems]; HBTitle * title; for( uint32_t i = 0; i < fTitleList->CountItems(); i++ ) { @@ -387,29 +477,31 @@ title->fLength % 60 ); [[fTitlePopUp menu] addItemWithTitle: [NSString stringWithCString: string] - action: @selector( UpdatePopUp: ) - keyEquivalent: @""]; + action: nil keyEquivalent: @""]; } - [self UpdatePopUp: self]; + [self TitlePopUpChanged: self]; break; } case HB_MODE_ENCODING: { - [fTitlePopUp setEnabled: NO]; - [fAudioPopUp setEnabled: NO]; - [fVideoField setEnabled: NO]; - [fVideoStepper setEnabled: NO]; - [fAudioField setEnabled: NO]; - [fAudioStepper setEnabled: NO]; - [fTwoPassCheck setEnabled: NO]; - [fCropButton setEnabled: NO]; - [fFileField setEnabled: NO]; - [fRipBrowseButton setEnabled: NO]; - [fRipButton setTitle: @"Cancel"]; - [fSuspendButton setEnabled: YES]; - [fSuspendButton setTitle: @"Suspend"]; + [fTitlePopUp setEnabled: NO]; + [fVideoCodecPopUp setEnabled: NO]; + [fVideoMatrix setEnabled: NO]; + [fCustomBitrateField setEnabled: NO]; + [fTargetSizeField setEnabled: NO]; + [fTwoPassCheck setEnabled: NO]; + [fCropButton setEnabled: NO]; + [fLanguagePopUp setEnabled: NO]; + [fSecondaryLanguagePopUp setEnabled: NO]; + [fAudioCodecPopUp setEnabled: NO]; + [fAudioBitratePopUp setEnabled: NO]; + [fFileFormatPopUp setEnabled: NO]; + [fFileBrowseButton setEnabled: NO]; + [fSuspendButton setEnabled: YES]; + [fSuspendButton setTitle: @"Suspend"]; + [fRipButton setTitle: @"Cancel"]; if( !status.fPosition ) { @@ -419,15 +511,22 @@ } else { - char string[1024]; memset( string, 0, 1024 ); - sprintf( string, "Encoding: %.2f %%, %.2f fps " - "(%02d:%02d:%02d remaining)", - 100 * status.fPosition, status.fFrameRate, + char string[1024]; + memset( string, 0, 1024 ); + sprintf( string, "Encoding: %.2f %%", + 100 * status.fPosition ); + [fRipStatusField setStringValue: + [NSString stringWithCString: string]]; + memset( string, 0, 1024 ); + sprintf( string, + "Speed: %.2f fps (%02d:%02d:%02d remaining)", + status.fFrameRate, status.fRemainingTime / 3600, ( status.fRemainingTime % 3600 ) / 60, status.fRemainingTime % 60 ); - [fRipStatusField setStringValue: + [fRipInfoField setStringValue: [NSString stringWithCString: string]]; + [fRipProgress setIndeterminate: NO]; [fRipProgress setDoubleValue: 100 * status.fPosition]; } @@ -438,10 +537,11 @@ case HB_MODE_SUSPENDED: { char string[1024]; memset( string, 0, 1024 ); - sprintf( string, "Encoding: %.2f %%, %.2f fps (PAUSED)", - 100 * status.fPosition, status.fFrameRate) ; + sprintf( string, "Encoding: %.2f %% (PAUSED)", + 100 * status.fPosition ) ; [fRipStatusField setStringValue: [NSString stringWithCString: string]]; + [fRipInfoField setStringValue: @""]; [fRipProgress setDoubleValue: 100 * status.fPosition]; @@ -449,50 +549,91 @@ break; } + case HB_MODE_STOPPING: + [fRipStatusField setStringValue: @"Stopping..."]; + [fRipInfoField setStringValue: @""]; + [fRipProgress setIndeterminate: YES]; + [fRipProgress startAnimation: self];; + break; + case HB_MODE_DONE: case HB_MODE_CANCELED: case HB_MODE_ERROR: - [fTitlePopUp setEnabled: YES]; - [fAudioPopUp setEnabled: YES]; - [fVideoField setEnabled: YES]; - [fVideoStepper setEnabled: YES]; - [fAudioField setEnabled: YES]; - [fAudioStepper setEnabled: YES]; - [fTwoPassCheck setEnabled: YES]; - [fCropButton setEnabled: YES]; - [fFileField setEnabled: YES]; - [fRipBrowseButton setEnabled: YES]; - [fRipButton setEnabled: YES]; - [fRipButton setTitle: @"Rip"]; - [fSuspendButton setEnabled: NO]; - [fSuspendButton setTitle: @"Suspend"]; + [fRipProgress setIndeterminate: NO]; if( status.fMode == HB_MODE_DONE ) { - [fRipStatusField setStringValue: @"Done." ]; [fRipProgress setDoubleValue: 100]; + [fRipStatusField setStringValue: @"Done." ]; NSBeep(); [NSApp requestUserAttention: NSInformationalRequest]; [NSApp beginSheet: fDonePanel - modalForWindow: fWindow - modalDelegate: nil - didEndSelector: nil - contextInfo: nil]; + modalForWindow: fWindow modalDelegate: nil + didEndSelector: nil contextInfo: nil]; [NSApp runModalForWindow: fDonePanel]; [NSApp endSheet: fDonePanel]; [fDonePanel orderOut: self]; } else if( status.fMode == HB_MODE_CANCELED ) { - [fRipStatusField setStringValue: @"Canceled." ]; [fRipProgress setDoubleValue: 0]; + [fRipStatusField setStringValue: @"Canceled." ]; } else { - [fRipStatusField setStringValue: @"An error occured." ]; [fRipProgress setDoubleValue: 0]; + switch( status.fError ) + { + case HB_ERROR_A52_SYNC: + [fRipStatusField setStringValue: + @"An error occured (corrupted AC3 data)." ]; + break; + case HB_ERROR_AVI_WRITE: + [fRipStatusField setStringValue: + @"An error occured (could not write to file)." ]; + break; + case HB_ERROR_DVD_OPEN: + [fRipStatusField setStringValue: + @"An error occured (could not open device)." ]; + break; + case HB_ERROR_DVD_READ: + [fRipStatusField setStringValue: + @"An error occured (DVD read failed)." ]; + break; + case HB_ERROR_MP3_INIT: + [fRipStatusField setStringValue: + @"An error occured (could not init MP3 encoder)." ]; + break; + case HB_ERROR_MP3_ENCODE: + [fRipStatusField setStringValue: + @"An error occured (MP3 encoder failed)." ]; + break; + case HB_ERROR_MPEG4_INIT: + [fRipStatusField setStringValue: + @"An error occured (could not init MPEG4 encoder)." ]; + break; + } } + [fRipInfoField setStringValue: @""]; + + [fTitlePopUp setEnabled: YES]; + [fVideoCodecPopUp setEnabled: YES]; + [fVideoMatrix setEnabled: YES]; + [fTwoPassCheck setEnabled: YES]; + [fCropButton setEnabled: YES]; + [fLanguagePopUp setEnabled: YES]; + [fSecondaryLanguagePopUp setEnabled: YES]; + [fAudioCodecPopUp setEnabled: YES]; + [fAudioBitratePopUp setEnabled: YES]; + [fFileFormatPopUp setEnabled: YES]; + [fFileBrowseButton setEnabled: YES]; + [fSuspendButton setEnabled: NO]; + [fSuspendButton setTitle: @"Suspend"]; + [fRipButton setTitle: @"Rip"]; + + [self VideoMatrixChanged: self]; + /* Warn the finder to update itself */ [[NSWorkspace sharedWorkspace] noteFileSystemChanged: [fFileField stringValue]]; @@ -502,18 +643,10 @@ break; } } - - /* Do it again 1/10 second later */ - [NSTimer scheduledTimerWithTimeInterval: 0.1 - target: self selector: @selector( UpdateIntf: ) - userInfo: nil repeats: FALSE]; } - (void) DetectDrives { - /* Empty the current popup */ - [fDVDPopUp removeAllItems]; - /* Scan DVD drives (stolen from VLC) */ io_object_t next_media; mach_port_t master_port; @@ -544,6 +677,9 @@ return; } + NSMutableArray * drivesList; + drivesList = [NSMutableArray arrayWithCapacity: 1]; + next_media = IOIteratorNext( media_iterator ); if( next_media != NULL ) { @@ -571,9 +707,8 @@ sizeof(psz_buf) - dev_path_length, kCFStringEncodingASCII ) ) { - [[fDVDPopUp menu] addItemWithTitle: - [NSString stringWithCString: psz_buf] - action: nil keyEquivalent: @""]; + [drivesList addObject: + [NSString stringWithCString: psz_buf]]; } CFRelease( str_bsd_path ); @@ -584,9 +719,37 @@ } IOObjectRelease( media_iterator ); + + /* Refresh only if a change occured */ + if( [drivesList count] == (unsigned) [fDVDPopUp numberOfItems] ) + { + bool isSame = true; + for( unsigned i = 0; i < [drivesList count]; i++ ) + { + if( ![[drivesList objectAtIndex: i] isEqualToString: + [fDVDPopUp itemTitleAtIndex: i]] ) + { + isSame = false; + break; + } + } + if( isSame ) + { + return; + } + } + + [fDVDPopUp removeAllItems]; + for( unsigned i = 0; i < [drivesList count]; i++ ) + { + [[fDVDPopUp menu] addItemWithTitle: + [drivesList objectAtIndex: i] action: nil + keyEquivalent: @""]; + } + [self ScanMatrixChanged: self]; } -- (void) ScanEnableIntf: (id) sender +- (IBAction) ScanMatrixChanged: (id) sender { if( ![fScanMatrix selectedRow] ) { @@ -604,12 +767,13 @@ } } -- (void) UpdatePopUp: (id) sender +- (IBAction) TitlePopUpChanged: (id) sender { HBTitle * title = (HBTitle*) fTitleList->ItemAt( [fTitlePopUp indexOfSelectedItem] ); - [fAudioPopUp removeAllItems]; + [fLanguagePopUp removeAllItems]; + [fSecondaryLanguagePopUp removeAllItems]; HBAudio * audio; for( uint32_t i = 0; i < title->fAudioList->CountItems(); i++ ) @@ -618,9 +782,30 @@ /* We cannot use NSPopUpButton's addItemWithTitle because it checks for duplicate entries */ - [[fAudioPopUp menu] addItemWithTitle: + [[fLanguagePopUp menu] addItemWithTitle: [NSString stringWithCString: audio->fDescription] action: nil keyEquivalent: @""]; + [[fSecondaryLanguagePopUp menu] addItemWithTitle: + [NSString stringWithCString: audio->fDescription] + action: nil keyEquivalent: @""]; + } + [fSecondaryLanguagePopUp addItemWithTitle: @"None"]; + [fSecondaryLanguagePopUp selectItemWithTitle: @"None"]; + [fSecondaryLanguagePopUp setEnabled: + ( title->fAudioList->CountItems() > 1 )]; + + [fTargetSizeField SetHBTitle: title]; + if( [fVideoMatrix selectedRow] ) + { + [fTargetSizeField UpdateBitrate]; + } +} + +- (IBAction) AudioPopUpChanged: (id) sender +{ + if( [fVideoMatrix selectedRow] ) + { + [fTargetSizeField UpdateBitrate]; } } diff --git a/macosx/English.lproj/InfoPlist.strings b/macosx/English.lproj/InfoPlist.strings Binary files differindex ae4f04858..5ed7ca9e2 100644 --- a/macosx/English.lproj/InfoPlist.strings +++ b/macosx/English.lproj/InfoPlist.strings diff --git a/macosx/English.lproj/MainMenu.nib/classes.nib b/macosx/English.lproj/MainMenu.nib/classes.nib index df2438f40..38429950c 100644 --- a/macosx/English.lproj/MainMenu.nib/classes.nib +++ b/macosx/English.lproj/MainMenu.nib/classes.nib @@ -3,6 +3,7 @@ {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, { ACTIONS = { + AudioPopUpChanged = id; BrowseDVD = id; BrowseFile = id; Cancel = id; @@ -12,36 +13,39 @@ Resume = id; Rip = id; Scan = id; - ScanEnableIntf = id; + ScanMatrixChanged = id; ShowPicturePanel = id; Suspend = id; + TitlePopUpChanged = id; UpdatePicture = id; - UpdatePopUp = id; + VideoMatrixChanged = id; }; CLASS = HBController; LANGUAGE = ObjC; OUTLETS = { - fAudioField = NSTextField; - fAudioPopUp = NSPopUpButton; - fAudioStepper = NSStepper; - fBlankView = NSView; + fAudioBitratePopUp = NSPopUpButton; + fAudioCodecPopUp = NSPopUpButton; fBottomField = NSTextField; fBottomStepper = NSStepper; fCropButton = NSButton; + fCustomBitrateField = NSTextField; fDVDFolderField = NSTextField; fDVDPopUp = NSPopUpButton; fDeinterlaceCheck = NSButton; fDonePanel = NSPanel; + fFileBrowseButton = NSButton; fFileField = NSTextField; + fFileFormatPopUp = NSPopUpButton; fInfoField = NSTextField; + fLanguagePopUp = NSPopUpButton; fLeftField = NSTextField; fLeftStepper = NSStepper; - fPictureGLView = PictureGLView; + fPictureGLView = HBPictureGLView; fPicturePanel = NSPanel; fRightField = NSTextField; fRightStepper = NSStepper; - fRipBrowseButton = NSButton; fRipButton = NSButton; + fRipInfoField = NSTextField; fRipProgress = NSProgressIndicator; fRipStatusField = NSTextField; fRipView = NSView; @@ -51,19 +55,33 @@ fScanProgress = NSProgressIndicator; fScanStatusField = NSTextField; fScanView = NSView; + fSecondaryLanguagePopUp = NSPopUpButton; fSuspendButton = NSButton; + fTargetSizeField = HBTargetSizeField; + fTempView = NSView; fTitlePopUp = NSPopUpButton; fTopField = NSTextField; fTopStepper = NSStepper; fTwoPassCheck = NSButton; - fVideoField = NSTextField; - fVideoStepper = NSStepper; + fVideoCodecPopUp = NSPopUpButton; + fVideoMatrix = NSMatrix; fWidthField = NSTextField; fWidthStepper = NSStepper; fWindow = NSWindow; }; SUPERCLASS = NSObject; }, + {CLASS = HBPictureGLView; LANGUAGE = ObjC; SUPERCLASS = NSOpenGLView; }, + { + CLASS = HBTargetSizeField; + LANGUAGE = ObjC; + OUTLETS = { + fAudioBitratePopUp = NSPopUpButton; + fBitrateField = NSTextField; + fSecondaryLanguagePopUp = NSPopUpButton; + }; + SUPERCLASS = NSTextField; + }, {CLASS = PictureGLView; LANGUAGE = ObjC; SUPERCLASS = NSOpenGLView; } ); IBVersion = 1; diff --git a/macosx/English.lproj/MainMenu.nib/info.nib b/macosx/English.lproj/MainMenu.nib/info.nib index 0dbd97023..af41a1429 100644 --- a/macosx/English.lproj/MainMenu.nib/info.nib +++ b/macosx/English.lproj/MainMenu.nib/info.nib @@ -3,25 +3,29 @@ <plist version="1.0"> <dict> <key>IBDocumentLocation</key> - <string>109 136 381 380 0 0 1440 878 </string> + <string>29 16 381 380 0 0 1440 878 </string> <key>IBEditorPositions</key> <dict> - <key>249</key> - <string>510 472 420 258 0 0 1440 878 </string> - <key>256</key> - <string>454 372 420 466 0 0 1440 878 </string> <key>29</key> <string>407 469 205 44 0 0 1440 878 </string> + <key>556</key> + <string>510 480 420 244 0 0 1440 878 </string> + <key>583</key> + <string>648 516 144 171 0 0 1440 878 </string> + <key>589</key> + <string>510 282 420 586 0 0 1440 878 </string> </dict> <key>IBFramework Version</key> <string>291.0</string> <key>IBOpenObjects</key> <array> - <integer>249</integer> - <integer>256</integer> + <integer>583</integer> <integer>21</integer> + <integer>589</integer> + <integer>365</integer> <integer>434</integer> <integer>29</integer> + <integer>556</integer> </array> <key>IBSystem Version</key> <string>6R73</string> diff --git a/macosx/English.lproj/MainMenu.nib/objects.nib b/macosx/English.lproj/MainMenu.nib/objects.nib Binary files differindex a7849eb54..9fe323510 100644 --- a/macosx/English.lproj/MainMenu.nib/objects.nib +++ b/macosx/English.lproj/MainMenu.nib/objects.nib diff --git a/macosx/HandBrake.pbproj/project.pbxproj b/macosx/HandBrake.pbproj/project.pbxproj index b4ea5fef5..5f4045553 100644 --- a/macosx/HandBrake.pbproj/project.pbxproj +++ b/macosx/HandBrake.pbproj/project.pbxproj @@ -17,6 +17,8 @@ 4DF3C8CC052889CD00A80101, 4D85758E052B78E300C39CA9, 4D85758F052B78E300C39CA9, + 4D358C000534A91300D654EB, + 4D358C010534A91300D654EB, ); isa = PBXGroup; name = Classes; @@ -156,6 +158,7 @@ 29B97315FDCFA39411CA2CEA = { children = ( 29B97316FDCFA39411CA2CEA, + 4D358C040534AB8100D654EB, 4D929FEB0527903D00A80101, ); isa = PBXGroup; @@ -260,7 +263,7 @@ <key>CFBundleExecutable</key> <string>HandBrake</string> <key>CFBundleGetInfoString</key> - <string>HandBrake 0.3 - By Eric Petit <[email protected]></string> + <string>HandBrake 0.4 - By Eric Petit <[email protected]></string> <key>CFBundleIconFile</key> <string>HandBrake.icns</string> <key>CFBundleIdentifier</key> @@ -272,11 +275,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>0.3</string> + <string>0.4</string> <key>CFBundleSignature</key> <string>HB##</string> <key>CFBundleVersion</key> - <string>0.3</string> + <string>0.4</string> <key>NSMainNibFile</key> <string>MainMenu</string> <key>NSPrincipalClass</key> @@ -291,6 +294,8 @@ 4D929FEC0527903D00A80101, 4D6615EA05288C2300A80101, 4D857591052B78E300C39CA9, + 4D358C020534A91300D654EB, + 4D358C050534AB8100D654EB, ); isa = PBXHeadersBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -311,6 +316,7 @@ 29B9732CFDCFA39411CA2CEA, 4DF3C8CE052889CD00A80101, 4D857590052B78E300C39CA9, + 4D358C030534A91300D654EB, ); isa = PBXSourcesBuildPhase; runOnlyForDeploymentPostprocessing = 0; @@ -391,6 +397,43 @@ settings = { }; }; + 4D358C000534A91300D654EB = { + fileEncoding = 30; + isa = PBXFileReference; + path = TargetSizeField.h; + refType = 4; + }; + 4D358C010534A91300D654EB = { + fileEncoding = 30; + isa = PBXFileReference; + path = TargetSizeField.mm; + refType = 4; + }; + 4D358C020534A91300D654EB = { + fileRef = 4D358C000534A91300D654EB; + isa = PBXBuildFile; + settings = { + }; + }; + 4D358C030534A91300D654EB = { + fileRef = 4D358C010534A91300D654EB; + isa = PBXBuildFile; + settings = { + }; + }; + 4D358C040534AB8100D654EB = { + fileEncoding = 30; + isa = PBXFileReference; + name = Common.h; + path = /Users/titer/HandBrake/core/Common.h; + refType = 0; + }; + 4D358C050534AB8100D654EB = { + fileRef = 4D358C040534AB8100D654EB; + isa = PBXBuildFile; + settings = { + }; + }; 4D6615EA05288C2300A80101 = { fileRef = 4DF3C8CB052889CD00A80101; isa = PBXBuildFile; @@ -557,13 +600,13 @@ 4DF3C8CB052889CD00A80101 = { fileEncoding = 30; isa = PBXFileReference; - path = HBController.h; + path = Controller.h; refType = 4; }; 4DF3C8CC052889CD00A80101 = { fileEncoding = 30; isa = PBXFileReference; - path = HBController.mm; + path = Controller.mm; refType = 4; }; 4DF3C8CE052889CD00A80101 = { diff --git a/macosx/PictureGLView.h b/macosx/PictureGLView.h index effbf3ee2..06e5a16e1 100644 --- a/macosx/PictureGLView.h +++ b/macosx/PictureGLView.h @@ -4,7 +4,7 @@ #include "Manager.h" -@interface PictureGLView : NSOpenGLView +@interface HBPictureGLView : NSOpenGLView { HBManager * fManager; diff --git a/macosx/PictureGLView.mm b/macosx/PictureGLView.mm index 72e564141..79103f6b6 100644 --- a/macosx/PictureGLView.mm +++ b/macosx/PictureGLView.mm @@ -2,7 +2,7 @@ #include "PictureGLView.h" -@implementation PictureGLView +@implementation HBPictureGLView - (void) SetManager: (HBManager*) manager { diff --git a/macosx/TargetSizeField.h b/macosx/TargetSizeField.h new file mode 100644 index 000000000..12224cae7 --- /dev/null +++ b/macosx/TargetSizeField.h @@ -0,0 +1,23 @@ +/* $Id: TargetSizeField.h,v 1.2 2003/10/09 23:33:36 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://beos.titer.org/handbrake/>. + It may be used under the terms of the GNU General Public License. */ + +#include <Cocoa/Cocoa.h> + +#include "Common.h" + +@interface HBTargetSizeField : NSTextField + +{ + HBTitle * fTitle; + IBOutlet NSTextField * fBitrateField; + IBOutlet NSPopUpButton * fSecondaryLanguagePopUp; + IBOutlet NSPopUpButton * fAudioBitratePopUp; +} + +- (void) SetHBTitle: (HBTitle *) title; +- (void) UpdateBitrate; + +@end diff --git a/macosx/TargetSizeField.mm b/macosx/TargetSizeField.mm new file mode 100644 index 000000000..0c43701fb --- /dev/null +++ b/macosx/TargetSizeField.mm @@ -0,0 +1,64 @@ +/* $Id: TargetSizeField.mm,v 1.4 2003/10/09 23:33:36 titer Exp $ + + This file is part of the HandBrake source code. + Homepage: <http://beos.titer.org/handbrake/>. + It may be used under the terms of the GNU General Public License. */ + +#include "TargetSizeField.h" + +@implementation HBTargetSizeField + +- (void) textDidBeginEditing: (NSNotification *) notification +{ + [self UpdateBitrate]; + [super textDidBeginEditing: notification]; +} + +- (void) textDidEndEditing: (NSNotification *) notification +{ + [self UpdateBitrate]; + [super textDidEndEditing: notification]; +} + +- (void) textDidChange: (NSNotification *) notification +{ + [self UpdateBitrate]; + [super textDidChange: notification]; +} + +- (void) SetHBTitle: (HBTitle*) title +{ + fTitle = title; +} + +- (void) UpdateBitrate +{ + int64_t available; + available = (int64_t) [self intValue] * 1024 * 1024; + + /* AVI headers */ + available -= 2048; + + /* Video chunk headers (8 bytes / frame) + and index (16 bytes / frame) */ + available -= 24 * fTitle->fLength * fTitle->fRate / fTitle->fScale; + + /* Audio tracks */ + available -= ( ( [[fSecondaryLanguagePopUp titleOfSelectedItem] + compare: @"None"] == NSOrderedSame ) ? 1 : 2 ) * + ( fTitle->fLength * + [[fAudioBitratePopUp titleOfSelectedItem] intValue] * + 128 + 24 * fTitle->fLength * 44100 / 1152 ); + + if( available < 0 ) + { + [fBitrateField setIntValue: 0]; + } + else + { + [fBitrateField setIntValue: + available / ( 128 * fTitle->fLength )]; + } +} + +@end |