![]() |
API 0.9.5
|
00001 /* 00002 * CPThemeBlend.j 00003 * AppKit 00004 * 00005 * Created by Francisco Tolmasky. 00006 * Copyright 2009, 280 North, Inc. 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00021 */ 00022 00023 00024 00025 00030 @implementation CPThemeBlend : CPObject 00031 { 00032 CPBundle _bundle; 00033 CPArray _themes; 00034 id _loadDelegate; 00035 } 00036 00037 - (id)initWithContentsOfURL:(CPURL)aURL 00038 { 00039 self = [super init]; 00040 00041 if (self) 00042 { 00043 _bundle = [[CPBundle alloc] initWithPath:aURL]; 00044 } 00045 00046 return self; 00047 } 00048 00053 - (CPArray)themes 00054 { 00055 return _themes; 00056 } 00057 00061 - (CPArray)themeNames 00062 { 00063 var names = []; 00064 00065 for (var i = 0; i < _themes.length; ++i) 00066 names.push(_themes[i].substring(0, _themes[i].indexOf(".keyedtheme"))); 00067 00068 return names; 00069 } 00070 00071 - (void)loadWithDelegate:(id)aDelegate 00072 { 00073 _loadDelegate = aDelegate; 00074 00075 [_bundle loadWithDelegate:self]; 00076 } 00077 00078 - (void)bundleDidFinishLoading:(CPBundle)aBundle 00079 { 00080 _themes = [_bundle objectForInfoDictionaryKey:@"CPKeyedThemes"]; 00081 00082 var count = _themes.length; 00083 00084 while (count--) 00085 { 00086 var path = [aBundle pathForResource:_themes[count]], 00087 unarchiver = [[_CPThemeKeyedUnarchiver alloc] 00088 initForReadingWithData:[[CPURL URLWithString:path] staticResourceData] 00089 bundle:_bundle]; 00090 00091 [unarchiver decodeObjectForKey:@"root"]; 00092 00093 [unarchiver finishDecoding]; 00094 } 00095 00096 [_loadDelegate blendDidFinishLoading:self]; 00097 } 00098 00099 @end