diff --git a/AppKit/CPDocument.j b/AppKit/CPDocument.j index 5c316f801..4ebd2e5db 100644 --- a/AppKit/CPDocument.j +++ b/AppKit/CPDocument.j @@ -261,6 +261,7 @@ var CPDocumentUntitledCount = 0; - (void)makeViewAndWindowControllers { var viewCibName = [self viewCibName], + windowCibName = [self windowCibName], viewController = nil, windowController = nil; @@ -268,31 +269,21 @@ var CPDocumentUntitledCount = 0; if ([viewCibName length]) viewController = [[CPViewController alloc] initWithCibName:viewCibName bundle:nil owner:self]; - // If we have a view controller, check if we have a free window for it. - if (viewController) - windowController = [self firstEligibleExistingWindowController]; + // From a cib if we have one. + if ([windowCibName length]) + windowController = [[CPWindowController alloc] initWithWindowCibName:windowCibName owner:self]; - // If not, create one. - if (!windowController) + // If not you get a standard window capable of displaying multiple documents and view + else if (viewController) { - var windowCibName = [self windowCibName]; + var view = [viewController view], + viewFrame = [view frame]; - // From a cib if we have one. - if ([windowCibName length]) - windowController = [[CPWindowController alloc] initWithWindowCibName:windowCibName owner:self]; + viewFrame.origin = CGPointMake(50, 50); - // If not you get a standard window capable of displaying multiple documents and view - else if (viewController) - { - var view = [viewController view], - viewFrame = [view frame]; + var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask]; - viewFrame.origin = CGPointMake(50, 50); - - var theWindow = [[CPWindow alloc] initWithContentRect:viewFrame styleMask:CPTitledWindowMask | CPClosableWindowMask | CPMiniaturizableWindowMask | CPResizableWindowMask]; - - windowController = [[CPWindowController alloc] initWithWindow:theWindow]; - } + windowController = [[CPWindowController alloc] initWithWindow:theWindow]; } if (windowController && viewController) diff --git a/AppKit/CPDocumentController.j b/AppKit/CPDocumentController.j index a36e96e4c..8d528a1df 100644 --- a/AppKit/CPDocumentController.j +++ b/AppKit/CPDocumentController.j @@ -253,6 +253,14 @@ var CPSharedDocumentController = nil; return _documents; } +/*! + Returns the CPDocument object associated with the main window. +*/ +- (CPDocument)currentDocument +{ + return [[[CPApp mainWindow] windowController] document]; +} + /*! Adds \c aDocument under the control of the receiver. @param aDocument the document to add