From 5868a4cefbfa4eb2fc34a081d6c20931bd2e0a24 Mon Sep 17 00:00:00 2001 From: Blair Duncan Date: Thu, 21 Mar 2013 11:15:25 -0400 Subject: [PATCH] added missing methods to CPDocumentController documentForWindow hasEditedDocuments both are in cocoa --- AppKit/CPDocumentController.j | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/AppKit/CPDocumentController.j b/AppKit/CPDocumentController.j index 8d528a1df..35a42559d 100644 --- a/AppKit/CPDocumentController.j +++ b/AppKit/CPDocumentController.j @@ -279,6 +279,33 @@ var CPSharedDocumentController = nil; [_documents removeObjectIdenticalTo:aDocument]; } +/*! + Returns the document object whose window controller + owns a specified window. +*/ +- (CPDocument)documentForWindow:(CPWindow)aWindow +{ + return [[aWindow windowController] document]; +} + +/*! + Returns a Boolean value that indicates whether the receiver + has any documents with unsaved changes. +*/ +- (BOOL)hasEditedDocuments +{ + var iter = [_documents objectEnumerator], + obj; + + while ((obj = [iter nextObject]) !== nil) + { + if ([obj isDocumentEdited]) + return YES; + } + + return NO; +} + - (CPString)defaultType { return [_documentTypes[0] objectForKey:@"CPBundleTypeName"];