00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 @import <Foundation/CPObject.j>
00024
00025 @import <AppKit/CPTheme.j>
00026 @import <AppKit/_CPCibCustomResource.j>
00027 @import <AppKit/_CPCibKeyedUnarchiver.j>
00028
00033 @implementation CPThemeBlend : CPObject
00034 {
00035 CPBundle _bundle;
00036 CPArray _themes @accessors(readonly, getter=themes);
00037 id _loadDelegate;
00038 }
00039
00040 - (id)initWithContentsOfURL:(CPURL)aURL
00041 {
00042 self = [super init];
00043
00044 if (self)
00045 {
00046 _bundle = [[CPBundle alloc] initWithPath:aURL + "/Info.plist"];
00047 }
00048
00049 return self;
00050 }
00051
00052 - (void)loadWithDelegate:(id)aDelegate
00053 {
00054 _loadDelegate = aDelegate;
00055
00056 [_bundle loadWithDelegate:self];
00057 }
00058
00059 - (void)bundleDidFinishLoading:(CPBundle)aBundle
00060 {
00061 var paths = [_bundle objectForInfoDictionaryKey:@"CPBundleReplacedFiles"],
00062 index = 0,
00063 count = paths.length,
00064 bundlePath = [_bundle bundlePath];
00065
00066 while (count--)
00067 {
00068 var path = paths[count];
00069
00070 if ([path pathExtension] === "keyedtheme")
00071 {
00072 var unarchiver = [[_CPThemeKeyedUnarchiver alloc]
00073 initForReadingWithData:[CPData dataWithString:objj_files[bundlePath + '/' + path].contents]
00074 bundle:_bundle];
00075
00076 [unarchiver decodeObjectForKey:@"root"];
00077
00078 [unarchiver finishDecoding];
00079 }
00080 }
00081
00082 [_loadDelegate blendDidFinishLoading:self];
00083 }
00084
00085 @end