rendered paste bodyIndex: macosx/Controller.mm===================================================================--- macosx/Controller.mm (revision 741)+++ macosx/Controller.mm (working copy)@@ -38,7 +38,6 @@ /* We setup the toolbar values here */ static NSString* MyDocToolbarIdentifier = @"My Document Toolbar Identifier"; static NSString* ToggleDrawerIdentifier = @"Toggle Drawer Item Identifier";-//static NSString* ToggleDrawerIdentifier = @"Toggle Presets Item Identifier"; static NSString* StartEncodingIdentifier = @"Start Encoding Item Identifier"; static NSString* PauseEncodingIdentifier = @"Pause Encoding Item Identifier"; static NSString* ShowQueueIdentifier = @"Show Queue Item Identifier";@@ -111,7 +110,9 @@ - (NSApplicationTerminateReply) applicationShouldTerminate: (NSApplication *) app {- if( [[fRipButton title] isEqualToString: _( @"Cancel" )] )++ //if( [[fRipButton title] isEqualToString: _( @"Cancel" )] )+ if( HBState == HB_STATE_WORKING || HBState == HB_STATE_PAUSED ) { [self Cancel: NULL]; return NSTerminateCancel;@@ -267,26 +268,15 @@ //[fRipButton setEnabled: NO]; /* Use new Toolbar start and pause here */ - pauseButtonEnabled = NO;- startButtonEnabled = NO;- [self setupToolbar];- /* In Ritsuka's patch, this goes below the Turbo stuff below- Lets try to keep it all together */- startButtonEnabled = NO;- stopOrStart = NO;- AddToQueueButtonEnabled = NO;- pauseButtonEnabled = NO;- resumeOrPause = NO;+ [self setupToolbar]; /* We disable the Turbo 1st pass checkbox since we are not x264 */ [fVidTurboPassCheck setEnabled: NO]; [fVidTurboPassCheck setState: NSOffState]; } -// ============================================================-// NSToolbar Related Methods-// ============================================================-+// NSToolbar Related Methods ------------------------------------------------------------------------------------------------------------+#pragma mark ToolBar - (void) setupToolbar { // Create a new toolbar instance, and attach it to our document window NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: MyDocToolbarIdentifier] autorelease];@@ -326,47 +316,36 @@ } else if ([itemIdent isEqual: StartEncodingIdentifier]) { toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; - // Set the text label to be displayed in the toolbar and customization palette [toolbarItem setLabel: @"Start"]; [toolbarItem setPaletteLabel: @"Start Encoding"]; - // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties [toolbarItem setToolTip: @"Start Encoding"]; [toolbarItem setImage: [NSImage imageNamed: @"Play"]]; - // Tell the item what message to send when it is clicked [toolbarItem setTarget: self]; [toolbarItem setAction: @selector(Rip:)]; -- } else if ([itemIdent isEqual: ShowQueueIdentifier]) { toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; - // Set the text label to be displayed in the toolbar and customization palette [toolbarItem setLabel: @"Show Queue"]; [toolbarItem setPaletteLabel: @"Show Queue"]; - // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties [toolbarItem setToolTip: @"Show Queue"]; [toolbarItem setImage: [NSImage imageNamed: @"Brushed Window"]]; - // Tell the item what message to send when it is clicked [toolbarItem setTarget: self]; [toolbarItem setAction: @selector(ShowQueuePanel:)]; } else if ([itemIdent isEqual: AddToQueueIdentifier]) { toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; - // Set the text label to be displayed in the toolbar and customization palette [toolbarItem setLabel: @"Add to Queue"]; [toolbarItem setPaletteLabel: @"Add to Queue"]; - // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties [toolbarItem setToolTip: @"Add to Queue"]; [toolbarItem setImage: [NSImage imageNamed: @"Add"]]; - // Tell the item what message to send when it is clicked [toolbarItem setTarget: self]; [toolbarItem setAction: @selector(AddToQueue:)]; @@ -374,36 +353,28 @@ } else if ([itemIdent isEqual: PauseEncodingIdentifier]) { toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; - // Set the text label to be displayed in the toolbar and customization palette [toolbarItem setLabel: @"Pause"]; [toolbarItem setPaletteLabel: @"Pause Encoding"]; - // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties [toolbarItem setToolTip: @"Pause Encoding"]; [toolbarItem setImage: [NSImage imageNamed: @"Pause"]]; - // Tell the item what message to send when it is clicked [toolbarItem setTarget: self]; [toolbarItem setAction: @selector(Pause:)]; } else if ([itemIdent isEqual: DebugOutputIdentifier]) { toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; - // Set the text label to be displayed in the toolbar and customization palette [toolbarItem setLabel: @"Activity Window"]; [toolbarItem setPaletteLabel: @"Show Activity Window"]; - // Set up a reasonable tooltip, and image Note, these aren't localized, but you will likely want to localize many of the item's properties [toolbarItem setToolTip: @"Show Activity Window"]; [toolbarItem setImage: [NSImage imageNamed: @"Terminal"]]; - // Tell the item what message to send when it is clicked [toolbarItem setTarget: self]; [toolbarItem setAction: @selector(showDebugOutputPanel:)]; } else {- //itemIdent refered to a toolbar item that is not provide or supported by us or cocoa - //Returning nil will inform the toolbar this kind of item is not supported toolbarItem = nil; } @@ -429,57 +400,58 @@ // does not assume any items are allowed, even the separator. So, every allowed item must be explicitly listed // The set of allowed items is used to construct the customization palette return [NSArray arrayWithObjects: StartEncodingIdentifier, PauseEncodingIdentifier, AddToQueueIdentifier, ShowQueueIdentifier,- DebugOutputIdentifier, NSToolbarCustomizeToolbarItemIdentifier,+ DebugOutputIdentifier, ToggleDrawerIdentifier, NSToolbarCustomizeToolbarItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier, NSToolbarSpaceItemIdentifier,- NSToolbarSeparatorItemIdentifier,ToggleDrawerIdentifier, nil];+ NSToolbarSeparatorItemIdentifier, nil]; } - (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem { // Optional method: This message is sent to us since we are the target of some toolbar item actions BOOL enable = NO;- if ([[toolbarItem itemIdentifier] isEqual: ToggleDrawerIdentifier]) {- enable = YES;- }- if ([[toolbarItem itemIdentifier] isEqual: StartEncodingIdentifier]) {- enable = startButtonEnabled;- if(stopOrStart) {- [toolbarItem setImage: [NSImage imageNamed: @"Stop"]];- [toolbarItem setLabel: @"Cancel"];- [toolbarItem setPaletteLabel: @"Cancel"];- [toolbarItem setToolTip: @"Cancel Encoding"];- }- else {- [toolbarItem setImage: [NSImage imageNamed: @"Play"]];- [toolbarItem setLabel: @"Start"];- [toolbarItem setPaletteLabel: @"Start Encoding"];- [toolbarItem setToolTip: @"Start Encoding"];- }+ if (fHandle && HBState != 0) { - }- if ([[toolbarItem itemIdentifier] isEqual: PauseEncodingIdentifier]) {- enable = pauseButtonEnabled;- if(resumeOrPause) {- [toolbarItem setImage: [NSImage imageNamed: @"Play"]];- [toolbarItem setLabel: @"Resume"];- [toolbarItem setPaletteLabel: @"Resume Encoding"];- [toolbarItem setToolTip: @"Resume Encoding"];+ if ([[toolbarItem itemIdentifier] isEqual: StartEncodingIdentifier]) {+ enable = YES;+ if (HBState == HB_STATE_WORKING && [[toolbarItem label] isEqualToString:@"Start"]) {+ [toolbarItem setImage: [NSImage imageNamed: @"Stop"]];+ [toolbarItem setLabel: @"Cancel"];+ [toolbarItem setPaletteLabel: @"Cancel"];+ [toolbarItem setToolTip: @"Cancel Encoding"];+ }+ else if (HBState == HB_STATE_WORKDONE && [[toolbarItem label] isEqualToString:@"Cancel"]) {+ [toolbarItem setImage: [NSImage imageNamed: @"Play"]];+ [toolbarItem setLabel: @"Start"];+ [toolbarItem setPaletteLabel: @"Start Encoding"];+ [toolbarItem setToolTip: @"Start Encoding"];++ } }- else {- [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];- [toolbarItem setLabel: @"Pause"];- [toolbarItem setPaletteLabel: @"Pause Encoding"];- [toolbarItem setToolTip: @"Pause Encoding"];+ if ([[toolbarItem itemIdentifier] isEqual: PauseEncodingIdentifier]) {+ if (HBState == HB_STATE_WORKING) {+ [toolbarItem setImage: [NSImage imageNamed: @"Pause"]];+ [toolbarItem setLabel: @"Pause"];+ [toolbarItem setPaletteLabel: @"Pause Encoding"];+ [toolbarItem setToolTip: @"Pause Encoding"];+ enable =YES;+ }+ else if (HBState == HB_STATE_PAUSED) {+ [toolbarItem setImage: [NSImage imageNamed: @"Play"]];+ [toolbarItem setLabel: @"Resume"];+ [toolbarItem setPaletteLabel: @"Resume Encoding"];+ [toolbarItem setToolTip: @"Resume Encoding"];+ enable = YES;+ } }++ if ([[toolbarItem itemIdentifier] isEqual: AddToQueueIdentifier])+ enable = YES; }- if ([[toolbarItem itemIdentifier] isEqual: DebugOutputIdentifier]) {+ if ([[toolbarItem itemIdentifier] isEqual: ShowQueueIdentifier])+ enable = YES;+ if ([[toolbarItem itemIdentifier] isEqual: DebugOutputIdentifier]) enable = YES;- }- if ([[toolbarItem itemIdentifier] isEqual: ShowQueueIdentifier]) {+ if ([[toolbarItem itemIdentifier] isEqual: ToggleDrawerIdentifier]) enable = YES;- }- if ([[toolbarItem itemIdentifier] isEqual: AddToQueueIdentifier]) {- enable = AddToQueueButtonEnabled;- } return enable; } @@ -615,8 +587,7 @@ hb_state_t s; hb_get_state( fHandle, &s );--+ switch( s.state ) { case HB_STATE_IDLE:@@ -663,10 +634,7 @@ [self UpdateDockIcon: progress_total]; /* new toolbar controls */- pauseButtonEnabled = YES;- resumeOrPause = NO;- startButtonEnabled = YES;- stopOrStart = YES;+ HBState = s.state; break; }@@ -693,6 +661,8 @@ //[fPauseButton setTitle: _( @"Pause" )]; //[fRipButton setEnabled: YES]; // [fRipButton setTitle: _( @"Cancel" )];++ HBState = s.state; break; } #undef p@@ -704,10 +674,9 @@ //[fRipButton setEnabled: YES]; //[fRipButton setTitle: _( @"Cancel" )]; /* new toolbar controls */- pauseButtonEnabled = YES;- resumeOrPause = YES;- startButtonEnabled = YES;- stopOrStart = YES;++ HBState = s.state;+ break; case HB_STATE_WORKDONE:@@ -725,10 +694,9 @@ // [fRipButton setEnabled: YES]; // [fRipButton setTitle: _( @"Start" )]; /* new toolbar controls */- pauseButtonEnabled = NO;- resumeOrPause = NO;- startButtonEnabled = YES;- stopOrStart = NO;++ HBState = s.state;+ NSRect frame = [fWindow frame]; if (frame.size.width <= 591) frame.size.width = 591;@@ -908,11 +876,8 @@ [self EnableUI: YES]; //[fPauseButton setEnabled: NO]; //[fRipButton setEnabled: YES];- startButtonEnabled = YES;- stopOrStart = NO;- AddToQueueButtonEnabled = YES;- pauseButtonEnabled = NO;- resumeOrPause = NO;+ + HBState = HB_STATE_IDLE; } @@ -1000,16 +965,14 @@ - (IBAction) OpenMainWindow: (id) sender {-[fWindow makeKeyAndOrderFront:nil];-[fWindow setReleasedWhenClosed: YES];+ [fWindow makeKeyAndOrderFront:nil];+ [fWindow setReleasedWhenClosed: YES]; } - (BOOL) windowShouldClose: (id) sender { /* See if we are currently running */- hb_state_t s;- hb_get_state( fHandle, &s );- if ( s.state == HB_STATE_WORKING)+ if (HBState == HB_STATE_WORKING || HBState == HB_STATE_PAUSED) { /* If we are running, leave in memory when closing main window */ [fWindow setReleasedWhenClosed: NO];@@ -1025,6 +988,12 @@ } +- (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender {+ /* Open the main window if the dock icon is clicked and there is no open window */+ [fWindow makeKeyAndOrderFront:nil];+ [fWindow setReleasedWhenClosed: YES];+}+ - (IBAction) VideoMatrixChanged: (id) sender; { bool target, bitrate, quality;@@ -1332,7 +1301,7 @@ { /* Rip or Cancel ? */ // if( [[fRipButton title] isEqualToString: _( @"Cancel" )] )- if(stopOrStart)+ if(HBState == HB_STATE_WORKING || HBState == HB_STATE_PAUSED) { [self Cancel: sender]; return;@@ -1410,8 +1379,6 @@ //[self EnableUI: NO]; // [fPauseButton setEnabled: NO]; // [fRipButton setEnabled: NO];- pauseButtonEnabled = NO;- startButtonEnabled = NO; NSRect frame = [fWindow frame]; if (frame.size.width <= 591) frame.size.width = 591;@@ -1436,8 +1403,6 @@ hb_stop( fHandle ); // [fPauseButton setEnabled: NO]; // [fRipButton setEnabled: NO];- pauseButtonEnabled = NO;- startButtonEnabled = NO; /*set the fEncodeState State */ fEncodeState = 2; }@@ -1447,18 +1412,16 @@ { // [fPauseButton setEnabled: NO]; // [fRipButton setEnabled: NO];- // if( [[fPauseButton title] isEqualToString: _( @"Resume" )] )- pauseButtonEnabled = NO;- startButtonEnabled = NO; - if(resumeOrPause)+ if(HBState == HB_STATE_PAUSED) { hb_resume( fHandle ); } else { hb_pause( fHandle );+ HBState = HB_STATE_PAUSED; } } Index: macosx/Controller.h===================================================================--- macosx/Controller.h (revision 741)+++ macosx/Controller.h (working copy)@@ -208,11 +208,7 @@ NSString * currentSource; HBOutputPanelController *outputPanel; - BOOL startButtonEnabled;- BOOL pauseButtonEnabled;- BOOL AddToQueueButtonEnabled;- BOOL stopOrStart;- BOOL resumeOrPause;+ int HBState; } - (void) TranslateStrings;