From d5fb6e012f6166bc6ea83aeb8dc7e84794199b1f Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Mon, 11 Aug 2008 12:08:58 +0000 Subject: [PATCH] Drastic reorganization of WinterBoard. --- Application.mm | 113 ++++++- Black Navigation Bars.theme/Info.plist | 8 + Library.mm | 295 ++++++++++++------ .../com.apple.springboard/SBDockBG.png | Bin {Saurik => Saurik.theme}/Info.plist | 7 +- {Saurik => Saurik.theme}/Private/Plant.png | Bin {Saurik => Saurik.theme}/Private/Rock.png | Bin {Saurik => Saurik.theme}/Wallpaper.html | 0 Test.sh | 2 +- Transparent Icon Labels.theme/Info.plist | 11 + User Wallpaper.theme/Wallpaper.jpg | 1 + control | 15 +- makefile | 14 +- postinst | 6 - preinst | 18 ++ prerm | 8 +- 16 files changed, 369 insertions(+), 129 deletions(-) create mode 100644 Black Navigation Bars.theme/Info.plist rename {Saurik => Saurik.theme}/Bundles/com.apple.springboard/SBDockBG.png (100%) rename {Saurik => Saurik.theme}/Info.plist (84%) rename {Saurik => Saurik.theme}/Private/Plant.png (100%) rename {Saurik => Saurik.theme}/Private/Rock.png (100%) rename {Saurik => Saurik.theme}/Wallpaper.html (100%) create mode 100644 Transparent Icon Labels.theme/Info.plist create mode 120000 User Wallpaper.theme/Wallpaper.jpg delete mode 100755 postinst diff --git a/Application.mm b/Application.mm index a7c72ad..5f16bc4 100644 --- a/Application.mm +++ b/Application.mm @@ -39,7 +39,21 @@ #import #import -#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, @@ -61,40 +75,104 @@ [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_]; @@ -102,6 +180,9 @@ [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 index 0000000..69b69dc --- /dev/null +++ b/Black Navigation Bars.theme/Info.plist @@ -0,0 +1,8 @@ + + + + +NavigationBarStyle +1 + + diff --git a/Library.mm b/Library.mm index 45deecc..6e46c33 100644 --- a/Library.mm +++ b/Library.mm @@ -71,9 +71,13 @@ extern "C" { #import #import #import +#import #import #import +#import +#import + #import @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 *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 *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 *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 self, SEL sel, NSString * return UIImage$imageNamed$inBundle$(self, sel, name, [NSBundle mainBundle]); } +static UIImage *UIImage$applicationImageNamed$(Class 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 *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 *self, S } bool UINavigationBar$setBarStyle$_(SBAppWindow *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 *self) { /*id UINavigationBarBackground$initWithFrame$withBarStyle$withTintColor$(UINavigationBarBackground *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 *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 *self, SEL sel, CGSize size) { @@ -346,10 +382,20 @@ static id SBContentLayer$initWithSize$(SBContentLayer *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 *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 *self, SEL sel, int mode, int orientation) { + return [self wb_initWithMode:mode orientation:orientation]; +}*/ + +static id SBStatusBarContentsView$initWithStatusBar$mode$(SBStatusBarContentsView *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 *self, SEL sel, CGRect rect) { id time; object_getInstanceVariable(self, "_time", (void **) &time); @@ -509,7 +582,7 @@ static void SBStatusBarTimeView$drawRect$(SBStatusBarTimeView *self static void SBIconLabel$setInDock$(SBIconLabel *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/Bundles/com.apple.springboard/SBDockBG.png b/Saurik.theme/Bundles/com.apple.springboard/SBDockBG.png similarity index 100% rename from Saurik/Bundles/com.apple.springboard/SBDockBG.png rename to Saurik.theme/Bundles/com.apple.springboard/SBDockBG.png diff --git a/Saurik/Info.plist b/Saurik.theme/Info.plist similarity index 84% rename from Saurik/Info.plist rename to Saurik.theme/Info.plist index 7b8d2e6..b782b31 100644 --- a/Saurik/Info.plist +++ b/Saurik.theme/Info.plist @@ -2,8 +2,11 @@ -NavigationBarStyle -1 + UndockedIconLabelStyle /*font-family: monospace; font-size: 13px;*/ color: white diff --git a/Saurik/Private/Plant.png b/Saurik.theme/Private/Plant.png similarity index 100% rename from Saurik/Private/Plant.png rename to Saurik.theme/Private/Plant.png diff --git a/Saurik/Private/Rock.png b/Saurik.theme/Private/Rock.png similarity index 100% rename from Saurik/Private/Rock.png rename to Saurik.theme/Private/Rock.png diff --git a/Saurik/Wallpaper.html b/Saurik.theme/Wallpaper.html similarity index 100% rename from Saurik/Wallpaper.html rename to Saurik.theme/Wallpaper.html diff --git a/Test.sh b/Test.sh index 55409f8..c42495e 100755 --- 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 index 0000000..dd87935 --- /dev/null +++ b/Transparent Icon Labels.theme/Info.plist @@ -0,0 +1,11 @@ + + + + +UndockedIconLabelStyle +color: transparent + +DockedIconLabelStyle +color: transparent + + diff --git a/User Wallpaper.theme/Wallpaper.jpg b/User Wallpaper.theme/Wallpaper.jpg new file mode 120000 index 0000000..d0c0b4b --- /dev/null +++ b/User Wallpaper.theme/Wallpaper.jpg @@ -0,0 +1 @@ +/var/mobile/Library/LockBackground.jpg \ No newline at end of file diff --git a/control b/control index a8abbaa..43d6b8e 100644 --- a/control +++ b/control @@ -1,20 +1,17 @@ Package: winterboard Priority: optional -Section: Themes +Section: System Maintainer: Jay Freeman (saurik) 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 SummerBoard themes without modification but is much 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) -Homepage: http://cydia.saurik.com/winterboard.html +Homepage: http://cydia.saurik.com/winterboard/ diff --git a/makefile b/makefile index c90666e..405934c 100644 --- 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 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 357b50c..2cb79e1 100755 --- 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 dbb80b8..a383ff2 100755 --- 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 -- 2.45.2