API  0.9.6
 All Classes Files Functions Variables Macros Groups Pages
CPThemeBlend.j
Go to the documentation of this file.
1 /*
2  * CPThemeBlend.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2009, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
25 
30 @implementation CPThemeBlend : CPObject
31 {
32  CPBundle _bundle;
33  CPArray _themes;
34  id _loadDelegate;
35 }
36 
37 - (id)initWithContentsOfURL:(CPURL)aURL
38 {
39  self = [super init];
40 
41  if (self)
42  {
43  _bundle = [[CPBundle alloc] initWithPath:aURL];
44  }
45 
46  return self;
47 }
48 
53 - (CPArray)themes
54 {
55  return _themes;
56 }
57 
61 - (CPArray)themeNames
62 {
63  var names = [];
64 
65  for (var i = 0; i < _themes.length; ++i)
66  names.push(_themes[i].substring(0, _themes[i].indexOf(".keyedtheme")));
67 
68  return names;
69 }
70 
71 - (void)loadWithDelegate:(id)aDelegate
72 {
73  _loadDelegate = aDelegate;
74 
75  [_bundle loadWithDelegate:self];
76 }
77 
78 - (void)bundleDidFinishLoading:(CPBundle)aBundle
79 {
80  _themes = [_bundle objectForInfoDictionaryKey:@"CPKeyedThemes"];
81 
82  var count = _themes.length;
83 
84  while (count--)
85  {
86  var path = [aBundle pathForResource:_themes[count]],
87  unarchiver = [[_CPThemeKeyedUnarchiver alloc]
88  initForReadingWithData:[[CPURL URLWithString:path] staticResourceData]
89  bundle:_bundle];
90 
91  [unarchiver decodeObjectForKey:@"root"];
92 
93  [unarchiver finishDecoding];
94  }
95 
96  [_loadDelegate blendDidFinishLoading:self];
97 }
98 
99 @end