1 /* WinterBoard - Theme Manager for the iPhone
2 * Copyright (C) 2008 Jay Freeman (saurik)
6 * Redistribution and use in source and binary
7 * forms, with or without modification, are permitted
8 * provided that the following conditions are met:
10 * 1. Redistributions of source code must retain the
11 * above copyright notice, this list of conditions
12 * and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the
14 * above copyright notice, this list of conditions
15 * and the following disclaimer in the documentation
16 * and/or other materials provided with the
18 * 3. The name of the author may not be used to endorse
19 * or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
24 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
25 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
27 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
28 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
32 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
33 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
34 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #import <Foundation/Foundation.h>
39 #import <CoreGraphics/CGGeometry.h>
40 #import <UIKit/UIKit.h>
42 #define _trace() NSLog(@"_trace(%u)", __LINE__);
44 @interface WBApplication : UIApplication <
45 UITableViewDataSource,
49 UITableView *themesTable_;
50 NSArray *themesArray_;
55 @implementation WBApplication
59 [themesTable_ release];
60 [themesArray_ release];
64 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
65 UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
66 cell.text = [themesArray_ objectAtIndex:[indexPath row]];
70 - (NSInteger) tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
71 return [themesArray_ count];
74 - (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
75 NSString *theme = [themesArray_ objectAtIndex:[indexPath row]];
77 [[NSDictionary dictionaryWithObjectsAndKeys:
79 nil] writeToFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist",
84 execlp("killall", "killall", "SpringBoard", NULL);
89 - (void) applicationDidFinishLaunching:(id)unused {
90 window_ = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
91 [window_ makeKeyAndVisible];
93 NSFileManager *manager = [NSFileManager defaultManager];
94 themesArray_ = [[manager contentsOfDirectoryAtPath:@"/Library/Themes" error:nil] retain];
96 themesTable_ = [[UITableView alloc] initWithFrame:window_.bounds];
97 [window_ addSubview:themesTable_];
99 [themesTable_ setDataSource:self];
100 [themesTable_ setDelegate:self];
102 [themesTable_ setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
107 int main(int argc, char *argv[]) {
108 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
110 int value = UIApplicationMain(argc, argv, @"WBApplication", @"WBApplication");