Created
July 31, 2009 21:03
-
-
Save nickjs/159450 to your computer and use it in GitHub Desktop.
Monkey Patches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CPMenuItem.j - Adds a designated initializer. | |
CPTableView.j - Fix a bug in -columnWithIdentifier: | |
CPWindowController.j - Fixes to make it work with programmatic windows. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/AppKit/CPTableView.j b/AppKit/CPTableView.j | |
index 7b1ebdb..b7f0908 100644 | |
--- a/AppKit/CPTableView.j | |
+++ b/AppKit/CPTableView.j | |
@@ -530,7 +530,7 @@ CPTableViewSolidHorizontalGridLineMask = 1 << 1; | |
count = NUMBER_OF_COLUMNS(); | |
for (; index < count; ++index) | |
- if ([_tableColumns identifier] === anIdentifier) | |
+ if ([_tableColumns[index] identifier] === anIdentifier) | |
return index; | |
return CPNotFound; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/AppKit/CPWindowController.j b/AppKit/CPWindowController.j | |
index f60abcf..145e839 100644 | |
--- a/AppKit/CPWindowController.j | |
+++ b/AppKit/CPWindowController.j | |
@@ -106,6 +106,9 @@ | |
{ | |
_cibOwner = anOwner; | |
_windowCibName = aWindowCibName; | |
+ | |
+ if (anOwner == self) | |
+ _windowCibPath = [[CPBundle mainBundle] pathForResource:_windowCibName + @".cib"]; | |
} | |
return self; | |
@@ -127,27 +130,25 @@ | |
/*! | |
Loads the window | |
*/ | |
-- (BOOL)loadWindow | |
+- (void)loadWindow | |
{ | |
if ([self isWindowLoaded]) | |
- return YES; | |
+ return; | |
- if (![self isWindowLoading]) | |
+ if (_cibOwner && ![self isWindowLoading]) | |
{ | |
_isWindowLoading = YES; | |
- | |
- [self windowWillLoad]; | |
- | |
+ | |
[CPBundle loadCibFile:[self windowCibPath] | |
externalNameTable:[CPDictionary dictionaryWithObject:_cibOwner forKey:CPCibOwner] | |
loadDelegate:self]; | |
} | |
- | |
- return NO; | |
} | |
- (void)cibDidFinishLoading:(CPCib)aCib | |
{ | |
+ _isWindowLoading = NO; | |
+ | |
if (_window === nil && _document !== nil && _cibOwner === _document) | |
[self setWindow:[_document valueForKey:@"window"]]; | |
@@ -165,14 +166,10 @@ | |
*/ | |
- (@action)showWindow:(id)aSender | |
{ | |
- if (![self loadWindow]) | |
- { | |
- _shouldDisplayWindowWhenLoaded = YES; | |
- | |
- return; | |
- } | |
- | |
var theWindow = [self window]; | |
+ | |
+ if ([self isWindowLoading]) | |
+ return _shouldDisplayWindowWhenLoaded = YES; | |
if ([theWindow respondsToSelector:@selector(becomesKeyOnlyIfNeeded)] && [theWindow becomesKeyOnlyIfNeeded]) | |
[theWindow orderFront:aSender]; | |
@@ -200,7 +197,13 @@ | |
- (CPWindow)window | |
{ | |
if (!_window) | |
- [self loadWindow]; | |
+ { | |
+ [self windowWillLoad]; | |
+ [self loadWindow]; | |
+ | |
+ if (_window) | |
+ [self windowDidLoad]; | |
+ } | |
return _window; | |
} | |
@@ -221,6 +224,8 @@ | |
/*! | |
The method notifies the controller that it's window has loaded. | |
+ | |
+ Subclasses should invoke super. | |
*/ | |
- (void)windowDidLoad | |
{ | |
@@ -231,6 +236,8 @@ | |
/*! | |
The method notifies the controller that it's window is about to load. | |
+ | |
+ Subclasses should invoke super. | |
*/ | |
- (void)windowWillLoad | |
{ | |
@@ -353,10 +360,10 @@ | |
- (CPString)windowCibPath | |
{ | |
- if (_windowCibPath) | |
- return _windowCibPath; | |
- | |
- return [[CPBundle bundleForClass:[_cibOwner class]] pathForResource:_windowCibName + @".cib"]; | |
+ if (!_windowCibPath) | |
+ _windowCibPath = [[CPBundle bundleForClass:[_cibOwner class]] pathForResource:_windowCibName + @".cib"]; | |
+ | |
+ return _windowCibPath; | |
} | |
// Setting and Getting Window Attributes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment