From 02a89e2343d874b46887f9d204f7bb9320bb1017 Mon Sep 17 00:00:00 2001 From: cacaodev Date: Sun, 22 Jul 2012 22:08:31 +0200 Subject: [PATCH 1/6] CPCib -instantiateCibWithOwner:(id)anOwner topLevelObjects:(CPArray)topLevelObjects : allow anOwner to be nil --- AppKit/Cib/CPCib.j | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AppKit/Cib/CPCib.j b/AppKit/Cib/CPCib.j index 7277e8bca..c9c9a3da0 100644 --- a/AppKit/Cib/CPCib.j +++ b/AppKit/Cib/CPCib.j @@ -162,7 +162,7 @@ var CPCibObjectDataKey = @"CPCibObjectDataKey"; - (BOOL)instantiateCibWithOwner:(id)anOwner topLevelObjects:(CPArray)topLevelObjects { - return [self instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObjectsAndKeys:anOwner, CPCibOwner, topLevelObjects, CPCibTopLevelObjects]]; + return [self instantiateCibWithExternalNameTable:[CPDictionary dictionaryWithObjects:[anOwner, topLevelObjects] forKeys:[CPCibOwner, CPCibTopLevelObjects]]]; } @end From b51a2e25c21bf1bc191b5df2c66c6c91d473059d Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Tue, 24 Jul 2012 20:09:18 +0200 Subject: [PATCH 2/6] Refs #1631. Unit test last index of index set with a single index. --- Tests/Foundation/CPIndexSetTest.j | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Tests/Foundation/CPIndexSetTest.j b/Tests/Foundation/CPIndexSetTest.j index 8641ae5c7..fefbd220d 100644 --- a/Tests/Foundation/CPIndexSetTest.j +++ b/Tests/Foundation/CPIndexSetTest.j @@ -288,6 +288,9 @@ function descriptionWithoutEntity(aString) { [self assert:[_set lastIndex] equals:19]; [self assert:[[CPIndexSet indexSet] lastIndex] equals:CPNotFound]; + + var singleIndexSet = [CPIndexSet indexSetWithIndex:3]; + [self assert:3 equals:[singleIndexSet lastIndex]]; } /* - (void)testAddSpeed From c57ef67784a9f944461011acd41abd601ff2b1f0 Mon Sep 17 00:00:00 2001 From: Ilya Kulakov Date: Wed, 25 Jul 2012 16:58:45 +0700 Subject: [PATCH 3/6] Starting from 10.7 NSUndoManager posts NSUndoManagerDidCloseUndoGroupNotification. --- Foundation/CPUndoManager.j | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Foundation/CPUndoManager.j b/Foundation/CPUndoManager.j index 16a70cd37..42c24163b 100644 --- a/Foundation/CPUndoManager.j +++ b/Foundation/CPUndoManager.j @@ -35,6 +35,7 @@ var CPUndoManagerNormal = 0, CPUndoManagerCheckpointNotification = @"CPUndoManagerCheckpointNotification"; CPUndoManagerDidOpenUndoGroupNotification = @"CPUndoManagerDidOpenUndoGroupNotification"; +CPUndoManagerDidCloseUndoGroupNotification = @"CPUndoManagerDidCloseUndoGroupNotification"; CPUndoManagerDidRedoChangeNotification = @"CPUndoManagerDidRedoChangeNotification"; CPUndoManagerDidUndoChangeNotification = @"CPUndoManagerDidUndoChangeNotification"; CPUndoManagerWillCloseUndoGroupNotification = @"CPUndoManagerWillCloseUndoGroupNotification"; @@ -490,6 +491,10 @@ if (_currentGroup == nil) if (_levelsOfUndo > 0 && stack.length > _levelsOfUndo) stack.splice(0, 1); + + [defaultCenter + postNotificationName:CPUndoManagerDidCloseUndoGroupNotification + object:self]; } // Nested Undo Grouping From fa1441cf71dcdd563a4c92ac5ce9e0435531d5c1 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 25 Jul 2012 12:00:09 -0700 Subject: [PATCH 4/6] small fix in theme to avoid 1px offset when editing a CPTextField --- AppKit/Themes/Aristo/ThemeDescriptors.j | 1 + 1 file changed, 1 insertion(+) diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index e1652f4f3..b2e52cbfc 100755 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -918,6 +918,7 @@ var themedButtonValues = nil, // with border [@"bezel-inset", CGInsetMakeZero(), CPThemeStateBezeled], [@"content-inset", CGInsetMake(8.0, 7.0, 7.0, 8.0), CPThemeStateBezeled], + [@"content-inset", CGInsetMake(8.0, 7.0, 7.0, 9.0), CPThemeStateBezeled | CPThemeStateEditing], [@"text-color", textDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled], [@"text-color", placeholderColor, CPTextFieldStatePlaceholder], From dcee0e5057c513230643134b5783aaf34550ab68 Mon Sep 17 00:00:00 2001 From: Antoine Mercadal Date: Wed, 25 Jul 2012 18:19:15 -0700 Subject: [PATCH 5/6] Revert "small fix in theme to avoid 1px offset when editing a CPTextField" This reverts commit fa1441cf71dcdd563a4c92ac5ce9e0435531d5c1. --- AppKit/Themes/Aristo/ThemeDescriptors.j | 1 - 1 file changed, 1 deletion(-) diff --git a/AppKit/Themes/Aristo/ThemeDescriptors.j b/AppKit/Themes/Aristo/ThemeDescriptors.j index b2e52cbfc..e1652f4f3 100755 --- a/AppKit/Themes/Aristo/ThemeDescriptors.j +++ b/AppKit/Themes/Aristo/ThemeDescriptors.j @@ -918,7 +918,6 @@ var themedButtonValues = nil, // with border [@"bezel-inset", CGInsetMakeZero(), CPThemeStateBezeled], [@"content-inset", CGInsetMake(8.0, 7.0, 7.0, 8.0), CPThemeStateBezeled], - [@"content-inset", CGInsetMake(8.0, 7.0, 7.0, 9.0), CPThemeStateBezeled | CPThemeStateEditing], [@"text-color", textDisabledColor, CPThemeStateBezeled | CPThemeStateDisabled], [@"text-color", placeholderColor, CPTextFieldStatePlaceholder], From 3e218d6aec395faef0ec0565b0b255765ef9d0bd Mon Sep 17 00:00:00 2001 From: Alexander Ljungberg Date: Thu, 26 Jul 2012 13:32:01 +0100 Subject: [PATCH 6/6] Refs #1632. Unit test for `CPUndoManagerDidCloseUndoGroupNotification`. --- Tests/Foundation/CPUndoManagerTest.j | 48 +++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/Tests/Foundation/CPUndoManagerTest.j b/Tests/Foundation/CPUndoManagerTest.j index 857794eba..67ef6308c 100644 --- a/Tests/Foundation/CPUndoManagerTest.j +++ b/Tests/Foundation/CPUndoManagerTest.j @@ -3,12 +3,16 @@ @implementation CPUndoManagerTest : OJTestCase { - CPUndoManager undoManager; + CPArray receivedNotifications; + CPUndoManager undoManager; + BOOL itIsDone; } - (void)setUp { undoManager = [[CPUndoManager alloc] init]; + itIsDone = NO; + receivedNotifications = [CPMutableArray array]; } - (void)testUndoMenuTitleForUndoActionName @@ -35,4 +39,46 @@ [self assert:[undoManager redoMenuTitleForUndoActionName:"STRING"] equals:@"Redo STRING"]; } +- (void)testNotifications +{ + + [[CPNotificationCenter defaultCenter] addObserver:self + selector:@selector(receiveNotification:) + name:CPUndoManagerDidCloseUndoGroupNotification + object:undoManager]; + + [self doIt]; + + // The default run loop undo grouping won't be closed until the next run loop cycle. + [[CPRunLoop currentRunLoop] limitDateForMode:CPDefaultRunLoopMode]; + + CPLog.error("receivedNotifications: %@", receivedNotifications); + [self assert:CPUndoManagerDidCloseUndoGroupNotification equals:[receivedNotifications[0] name]]; + + [[CPNotificationCenter defaultCenter] removeObserver:self]; +} + +- (void)receiveNotification:(CPNotification)aNotification +{ + [receivedNotifications addObject:aNotification]; +} + +- (void)doIt +{ + [undoManager registerUndoWithTarget:self + selector:@selector(undoIt) + object:nil]; + + itIsDone = YES; +} + +- (void)undoIt +{ + [undoManager registerUndoWithTarget:self + selector:@selector(doit) + object:nil]; + + itIsDone = NO; +} + @end