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];
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 themes = [_bundle objectForInfoDictionaryKey:@"CPKeyedThemes"],
00062 count = themes.length;
00063
00064 while (count--)
00065 {
00066 var path = [aBundle pathForResource:themes[count]],
00067 unarchiver = [[_CPThemeKeyedUnarchiver alloc]
00068 initForReadingWithData:[[CPURL URLWithString:path] staticResourceData]
00069 bundle:_bundle];
00070
00071 [unarchiver decodeObjectForKey:@"root"];
00072
00073 [unarchiver finishDecoding];
00074 }
00075
00076 [_loadDelegate blendDidFinishLoading:self];
00077 }
00078
00079 @end