diff options
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.h | 5 | ||||
-rw-r--r-- | macosx/Controller.mm | 278 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/classes.nib | 1 | ||||
-rw-r--r-- | macosx/English.lproj/MainMenu.nib/keyedobjects.nib | bin | 124101 -> 124513 bytes | |||
-rw-r--r-- | macosx/QueueController.mm | 3 | ||||
-rw-r--r-- | macosx/ScanController.mm | 92 |
6 files changed, 211 insertions, 168 deletions
diff --git a/macosx/Controller.h b/macosx/Controller.h index da1399672..f7e1d5068 100644 --- a/macosx/Controller.h +++ b/macosx/Controller.h @@ -204,7 +204,8 @@ /* integer to set to determine the previous state of encode 0==idle, 1==encoding, 2==cancelled*/ int fEncodeState; - + int currentScanCount; + NSString * currentSource; HBOutputPanelController *outputPanel; } @@ -212,7 +213,7 @@ - (void) UpdateUI: (NSTimer *) timer; - (void) EnableUI: (bool) enable; - +- (IBAction) ShowNewScan: (id) sender; - (IBAction) ShowScanPanel: (id) sender; - (IBAction) TitlePopUpChanged: (id) sender; diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 869f8fd24..2edfb70d6 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -111,7 +111,7 @@ static int FormatSettings[3][4] = [fWindow center]; [self TranslateStrings]; - + currentScanCount = 0; //[self registrationDictionaryForGrowl]; /* Init User Presets .plist */ @@ -367,10 +367,24 @@ return registrationDictionary; - (void) UpdateUI: (NSTimer *) timer { +/* check to see if there has been a new scan done + this bypasses the constraints of HB_STATE_WORKING + not allowing setting a newly scanned source */ +int checkScanCount = hb_get_scancount( fHandle ); +if (checkScanCount > currentScanCount) + { + [fScanController Cancel: NULL]; + [self ShowNewScan: NULL]; + currentScanCount = checkScanCount; + } + + + hb_state_t s; hb_get_state( fHandle, &s ); + switch( s.state ) { case HB_STATE_IDLE: @@ -379,118 +393,12 @@ return registrationDictionary; case HB_STATE_SCANNING: [fScanController UpdateUI: &s]; break; - + #define p s.param.scandone case HB_STATE_SCANDONE: { - hb_list_t * list; - hb_title_t * title; - int indxpri=0; // Used to search the longuest title (default in combobox) - int longuestpri=0; // Used to search the longuest title (default in combobox) - - [fScanController UpdateUI: &s]; - - list = hb_get_titles( fHandle ); - - if( !hb_list_count( list ) ) - { - /* We display a message if a valid dvd source was not chosen */ - [fSrcDVD2Field setStringValue: @"No Valid DVD Source Chosen"]; - break; - } - - - [fSrcTitlePopUp removeAllItems]; - for( int i = 0; i < hb_list_count( list ); i++ ) - { - title = (hb_title_t *) hb_list_item( list, i ); - /*Set DVD Name at top of window*/ - [fSrcDVD2Field setStringValue: [NSString stringWithUTF8String: title->name]]; - - /* Use the dvd name in the default output field here - May want to add code to remove blank spaces for some dvd names*/ - /* Check to see if the last destination has been set,use if so, if not, use Desktop */ - if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"]) - { - [fDstFile2Field setStringValue: [NSString stringWithFormat: - @"%@/%@.mp4", [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"],[NSString - stringWithUTF8String: title->name]]]; - } - else - { - [fDstFile2Field setStringValue: [NSString stringWithFormat: - @"%@/Desktop/%@.mp4", NSHomeDirectory(),[NSString - stringWithUTF8String: title->name]]]; - } - - - if (longuestpri < title->hours*60*60 + title->minutes *60 + title->seconds) - { - longuestpri=title->hours*60*60 + title->minutes *60 + title->seconds; - indxpri=i; - } - - - int format = [fDstFormatPopUp indexOfSelectedItem]; - char * ext = NULL; - switch( format ) - { - case 0: - - /*Get Default MP4 File Extension for mpeg4 (.mp4 or .m4v) from prefs*/ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0) - { - ext = "m4v"; - } - else - { - ext = "mp4"; - } - break; - case 1: - ext = "avi"; - break; - case 2: - ext = "ogm"; - break; - } - - - NSString * string = [fDstFile2Field stringValue]; - /* Add/replace File Output name to the correct extension*/ - if( [string characterAtIndex: [string length] - 4] == '.' ) - { - [fDstFile2Field setStringValue: [NSString stringWithFormat: - @"%@.%s", [string substringToIndex: [string length] - 4], - ext]]; - } - else - { - [fDstFile2Field setStringValue: [NSString stringWithFormat: - @"%@.%s", string, ext]]; - } - - - [fSrcTitlePopUp addItemWithTitle: [NSString - stringWithFormat: @"%d - %02dh%02dm%02ds", - title->index, title->hours, title->minutes, - title->seconds]]; - - } - // Select the longuest title - [fSrcTitlePopUp selectItemAtIndex: indxpri]; - /* We set the Settings Display to "Default" here - until we get default presets implemented */ - [fPresetSelectedDisplay setStringValue: @"Default"]; - /* We set the auto crop in the main window to value "1" just as in PictureController, - as it does not seem to be taken from any job-> variable */ - [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat: - @"%d", 1]]; - - [self TitlePopUpChanged: NULL]; - [self EnableUI: YES]; - [fPauseButton setEnabled: NO]; - [fRipButton setEnabled: YES]; + [fScanController Cancel: NULL]; + [self ShowNewScan: NULL]; break; } #undef p @@ -500,31 +408,35 @@ return registrationDictionary; { float progress_total; NSMutableString * string; - - /* Update text field */ - string = [NSMutableString stringWithFormat: - _( @"Encoding: task %d of %d, %.2f %%" ), - p.job_cur, p.job_count, 100.0 * p.progress]; - if( p.seconds > -1 ) + /* Currently, p.job_cur and p.job_count get screwed up when adding + jobs during encoding, if they cannot be fixed in libhb, will implement a + nasty but working cocoa solution */ + /* Update text field */ + string = [NSMutableString stringWithFormat: _( @"Encoding: task %d of %d, %.2f %%" ), p.job_cur, p.job_count, 100.0 * p.progress]; + + if( p.seconds > -1 ) { [string appendFormat: _( @" (%.2f fps, avg %.2f fps, ETA %02dh%02dm%02ds)" ), p.rate_cur, p.rate_avg, p.hours, p.minutes, p.seconds]; } [fStatusField setStringValue: string]; - + /* Update slider */ - progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count; + progress_total = ( p.progress + p.job_cur - 1 ) / p.job_count; [fRipIndicator setIndeterminate: NO]; [fRipIndicator setDoubleValue: 100.0 * progress_total]; - + /* Update dock icon */ [self UpdateDockIcon: progress_total]; - + [fPauseButton setEnabled: YES]; [fPauseButton setTitle: _( @"Pause" )]; [fRipButton setEnabled: YES]; [fRipButton setTitle: _( @"Cancel" )]; + + + break; } #undef p @@ -564,7 +476,6 @@ return registrationDictionary; case HB_STATE_WORKDONE: { - //[self EnableUI: YES]; [fStatusField setStringValue: _( @"Done." )]; [fRipIndicator setIndeterminate: NO]; [fRipIndicator setDoubleValue: 0.0]; @@ -623,13 +534,12 @@ return registrationDictionary; /* Lets show the queue status here in the main window*/ - - int count = hb_count( fHandle ); - if( count ) + int queue_count = hb_count( fHandle ); + if( queue_count ) { [fQueueStatus setStringValue: [NSString stringWithFormat: @"%d task%s in the queue", - count, ( count > 1 ) ? "s" : ""]]; + queue_count, ( queue_count > 1 ) ? "s" : ""]]; } else { @@ -641,6 +551,118 @@ return registrationDictionary; selector: @selector( UpdateUI: ) userInfo: NULL repeats: FALSE] forMode: NSModalPanelRunLoopMode]; } +- (IBAction) ShowNewScan:(id)sender +{ + hb_list_t * list; + hb_title_t * title; + int indxpri=0; // Used to search the longuest title (default in combobox) + int longuestpri=0; // Used to search the longuest title (default in combobox) + + //[fScanController UpdateUI: &s]; + + list = hb_get_titles( fHandle ); + + if( !hb_list_count( list ) ) + { + /* We display a message if a valid dvd source was not chosen */ + [fSrcDVD2Field setStringValue: @"No Valid DVD Source Chosen"]; + currentSource = [fSrcDVD2Field stringValue]; + } + + + [fSrcTitlePopUp removeAllItems]; + for( int i = 0; i < hb_list_count( list ); i++ ) + { + title = (hb_title_t *) hb_list_item( list, i ); + /*Set DVD Name at top of window*/ + [fSrcDVD2Field setStringValue:[NSString stringWithUTF8String: title->name]]; + currentSource = [NSString stringWithUTF8String: title->dvd]; + /* Use the dvd name in the default output field here + May want to add code to remove blank spaces for some dvd names*/ + /* Check to see if the last destination has been set,use if so, if not, use Desktop */ + if ([[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"]) + { + [fDstFile2Field setStringValue: [NSString stringWithFormat: + @"%@/%@.mp4", [[NSUserDefaults standardUserDefaults] stringForKey:@"LastDestinationDirectory"],[NSString + stringWithUTF8String: title->name]]]; + } + else + { + [fDstFile2Field setStringValue: [NSString stringWithFormat: + @"%@/Desktop/%@.mp4", NSHomeDirectory(),[NSString + stringWithUTF8String: title->name]]]; + } + + + if (longuestpri < title->hours*60*60 + title->minutes *60 + title->seconds) + { + longuestpri=title->hours*60*60 + title->minutes *60 + title->seconds; + indxpri=i; + } + + + int format = [fDstFormatPopUp indexOfSelectedItem]; + char * ext = NULL; + switch( format ) + { + case 0: + + /*Get Default MP4 File Extension for mpeg4 (.mp4 or .m4v) from prefs*/ + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DefaultMpegName"] > 0) + { + ext = "m4v"; + } + else + { + ext = "mp4"; + } + break; + case 1: + ext = "avi"; + break; + case 2: + ext = "ogm"; + break; + } + + + NSString * string = [fDstFile2Field stringValue]; + /* Add/replace File Output name to the correct extension*/ + if( [string characterAtIndex: [string length] - 4] == '.' ) + { + [fDstFile2Field setStringValue: [NSString stringWithFormat: + @"%@.%s", [string substringToIndex: [string length] - 4], + ext]]; + } + else + { + [fDstFile2Field setStringValue: [NSString stringWithFormat: + @"%@.%s", string, ext]]; + } + + + [fSrcTitlePopUp addItemWithTitle: [NSString + stringWithFormat: @"%d - %02dh%02dm%02ds", + title->index, title->hours, title->minutes, + title->seconds]]; + + } + // Select the longuest title + [fSrcTitlePopUp selectItemAtIndex: indxpri]; + /* We set the Settings Display to "Default" here + until we get default presets implemented */ + [fPresetSelectedDisplay setStringValue: @"Default"]; + /* We set the auto crop in the main window to value "1" just as in PictureController, + as it does not seem to be taken from any job-> variable */ + [fPicSettingAutoCrop setStringValue: [NSString stringWithFormat: + @"%d", 1]]; + + [self TitlePopUpChanged: NULL]; + [self EnableUI: YES]; + [fPauseButton setEnabled: NO]; + [fRipButton setEnabled: YES]; +} + -(IBAction)showGrowlDoneNotification:(id)sender { @@ -655,7 +677,6 @@ return registrationDictionary; isSticky:1 clickContext:nil]; } - - (void) EnableUI: (bool) b { NSControl * controls[] = @@ -1049,6 +1070,9 @@ return registrationDictionary; } [[NSUserDefaults standardUserDefaults] setObject:destinationDirectory forKey:@"LastDestinationDirectory"]; + /* Lets try to update stuff, taken from remove in the queue controller */ + [fQueueController performSelectorOnMainThread: @selector( Update: ) + withObject: sender waitUntilDone: NO]; } } @@ -1130,7 +1154,7 @@ return registrationDictionary; fEncodeState = 1; /* Disable interface */ - [self EnableUI: NO]; + //[self EnableUI: NO]; [fPauseButton setEnabled: NO]; [fRipButton setEnabled: NO]; } diff --git a/macosx/English.lproj/MainMenu.nib/classes.nib b/macosx/English.lproj/MainMenu.nib/classes.nib index 795ddf3ce..6967469df 100644 --- a/macosx/English.lproj/MainMenu.nib/classes.nib +++ b/macosx/English.lproj/MainMenu.nib/classes.nib @@ -31,6 +31,7 @@ Rip = id; SetEnabledStateOfAudioMixdownControls = id; ShowAddPresetPanel = id; + ShowNewScan = id; ShowPicturePanel = id; ShowQueuePanel = id; ShowScanPanel = id; diff --git a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib Binary files differindex a10566a0c..2af236d48 100644 --- a/macosx/English.lproj/MainMenu.nib/keyedobjects.nib +++ b/macosx/English.lproj/MainMenu.nib/keyedobjects.nib diff --git a/macosx/QueueController.mm b/macosx/QueueController.mm index 0d2869428..eee7fe60b 100644 --- a/macosx/QueueController.mm +++ b/macosx/QueueController.mm @@ -91,7 +91,7 @@ removeFromSuperviewWithoutNeedingDisplay]; } - for( i = 0; i < hb_count( fHandle ); i++ ) + for( i = 0; i < hb_count( fHandle ); i++ ) { j = hb_job( fHandle, i ); title = j->title; @@ -171,6 +171,7 @@ int displayparwidth = titlewidth * j->pixel_aspect_width / j->pixel_aspect_height; int displayparheight = title->height - j->crop[0] - j->crop[1]; jobPictureDetail = [NSString stringWithFormat: @"Picture: %d x %d Anamorphic", displayparwidth, displayparheight]; + //jobPictureDetail = [NSString stringWithFormat: @"Picture: Anamorphic"]; } else { diff --git a/macosx/ScanController.mm b/macosx/ScanController.mm index 6f2bd22b4..0d40b6ebf 100644 --- a/macosx/ScanController.mm +++ b/macosx/ScanController.mm @@ -57,7 +57,7 @@ /* We show the scan choice sheet */ [NSApp beginSheet:fPanel modalForWindow:fWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; } - else + else // If dvd auto detect is turned off { [fSelectString setStringValue:@""]; @@ -145,7 +145,7 @@ { #define p s->param.scanning case HB_STATE_SCANNING: - [fSelectString setStringValue:@"HandBrake is Scanning Your Source..."]; + [fSelectString setStringValue:@"HandBrake is Scanning Your Source..."]; [fStatusField setStringValue: [NSString stringWithFormat: _( @"Scanning title %d of %d..." ), p.title_cur, p.title_count]]; @@ -153,29 +153,46 @@ p.title_count]; break; #undef p - + case HB_STATE_SCANDONE: [self EnableUI: YES]; [fIndicator setDoubleValue: 0.0]; - - if (hb_list_count(hb_get_titles(fHandle))) + /* + if (hb_list_count(hb_get_titles(fHandle))) { - [fStatusField setStringValue:@""]; - [NSApp endSheet:fPanel]; - [fPanel orderOut:self]; - - } - else - { - [fStatusField setStringValue:_( @"No valid title found.")]; - /* If DVD Auto Detect is disabled */ - if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisableDvdAutoDetect"] == 1) - { - [NSApp endSheet:fPanel]; - [fPanel orderOut:self]; + [fStatusField setStringValue:@""]; + [NSApp endSheet:fPanel]; + [fPanel orderOut:self]; + } - } + else + { + [fStatusField setStringValue:_( @"No valid title found.")]; + // If DVD Auto Detect is disabled + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"DisableDvdAutoDetect"] == 1) + { + [NSApp endSheet:fPanel]; + [fPanel orderOut:self]; + } + } + */ + [fStatusField setStringValue:@""]; + [NSApp endSheet:fPanel]; + [fPanel orderOut:self]; break; + /* garbage collection here just in case we get caught in a HB_STATE_WORKING + phase if scanning while encoding */ + case HB_STATE_WORKING: + + /* Update slider */ + /* Use "barber pole" as we currently have no way to measure + progress of scan while encoding */ + [fStatusField setStringValue:@"Performing background scan ..."]; + [fIndicator setIndeterminate: YES]; + [fIndicator startAnimation: nil]; + break; + + } } @@ -298,30 +315,29 @@ - (void) BrowseDone2: (id) sender { [NSApp beginSheet:fPanel modalForWindow:fWindow modalDelegate:nil didEndSelector:NULL contextInfo:NULL]; + } - (IBAction) Open: (id) sender { - [self EnableUI: NO]; - [fStatusField setStringValue: _( @"Opening..." )]; - - [fDriveDetector stop]; - if( [fMatrix selectedRow] ) - { - /* we set the last source directory in the prefs here */ - NSString *sourceDirectory = [[fFolderField stringValue] stringByDeletingLastPathComponent]; - [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"]; - hb_scan( fHandle, [[fFolderField stringValue] UTF8String], 0 ); - } - else - { - hb_scan( fHandle, [[fDrives objectForKey: [fDetectedPopUp - titleOfSelectedItem]] UTF8String], 0 ); - } - - - + [fStatusField setStringValue: _( @"Opening..." )]; + [fIndicator setIndeterminate: YES]; + [fIndicator startAnimation: nil]; + [fDriveDetector stop]; + + if( [fMatrix selectedRow] ) + { + /* we set the last source directory in the prefs here */ + NSString *sourceDirectory = [[fFolderField stringValue] stringByDeletingLastPathComponent]; + [[NSUserDefaults standardUserDefaults] setObject:sourceDirectory forKey:@"LastSourceDirectory"]; + hb_scan( fHandle, [[fFolderField stringValue] UTF8String], 0 ); + } + else + { + hb_scan( fHandle, [[fDrives objectForKey: [fDetectedPopUp + titleOfSelectedItem]] UTF8String], 0 ); + } } - (IBAction) Cancel: (id) sender |