]> git.saurik.com Git - winterboard.git/commitdiff
Drastic reorganization of WinterBoard.
authorJay Freeman (saurik) <saurik@saurik.com>
Mon, 11 Aug 2008 12:08:58 +0000 (12:08 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 11 Aug 2008 12:08:58 +0000 (12:08 +0000)
21 files changed:
Application.mm
Black Navigation Bars.theme/Info.plist [new file with mode: 0644]
Library.mm
Saurik.theme/Bundles/com.apple.springboard/SBDockBG.png [new file with mode: 0644]
Saurik.theme/Info.plist [new file with mode: 0644]
Saurik.theme/Private/Plant.png [new file with mode: 0644]
Saurik.theme/Private/Rock.png [new file with mode: 0644]
Saurik.theme/Wallpaper.html [new file with mode: 0644]
Saurik/Bundles/com.apple.springboard/SBDockBG.png [deleted file]
Saurik/Info.plist [deleted file]
Saurik/Private/Plant.png [deleted file]
Saurik/Private/Rock.png [deleted file]
Saurik/Wallpaper.html [deleted file]
Test.sh
Transparent Icon Labels.theme/Info.plist [new file with mode: 0644]
User Wallpaper.theme/Wallpaper.jpg [new symlink]
control
makefile
postinst [deleted file]
preinst
prerm

index a7c72ad0696a47c9ae996fca57123316e37e6440..5f16bc40a2e03cd0f23ad1300847462c910fb994 100644 (file)
 #import <CoreGraphics/CGGeometry.h>
 #import <UIKit/UIKit.h>
 
-#define _trace() NSLog(@"_trace(%u)", __LINE__);
+#define _trace() NSLog(@"WE:_trace(%u)", __LINE__);
+
+static NSString *plist_;
+static NSMutableDictionary *settings_;
+
+@interface WBThemeTableViewCell : UITableViewCell {
+    UILabel *label;
+}
+
+@end
+
+@implementation WBThemeTableViewCell
+
+
+@end
 
 @interface WBApplication : UIApplication <
     UITableViewDataSource,
     [super dealloc];
 }
 
+- (void) applicationWillTerminate:(UIApplication *)application {
+    [settings_ writeToFile:plist_ atomically:YES];
+    system("killall SpringBoard");
+}
+
 - (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
     UITableViewCell *cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero] autorelease];
-    cell.text = [themesArray_ objectAtIndex:[indexPath row]];
+    NSMutableDictionary *theme = [themesArray_ objectAtIndex:[indexPath row]];
+    cell.text = [theme objectForKey:@"Name"];
+    cell.hidesAccessoryWhenEditing = NO;
+    NSNumber *active = [theme objectForKey:@"Active"];
+    BOOL inactive = active == nil || ![active boolValue];
+    cell.accessoryType = inactive ? UITableViewCellAccessoryNone : UITableViewCellAccessoryCheckmark;
     return cell;
 }
 
+- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
+    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
+    NSMutableDictionary *theme = [themesArray_ objectAtIndex:[indexPath row]];
+    NSNumber *active = [theme objectForKey:@"Active"];
+    BOOL inactive = active == nil || ![active boolValue];
+    [theme setObject:[NSNumber numberWithBool:inactive] forKey:@"Active"];
+    cell.accessoryType = inactive ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
+    [themesTable_ deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:YES];
+}
+
 - (NSInteger) tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
     return [themesArray_ count];
 }
 
-- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
-    NSString *theme = [themesArray_ objectAtIndex:[indexPath row]];
+- (UITableViewCellEditingStyle) tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath {
+    return UITableViewCellEditingStyleNone;
+}
 
-    [[NSDictionary dictionaryWithObjectsAndKeys:
-        theme, @"Theme",
-    nil] writeToFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist",
-        NSHomeDirectory()
-    ] atomically:YES];
+- (void) tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
+    NSUInteger fromIndex = [fromIndexPath row];
+    NSUInteger toIndex = [toIndexPath row];
+    if (fromIndex == toIndex)
+        return;
+    NSMutableDictionary *theme = [[[themesArray_ objectAtIndex:fromIndex] retain] autorelease];
+    [themesArray_ removeObjectAtIndex:fromIndex];
+    [themesArray_ insertObject:theme atIndex:toIndex];
+}
 
-    if (fork() == 0) {
-        execlp("killall", "killall", "SpringBoard", NULL);
-        exit(0);
-    }
+- (BOOL) tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
+    return YES;
 }
 
 - (void) applicationDidFinishLaunching:(id)unused {
     window_ = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
     [window_ makeKeyAndVisible];
 
-    themesArray_ = [[NSMutableArray arrayWithCapacity:32] retain];
+    plist_ = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist",
+        NSHomeDirectory()
+    ] retain];
+
+    settings_ = [[NSMutableDictionary alloc] initWithContentsOfFile:plist_];
+
+    themesArray_ = [settings_ objectForKey:@"Themes"];
+    if (themesArray_ == nil) {
+        if (NSString *theme = [settings_ objectForKey:@"Theme"]) {
+            themesArray_ = [[NSArray arrayWithObject:[[NSDictionary dictionaryWithObjectsAndKeys:
+                theme, @"Name",
+                [NSNumber numberWithBool:YES], @"Active",
+            nil] mutableCopy]] mutableCopy];
+
+            [settings_ removeObjectForKey:@"Theme"];
+        }
+
+        if (themesArray_ == nil)
+            themesArray_ = [NSMutableArray arrayWithCapacity:16];
+        [settings_ setObject:themesArray_ forKey:@"Themes"];
+    }
+
+    themesArray_ = [themesArray_ retain];
+
+    NSMutableSet *themesSet = [NSMutableSet setWithCapacity:32];
+    for (NSMutableDictionary *theme in themesArray_)
+        if (NSString *name = [theme objectForKey:@"Name"])
+            [themesSet addObject:name];
+
     NSFileManager *manager = [NSFileManager defaultManager];
 
