- else if (hb_count(fHandle) > 0)
- [fHBController doRip];
- }
-}
-
-//------------------------------------------------------------------------------------
-// Toggles the pause/resume state of hblib
-//------------------------------------------------------------------------------------
-- (IBAction)togglePauseResume: (id)sender
-{
- if (!fHandle) return;
-
- hb_state_t s;
- hb_get_state2 (fHandle, &s);
-
- if (s.state == HB_STATE_PAUSED)
- hb_resume (fHandle);
- else if ((s.state == HB_STATE_WORKING) || (s.state == HB_STATE_MUXING))
- hb_pause (fHandle);
-}
-
-#if HB_OUTLINE_METRIC_CONTROLS
-static float spacingWidth = 3.0;
-- (IBAction)imageSpacingChanged: (id)sender;
-{
- spacingWidth = [sender floatValue];
- [fOutlineView setNeedsDisplay: YES];
-}
-- (IBAction)indentChanged: (id)sender
-{
- [fOutlineView setIndentationPerLevel: [sender floatValue]];
- [fOutlineView setNeedsDisplay: YES];
-}
-#endif
-
-
-#pragma mark -
-#pragma mark Toolbar
-
-//------------------------------------------------------------------------------------
-// setupToolbar
-//------------------------------------------------------------------------------------
-- (void)setupToolbar
-{
- // Create a new toolbar instance, and attach it to our window
- NSToolbar *toolbar = [[[NSToolbar alloc] initWithIdentifier: HBQueueToolbar] autorelease];
-
- // Set up toolbar properties: Allow customization, give a default display mode, and remember state in user defaults
- [toolbar setAllowsUserCustomization: YES];
- [toolbar setAutosavesConfiguration: YES];
- [toolbar setDisplayMode: NSToolbarDisplayModeIconAndLabel];
-
- // We are the delegate
- [toolbar setDelegate: self];
-
- // Attach the toolbar to our window
- [fQueueWindow setToolbar: toolbar];
-}
-
-//------------------------------------------------------------------------------------
-// toolbar:itemForItemIdentifier:willBeInsertedIntoToolbar:
-//------------------------------------------------------------------------------------
-- (NSToolbarItem *)toolbar:(NSToolbar *)toolbar
- itemForItemIdentifier:(NSString *)itemIdentifier
- willBeInsertedIntoToolbar:(BOOL)flag
-{
- // Required delegate method: Given an item identifier, this method returns an item.
- // The toolbar will use this method to obtain toolbar items that can be displayed
- // in the customization sheet, or in the toolbar itself.
-
- NSToolbarItem *toolbarItem = nil;
-
- if ([itemIdentifier isEqual: HBQueueStartCancelToolbarIdentifier])
- {
- toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
-
- // Set the text label to be displayed in the toolbar and customization palette
- [toolbarItem setLabel: @"Start"];
- [toolbarItem setPaletteLabel: @"Start/Cancel"];
-
- // Set up a reasonable tooltip, and image
- [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(toggleStartCancel:)];
- }
-
- if ([itemIdentifier isEqual: HBQueuePauseResumeToolbarIdentifier])
- {
- toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
-
- // Set the text label to be displayed in the toolbar and customization palette
- [toolbarItem setLabel: @"Pause"];
- [toolbarItem setPaletteLabel: @"Pause/Resume"];
-
- // Set up a reasonable tooltip, and image
- [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(togglePauseResume:)];
- }
-
-#if !HB_OUTLINE_QUEUE
- else if ([itemIdentifier isEqual: HBShowDetailToolbarIdentifier])
- {
- toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
-
- // Set the text label to be displayed in the toolbar and customization palette
- [toolbarItem setLabel: @"Detail"];
- [toolbarItem setPaletteLabel: @"Detail"];
-
- // Set up a reasonable tooltip, and image
- [toolbarItem setToolTip: @"Displays detailed information in the queue"];
- [toolbarItem setImage: [NSImage imageNamed: @"Detail"]];
-
- // Tell the item what message to send when it is clicked
- [toolbarItem setTarget: self];
- [toolbarItem setAction: fShowsDetail ? @selector(hideDetail:) : @selector(showDetail:)];
- }
-
- else if ([itemIdentifier isEqual: HBShowGroupsToolbarIdentifier])
- {
- toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier: itemIdentifier] autorelease];
-
-/*
- // Set the text label to be displayed in the toolbar and customization palette
- [toolbarItem setLabel: @"Passes"];
- [toolbarItem setPaletteLabel: @"Passes"];
-
- // Set up a reasonable tooltip, and image
- [toolbarItem setToolTip: @"Displays individual passes in the queue"];
- [toolbarItem setImage: [NSImage imageNamed: @"Passes"]];
-
- // Tell the item what message to send when it is clicked
- [toolbarItem setTarget: self];
- [toolbarItem setAction: fShowsJobsAsGroups ? @selector(showJobsAsPasses:) : @selector(showJobsAsGroups:)];
-*/
-
-// Various attempts at other button types in the toolbar. A matrix worked fine to display
-// a button for encodes & passes, but ultimately I decided to go with a single button
-// called "Passes" that toggles on or off. All these suffer from the fact taht you need
-// to override NSToolbarItem for them in order to validate their state.
- [toolbarItem setLabel: @"View"];
- [toolbarItem setPaletteLabel: @"View"];
-
- NSButtonCell * buttonCell = [[[NSButtonCell alloc] initImageCell:nil] autorelease];
- [buttonCell setBezelStyle:NSShadowlessSquareBezelStyle];
- [buttonCell setButtonType:NSToggleButton];
- [buttonCell setBordered:NO];
- [buttonCell setImagePosition:NSImageOnly];
-
- NSMatrix * matrix = [[[NSMatrix alloc] initWithFrame:NSMakeRect(0,0,54,25)
- mode:NSRadioModeMatrix
- prototype:buttonCell
- numberOfRows:1
- numberOfColumns:2] autorelease];
- [matrix setCellSize:NSMakeSize(27, 25)];
- [matrix setIntercellSpacing:NSMakeSize(0, 0)];
- [matrix selectCellAtRow:0 column:(fShowsJobsAsGroups ? 0 : 1)];
-
- buttonCell = [matrix cellAtRow:0 column:0];
- [buttonCell setTitle:@""];
- [buttonCell setImage:[NSImage imageNamed: @"Encodes"]];
- [buttonCell setAlternateImage:[NSImage imageNamed: @"EncodesPressed"]];
- [buttonCell setAction: @selector(showJobsAsGroups:)];
- [matrix setToolTip: @"Displays encodes in the queue" forCell:buttonCell];
-
- buttonCell = [matrix cellAtRow:0 column:1];
- [buttonCell setTitle:@""];
- [buttonCell setImage:[NSImage imageNamed: @"Passes"]];
- [buttonCell setAlternateImage:[NSImage imageNamed: @"PassesPressed"]];
- [buttonCell setAction: @selector(showJobsAsPasses:)];
- [matrix setToolTip: @"Displays individual passes in the queue" forCell:buttonCell];
-
- [toolbarItem setMinSize: [matrix frame].size];
- [toolbarItem setMaxSize: [matrix frame].size];
- [toolbarItem setView: matrix];
-
-/*
- NSSegmentedControl * segControl = [[[NSSegmentedControl alloc] initWithFrame:NSMakeRect(0,0,20,20)] autorelease];
- [[segControl cell] setControlSize:NSSmallControlSize];
- [segControl setSegmentCount:2];
- [segControl setLabel:@"Encodes" forSegment:0];
- [segControl setLabel:@"Passes" forSegment:1];
- [segControl setImage:[NSImage imageNamed:@"Delete"] forSegment:0];
- [segControl setImage:[NSImage imageNamed:@"Delete"] forSegment:1];
- [segControl setSelectedSegment: (fShowsJobsAsGroups ? 0 : 1)];
- [segControl sizeToFit];
- [toolbarItem setMinSize: [segControl frame].size];
- [toolbarItem setMaxSize: [segControl frame].size];
- [toolbarItem setView: segControl];
-*/
-
-/*
- NSButton * button = [[[NSButton alloc] initWithFrame:NSMakeRect(0,0,32,32)] autorelease];
- [button setButtonType:NSSwitchButton];
- [button setTitle:@""];
- [button setState: fShowsJobsAsGroups ? NSOnState : NSOffState];
- [toolbarItem setMinSize: NSMakeSize(20,20)];
- [toolbarItem setMaxSize: NSMakeSize(20,20)];
- [toolbarItem setView: button];
-
- // Tell the item what message to send when it is clicked
- [toolbarItem setTarget: self];
- [toolbarItem setAction: @selector(jobGroupsChanged:)];
-*/
- }
-#endif
-
- return toolbarItem;
-}
-
-//------------------------------------------------------------------------------------
-// toolbarDefaultItemIdentifiers:
-//------------------------------------------------------------------------------------
-- (NSArray *) toolbarDefaultItemIdentifiers: (NSToolbar *) toolbar
-{
- // Required delegate method: Returns the ordered list of items to be shown in the
- // toolbar by default.
-
- return [NSArray arrayWithObjects:
- HBQueueStartCancelToolbarIdentifier,
- HBQueuePauseResumeToolbarIdentifier,
-#if !HB_OUTLINE_QUEUE
- NSToolbarSeparatorItemIdentifier,
- HBShowGroupsToolbarIdentifier,
- HBShowDetailToolbarIdentifier,
-#endif
- nil];
-}
-
-//------------------------------------------------------------------------------------
-// toolbarAllowedItemIdentifiers:
-//------------------------------------------------------------------------------------
-- (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.
-
- return [NSArray arrayWithObjects:
- HBQueueStartCancelToolbarIdentifier,
- HBQueuePauseResumeToolbarIdentifier,
-#if !HB_OUTLINE_QUEUE
- HBShowGroupsToolbarIdentifier,
- HBShowDetailToolbarIdentifier,
-#endif
- NSToolbarCustomizeToolbarItemIdentifier,
- NSToolbarFlexibleSpaceItemIdentifier,
- NSToolbarSpaceItemIdentifier,
- NSToolbarSeparatorItemIdentifier,
- nil];
-}
-
-//------------------------------------------------------------------------------------
-// validateToolbarItem:
-//------------------------------------------------------------------------------------
-- (BOOL) validateToolbarItem: (NSToolbarItem *) toolbarItem
-{
- // Optional method: This message is sent to us since we are the target of some
- // toolbar item actions.
-
- if (!fHandle) return NO;
-
- BOOL enable = NO;
-
- hb_state_t s;
- hb_get_state2 (fHandle, &s);
-
- if ([[toolbarItem itemIdentifier] isEqual: HBQueueStartCancelToolbarIdentifier])
- {
- if ((s.state == HB_STATE_PAUSED) || (s.state == HB_STATE_WORKING) || (s.state == HB_STATE_MUXING))