forked from cappuccino/cappuccino
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for MainMenu.cib needing to be loaded manually in cib apps.
Closes #9.
Reviewed by me.
- Loading branch information
Francisco Tolmasky
committed
May 3, 2009
1 parent
586a1e3
commit 390cf2c
Showing
12 changed files
with
3,228 additions
and
292 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
* _CPCibLoading.j | ||
* AppKit | ||
* | ||
* Created by Francisco Tolmasky. | ||
* Copyright 2008, 280 North, Inc. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
@import <Foundation/CPBundle.j> | ||
@import <Foundation/CPDictionary.j> | ||
@import <Foundation/CPString.j> | ||
|
||
|
||
var CPCibOwner = @"CPCibOwner"; | ||
|
||
var LoadInfoForCib = {}; | ||
|
||
@implementation CPObject (CPCibLoading) | ||
|
||
- (void)awakeFromCib | ||
{ | ||
} | ||
|
||
@end | ||
|
||
@implementation CPBundle (CPCibLoading) | ||
|
||
+ (void)loadCibFile:(CPString)anAbsolutePath externalNameTable:(CPDictionary)aNameTable loadDelegate:aDelegate | ||
{ | ||
var cib = [[CPCib alloc] initWithContentsOfURL:anAbsolutePath loadDelegate:self]; | ||
|
||
LoadInfoForCib[[cib hash]] = { loadDelegate:aDelegate, externalNameTable:aNameTable }; | ||
} | ||
|
||
+ (void)loadCibNamed:(CPString)aName owner:(id)anOwner loadDelegate:(id)aDelegate | ||
{ | ||
// Path is based solely on anOwner: | ||
var bundle = anOwner ? [CPBundle bundleForClass:[anOwner class]] : [CPBundle mainBundle], | ||
path = [bundle pathForResource:aName]; | ||
|
||
[self loadCibFile:path externalNameTable:[CPDictionary dictionaryWithObject:anOwner forKey:CPCibOwner] loadDelegate:aDelegate]; | ||
} | ||
|
||
- (void)loadCibFile:(CPString)aFileName externalNameTable:(CPDictionary)aNameTable loadDelegate:(id)aDelegate | ||
{ | ||
var cib = [[CPCib alloc] initWithCibNamed:aFileName bundle:self loadDelegate:[self class]]; | ||
|
||
LoadInfoForCib[[cib hash]] = { loadDelegate:aDelegate, externalNameTable:aNameTable }; | ||
} | ||
|
||
+ (void)cibDidFinishLoading:(CPCib)aCib | ||
{ | ||
var loadInfo = LoadInfoForCib[[aCib hash]]; | ||
|
||
delete LoadInfoForCib[[aCib hash]]; | ||
|
||
[aCib instantiateCibWithExternalNameTable:loadInfo.externalNameTable]; | ||
|
||
[loadInfo.loadDelegate cibDidFinishLoading:aCib]; | ||
} | ||
|
||
@end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,4 +43,4 @@ | |
return _objects[aUID]; | ||
} | ||
|
||
@end | ||
@end |
Oops, something went wrong.