-    [themesArray_ addObjectsFromArray:[manager contentsOfDirectoryAtPath:@"/Library/Themes" error:NULL]];
-    [themesArray_ addObjectsFromArray:[manager contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()] error:NULL]];
+    NSMutableArray *themes = [NSMutableArray arrayWithCapacity:32];
+    [themes addObjectsFromArray:[manager contentsOfDirectoryAtPath:@"/Library/Themes" error:NULL]];
+    [themes addObjectsFromArray:[manager contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()] error:NULL]];
+
+    for (NSString *theme in themes) {
+        if ([theme hasSuffix:@".theme"])
+            theme = [theme substringWithRange:NSMakeRange(0, [theme length] - 6)];
+        if ([themesSet containsObject:theme])
+            continue;
+        [themesSet addObject:theme];
+        [themesArray_ addObject:[[NSDictionary dictionaryWithObjectsAndKeys:
+            theme, @"Name",
+            [NSNumber numberWithBool:NO], @"Active",
+        nil] mutableCopy]];
+    }
 
     themesTable_ = [[UITableView alloc] initWithFrame:window_.bounds];
     [window_ addSubview:themesTable_];
     [themesTable_ setDataSource:self];
     [themesTable_ setDelegate:self];
 
+    [themesTable_ setEditing:YES animated:NO];
+    themesTable_.allowsSelectionDuringEditing = YES;
+
     [themesTable_ setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
 }
 
