Index: macosx/Controller.mm =================================================================== --- macosx/Controller.mm (revision 730) +++ macosx/Controller.mm (working copy) @@ -35,6 +35,15 @@ 0, 0 } }; +static NSString* MyDocToolbarIdentifier = @"My Document Toolbar Identifier"; +static NSString* ToggleDrawerIdentifier = @"Toggle Drawer Item Identifier"; +static NSString* StartEncodingIdentifier = @"Start Encoding Item Identifier"; +static NSString* PauseEncodingIdentifier = @"Pause Encoding Item Identifier"; +static NSString* ShowQueueIdentifier = @"Show Queue Item Identifier"; +static NSString* AddToQueueIdentifier = @"Add to Queue Item Identifier"; +static NSString* DebugOutputIdentifier = @"Debug Output Item Identifier"; + + /******************************* * HBController implementation * *******************************/ @@ -253,15 +262,192 @@ [fStatusField setStringValue: @""]; [self EnableUI: NO]; - [fPauseButton setEnabled: NO]; - [fRipButton setEnabled: NO]; + startButtonEnabled = NO; + pauseButtonEnabled = NO; + stopOrStart = NO; + AddToQueueButtonEnabled = NO; + resumeOrPause = NO; - /* We disable the Turbo 1st pass checkbox since we are not x264 */ [fVidTurboPassCheck setEnabled: NO]; [fVidTurboPassCheck setState: NSOffState]; + + [self setupToolbar]; + + } +// ============================================================ +// NSToolbar Related Methods +// ============================================================ + +- (void) setupToolbar { + NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: MyDocToolbarIdentifier] autorelease]; + + [toolbar setAllowsUserCustomization: YES]; + [toolbar setAutosavesConfiguration: YES]; + [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel]; + + [toolbar setDelegate: self]; + + [fWindow setToolbar: toolbar]; +} + +- (NSToolbarItem *) toolbar: (NSToolbar *)toolbar itemForItemIdentifier: (NSString *) itemIdent willBeInsertedIntoToolbar:(BOOL) willBeInserted { + NSToolbarItem *toolbarItem = nil; + + if ([itemIdent isEqual: StartEncodingIdentifier]) { + toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; + + [toolbarItem setLabel: @"Start"]; + [toolbarItem setPaletteLabel: @"Start Encoding"]; + + [toolbarItem setToolTip: @"Start Encoding"]; + [toolbarItem setImage: [NSImage imageNamed: @"Play"]]; + + [toolbarItem setTarget: self]; + [toolbarItem setAction: @selector(Rip:)]; + } + else if ([itemIdent isEqual: PauseEncodingIdentifier]) { + toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; + + [toolbarItem setLabel: @"Pause"]; + [toolbarItem setPaletteLabel: @"Pause Encoding"]; + + [toolbarItem setToolTip: @"Pause Encoding"]; + [toolbarItem setImage: [NSImage imageNamed: @"Pause"]]; + + [toolbarItem setTarget: self]; + [toolbarItem setAction: @selector(Pause:)]; + } + else if ([itemIdent isEqual: ShowQueueIdentifier]) { + toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; + + [toolbarItem setLabel: @"Show Queue"]; + [toolbarItem setPaletteLabel: @"Show Queue"]; + + [toolbarItem setToolTip: @"Show Queue"]; + [toolbarItem setImage: [NSImage imageNamed: @"Brushed Window"]]; + + [toolbarItem setTarget: self]; + [toolbarItem setAction: @selector(ShowQueuePanel:)]; + } + else if ([itemIdent isEqual: AddToQueueIdentifier]) { + toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; + + [toolbarItem setLabel: @"Add to Queue"]; + [toolbarItem setPaletteLabel: @"Add to Queue"]; + + [toolbarItem setToolTip: @"Add to Queue"]; + [toolbarItem setImage: [NSImage imageNamed: @"Add"]]; + + [toolbarItem setTarget: self]; + [toolbarItem setAction: @selector(AddToQueue:)]; + } + else if ([itemIdent isEqual: DebugOutputIdentifier]) { + toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; + + [toolbarItem setLabel: @"Debug Output"]; + [toolbarItem setPaletteLabel: @"Show Debug Output Window"]; + + [toolbarItem setToolTip: @"Show Debug Output Window"]; + [toolbarItem setImage: [NSImage imageNamed: @"Terminal"]]; + + [toolbarItem setTarget: self]; + [toolbarItem setAction: @selector(showDebugOutputPanel:)]; + } + else if ([itemIdent isEqual: ToggleDrawerIdentifier]) { + toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdent] autorelease]; + + [toolbarItem setLabel: @"Toggle Drawer"]; + [toolbarItem setPaletteLabel: @"Toggler Drawer"]; + + [toolbarItem setToolTip: @"Open/Close Preset Drawer"]; + [toolbarItem setImage: [NSImage imageNamed: @"Drawer-List2"]]; + + [toolbarItem setTarget: self]; + [toolbarItem setAction: @selector(toggleDrawer)]; + } + else { + toolbarItem = nil; + } + + return toolbarItem; +} + +- (void) toggleDrawer { + [fPresetDrawer toggle:self]; +} + +- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar { + // Required delegate method: Returns the ordered list of items to be shown in the toolbar by default + // If during the toolbar's initialization, no overriding values are found in the user defaults, or if the + // user chooses to revert to the default items this set will be used + return [NSArray arrayWithObjects: StartEncodingIdentifier, PauseEncodingIdentifier, NSToolbarSeparatorItemIdentifier, + AddToQueueIdentifier, ShowQueueIdentifier, + NSToolbarFlexibleSpaceItemIdentifier, + NSToolbarSpaceItemIdentifier, DebugOutputIdentifier, ToggleDrawerIdentifier, nil]; +} + +- (NSArray *) toolbarAllowedItemIdentifiers: (NSToolbar *) toolbar { + // Required delegate method: Returns the list of all allowed items by identifier. By default, the toolbar + // 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, + NSToolbarFlexibleSpaceItemIdentifier, NSToolbarSpaceItemIdentifier, + NSToolbarSeparatorItemIdentifier,ToggleDrawerIdentifier, 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: @"Stop"]; + [toolbarItem setPaletteLabel: @"Stop Encoding"]; + [toolbarItem setToolTip: @"Stop Encoding"]; + } + else { + [toolbarItem setImage: [NSImage imageNamed: @"Play"]]; + [toolbarItem setLabel: @"Start"]; + [toolbarItem setPaletteLabel: @"Start Encoding"]; + [toolbarItem setToolTip: @"Start Encoding"]; + } + } + 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"]; + } + else { + [toolbarItem setImage: [NSImage imageNamed: @"Pause"]]; + [toolbarItem setLabel: @"Pause"]; + [toolbarItem setPaletteLabel: @"Pause Encoding"]; + [toolbarItem setToolTip: @"Pause Encoding"]; + } + } + if ([[toolbarItem itemIdentifier] isEqual: DebugOutputIdentifier]) { + enable = YES; + } + if ([[toolbarItem itemIdentifier] isEqual: ShowQueueIdentifier]) { + enable = YES; + } + if ([[toolbarItem itemIdentifier] isEqual: AddToQueueIdentifier]) { + enable = AddToQueueButtonEnabled; + } + return enable; +} + + // register a test notification and make // it enabled by default #define SERVICE_NAME @"Encode Done" @@ -441,13 +627,11 @@ /* Update dock icon */ [self UpdateDockIcon: progress_total]; - [fPauseButton setEnabled: YES]; - [fPauseButton setTitle: _( @"Pause" )]; - [fRipButton setEnabled: YES]; - [fRipButton setTitle: _( @"Cancel" )]; + pauseButtonEnabled = YES; + resumeOrPause = NO; + startButtonEnabled = YES; + stopOrStart = YES; - - break; } #undef p @@ -469,20 +653,20 @@ /* Update dock icon */ [self UpdateDockIcon: 1.0]; - [fPauseButton setEnabled: YES]; - [fPauseButton setTitle: _( @"Pause" )]; - [fRipButton setEnabled: YES]; - [fRipButton setTitle: _( @"Cancel" )]; + pauseButtonEnabled = YES; + resumeOrPause = NO; + startButtonEnabled = YES; + stopOrStart = YES; + break; } #undef p case HB_STATE_PAUSED: - [fStatusField setStringValue: _( @"Paused" )]; - [fPauseButton setEnabled: YES]; - [fPauseButton setTitle: _( @"Resume" )]; - [fRipButton setEnabled: YES]; - [fRipButton setTitle: _( @"Cancel" )]; + pauseButtonEnabled = YES; + resumeOrPause = YES; + startButtonEnabled = YES; + stopOrStart = YES; break; case HB_STATE_WORKDONE: @@ -490,15 +674,14 @@ [fStatusField setStringValue: _( @"Done." )]; [fRipIndicator setIndeterminate: NO]; [fRipIndicator setDoubleValue: 0.0]; - [fRipButton setTitle: _( @"Start" )]; + stopOrStart = NO; + resumeOrPause = NO; /* Restore dock icon */ [self UpdateDockIcon: -1.0]; - [fPauseButton setEnabled: NO]; - [fPauseButton setTitle: _( @"Pause" )]; - [fRipButton setEnabled: YES]; - [fRipButton setTitle: _( @"Start" )]; + pauseButtonEnabled = NO; + startButtonEnabled = YES; /* FIXME */ hb_job_t * job; @@ -539,6 +722,12 @@ { [self EnableUI: YES]; } + NSRect frame = [fWindow frame]; + if (frame.size.width <= 591) + frame.size.width = 591; + frame.size.height += -38; + frame.origin.y -= -38; + [fWindow setFrame:frame display:YES animate:YES]; break; } } @@ -670,8 +859,9 @@ [self TitlePopUpChanged: NULL]; [self EnableUI: YES]; - [fPauseButton setEnabled: NO]; - [fRipButton setEnabled: YES]; + pauseButtonEnabled = NO; + startButtonEnabled = YES; + AddToQueueButtonEnabled = YES; } @@ -1090,7 +1280,7 @@ - (IBAction) Rip: (id) sender { /* Rip or Cancel ? */ - if( [[fRipButton title] isEqualToString: _( @"Cancel" )] ) + if(stopOrStart) { [self Cancel: sender]; return; @@ -1166,8 +1356,14 @@ /* Disable interface */ //[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; + frame.size.height += 38; + frame.origin.y -= 38; + [fWindow setFrame:frame display:YES animate:YES]; } - (IBAction) Cancel: (id) sender @@ -1184,8 +1380,8 @@ if( returnCode == NSAlertAlternateReturn ) { hb_stop( fHandle ); - [fPauseButton setEnabled: NO]; - [fRipButton setEnabled: NO]; + pauseButtonEnabled = NO; + startButtonEnabled = NO; /*set the fEncodeState State */ fEncodeState = 2; } @@ -1193,10 +1389,10 @@ - (IBAction) Pause: (id) sender { - [fPauseButton setEnabled: NO]; - [fRipButton setEnabled: NO]; - - if( [[fPauseButton title] isEqualToString: _( @"Resume" )] ) + pauseButtonEnabled = NO; + startButtonEnabled = NO; + + if(resumeOrPause) { hb_resume( fHandle ); } Index: macosx/HandBrake.xcodeproj/project.pbxproj =================================================================== --- macosx/HandBrake.xcodeproj/project.pbxproj (revision 730) +++ macosx/HandBrake.xcodeproj/project.pbxproj (working copy) @@ -114,6 +114,13 @@ 59CBD2650BBB4D1B004A3BE3 /* ChapterTitles.m in Sources */ = {isa = PBXBuildFile; fileRef = 593034EA0BBA39A100172349 /* ChapterTitles.m */; }; A29E05800BE1283E000533F5 /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A29E057F0BE1283E000533F5 /* Growl.framework */; }; A29E058B0BE12889000533F5 /* Growl.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = A29E057F0BE1283E000533F5 /* Growl.framework */; }; + A986C76A0C57697300E2B326 /* Add.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A986C7630C57697300E2B326 /* Add.tiff */; }; + A986C76B0C57697300E2B326 /* Brushed Window.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A986C7640C57697300E2B326 /* Brushed Window.tiff */; }; + A986C76C0C57697300E2B326 /* Drawer-List2.png in Resources */ = {isa = PBXBuildFile; fileRef = A986C7650C57697300E2B326 /* Drawer-List2.png */; }; + A986C76D0C57697300E2B326 /* Pause.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A986C7660C57697300E2B326 /* Pause.tiff */; }; + A986C76E0C57697300E2B326 /* Play.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A986C7670C57697300E2B326 /* Play.tiff */; }; + A986C76F0C57697300E2B326 /* Stop.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A986C7680C57697300E2B326 /* Stop.tiff */; }; + A986C7700C57697300E2B326 /* Terminal.tiff in Resources */ = {isa = PBXBuildFile; fileRef = A986C7690C57697300E2B326 /* Terminal.tiff */; }; EAA526930C3B25D200944FF2 /* stream.c in Sources */ = {isa = PBXBuildFile; fileRef = EAA526920C3B25D200944FF2 /* stream.c */; }; EAA526940C3B25D200944FF2 /* stream.c in Sources */ = {isa = PBXBuildFile; fileRef = EAA526920C3B25D200944FF2 /* stream.c */; }; FC6CE2C10C495A6B001A2D5B /* muxmkv.c in Sources */ = {isa = PBXBuildFile; fileRef = FC6CE2C00C495A6B001A2D5B /* muxmkv.c */; }; @@ -235,6 +242,13 @@ 593034EA0BBA39A100172349 /* ChapterTitles.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ChapterTitles.m; sourceTree = ""; }; 59CBD2360BBB44DA004A3BE3 /* parsecsv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = parsecsv.c; path = ../test/parsecsv.c; sourceTree = SOURCE_ROOT; }; A29E057F0BE1283E000533F5 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = Growl.framework; sourceTree = ""; }; + A986C7630C57697300E2B326 /* Add.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Add.tiff; sourceTree = ""; }; + A986C7640C57697300E2B326 /* Brushed Window.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = "Brushed Window.tiff"; sourceTree = ""; }; + A986C7650C57697300E2B326 /* Drawer-List2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Drawer-List2.png"; sourceTree = ""; }; + A986C7660C57697300E2B326 /* Pause.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Pause.tiff; sourceTree = ""; }; + A986C7670C57697300E2B326 /* Play.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Play.tiff; sourceTree = ""; }; + A986C7680C57697300E2B326 /* Stop.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Stop.tiff; sourceTree = ""; }; + A986C7690C57697300E2B326 /* Terminal.tiff */ = {isa = PBXFileReference; lastKnownFileType = image.tiff; path = Terminal.tiff; sourceTree = ""; }; EAA526920C3B25D200944FF2 /* stream.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = stream.c; path = ../libhb/stream.c; sourceTree = SOURCE_ROOT; }; FC6CE2C00C495A6B001A2D5B /* muxmkv.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = muxmkv.c; path = ../libhb/muxmkv.c; sourceTree = SOURCE_ROOT; }; /* End PBXFileReference section */ @@ -302,7 +316,6 @@ 29B97314FDCFA39411CA2CEA /* HandBrake */ = { isa = PBXGroup; children = ( - FC6CE2C00C495A6B001A2D5B /* muxmkv.c */, 526FBC940B4CAA310064E04C /* Instant HandBrake Sources */, 526FBC930B4CAA260064E04C /* HandBrake Sources */, 526FBC920B4CAA120064E04C /* HandBrakeCLI Sources */, @@ -327,6 +340,7 @@ 29B97317FDCFA39411CA2CEA /* Resources */ = { isa = PBXGroup; children = ( + A986C7620C57697300E2B326 /* icons */, 0DFA5C7A0B8DD1E90020BC09 /* HandBrake.icns */, 29B97318FDCFA39411CA2CEA /* MainMenu.nib */, 2538860A0BFE0B730064E995 /* OutputPanel.nib */, @@ -353,6 +367,7 @@ 526FBC8D0B4CA9F90064E04C /* libhb Sources */ = { isa = PBXGroup; children = ( + FC6CE2C00C495A6B001A2D5B /* muxmkv.c */, EAA526920C3B25D200944FF2 /* stream.c */, 0DFA5C7E0B8DD3B60020BC09 /* declpcm.c */, 0DFA5C7F0B8DD3B60020BC09 /* decmpeg2.c */, @@ -437,6 +452,20 @@ name = "Instant HandBrake Sources"; sourceTree = ""; }; + A986C7620C57697300E2B326 /* icons */ = { + isa = PBXGroup; + children = ( + A986C7630C57697300E2B326 /* Add.tiff */, + A986C7640C57697300E2B326 /* Brushed Window.tiff */, + A986C7650C57697300E2B326 /* Drawer-List2.png */, + A986C7660C57697300E2B326 /* Pause.tiff */, + A986C7670C57697300E2B326 /* Play.tiff */, + A986C7680C57697300E2B326 /* Stop.tiff */, + A986C7690C57697300E2B326 /* Terminal.tiff */, + ); + path = icons; + sourceTree = ""; + }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -604,6 +633,13 @@ 0DFA5C7B0B8DD1E90020BC09 /* HandBrake.icns in Resources */, 2538860C0BFE0B730064E995 /* OutputPanel.nib in Resources */, 25DE1FAD0C1699E500F01FC8 /* Preferences.nib in Resources */, + A986C76A0C57697300E2B326 /* Add.tiff in Resources */, + A986C76B0C57697300E2B326 /* Brushed Window.tiff in Resources */, + A986C76C0C57697300E2B326 /* Drawer-List2.png in Resources */, + A986C76D0C57697300E2B326 /* Pause.tiff in Resources */, + A986C76E0C57697300E2B326 /* Play.tiff in Resources */, + A986C76F0C57697300E2B326 /* Stop.tiff in Resources */, + A986C7700C57697300E2B326 /* Terminal.tiff in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; Index: macosx/HBOutputPanelController.m =================================================================== --- macosx/HBOutputPanelController.m (revision 730) +++ macosx/HBOutputPanelController.m (working copy) @@ -55,8 +55,13 @@ [outputPanel setFrameAutosaveName:@"OutputPanelFrame"]; [[textView layoutManager] replaceTextStorage:outputTextStorage]; +<<<<<<< .mine + [[textView enclosingScrollView] setLineScroll:10]; + [[textView enclosingScrollView] setPageScroll:20]; +======= [[textView enclosingScrollView] setLineScroll:10]; [[textView enclosingScrollView] setPageScroll:20]; +>>>>>>> .r730 } [textView scrollRangeToVisible:NSMakeRange([outputTextStorage length], 0)]; Index: macosx/Controller.h =================================================================== --- macosx/Controller.h (revision 730) +++ macosx/Controller.h (working copy) @@ -34,8 +34,6 @@ IBOutlet QueueController * fQueueController; IBOutlet NSPanel * fQueuePanel; IBOutlet NSTextField * fQueueStatus; - IBOutlet NSButton * fQueueAddButton; - IBOutlet NSButton * fQueueShowButton; /* Source box */ IBOutlet NSTextField * fSrcDVD1Field; @@ -205,8 +203,14 @@ of encode 0==idle, 1==encoding, 2==cancelled*/ int fEncodeState; int currentScanCount; - NSString * currentSource; - HBOutputPanelController *outputPanel; + NSString * currentSource; + HBOutputPanelController * outputPanel; + + BOOL startButtonEnabled; + BOOL pauseButtonEnabled; + BOOL AddToQueueButtonEnabled; + BOOL stopOrStart; + bool resumeOrPause; } - (void) TranslateStrings; @@ -319,5 +323,7 @@ -(IBAction)showGrowlDoneNotification:(id)sender; - (IBAction)showDebugOutputPanel:(id)sender; +- (void)setupToolbar; + @end