Merge branch 'master' of git@github.com:280north/cappuccino

This commit is contained in:
Francisco Ryan Tolmasky I
2009-10-29 20:46:24 -07:00
3 changed files with 41 additions and 14 deletions
+23 -1
View File
@@ -317,6 +317,20 @@ var CPDocumentUntitledCount = 0;
[aWindowController setDocument:self];
}
/*!
Remove a controller to the document's list of controllers. This should
be called after closing the controller's window.
@param aWindowController the controller to remove
*/
- (void)removeWindowController:(CPWindowController)aWindowController
{
if (aWindowController)
[_windowControllers removeObject:aWindowController];
if ([aWindowController document] === self)
[aWindowController setDocument:nil];
}
- (CPView)view
{
return _view;
@@ -846,12 +860,20 @@ var CPDocumentUntitledCount = 0;
- (void)shouldCloseWindowController:(CPWindowController)controller delegate:(id)delegate shouldCloseSelector:(SEL)selector contextInfo:(Object)info
{
if ([controller shouldCloseDocument] || ([_windowControllers count] < 2 && [_windowControllers indexOfObject:controller] !== CPNotFound))
[self canCloseDocumentWithDelegate:delegate shouldCloseSelector:selector contextInfo:info];
[self canCloseDocumentWithDelegate:self shouldCloseSelector:@selector(_document:shouldClose:context:) contextInfo:{delegate:delegate, selector:selector, context:info}];
else if ([delegate respondsToSelector:selector])
objj_msgSend(delegate, selector, self, YES, info);
}
- (void)_document:(CPDocument)aDocument shouldClose:(BOOL)shouldClose context:(Object)context
{
if (aDocument === self && shouldClose)
[self close];
objj_msgSend(context.delegate, context.selector, aDocument, shouldClose, context.context);
}
- (void)canCloseDocumentWithDelegate:(id)aDelegate shouldCloseSelector:(SEL)aSelector contextInfo:(Object)context
{
if (![self isDocumentEdited])
+13 -13
View File
@@ -1643,33 +1643,33 @@ CPTexturedBackgroundWindowMask
[documents[index] shouldCloseWindowController:_windowController
delegate:self
shouldCloseSelector:@selector(_document:shouldClose:contextInfo:)
contextInfo:index];
shouldCloseSelector:@selector(_windowControllerContainingDocument:shouldClose:contextInfo:)
contextInfo:{documents:[documents copy], visited:0, index:index}];
}
else
[self close];
}
- (void)_document:(CPDocument)document shouldClose:(BOOL)shouldClose contextInfo:(Object)context
- (void)_windowControllerContainingDocument:(CPDocument)document shouldClose:(BOOL)shouldClose contextInfo:(Object)context
{
if (shouldClose)
{
var windowController = [self windowController],
documents = [windowController documents];
documents = context.documents,
count = [documents count],
visited = ++context.visited,
index = ++context.index % count;
[documents[context] close];
[document removeWindowController:windowController];
var count = [documents count];
if (count)
if (visited < count)
{
var index = context % count;
[windowController setDocument:documents[index]];
[documents[index] shouldCloseWindowController:_windowController
delegate:self
shouldCloseSelector:@selector(_document:shouldClose:contextInfo:)
contextInfo:index];
shouldCloseSelector:@selector(_windowControllerContainingDocument:shouldClose:contextInfo:)
contextInfo:context];
}
else
[self close];
@@ -1682,9 +1682,9 @@ CPTexturedBackgroundWindowMask
*/
- (void)close
{
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillCloseNotification object:self];
[[CPNotificationCenter defaultCenter] postNotificationName:CPWindowWillCloseNotification object:self];
[self orderOut:nil];
[self orderOut:nil];
}
// Managing Main Status
+5
View File
@@ -127,6 +127,11 @@ var CPDateReferenceDate = new Date(Date.UTC(2001,1,1,0,0,0,0));
return [[CPDate date] timeIntervalSinceReferenceDate];
}
- (BOOL)isEqual:(CPDate)aDate
{
return [self isEqualToDate:aDate];
}
- (BOOL)isEqualToDate:(CPDate)anotherDate
{
return !(self < anotherDate || self > anotherDate);