diff --git a/Black Navigation Bars.theme/Info.plist b/Black Navigation Bars.theme/Info.plist
new file mode 100644 (file)
index 0000000..69b69dc
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0"><dict>
+
+<key>NavigationBarStyle</key>
+<string>1</string>
+
+</dict></plist>
index 45deecce91eb87aae58eb63419550c6c1096e503..6e46c334f6b571361e73b92d0a0f063cf72693ff 100644 (file)
@@ -71,9 +71,13 @@ extern "C" {
 #import <SpringBoard/SBContentLayer.h>
 #import <SpringBoard/SBIconLabel.h>
 #import <SpringBoard/SBStatusBarContentsView.h>
+#import <SpringBoard/SBStatusBarController.h>
 #import <SpringBoard/SBStatusBarTimeView.h>
 #import <SpringBoard/SBUIController.h>
 
+#import <MediaPlayer/MPVideoView.h>
+#import <MediaPlayer/MPVideoView-PlaybackControl.h>
+
 #import <CoreGraphics/CGGeometry.h>
 
 @interface NSDictionary (WinterBoard)
@@ -99,7 +103,7 @@ extern "C" {
 
 @end
 
-bool Debug_ = false;
+bool Debug_ = true;
 bool Engineer_ = false;
 
 /* WinterBoard Backend {{{ */
@@ -171,82 +175,106 @@ void WBRename(bool instance, const char *classname, const char *oldname, IMP new
 - (void) wb_setInDock:(BOOL)docked;
 - (void) wb_didMoveToSuperview;
 + (UIImage *) wb_imageNamed:(NSString *)name inBundle:(NSBundle *)bundle;
++ (UIImage *) wb_applicationImageNamed:(NSString *)name;
 - (NSDictionary *) wb_infoDictionary;
 - (UIImage *) wb_icon;
+- (id) wb_initWithStatusBar:(id)bar mode:(int)mode;
+- (id) wb_initWithMode:(int)mode orientation:(int)orientation;
+- (void) wb_setStatusBarMode:(int)mode orientation:(int)orientation duration:(float)duration fenceID:(int)id animation:(int)animation;
 @end
 
 NSMutableDictionary **ImageMap_;
+NSMutableSet *UIImages_;
 
 NSFileManager *Manager_;
 NSDictionary *English_;
-NSDictionary *Info_;
-NSString *theme_;
+NSMutableDictionary *Info_;
+NSMutableArray *themes_;
 
 NSString *$pathForIcon$(SBApplication<WinterBoard> *self) {
-    NSString *identifier = [self bundleIdentifier];
+    for (NSString *theme in themes_) {
+        NSString *identifier = [self bundleIdentifier];
+        NSString *folder = [[self path] lastPathComponent];
+        NSString *dname = [self displayName];
+        NSString *didentifier = [self displayIdentifier];
+
+        if (Debug_) {
+            NSLog(@"WB:Debug: [SBApplication(%@:%@:%@:%@) pathForIcon]", identifier, folder, dname, didentifier);
+        }
 
-    #define testForIcon(Name) \
-        if (NSString *name = Name) { \
-            NSString *path = [NSString stringWithFormat:@"%@/Icons/%@.png", theme_, name]; \
-            if ([Manager_ fileExistsAtPath:path]) \
-                return path; \
+        #define testForIcon(Name) \
+            if (NSString *name = Name) { \
+                NSString *path = [NSString stringWithFormat:@"%@/Icons/%@.png", theme, name]; \
+                if ([Manager_ fileExistsAtPath:path]) \
+                    return path; \
+            }
+
+        if (identifier != nil) {
+            NSString *path = [NSString stringWithFormat:@"%@/Bundles/%@/icon.png", theme, identifier];
+            if ([Manager_ fileExistsAtPath:path])
+                return path;
         }
 
-    if (identifier != nil) {
-        NSString *path = [NSString stringWithFormat:@"%@/Bundles/%@/icon.png", theme_, identifier];
-        if ([Manager_ fileExistsAtPath:path])
-            return path;
-    }
+        if (folder != nil) {
+            NSString *path = [NSString stringWithFormat:@"%@/Folders/%@/icon.png", theme, folder];
+            if ([Manager_ fileExistsAtPath:path])
+                return path;
+        }
 
-    if (NSString *folder = [[self path] lastPathComponent]) {
-        NSString *path = [NSString stringWithFormat:@"%@/Folders/%@/icon.png", theme_, folder];
-        if ([Manager_ fileExistsAtPath:path])
-            return path;
-    }
+        testForIcon(identifier);
+        testForIcon(dname);
 
-    testForIcon(identifier);
-    testForIcon([self displayName]);
+        if (didentifier != nil) {
+            testForIcon([English_ objectForKey:didentifier]);
 
-    if (NSString *display = [self displayIdentifier])
-        testForIcon([English_ objectForKey:display]);
+            NSArray *parts = [didentifier componentsSeparatedByString:@"-"];
+            if ([parts count] != 1)
+                if (NSDictionary *english = [[[NSDictionary alloc] initWithContentsOfFile:[[self path] stringByAppendingString:@"/English.lproj/UIRoleDisplayNames.strings"]] autorelease])
+                    testForIcon([english objectForKey:[parts lastObject]]);
+        }
+    }
 
     return nil;
 }
 
 static UIImage *SBApplicationIcon$icon(SBApplicationIcon<WinterBoard> *self, SEL sel) {
-    if (Info_ == nil || ![Info_ boolForKey:@"ComposeStoreIcons"])
+    if (![Info_ boolForKey:@"ComposeStoreIcons"])
         if (NSString *path = $pathForIcon$([self application]))
             return [UIImage imageWithContentsOfFile:path];
     return [self wb_icon];
 }
 
 static NSString *SBApplication$pathForIcon(SBApplication<WinterBoard> *self, SEL sel) {
-    if (theme_ != nil)
-        if (NSString *path = $pathForIcon$(self))
-            return path;
-
+    if (NSString *path = $pathForIcon$(self))
+        return path;
     return [self wb_pathForIcon];
 }
 
 static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle) {
-    if (theme_ != nil) {
+    for (NSString *theme in themes_) {
         NSString *identifier = [bundle bundleIdentifier];
 
         if (identifier != nil) {
-            NSString *path = [NSString stringWithFormat:@"%@/Bundles/%@/%@", theme_, identifier, file];
+            NSString *path = [NSString stringWithFormat:@"%@/Bundles/%@/%@", theme, identifier, file];
+            if (Debug_)
+                NSLog(@"WB:Debug:%@", path);
             if ([Manager_ fileExistsAtPath:path])
                 return path;
         }
 
         if (NSString *folder = [[bundle bundlePath] lastPathComponent]) {
-            NSString *path = [NSString stringWithFormat:@"%@/Folders/%@/%@", theme_, folder, file];
+            NSString *path = [NSString stringWithFormat:@"%@/Folders/%@/%@", theme, folder, file];
+            if (Debug_)
+                NSLog(@"WB:Debug:%@", path);
             if ([Manager_ fileExistsAtPath:path])
                 return path;
         }
 
         #define remapResourceName(oldname, newname) \
             else if ([file isEqualToString:oldname]) { \
-                NSString *path = [NSString stringWithFormat:@"%@/%@.png", theme_, newname]; \
+                NSString *path = [NSString stringWithFormat:@"%@/%@.png", theme, newname]; \
+                if (Debug_) \
+                    NSLog(@"WB:Debug:%@", path); \
                 if ([Manager_ fileExistsAtPath:path]) \
                     return path; \
             }
@@ -272,6 +300,15 @@ static UIImage *UIImage$imageNamed$(Class<WinterBoard> self, SEL sel, NSString *
     return UIImage$imageNamed$inBundle$(self, sel, name, [NSBundle mainBundle]);
 }
 
+static UIImage *UIImage$applicationImageNamed$(Class<WinterBoard> self, SEL sel, NSString *name) {
+    NSBundle *bundle = [NSBundle mainBundle];
+    if (Debug_)
+        NSLog(@"WB:Debug: [UIImage(%@) applicationImageNamed:\"%@\"]", [bundle bundleIdentifier], name);
+    if (NSString *path = $pathForFile$inBundle$(name, bundle))
+        return [UIImage imageWithContentsOfFile:path];
+    return [self wb_applicationImageNamed:name];
+}
+
 static NSString *NSBundle$pathForResource$ofType$(NSBundle<WinterBoard> *self, SEL sel, NSString *resource, NSString *type) {
     NSString *file = type == nil ? resource : [NSString stringWithFormat:@"%@.%@", resource, type];
     if (Debug_)
@@ -282,12 +319,9 @@ static NSString *NSBundle$pathForResource$ofType$(NSBundle<WinterBoard> *self, S
 }
 
 bool UINavigationBar$setBarStyle$_(SBAppWindow<WinterBoard> *self) {
-    if (Info_ != nil) {
-        NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"];
-        if (number != nil) {
-            [self wb_setBarStyle:[number intValue]];
-            return true;
-        }
+    if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"]) {
+        [self wb_setBarStyle:[number intValue]];
+        return true;
     }
 
     return false;
@@ -296,15 +330,11 @@ bool UINavigationBar$setBarStyle$_(SBAppWindow<WinterBoard> *self) {
 /*id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground<WinterBoard> *self, SEL sel, CGRect frame, int style, UIColor *tint) {
     _trace();
 
-    if (Info_ != nil) {
-        NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"];
-        if (number != nil)
-            style = [number intValue];
+    if (NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"])
+        style = [number intValue];
 
-        UIColor *color = [Info_ colorForKey:@"NavigationBarTint"];
-        if (color != nil)
-            tint = color;
-    }
+    if (UIColor *color = [Info_ colorForKey:@"NavigationBarTint"])
+        tint = color;
 
     return [self wb_initWithFrame:frame withBarStyle:style withTintColor:tint];
 }*/
@@ -336,9 +366,15 @@ static void $didMoveToSuperview(SBButtonBar<WinterBoard> *self, SEL sel) {
     [self wb_didMoveToSuperview];
 }
 
-static NSString *$getTheme$(NSString *file) {
-    NSString *path([NSString stringWithFormat:@"%@/%@", theme_, file]);
-    return [Manager_ fileExistsAtPath:path] ? path : nil;
+static NSString *$getTheme$(NSArray *files) {
+    for (NSString *theme in themes_)
+        for (NSString *file in files) {
+            NSString *path([NSString stringWithFormat:@"%@/%@", theme, file]);
+            if ([Manager_ fileExistsAtPath:path])
+                return path;
+        }
+
+    return nil;
 }
 
 static id SBContentLayer$initWithSize$(SBContentLayer<WinterBoard> *self, SEL sel, CGSize size) {
@@ -346,10 +382,20 @@ static id SBContentLayer$initWithSize$(SBContentLayer<WinterBoard> *self, SEL se
     if (self == nil)
         return nil;
 
-    if (NSString *path = $getTheme$(@"Wallpaper.png"))
+    if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Wallpaper.mp4"])) {
+        MPVideoView *video = [[[MPVideoView alloc] initWithFrame:[self bounds]] autorelease];
+        [video setMovieWithPath:path];
+        [video setRepeatMode:1];
+        [video setRepeatGap:0];
+        [self addSubview:video];
+        [video playFromBeginning];;
+    }
+
+    if (NSString *path = $getTheme$([NSArray arrayWithObjects:@"Wallpaper.png", @"Wallpaper.jpg", nil]))
         if (UIImage *image = [[[UIImage alloc] initWithContentsOfFile:path] autorelease])
             [self addSubview:[[[UIImageView alloc] initWithImage:image] autorelease]];
-    if (NSString *path = $getTheme$(@"Wallpaper.html")) {
+
+    if (NSString *path = $getTheme$([NSArray arrayWithObject:@"Wallpaper.html"])) {
         CGRect bounds = [self bounds];
 
         UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
@@ -417,20 +463,19 @@ extern "C" NSString *UIStyleStringFromColor(CGColorRef);
 WBDelegate(time_)
 
 - (CGSize) drawAtPoint:(CGPoint)point forWidth:(float)width withFont:(UIFont *)font lineBreakMode:(int)mode {
-    if (Info_ != nil)
-        if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
-            BOOL mode;
-            object_getInstanceVariable(view_, "_mode", (void **) &mode);
-
-            [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
-                "font-family: Helvetica; "
-                "font-weight: bold; "
-                "font-size: 14px; "
-                "color: %@; "
-            "%@", mode ? @"white" : @"black", custom]];
-
-            return CGSizeZero;
-        }
+    if (NSString *custom = [Info_ objectForKey:@"TimeStyle"]) {
+        BOOL mode;
+        object_getInstanceVariable(view_, "_mode", (void **) &mode);
+
+        [time_ drawAtPoint:point withStyle:[NSString stringWithFormat:@""
+            "font-family: Helvetica; "
+            "font-weight: bold; "
+            "font-size: 14px; "
+            "color: %@; "
+        "%@", mode ? @"white" : @"black", custom]];
+
+        return CGSizeZero;
+    }
 
     return [time_ drawAtPoint:point forWidth:width withFont:font lineBreakMode:mode];
 }
@@ -461,19 +506,26 @@ WBDelegate(time_)
 WBDelegate(string_)
 
 - (NSString *) _iconLabelStyle {
-    return Info_ == nil ? nil : [Info_ objectForKey:(docked_ ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle")];
+    NSString *key = docked_ ? @"DockedIconLabelStyle" : @"UndockedIconLabelStyle";
+    NSString *style = [Info_ objectForKey:key];
+    NSLog(@"WB:Debug:%@ = %@", key, style);
+    return style;
 }
 
 - (CGSize) drawInRect:(CGRect)rect withFont:(UIFont *)font lineBreakMode:(int)mode alignment:(int)alignment {
+    _trace();
     if (NSString *custom = [self _iconLabelStyle]) {
-        [string_ drawInRect:rect withStyle:[NSString stringWithFormat:@""
+        NSString *style = [NSString stringWithFormat:@""
             "font-family: Helvetica; "
             "font-weight: bold; "
             "font-size: 11px; "
             "text-align: center; "
             "color: %@; "
-        "%@", docked_ ? @"white" : @"#b3b3b3", custom]];
+        "%@", docked_ ? @"white" : @"#b3b3b3", custom];
 
+        if (Debug_)
+            NSLog(@"WB:Debug:style = %@", style);
+        [string_ drawInRect:rect withStyle:style];
         return CGSizeZero;
     }
 
@@ -481,8 +533,13 @@ WBDelegate(string_)
 }
 
 - (void) drawInRect:(CGRect)rect withStyle:(NSString *)style {
-    if (NSString *custom = [self _iconLabelStyle])
-        return [string_ drawInRect:rect withStyle:[NSString stringWithFormat:@"%@; %@", style, custom]];
+    _trace();
+    if (NSString *custom = [self _iconLabelStyle]) {
+        NSString *combined = [NSString stringWithFormat:@"%@; %@", style, custom];
+        if (Debug_)
+            NSLog(@"WB:Debug:combined = %@", combined);
+        return [string_ drawInRect:rect withStyle:combined];
+    }
     return [string_ drawInRect:rect withStyle:style];
 }
 
@@ -498,6 +555,22 @@ WBDelegate(string_)
 
 @end
 
+static void SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$(SBStatusBarController<WinterBoard> *self, SEL sel, int mode, int orientation, float duration, int id, int animation) {
+    if (NSNumber *number = [Info_ objectForKey:@"StatusBarMode"])
+        mode = [number intValue];
+    return [self wb_setStatusBarMode:mode orientation:orientation duration:duration fenceID:id animation:animation];
+}
+
+/*static id SBStatusBar$initWithMode$orientation$(SBStatusBar<WinterBoard> *self, SEL sel, int mode, int orientation) {
+    return [self wb_initWithMode:mode orientation:orientation];
+}*/
+
+static id SBStatusBarContentsView$initWithStatusBar$mode$(SBStatusBarContentsView<WinterBoard> *self, SEL sel, id bar, int mode) {
+    if (NSNumber *number = [Info_ objectForKey:@"StatusBarContentsMode"])
+        mode = [number intValue];
+    return [self wb_initWithStatusBar:bar mode:mode];
+}
+
 static void SBStatusBarTimeView$drawRect$(SBStatusBarTimeView<WinterBoard> *self, SEL sel, CGRect rect) {
     id time;
     object_getInstanceVariable(self, "_time", (void **) &time);
@@ -509,7 +582,7 @@ static void SBStatusBarTimeView$drawRect$(SBStatusBarTimeView<WinterBoard> *self
 static void SBIconLabel$setInDock$(SBIconLabel<WinterBoard> *self, SEL sel, BOOL docked) {
     id label;
     object_getInstanceVariable(self, "_label", (void **) &label);
-    if (Info_ == nil || [Info_ boolForKey:@"IconLabelInDock"])
+    if (![Info_ boolForKey:@"UndockedIconLabels"])
         docked = YES;
     if (label != nil && [label respondsToSelector:@selector(setInDock:)])
         [label setInDock:docked];
@@ -554,6 +627,7 @@ extern "C" void WBInitialize() {
         English_ = [English_ retain];
 
     Manager_ = [[NSFileManager defaultManager] retain];
+    UIImages_ = [[NSMutableSet alloc] initWithCapacity:16];
 
     //WBRename("UINavigationBar", "initWithCoder:", (IMP) &UINavigationBar$initWithCoder$);
     WBRename(true, "UINavigationBar", "setBarStyle:", (IMP) &UINavigationBar$setBarStyle$);
@@ -561,48 +635,95 @@ extern "C" void WBInitialize() {
 
     WBRename(false, "UIImage", "imageNamed:inBundle:", (IMP) &UIImage$imageNamed$inBundle$);
     WBRename(false, "UIImage", "imageNamed:", (IMP) &UIImage$imageNamed$);
+    WBRename(false, "UIImage", "applicationImageNamed:", (IMP) &UIImage$applicationImageNamed$);
     WBRename(true, "SBApplicationIcon", "icon", (IMP) &SBApplicationIcon$icon);
     WBRename(true, "SBApplication", "pathForIcon", (IMP) &SBApplication$pathForIcon);
     WBRename(true, "NSBundle", "pathForResource:ofType:", (IMP) &NSBundle$pathForResource$ofType$);
     WBRename(true, "SBContentLayer", "initWithSize:", (IMP) &SBContentLayer$initWithSize$);
+    WBRename(true, "SBStatusBarContentsView", "initWithStatusBar:mode:", (IMP) &SBStatusBarContentsView$initWithStatusBar$mode$);
+    //WBRename(true, "SBStatusBar", "initWithMode:orientation:", (IMP) &SBStatusBar$initWithMode$orientation$);
     WBRename(true, "SBStatusBarContentsView", "didMoveToSuperview", (IMP) &$didMoveToSuperview);
     WBRename(true, "SBButtonBar", "didMoveToSuperview", (IMP) &$didMoveToSuperview);
     WBRename(true, "SBIconLabel", "setInDock:", (IMP) &SBIconLabel$setInDock$);
     WBRename(true, "SBIconLabel", "initWithSize:label:", (IMP) &SBIconLabel$initWithSize$label$);
     WBRename(true, "SBStatusBarTimeView", "drawRect:", (IMP) &SBStatusBarTimeView$drawRect$);
+    WBRename(true, "SBStatusBarController", "setStatusBarMode:orientation:duration:fenceID:animation:", (IMP) &SBStatusBarController$setStatusBarMode$orientation$duration$fenceID$animation$);
+
+    themes_ = [[NSMutableArray alloc] initWithCapacity:8];
 
-    if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()]]) {
+    if (NSDictionary *settings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"/User/Library/Preferences/com.saurik.WinterBoard.plist"]]) {
         [settings autorelease];
-        NSString *name = [settings objectForKey:@"Theme"];
-        NSString *path;
 
-        if (theme_ == nil) {
-            path = [NSString stringWithFormat:@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name];
-            if ([Manager_ fileExistsAtPath:path])
-                theme_ = [path retain];
-        }
+        NSArray *themes = [settings objectForKey:@"Themes"];
+        if (themes == nil)
+            if (NSString *theme = [settings objectForKey:@"Theme"])
+                themes = [NSArray arrayWithObject:[NSDictionary dictionaryWithObjectsAndKeys:
+                    theme, @"Name",
+                    [NSNumber numberWithBool:YES], @"Active",
+                nil]];
+        if (themes != nil)
+            for (NSDictionary *theme in themes) {
+                NSNumber *active = [theme objectForKey:@"Active"];
+                if (![active boolValue])
+                    continue;
 
-        if (theme_ == nil) {
-            path = [NSString stringWithFormat:@"/Library/Themes/%@", name];
-            if ([Manager_ fileExistsAtPath:path])
-                theme_ = [path retain];
-        }
+                NSString *name = [theme objectForKey:@"Name"];
+                if (name == nil)
+                    continue;
+
+                NSString *theme = nil;
+
+                if (theme == nil) {
+                    NSString *path = [NSString stringWithFormat:@"/Library/Themes/%@.theme", name];
+                    if ([Manager_ fileExistsAtPath:path]) {
+                        [themes_ addObject:path];
+                        continue;
+                    }
+                }
+
+                if (theme == nil) {
+                    NSString *path = [NSString stringWithFormat:@"/Library/Themes/%@", name];
+                    if ([Manager_ fileExistsAtPath:path]) {
+                        [themes_ addObject:path];
+                        continue;
+                    }
+                }
+
+                if (theme == nil) {
+                    NSString *path = [NSString stringWithFormat:@"%@/Library/SummerBoard/Themes/%@", NSHomeDirectory(), name];
+                    if ([Manager_ fileExistsAtPath:path]) {
+                        [themes_ addObject:path];
+                        continue;
+                    }
+                }
+            }
     }
 
-    if (theme_ != nil) {
-        NSString *folder = [NSString stringWithFormat:@"%@/UIImages", theme_];
+    Info_ = [[NSMutableDictionary dictionaryWithCapacity:16] retain];
+
+    for (NSString *theme in themes_) {
+        NSString *folder = [NSString stringWithFormat:@"%@/UIImages", theme];
         if (NSArray *images = [Manager_ contentsOfDirectoryAtPath:folder error:NULL])
             for (int i(0), e = [images count]; i != e; ++i) {
                 NSString *name = [images objectAtIndex:i];
                 if (![name hasSuffix:@".png"])
                     continue;
+                if ([UIImages_ containsObject:name])
+                    continue;
                 NSString *path = [NSString stringWithFormat:@"%@/%@", folder, name];
                 UIImage *image = [UIImage imageWithContentsOfFile:path];
                 [*ImageMap_ setObject:(id)[image imageRef] forKey:name];
+                [UIImages_ addObject:name];
             }
 
-        Info_ = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme_]];
+        if (NSDictionary *info = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme]])
+            for (NSString *key in [info allKeys])
+                if ([Info_ objectForKey:key] == nil)
+                    [Info_ setObject:[info objectForKey:key] forKey:key];
     }
 
+    if (Debug_)
+        NSLog(@"WB:Debug:Info = %@", [Info_ description]);
+
     [pool release];
 }
diff --git a/Saurik.theme/Bundles/com.apple.springboard/SBDockBG.png b/Saurik.theme/Bundles/com.apple.springboard/SBDockBG.png
new file mode 100644 (file)
index 0000000..a8c73e6
Binary files /dev/null and b/Saurik.theme/Bundles/com.apple.springboard/SBDockBG.png differ
diff --git a/Saurik.theme/Info.plist b/Saurik.theme/Info.plist
new file mode 100644 (file)
index 0000000..b782b31
--- /dev/null
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0"><dict>
+
+<!--key>StatusBarMode</key>
+<string>0</string>
+
+<key>StatusBarContentsMode</key>
+<string>0</string-->
+
+<key>UndockedIconLabelStyle</key>
+<string>/*font-family: monospace; font-size: 13px;*/ color: white</string>
+
+<key>DockedIconLabelStyle</key>
+<string>/*font-family: monospace; font-size: 13px;*/ color: burlywood</string>
+
+<key>TimeStyle</key>
+<string>/*font-family: monospace; font-size: 16px*/</string>
+
+<!--key>ComposeStoreIcons</key>
+<false/-->
+
+</dict></plist>
diff --git a/Saurik.theme/Private/Plant.png b/Saurik.theme/Private/Plant.png
new file mode 100644 (file)
index 0000000..cdf4a24
Binary files /dev/null and b/Saurik.theme/Private/Plant.png differ
diff --git a/Saurik.theme/Private/Rock.png b/Saurik.theme/Private/Rock.png
new file mode 100644 (file)
index 0000000..005aa07
Binary files /dev/null and b/Saurik.theme/Private/Rock.png differ
diff --git a/Saurik.theme/Wallpaper.html b/Saurik.theme/Wallpaper.html
new file mode 100644 (file)
index 0000000..589c9b2
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-16"?>
+<html><head>
+    <base href="Private/"/>
+    <!--meta name="viewport" content="width=320, minimum-scale=1.0, maximum-scale=1.0"/-->
+    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
+
+    <style>
+        body {
+            background-color: black;
+            margin: 0;
+            padding: 20px 0 0 0;
+            height: 442px;
+            width: 320px;
+        }
+
+        img {
+            -webkit-transition-property: opacity;
+            -webkit-transition-duration: 2s;
+            position: absolute;
+            width: 320px;
+            height: auto;
+        }
+
+        img.fade-out {
+            opacity: 0;
+        }
+
+        img.fade-in {
+            opacity: 1;
+        }
+    </style>
+</head><body style="color: black">
+    <img src="Rock.png" id="rock"/>
+    <img src="Plant.png" id="plant"/>
+
+    <script>
+        var fade_in = rock;
+        var fade_out = plant;
+
+        var fade = function () {
+            fade_in.className = 'fade-out';
+            fade_out.className = 'fade-in';
+
+            var fade_tmp = fade_in;
+            fade_in = fade_out;
+            fade_out = fade_tmp;
+
+            setTimeout(fade, 15000);
+        };
+
+        fade();
+    </script>
+</body></html>
diff --git a/Saurik/Bundles/com.apple.springboard/SBDockBG.png b/Saurik/Bundles/com.apple.springboard/SBDockBG.png
deleted file mode 100644 (file)
index a8c73e6..0000000
Binary files a/Saurik/Bundles/com.apple.springboard/SBDockBG.png and /dev/null differ
diff --git a/Saurik/Info.plist b/Saurik/Info.plist
deleted file mode 100644 (file)
index 7b8d2e6..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0"><dict>
-
-<key>NavigationBarStyle</key>
-<string>1</string>
-
-<key>UndockedIconLabelStyle</key>
-<string>/*font-family: monospace; font-size: 13px;*/ color: white</string>
-
-<key>DockedIconLabelStyle</key>
-<string>/*font-family: monospace; font-size: 13px;*/ color: burlywood</string>
-
-<key>TimeStyle</key>
-<string>/*font-family: monospace; font-size: 16px*/</string>
-
-<!--key>ComposeStoreIcons</key>
-<false/-->
-
-</dict></plist>
diff --git a/Saurik/Private/Plant.png b/Saurik/Private/Plant.png
deleted file mode 100644 (file)
index cdf4a24..0000000
Binary files a/Saurik/Private/Plant.png and /dev/null differ
diff --git a/Saurik/Private/Rock.png b/Saurik/Private/Rock.png
deleted file mode 100644 (file)
index 005aa07..0000000
Binary files a/Saurik/Private/Rock.png and /dev/null differ
diff --git a/Saurik/Wallpaper.html b/Saurik/Wallpaper.html
deleted file mode 100644 (file)
index 589c9b2..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="UTF-16"?>
-<html><head>
-    <base href="Private/"/>
-    <!--meta name="viewport" content="width=320, minimum-scale=1.0, maximum-scale=1.0"/-->
-    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
-
-    <style>
-        body {
-            background-color: black;
-            margin: 0;
-            padding: 20px 0 0 0;
-            height: 442px;
-            width: 320px;
-        }
-
-        img {
-            -webkit-transition-property: opacity;
-            -webkit-transition-duration: 2s;
-            position: absolute;
-            width: 320px;
-            height: auto;
-        }
-
-        img.fade-out {
-            opacity: 0;
-        }
-
-        img.fade-in {
-            opacity: 1;
-        }
-    </style>
-</head><body style="color: black">
-    <img src="Rock.png" id="rock"/>
-    <img src="Plant.png" id="plant"/>
-
-    <script>
-        var fade_in = rock;
-        var fade_out = plant;
-
-        var fade = function () {
-            fade_in.className = 'fade-out';
-            fade_out.className = 'fade-in';
-
-            var fade_tmp = fade_in;
-            fade_in = fade_out;
-            fade_out = fade_tmp;
-
-            setTimeout(fade, 15000);
-        };
-
-        fade();
-    </script>
-</body></html>
diff --git a/Test.sh b/Test.sh
index 55409f89d46eadf520a4c82681f54faac2c9a414..c42495ec062d572e8c08911006a24720e42bd93f 100755 (executable)
--- a/Test.sh
+++ b/Test.sh
@@ -2,5 +2,5 @@
 rm -f WinterBoard.dylib
 set -e
 rsync --exclude .svn -SPaz 'saurik@carrier.saurik.com:menes/winterboard/WinterBoard{,.dylib}' .
-rsync --exclude .svn -SPaz 'saurik@carrier.saurik.com:menes/winterboard/Nature/' /Library/Themes/com.saurik.WinterBoard.Nature
+rsync --exclude .svn -SPaz 'saurik@carrier.saurik.com:menes/winterboard/*.theme' /Library/Themes/
 #killall SpringBoard
diff --git a/Transparent Icon Labels.theme/Info.plist b/Transparent Icon Labels.theme/Info.plist
new file mode 100644 (file)
index 0000000..dd87935
--- /dev/null
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0"><dict>
+
+<key>UndockedIconLabelStyle</key>
+<string>color: transparent</string>
+
+<key>DockedIconLabelStyle</key>
+<string>color: transparent</string>
+
+</dict></plist>
diff --git a/User Wallpaper.theme/Wallpaper.jpg b/User Wallpaper.theme/Wallpaper.jpg
new file mode 120000 (symlink)
index 0000000..d0c0b4b
--- /dev/null
@@ -0,0 +1 @@
+/var/mobile/Library/LockBackground.jpg
\ No newline at end of file
diff --git a/control b/control
index a8abbaa7440aaf862810980660e3dccf0caa947e..43d6b8e968f772c2d4f9e7ad0644c0dc596f1f1c 100644 (file)
--- a/control
+++ b/control
@@ -1,20 +1,17 @@
 Package: winterboard
 Priority: optional
-Section: Themes
+Section: System
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.2506-1
+Version: 0.9.2519-1
 Description: more powerful, open-source SummerBoard
After you install or uninstall this package you will have to /reboot/ (seriously, REBOOT) your phone to it to take effect.
This tool lets you give your device a graphical overhaul. Themes are taken from /Library/Themes (or, now, the older SummerBoard folder). Using the relatively simple frontend you can activate and deactivate multiple themes and give them a priority ordering.
  
- This tool lets you apply SummerBoard themes. Themes are taken from /Library/Themes (or, now, the older SummerBoard folder). Right now the front-end for selecting themes is /very/ simplistic: I have spent only a couple days coding this and almost all of that time has been on the backend.
- More work will be done on this package in the very near future to make it actually have an interface ;P.
- WinterBoard is /much/ more powerful than SummerBoard and lets you theme almost any graphic on the system. You can even easily theme .artwork files without having to hack their contents. Instructions on how this works will be posted soon on the More Information page.
+ WinterBoard was designed to accept <a href="http://www.apptapp.com/summerboard/">SummerBoard</a> themes without modification but is <strong>much</strong> more powerful than its predecessor. With WinterBoard you can theme almost any graphic on the system. You can even easily modify .artwork files without having to hack their contents, all from the safety of your theme folder.
 Name: WinterBoard
+Depends: mobilesubstrate
 Provides: theme-manager
 Conflicts: com.modmyifone.winterboardicon
 Replaces: com.modmyifone.winterboardicon
 Author: Jay Freeman (saurik) <saurik@saurik.com>
-Homepage: http://cydia.saurik.com/winterboard.html
+Homepage: http://cydia.saurik.com/winterboard/
index c90666e7d072298d07274f781ae5393f893a1e73..405934ce871b1ab4deb20726eb50c0943f83dc0e 100644 (file)
--- a/makefile
+++ b/makefile
@@ -10,7 +10,7 @@ clean:
        rm -f WinterBoard WinterBoard.dylib UIImages
 
 WinterBoard.dylib: Library.mm makefile
-       $(target)g++ -dynamiclib -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework CoreFoundation -framework Foundation -lobjc -init _WBInitialize -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics
+       $(target)g++ -dynamiclib -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework CoreFoundation -framework Foundation -lobjc -init _WBInitialize -I/apl/inc/iPhoneOS-2.0 -framework CoreGraphics -framework MediaPlayer
 
 UIImages: UIImages.mm makefile
        $(target)g++ -g0 -O2 -Wall -Werror -o $@ $(filter %.mm,$^) -framework UIKit -framework Foundation -framework CoreFoundation -lobjc
@@ -23,10 +23,12 @@ package:
        mkdir -p winterboard/DEBIAN
        mkdir -p winterboard/Applications/WinterBoard.app
        mkdir -p winterboard/Library/Themes
-       cp -a Saurik winterboard/Library/Themes
-       find winterboard/Library/Themes/Saurik -name .svn | while read -r line; do rm -rf "$${line}"; done
-       cp -a control preinst postinst prerm winterboard/DEBIAN
-       cp -a Test.sh icon.png WinterBoard.dylib WinterBoard UIImages Info.plist ../pledit/pledit winterboard/Applications/WinterBoard.app
-       dpkg-deb -b winterboard winterboard_0.9.2506-1_iphoneos-arm.deb
+       mkdir -p winterboard/Library/MobileSubstrate/DynamicLibraries
+       ln -s /Applications/WinterBoard.app/WinterBoard.dylib winterboard/Library/MobileSubstrate/DynamicLibraries
+       cp -a *.theme winterboard/Library/Themes
+       find winterboard/Library/Themes -name .svn | while read -r line; do rm -rf "$${line}"; done
+       cp -a control preinst prerm winterboard/DEBIAN
+       cp -a Test.sh icon.png WinterBoard.dylib WinterBoard UIImages Info.plist winterboard/Applications/WinterBoard.app
+       dpkg-deb -b winterboard winterboard_0.9.2519-1_iphoneos-arm.deb
 
 .PHONY: all clean package
diff --git a/postinst b/postinst
deleted file mode 100755 (executable)
index 6b94318..0000000
--- a/postinst
+++ /dev/null
@@ -1,6 +0,0 @@
-#!/bin/sh
-
-if [[ $1 == configure ]]; then
-    /Applications/WinterBoard.app/pledit /System/Library/LaunchDaemons/com.apple.SpringBoard.plist \
-        -a /Applications/WinterBoard.app/WinterBoard.dylib
-fi
diff --git a/preinst b/preinst
index 357b50c9f3998ea60ec3fe39eb9dfb9928567783..2cb79e1364b6fb180cbdb6906c462ce755c6b1bb 100755 (executable)
--- a/preinst
+++ b/preinst
@@ -1,7 +1,25 @@
 #!/bin/bash
 
+declare -a cydia
+cydia=($CYDIA)
+
 if [[ $1 == install ]]; then
     /usr/libexec/cydia/move.sh /Library/Themes
+    if [[ ${CYDIA+@} ]]; then
+        eval "echo 'finish:restart' >&${cydia[0]}"
+    fi
+elif [[ $1 == upgrade ]]; then
+    if [[ -e /Applications/WinterBoard.app/pledit ]]; then
+        /Applications/WinterBoard.app/pledit /System/Library/LaunchDaemons/com.apple.SpringBoard.plist \
+            -r /Applications/WinterBoard.app/WinterBoard.dylib
+        if [[ ${CYDIA+@} ]]; then
+            eval "echo 'finish:reload' >&${cydia[0]}"
+        fi
+    else
+        if [[ ${CYDIA+@} ]]; then
+            eval "echo 'finish:restart' >&${cydia[0]}"
+        fi
+    fi
 fi
 
 exit 0
diff --git a/prerm b/prerm
index dbb80b8aa335a90fd6ca29cc1a0da15ab59316d0..a383ff2cb658ca885f8f304ac9d64526fdfe0dc7 100755 (executable)
--- a/prerm
+++ b/prerm
@@ -1,6 +1,10 @@
 #!/bin/sh
 
+declare -a cydia
+cydia=($CYDIA)
+
 if [[ $1 == remove ]]; then
-    /Applications/WinterBoard.app/pledit /System/Library/LaunchDaemons/com.apple.SpringBoard.plist \
-        -r /Applications/WinterBoard.app/WinterBoard.dylib
+    if [[ ${CYDIA+@} ]]; then
+        eval "echo 'finish:restart' >&${cydia[0]}"
+    fi
 fi