diff --git a/AppKit/CPApplication.j b/AppKit/CPApplication.j index 3736ad700..e35b96dd0 100644 --- a/AppKit/CPApplication.j +++ b/AppKit/CPApplication.j @@ -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]; diff --git a/AppKit/CPTheme.j b/AppKit/CPTheme.j index 76f08eb06..e4c39a17f 100644 --- a/AppKit/CPTheme.j +++ b/AppKit/CPTheme.j @@ -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, diff --git a/Foundation/CPBundle.j b/Foundation/CPBundle.j index b4565c6e5..32736b885 100644 --- a/Foundation/CPBundle.j +++ b/Foundation/CPBundle.j @@ -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 { }