]> git.saurik.com Git - winterboard.git/commitdiff
Added some amazing theme features.
authorJay Freeman (saurik) <saurik@saurik.com>
Tue, 5 Aug 2008 02:17:29 +0000 (02:17 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Tue, 5 Aug 2008 02:17:29 +0000 (02:17 +0000)
Library.mm
Nature/Bundles/com.apple.springboard/SBDockBG.png [deleted file]
Nature/Info.plist [deleted file]
Nature/Wallpaper.png [deleted file]
Saurik/Bundles/com.apple.springboard/SBDockBG.png [new file with mode: 0644]
Saurik/Info.plist [new file with mode: 0644]
Saurik/Private/Plant.png [new file with mode: 0644]
Saurik/Private/Rock.png [new file with mode: 0644]
Saurik/Wallpaper.html [new file with mode: 0644]
control
makefile

index 2b7a9ae9252a68fc41171f03fc5c5a78438218cb..a6dde911d65c4bc06f04358d7bc95f28008ec7d6 100644 (file)
@@ -53,6 +53,7 @@ extern "C" {
 #import <UIKit/UIImage.h>
 #import <UIKit/UIImageView.h>
 #import <UIKit/UINavigationBarBackground.h>
+#import <UIKit/UIWebDocumentView.h>
 
 #import <UIKit/NSString-UIStringDrawing.h>
 #import <UIKit/NSString-UIStringDrawingDeprecated.h>
@@ -64,6 +65,7 @@ extern "C" {
 #import <UIKit/UIView-Rendering.h>
 
 #import <SpringBoard/SBApplication.h>
+#import <SpringBoard/SBApplicationIcon.h>
 #import <SpringBoard/SBAppWindow.h>
 #import <SpringBoard/SBButtonBar.h>
 #import <SpringBoard/SBContentLayer.h>
@@ -169,6 +171,8 @@ 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;
+- (NSDictionary *) wb_infoDictionary;
+- (UIImage *) wb_icon;
 @end
 
 NSMutableDictionary **ImageMap_;
@@ -177,55 +181,53 @@ NSFileManager *Manager_;
 NSDictionary *English_;
 NSDictionary *Info_;
 NSString *theme_;
-NSString *Wallpaper_;
 
-NSString *SBApplication$pathForIcon(SBApplication<WinterBoard> *self, SEL sel) {
-    if (theme_ != nil) {
-        NSString *identifier = [self bundleIdentifier];
-
-        #define testForIcon(Name) \
-            if (NSString *name = Name) { \
-                NSString *path = [NSString stringWithFormat:@"%@/Icons/%@.png", theme_, name]; \
-                if ([Manager_ fileExistsAtPath:path]) \
-                    return path; \
-            }
+NSString *$pathForIcon$(SBApplication<WinterBoard> *self) {
+    NSString *identifier = [self bundleIdentifier];
 
-        if (identifier != nil) {
-            NSString *path = [NSString stringWithFormat:@"%@/Bundles/%@/icon.png", theme_, identifier];
-            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 (NSString *folder = [[self path] lastPathComponent]) {
-            NSString *path = [NSString stringWithFormat:@"%@/Folders/%@/icon.png", theme_, folder];
-            if ([Manager_ fileExistsAtPath:path])
-                return path;
-        }
+    if (identifier != nil) {
+        NSString *path = [NSString stringWithFormat:@"%@/Bundles/%@/icon.png", theme_, identifier];
+        if ([Manager_ fileExistsAtPath:path])
+            return path;
+    }
 
-        testForIcon(identifier);
-        testForIcon([self displayName]);
+    if (NSString *folder = [[self path] lastPathComponent]) {
+        NSString *path = [NSString stringWithFormat:@"%@/Folders/%@/icon.png", theme_, folder];
+        if ([Manager_ fileExistsAtPath:path])
+            return path;
+    }
 
-        if (NSString *display = [self displayIdentifier])
-            testForIcon([English_ objectForKey:display]);
+    testForIcon(identifier);
+    testForIcon([self displayName]);
 
-        /*if (NSDictionary *strings = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/English.lproj/InfoPlist.strings", [self path]]]) {
-            testForIcon([strings objectForKey:@"UISettingsDisplayName"]);
+    if (NSString *display = [self displayIdentifier])
+        testForIcon([English_ objectForKey:display]);
 
-            _trace();
-            if (NSString *bundle = [strings objectForKey:@"CFBundleName"]) {
-                if ([bundle hasPrefix:@"Mobile"]) {
-                    NSLog(@"bd:%@:%@", bundle, [bundle substringFromIndex:6]);
-                    testForIcon([bundle substringFromIndex:6]);
-                }
-                testForIcon(bundle);
-            }
-        }*/
-    }
+    return nil;
+}
+
+static UIImage *SBApplicationIcon$icon(SBApplicationIcon<WinterBoard> *self, SEL sel) {
+    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;
 
     return [self wb_pathForIcon];
 }
 
-NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle) {
+static NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle) {
     if (theme_ != nil) {
         NSString *identifier = [bundle bundleIdentifier];
 
@@ -257,7 +259,7 @@ NSString *$pathForFile$inBundle$(NSString *file, NSBundle *bundle) {
     return nil;
 }
 
-UIImage *UIImage$imageNamed$inBundle$(Class<WinterBoard> self, SEL sel, NSString *name, NSBundle *bundle) {
+static UIImage *UIImage$imageNamed$inBundle$(Class<WinterBoard> self, SEL sel, NSString *name, NSBundle *bundle) {
     if (Debug_)
         NSLog(@"WB:Debug: [UIImage(%@) imageNamed:\"%@\"]", [bundle bundleIdentifier], name);
     if (NSString *path = $pathForFile$inBundle$(name, bundle))
@@ -265,11 +267,11 @@ UIImage *UIImage$imageNamed$inBundle$(Class<WinterBoard> self, SEL sel, NSString
     return [self wb_imageNamed:name inBundle:bundle];
 }
 
-UIImage *UIImage$imageNamed$(Class<WinterBoard> self, SEL sel, NSString *name) {
+static UIImage *UIImage$imageNamed$(Class<WinterBoard> self, SEL sel, NSString *name) {
     return UIImage$imageNamed$inBundle$(self, sel, name, [NSBundle mainBundle]);
 }
 
-NSString *NSBundle$pathForResource$ofType$(NSBundle<WinterBoard> *self, SEL sel, NSString *resource, NSString *type) {
+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_)
         NSLog(@"WB:Debug: [NSBundle(%@) pathForResource:\"%@\"]", [self bundleIdentifier], file);
@@ -278,25 +280,6 @@ NSString *NSBundle$pathForResource$ofType$(NSBundle<WinterBoard> *self, SEL sel,
     return [self wb_pathForResource:resource ofType:type];
 }
 
-void $setBackgroundColor$(id<WinterBoard> self, SEL sel, UIColor *color) {
-    if (Wallpaper_ != nil)
-        return [self wb_setBackgroundColor:[UIColor clearColor]];
-    return [self wb_setBackgroundColor:color];
-}
-
-/*id SBStatusBarContentsView$initWithFrame$(SBStatusBarContentsView<WinterBoard> *self, SEL sel, CGRect frame) {
-    self = [self wb_initWithFrame:frame];
-    if (self == nil)
-        return nil;
-
-    NSString *path = [NSString stringWithFormat:@"%@/StatusBar.png", theme_];
-    if ([Manager_ fileExistsAtPath:path])
-        [self addSubview:[[[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:path]] autorelease]];
-    //[self setBackgroundColor:[UIColor clearColor]];
-
-    return self;
-}*/
-
 bool UINavigationBar$setBarStyle$_(SBAppWindow<WinterBoard> *self) {
     if (Info_ != nil) {
         NSNumber *number = [Info_ objectForKey:@"NavigationBarStyle"];
@@ -341,26 +324,42 @@ id UINavigationBar$initWithFrame$(SBAppWindow<WinterBoard> *self, SEL sel, CGRec
     return self;
 }*/
 
-void UINavigationBar$setBarStyle$(SBAppWindow<WinterBoard> *self, SEL sel, int style) {
+static void UINavigationBar$setBarStyle$(SBAppWindow<WinterBoard> *self, SEL sel, int style) {
     if (UINavigationBar$setBarStyle$_(self))
         return;
     return [self wb_setBarStyle:style];
 }
 
-void $didMoveToSuperview(SBButtonBar<WinterBoard> *self, SEL sel) {
+static void $didMoveToSuperview(SBButtonBar<WinterBoard> *self, SEL sel) {
     [[self superview] setBackgroundColor:[UIColor clearColor]];
     [self wb_didMoveToSuperview];
 }
 
-id SBContentLayer$initWithSize$(SBContentLayer<WinterBoard> *self, SEL sel, CGSize size) {
+static NSString *$getTheme$(NSString *file) {
+    NSString *path([NSString stringWithFormat:@"%@/%@", theme_, file]);
+    return [Manager_ fileExistsAtPath:path] ? path : nil;
+}
+
+static id SBContentLayer$initWithSize$(SBContentLayer<WinterBoard> *self, SEL sel, CGSize size) {
     self = [self wb_initWithSize:size];
     if (self == nil)
         return nil;
 
-    if (Wallpaper_ != nil) {
-        if (UIImage *image = [[UIImage alloc] initWithContentsOfFile:Wallpaper_])
+    if (NSString *path = $getTheme$(@"Wallpaper.png"))
+        if (UIImage *image = [[[UIImage alloc] initWithContentsOfFile:path] autorelease])
             [self addSubview:[[[UIImageView alloc] initWithImage:image] autorelease]];
-        [self setBackgroundColor:[UIColor redColor]];
+    if (NSString *path = $getTheme$(@"Wallpaper.html")) {
+        CGRect bounds = [self bounds];
+
+        UIWebDocumentView *view([[[UIWebDocumentView alloc] initWithFrame:bounds] autorelease]);
+        [view setAutoresizes:YES];
+
+        [view loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
+
+        [[view webView] setDrawsBackground:NO];
+        [view setBackgroundColor:[UIColor clearColor]];
+
+        [self addSubview:view];
     }
 
     return self;
@@ -384,8 +383,8 @@ id SBContentLayer$initWithSize$(SBContentLayer<WinterBoard> *self, SEL sel, CGSi
             NSLog(@"WB:Error: [%s forwardInvocation:(%s)]", class_getName([self class]), sel_getName(sel)); \
     }
 
-unsigned *ContextCount_;
-void ***ContextStack_;
+static unsigned *ContextCount_;
+static void ***ContextStack_;
 
 extern "C" CGColorRef CGGStateGetSystemColor(void *);
 extern "C" CGColorRef CGGStateGetFillColor(void *);
@@ -498,7 +497,7 @@ WBDelegate(string_)
 
 @end
 
-void SBStatusBarTimeView$drawRect$(SBStatusBarTimeView<WinterBoard> *self, SEL sel, CGRect rect) {
+static void SBStatusBarTimeView$drawRect$(SBStatusBarTimeView<WinterBoard> *self, SEL sel, CGRect rect) {
     id time;
     object_getInstanceVariable(self, "_time", (void **) &time);
     if (time != nil && [time class] != [WBTime class])
@@ -506,7 +505,7 @@ void SBStatusBarTimeView$drawRect$(SBStatusBarTimeView<WinterBoard> *self, SEL s
     return [self wb_drawRect:rect];
 }
 
-void SBIconLabel$setInDock$(SBIconLabel<WinterBoard> *self, SEL sel, BOOL docked) {
+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"])
@@ -516,7 +515,7 @@ void SBIconLabel$setInDock$(SBIconLabel<WinterBoard> *self, SEL sel, BOOL docked
     return [self wb_setInDock:docked];
 }
 
-id SBIconLabel$initWithSize$label$(SBIconLabel<WinterBoard> *self, SEL sel, CGSize size, NSString *label) {
+static id SBIconLabel$initWithSize$label$(SBIconLabel<WinterBoard> *self, SEL sel, CGSize size, NSString *label) {
     // XXX: technically I'm misusing self here
     return [self wb_initWithSize:size label:[[[WBIconLabel alloc] initWithString:label] autorelease]];
     //return [self wb_initWithSize:size label:label];
@@ -525,6 +524,8 @@ id SBIconLabel$initWithSize$label$(SBIconLabel<WinterBoard> *self, SEL sel, CGSi
 extern "C" void FindMappedImages(void);
 extern "C" NSData *UIImagePNGRepresentation(UIImage *);
 
+static void (*__UISharedImageInitialize)(bool);
+
 extern "C" void WBInitialize() {
     NSLog(@"WB:Notice: Installing WinterBoard...");
 
@@ -532,13 +533,16 @@ extern "C" void WBInitialize() {
 
     struct nlist nl[5];
     memset(nl, 0, sizeof(nl));
+
     nl[0].n_un.n_name = (char *) "___mappedImages";
     nl[1].n_un.n_name = (char *) "__UISharedImageInitialize";
     nl[2].n_un.n_name = (char *) "___currentContextCount";
     nl[3].n_un.n_name = (char *) "___currentContextStack";
+
     nlist("/System/Library/Frameworks/UIKit.framework/UIKit", nl);
+
     ImageMap_ = (id *) nl[0].n_value;
-    void (*__UISharedImageInitialize)(bool) = (void (*)(bool)) nl[1].n_value;
+    __UISharedImageInitialize = (void (*)(bool)) nl[1].n_value;
     ContextCount_ = (unsigned *) nl[2].n_value;
     ContextStack_ = (void ***) nl[3].n_value;
 
@@ -550,15 +554,13 @@ extern "C" void WBInitialize() {
 
     Manager_ = [[NSFileManager defaultManager] retain];
 
-    //WBRename("SBStatusBarContentsView", "setBackgroundColor:", (IMP) &$setBackgroundColor$);
-    //WBRename("UINavigationBar", "initWithFrame:", (IMP) &UINavigationBar$initWithFrame$);
     //WBRename("UINavigationBar", "initWithCoder:", (IMP) &UINavigationBar$initWithCoder$);
     WBRename(true, "UINavigationBar", "setBarStyle:", (IMP) &UINavigationBar$setBarStyle$);
     //WBRename("UINavigationBarBackground", "initWithFrame:withBarStyle:withTintColor:", (IMP) &UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$);
-    //WBRename("SBStatusBarContentsView", "initWithFrame:", (IMP) &SBStatusBarContentsView$initWithFrame$);
 
     WBRename(false, "UIImage", "imageNamed:inBundle:", (IMP) &UIImage$imageNamed$inBundle$);
     WBRename(false, "UIImage", "imageNamed:", (IMP) &UIImage$imageNamed$);
+    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$);
@@ -587,10 +589,6 @@ extern "C" void WBInitialize() {
     }
 
     if (theme_ != nil) {
-        NSString *path = [NSString stringWithFormat:@"%@/Wallpaper.png", theme_];
-        if ([Manager_ fileExistsAtPath:path])
-            Wallpaper_ = [path retain];
-
         NSString *folder = [NSString stringWithFormat:@"%@/UIImages", theme_];
         if (NSArray *images = [Manager_ contentsOfDirectoryAtPath:folder error:NULL])
             for (int i(0), e = [images count]; i != e; ++i) {
@@ -603,11 +601,6 @@ extern "C" void WBInitialize() {
             }
 
         Info_ = [[NSDictionary alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/Info.plist", theme_]];
-        if (Info_ == nil) {
-            //LabelColor_ = [UIColor whiteColor];
-        } else {
-            //LabelColor_ = [Info_ colorForKey:@"LabelColor"];
-        }
     }
 
     [pool release];
diff --git a/Nature/Bundles/com.apple.springboard/SBDockBG.png b/Nature/Bundles/com.apple.springboard/SBDockBG.png
deleted file mode 100644 (file)
index a8c73e6..0000000
Binary files a/Nature/Bundles/com.apple.springboard/SBDockBG.png and /dev/null differ
diff --git a/Nature/Info.plist b/Nature/Info.plist
deleted file mode 100644 (file)
index 645d6b0..0000000
+++ /dev/null
@@ -1,17 +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>
-
-</dict></plist>
diff --git a/Nature/Wallpaper.png b/Nature/Wallpaper.png
deleted file mode 100644 (file)
index 685b952..0000000
Binary files a/Nature/Wallpaper.png and /dev/null differ
diff --git a/Saurik/Bundles/com.apple.springboard/SBDockBG.png b/Saurik/Bundles/com.apple.springboard/SBDockBG.png
new file mode 100644 (file)
index 0000000..a8c73e6
Binary files /dev/null and b/Saurik/Bundles/com.apple.springboard/SBDockBG.png differ
diff --git a/Saurik/Info.plist b/Saurik/Info.plist
new file mode 100644 (file)
index 0000000..645d6b0
--- /dev/null
@@ -0,0 +1,17 @@
+<?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>
+
+</dict></plist>
diff --git a/Saurik/Private/Plant.png b/Saurik/Private/Plant.png
new file mode 100644 (file)
index 0000000..cdf4a24
Binary files /dev/null and b/Saurik/Private/Plant.png differ
diff --git a/Saurik/Private/Rock.png b/Saurik/Private/Rock.png
new file mode 100644 (file)
index 0000000..005aa07
Binary files /dev/null and b/Saurik/Private/Rock.png differ
diff --git a/Saurik/Wallpaper.html b/Saurik/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/control b/control
index 524cf0d10221627e744c5a2e8450fc4708267022..a8abbaa7440aaf862810980660e3dccf0caa947e 100644 (file)
--- a/control
+++ b/control
@@ -3,7 +3,7 @@ Priority: optional
 Section: Themes
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 0.9.2505-1
+Version: 0.9.2506-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.
  
index 25a3974f51d2265a4809f15d37b0e8aee721a345..c90666e7d072298d07274f781ae5393f893a1e73 100644 (file)
--- a/makefile
+++ b/makefile
@@ -23,9 +23,10 @@ package:
        mkdir -p winterboard/DEBIAN
        mkdir -p winterboard/Applications/WinterBoard.app
        mkdir -p winterboard/Library/Themes
-       cp -a Nature winterboard/Library/Themes/com.saurik.WinterBoard.Nature
+       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.2505-1_iphoneos-arm.deb
+       dpkg-deb -b winterboard winterboard_0.9.2506-1_iphoneos-arm.deb
 
 .PHONY: all clean package