mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-13 06:01:28 +00:00
Support for blends.
Reviewed by me.
This commit is contained in:
@@ -739,7 +739,23 @@ var _CPRunModalLoop = function(anEvent)
|
||||
@class CPApplication
|
||||
@return void
|
||||
*/
|
||||
@implementation X : CPObject
|
||||
{
|
||||
}
|
||||
- (void)blendDidFinishLoading:(CPBundle)aBundle
|
||||
{
|
||||
[CPTheme setDefaultTheme:[CPTheme themeNamed:@"Aristo"]];
|
||||
_CPApplicationMain()
|
||||
}
|
||||
@end
|
||||
function CPApplicationMain(args, namedArgs)
|
||||
{
|
||||
var blend = [[CPBlend alloc] initWithContentsOfURL:[[CPBundle bundleForClass:[CPApplication class]] pathForResource:@"Aristo.blend"]];
|
||||
|
||||
[blend loadWithDelegate:[X new]];
|
||||
}
|
||||
|
||||
function _CPApplicationMain(args, namedArgs)
|
||||
{
|
||||
var mainBundle = [CPBundle mainBundle],
|
||||
principalClass = [mainBundle principalClass];
|
||||
|
||||
@@ -27,6 +27,60 @@
|
||||
@import "CPThemedAttribute.j"
|
||||
|
||||
|
||||
@implementation CPBlend : CPObject
|
||||
{
|
||||
CPBundle _bundle;
|
||||
CPArray _themes @accessors(readonly);
|
||||
id _loadDelegate;
|
||||
}
|
||||
|
||||
- (id)initWithContentsOfURL:(CPURL)aURL
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
_bundle = [[CPBundle alloc] initWithPath:aURL + "/Info.plist"];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)loadWithDelegate:(id)aDelegate
|
||||
{
|
||||
_loadDelegate = aDelegate;
|
||||
|
||||
[_bundle loadWithDelegate:self];
|
||||
}
|
||||
|
||||
- (void)bundleDidFinishLoading:(CPBundle)aBundle
|
||||
{
|
||||
var paths = [_bundle objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
|
||||
index = 0,
|
||||
count = paths.length,
|
||||
bundlePath = [_bundle bundlePath];
|
||||
|
||||
while (count--)
|
||||
{
|
||||
var path = paths[count];
|
||||
|
||||
if ([path pathExtension] === "keyedtheme")
|
||||
{
|
||||
var unarchiver = [[_CPThemeKeyedUnarchiver alloc]
|
||||
initForReadingWithData:[CPData dataWithString:objj_files[bundlePath + '/' + path].contents]
|
||||
bundle:_bundle];
|
||||
|
||||
[unarchiver decodeObjectForKey:@"root"];
|
||||
|
||||
[unarchiver finishDecoding];
|
||||
}
|
||||
}
|
||||
|
||||
[_loadDelegate blendDidFinishLoading:self];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var CPThemesByName = nil,
|
||||
CPThemeDefaultTheme = nil,
|
||||
|
||||
|
||||
+17
-3
@@ -129,15 +129,29 @@
|
||||
context.didCompleteCallback = function() { [_delegate bundleDidFinishLoading:self]; };
|
||||
|
||||
var files = [self objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
|
||||
count = files.length;
|
||||
count = files.length,
|
||||
bundlePath = [self bundlePath];
|
||||
|
||||
while (count--)
|
||||
context.pushFragment(fragment_create_file([self bundlePath] + '/' + files[count], new objj_bundle(""), YES, NULL));
|
||||
{
|
||||
var fileName = files[count];
|
||||
|
||||
if (fileName.indexOf(".j") === fileName.length - 2)
|
||||
context.pushFragment(fragment_create_file(bundlePath + '/' + fileName, new objj_bundle(""), YES, NULL));
|
||||
}
|
||||
|
||||
context.evaluate();
|
||||
if (context.fragments.length)
|
||||
context.evaluate();
|
||||
else
|
||||
[_delegate bundleDidFinishLoading:self];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)connection:(CPURLConnection)aConnection didFailWithError:(CPError)anError
|
||||
{
|
||||
alert("what the hell!?!!!" + anError)
|
||||
}
|
||||
|
||||
- (void)connectionDidFinishLoading:(CPURLConnection)aConnection
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user