/* HBQueueController
This file is part of the HandBrake source code.
- Homepage: <http://handbrake.m0k.org/>.
+ Homepage: <http://handbrake.fr/>.
It may be used under the terms of the GNU General Public License. */
#include "HBQueueController.h"
// HBJob
//------------------------------------------------------------------------------------
-static NSMutableParagraphStyle * _descriptionParagraphStyle = NULL;
-static NSDictionary* _detailAttribute = NULL;
-static NSDictionary* _detailBoldAttribute = NULL;
-static NSDictionary* _titleAttribute = NULL;
-static NSDictionary* _shortHeightAttribute = NULL;
+static NSMutableParagraphStyle * _descriptionParagraphStyle = nil;
+static NSDictionary* _detailAttribute = nil;
+static NSDictionary* _detailBoldAttribute = nil;
+static NSDictionary* _titleAttribute = nil;
+static NSDictionary* _shortHeightAttribute = nil;
@implementation HBJob
//------------------------------------------------------------------------------------
- (id)init
{
- if (self = [super init])
+ if (self = [super initWithWindowNibName:@"Queue"])
{
+ // NSWindowController likes to lazily load its window nib. Since this
+ // controller tries to touch the outlets before accessing the window, we
+ // need to force it to load immadiately by invoking its accessor.
+ //
+ // If/when we switch to using bindings, this can probably go away.
+ [self window];
+
// Our defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
@"NO", @"QueueWindowIsOpen",
fJobGroups = [[NSMutableArray arrayWithCapacity:0] retain];
- BOOL loadSucceeded = [NSBundle loadNibNamed:@"Queue" owner:self] && fQueueWindow;
- NSAssert(loadSucceeded, @"Could not open Queue nib");
- NSAssert(fQueueWindow, @"fQueueWindow not found in Queue nib");
-
// Register for HBJobGroup status changes
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(jobGroupStatusNotification:) name:HBJobGroupStatusNotification object:nil];
}
- return self;
+ return self;
}
//------------------------------------------------------------------------------------
- (void)dealloc
{
// clear the delegate so that windowWillClose is not attempted
- if ([fQueueWindow delegate] == self)
- [fQueueWindow setDelegate:nil];
-
+ if( [[self window] delegate] == self )
+ [[self window] setDelegate:nil];
+
[fJobGroups release];
[fCurrentJobGroup release];
[fSavedExpandedItems release];
//------------------------------------------------------------------------------------
- (IBAction) showQueueWindow: (id)sender
{
- [fQueueWindow makeKeyAndOrderFront: self];
+ [self showWindow:sender];
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"QueueWindowIsOpen"];
}
//------------------------------------------------------------------------------------
- (void)setupToolbar
{
- // Create a new toolbar instance, and attach it to our window
+ // 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
+
+ // 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];
+
+ // Attach the toolbar to our window
+ [[self window] setToolbar:toolbar];
}
//------------------------------------------------------------------------------------
- (void)awakeFromNib
{
[self setupToolbar];
-
- if (![fQueueWindow setFrameUsingName:@"Queue"])
- [fQueueWindow center];
- [fQueueWindow setFrameAutosaveName: @"Queue"];
- [fQueueWindow setExcludedFromWindowsMenu:YES];
+
+ if( ![[self window] setFrameUsingName:@"Queue"] )
+ [[self window] center];
+ [self setWindowFrameAutosaveName:@"Queue"];
+ [[self window] setExcludedFromWindowsMenu:YES];
#if HB_QUEUE_DRAGGING
[fOutlineView registerForDraggedTypes: [NSArray arrayWithObject:HBQueuePboardType] ];