[HBPreferencesController registerUserDefaults];
fHandle = NULL;
outputPanel = [[HBOutputPanelController alloc] init];
- fPictureController = [[PictureController alloc] init];
+ fPictureController = [[PictureController alloc] initWithDelegate:self];
fQueueController = [[HBQueueController alloc] init];
fAdvancedOptions = [[HBAdvancedController alloc] init];
return self;
fChapterTitlesDelegate = [[ChapterTitles alloc] init];
[fChapterTable setDataSource:fChapterTitlesDelegate];
- /* Call UpdateUI every 2/10 sec */
+ /* Call UpdateUI every 1/2 sec */
[[NSRunLoop currentRunLoop] addTimer: [NSTimer
- scheduledTimerWithTimeInterval: 0.2 target: self
- selector: @selector( updateUI: ) userInfo: NULL repeats: FALSE]
- forMode: NSModalPanelRunLoopMode];
+ scheduledTimerWithTimeInterval: 0.5 target: self
+ selector: @selector( updateUI: ) userInfo: NULL repeats: YES]
+ forMode: NSEventTrackingRunLoopMode];
if( ( build = hb_check_update( fHandle, &version ) ) > -1 )
{
[fWindow center];
[fWindow setExcludedFromWindowsMenu:YES];
[fAdvancedOptions setView:fAdvancedView];
- /* set the main menu bar so it doesnt auto enable the menu items
- so we can manually do it with setEnabled: This should be changed
- to use validateUserInterfaceItem: along with setAutoEnablesItems: YES
- in the next release */
- [fMenuBarFileMenu setAutoenablesItems: NO];
- [fMenuBarWindowMenu setAutoenablesItems: NO];
- [fMenuPauseEncode setEnabled: NO];
- [self TranslateStrings];
+
/* Initialize currentScanCount so HB can use it to
evaluate successive scans */
currentScanCount = 0;
return NO;
}
+- (BOOL) validateMenuItem: (NSMenuItem *) menuItem
+{
+ SEL action = [menuItem action];
+
+ hb_state_t s;
+ hb_get_state2( fHandle, &s );
+
+ if (fHandle)
+ {
+ if (action == @selector(addToQueue:) || action == @selector(showPicturePanel:) || action == @selector(showAddPresetPanel:))
+ return SuccessfulScan && [fWindow attachedSheet] == nil;
+
+ if (action == @selector(showScanPanel:))
+ {
+ if (s.state == HB_STATE_SCANNING)
+ return NO;
+ else
+ return [fWindow attachedSheet] == nil;
+ }
+ if (action == @selector(selectDefaultPreset:))
+ return [tableView selectedRow] >= 0 && [fWindow attachedSheet] == nil;
+ if (action == @selector(Pause:))
+ {
+ if (s.state == HB_STATE_WORKING)
+ {
+ if(![[menuItem title] isEqualToString:@"Pause Encoding"])
+ [menuItem setTitle:@"Pause Encoding"];
+ return YES;
+ }
+ else if (s.state == HB_STATE_PAUSED)
+ {
+ if(![[menuItem title] isEqualToString:@"Resume Encoding"])
+ [menuItem setTitle:@"Resume Encoding"];
+ return YES;
+ }
+ else
+ return NO;
+ }
+ if (action == @selector(Rip:))
+ if (s.state == HB_STATE_WORKING || s.state == HB_STATE_MUXING || s.state == HB_STATE_PAUSED)
+ {
+ if(![[menuItem title] isEqualToString:@"Stop Encoding"])
+ [menuItem setTitle:@"Stop Encoding"];
+ return YES;
+ }
+ else if (SuccessfulScan)
+ {
+ if(![[menuItem title] isEqualToString:@"Start Encoding"])
+ [menuItem setTitle:@"Start Encoding"];
+ return [fWindow attachedSheet] == nil;
+ }
+ else
+ return NO;
+ }
+
+ return YES;
+}
+
+
// register a test notification and make
// it enabled by default
#define SERVICE_NAME @"Encode Done"
- (NSDictionary *)registrationDictionaryForGrowl
{
-NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
-[NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL,
-[NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT,
-nil];
+ NSDictionary *registrationDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+ [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_ALL,
+ [NSArray arrayWithObjects:SERVICE_NAME,nil], GROWL_NOTIFICATIONS_DEFAULT,
+ nil];
-return registrationDictionary;
+ return registrationDictionary;
}
+
- (void) TranslateStrings
{
[fSrcTitleField setStringValue: _( @"Title:" )];
- (void) updateUI: (NSTimer *) timer
{
-hb_list_t * list;
-list = hb_get_titles( fHandle );
+ hb_list_t * list;
+ list = hb_get_titles( fHandle );
/* 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 */
/* Update dock icon */
[self UpdateDockIcon: progress_total];
- /* Main Menu controls */
- [fMenuPauseEncode setTitle: @"Pause Encode"];
- [fMenuStartEncode setTitle: @"Cancel Encode"];
-
// Has current job changed? That means the queue has probably changed as
// well so update it
if (fLastKnownCurrentJob != hb_current_job(fHandle))
case HB_STATE_PAUSED:
[fStatusField setStringValue: _( @"Paused" )];
- [fMenuPauseEncode setTitle: @"Resume Encode"];
-
// Pass along the info to HBQueueController
[fQueueController updateCurrentJobUI];
[fRipIndicator setIndeterminate: NO];
[fRipIndicator setDoubleValue: 0.0];
[toolbar validateVisibleItems];
-
- /* Main Menu Controls*/
- [fMenuPauseEncode setTitle: @"Pause Encode"];
- [fMenuPauseEncode setEnabled: NO];
- [fMenuStartEncode setTitle: @"Start Encode"];
+
/* Restore dock icon */
[self UpdateDockIcon: -1.0];
{
[fQueueStatus setStringValue: @""];
}
-
- [[NSRunLoop currentRunLoop] addTimer: [NSTimer
- scheduledTimerWithTimeInterval: 0.5 target: self
- selector: @selector( updateUI: ) userInfo: NULL repeats: FALSE]
- forMode: NSModalPanelRunLoopMode];
}
- (IBAction) showNewScan:(id)sender
{
/* We display a message if a valid dvd source was not chosen */
[fSrcDVD2Field setStringValue: @"No Valid Title Found"];
- [fMenuOpenSource setEnabled: YES];
SuccessfulScan = 0;
}
else
currentSuccessfulScanCount++;
[self enableUI: YES];
- /* Enable/Disable Menu Controls Accordingly */
- [fMenuOpenSource setEnabled: YES];
- [fMenuStartEncode setEnabled: YES];
- [fMenuAddToQueue setEnabled: YES];
- [fMenuPicturePanelShow setEnabled: YES];
- [fMenuQueuePanelShow setEnabled: YES];
+
[toolbar validateVisibleItems];
[fSrcTitlePopUp removeAllItems];
- (IBAction) showScanPanel: (id) sender
{
- /* Enable/Disable Menu Controls Accordingly */
- [fMenuOpenSource setEnabled: NO];
- [fMenuStartEncode setEnabled: NO];
- [fMenuAddToQueue setEnabled: NO];
-
- [fMenuPicturePanelShow setEnabled: NO];
- [fMenuQueuePanelShow setEnabled: NO];
[self enableUI: NO];
[self browseSources:NULL];
}
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];
- [fMenuQueuePanelShow setEnabled: YES];
/* if we have a title loaded up */
if ([[fSrcDVD2Field stringValue] length] > 0)
{
- [fMenuAddToQueue setEnabled: YES];
- [fMenuStartEncode setEnabled: YES];
- [fMenuPicturePanelShow setEnabled: YES];
- [self enableUI: YES];
+ [self enableUI: YES];
}
}
}
if( returnCode == NSOKButton )
{
[fDstFile2Field setStringValue: [sheet filename]];
-
}
}
- (IBAction) showPicturePanel: (id) sender
{
- /* Enable/Disable Menu Controls Accordingly */
- [fMenuOpenSource setEnabled: NO];
- [fMenuStartEncode setEnabled: NO];
- [fMenuAddToQueue setEnabled: NO];
-
- [fMenuPicturePanelShow setEnabled: NO];
- [fMenuQueuePanelShow setEnabled: NO];
-
hb_list_t * list = hb_get_titles( fHandle );
hb_title_t * title = (hb_title_t *) hb_list_item( list,
[fSrcTitlePopUp indexOfSelectedItem] );
-
[fPictureController showPanelInWindow:fWindow forTitle:title];
+}
- [fMenuOpenSource setEnabled: YES];
- [fMenuStartEncode setEnabled: YES];
- [fMenuAddToQueue setEnabled: YES];
-
- [fMenuPicturePanelShow setEnabled: YES];
- [fMenuQueuePanelShow setEnabled: YES];
-
- [self calculatePictureSizing: sender];
+- (void)pictureSettingsDidChange {
+ [self calculatePictureSizing: NULL];
}
- (void) PrepareJob
hb_start( fHandle );
/*set the fEncodeState State */
fEncodeState = 1;
-
- [fMenuPauseEncode setEnabled: YES];
}
- (IBAction) Cancel: (id) sender
{
hb_list_t * list = hb_get_titles( fHandle );
hb_title_t * title = (hb_title_t*)
- hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
+ hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
/* If Auto Naming is on. We create an output filename of dvd name - title number */
/* Pixel Ratio Setting */
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"PixelRatio"])
{
-
job->pixel_ratio = 1 ;
}
else
}
-
hb_list_t * list = hb_get_titles( fHandle );
hb_title_t * title = (hb_title_t *)
hb_list_item( list, [fSrcTitlePopUp indexOfSelectedItem] );
{
if ([fSubPopUp indexOfSelectedItem] == 0)
{
- [fSubForcedCheck setState: NSOffState];
- [fSubForcedCheck setEnabled: NO];
+ [fSubForcedCheck setState: NSOffState];
+ [fSubForcedCheck setEnabled: NO];
}
else
{
- [fSubForcedCheck setEnabled: YES];
+ [fSubForcedCheck setEnabled: YES];
}
}
[fVidBitrateField setIntValue: hb_calc_bitrate( job,
[fVidTargetSizeField intValue] )];
-
+ [self customSettingUsed:sender];
}
/* Method to determine if we should change the UI
[fPresetSelectedDisplay setStringValue: @"Custom"];
curUserPresetChosenNum = nil;
-
-
}
}
- (IBAction) showAddPresetPanel: (id) sender
{
/* Deselect the currently selected Preset if there is one*/
- [tableView deselectRow:[tableView selectedRow]];
+ [tableView deselectRow:[tableView selectedRow]];
- /* Populate the preset picture settings popup here */
- [fPresetNewPicSettingsPopUp removeAllItems];
- [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
- [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
- [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
- [fPresetNewPicSettingsPopUp selectItemAtIndex: 0];
+ /* Populate the preset picture settings popup here */
+ [fPresetNewPicSettingsPopUp removeAllItems];
+ [fPresetNewPicSettingsPopUp addItemWithTitle:@"None"];
+ [fPresetNewPicSettingsPopUp addItemWithTitle:@"Current"];
+ [fPresetNewPicSettingsPopUp addItemWithTitle:@"Source Maximum (post source scan)"];
+ [fPresetNewPicSettingsPopUp selectItemAtIndex: 0];
- /* Erase info from the input fields fPresetNewDesc*/
+ /* Erase info from the input fields fPresetNewDesc*/
[fPresetNewName setStringValue: @""];
[fPresetNewDesc setStringValue: @""];
/* Show the panel */
- [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow
- modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
- [NSApp runModalForWindow: fAddPresetPanel];
- [NSApp endSheet: fAddPresetPanel];
- [fAddPresetPanel orderOut: self];
-
-
+ [NSApp beginSheet: fAddPresetPanel modalForWindow: fWindow modalDelegate: NULL didEndSelector: NULL contextInfo: NULL];
}
+
- (IBAction) closeAddPresetPanel: (id) sender
{
- [NSApp stopModal];
+ [NSApp endSheet: fAddPresetPanel];
+ [fAddPresetPanel orderOut: self];
}
-
- (IBAction)addUserPreset:(id)sender
{
-
- /* Here we create a custom user preset */
- [UserPresets addObject:[self createPreset]];
- /* Erase info from the input fields */
- [fPresetNewName setStringValue: @""];
- [fPresetNewDesc setStringValue: @""];
- /* We stop the modal window for the new preset */
- [NSApp stopModal];
- [self addPreset];
-
-
+ if (![[fPresetNewName stringValue] length])
+ NSRunAlertPanel(@"Warning!", @"You need to insert a name for the preset.", @"OK", nil , nil);
+ else
+ {
+ /* Here we create a custom user preset */
+ [UserPresets addObject:[self createPreset]];
+ [self addPreset];
+
+ [self closeAddPresetPanel:NULL];
+ }
}
- (void)addPreset
{
/* if there is a description for the preset, we show it in the tooltip */
if ([[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"])
{
- loc_tip = [NSString stringWithFormat: @"%@",[[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"]];
- return (loc_tip);
+ loc_tip = [NSString stringWithFormat: @"%@",[[UserPresets objectAtIndex:rowIndex] valueForKey:@"PresetDescription"]];
+ return (loc_tip);
}
else
{
- loc_tip = @"No description available";
+ loc_tip = @"No description available";
}
return (loc_tip);
[self savePreset];
}
-
- (void)savePreset
{
[UserPresets writeToFile:UserPresetsFile atomically:YES];
}
-
-
- (void) controlTextDidBeginEditing: (NSNotification *) notification
{
[self calculateBitrate: NULL];