summaryrefslogtreecommitdiffstats
path: root/macosx/Controller.mm
diff options
context:
space:
mode:
authordynaflash <[email protected]>2007-07-16 16:47:45 +0000
committerdynaflash <[email protected]>2007-07-16 16:47:45 +0000
commit5e8776b2f2e87120efaae2ed509bce845c5de94c (patch)
tree4195bc8359ea8737f13201d7be1982dabb4261e4 /macosx/Controller.mm
parentec47c624557962fe6cb38499644b40b681f324fb (diff)
MacGui: Active Queue Initial Implementation
- Warning: currently, when adding jobs during encoding, the main window progress bar and task info gets hosed, if a workaround via libhb cannot be easily obtained, a cocoa workaround is available for checkin. - Can now add jobs during encoding - Scan progress bar is a barber pole until scanning progress during encoding is fine tuned. - Needs further testing if DVD Auto Detect is turned on. If conflicts with drive arise, automatically turning off dvd auto detect when adding jobs during encoding is ready for checkin. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@695 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx/Controller.mm')
-rw-r--r--macosx/Controller.mm278
1 files changed, 151 insertions, 127 deletions
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];
}