]> git.saurik.com Git - winterboard.git/blobdiff - Settings.mm
Support CPBitmapCreateImagesFromPath() name array.
[winterboard.git] / Settings.mm
index 619df9bae7cb45a9ef17842c8534f185d9415b22..7d15baabc56a9325dcc7ca2dfa96f41ffa035700 100644 (file)
 #include <dlfcn.h>
 #include <objc/runtime.h>
 
-static void *libhide;
-static BOOL (*IsIconHiddenDisplayId)(NSString *);
-static BOOL (*HideIconViaDisplayId)(NSString *);
-static BOOL (*UnHideIconViaDisplayId)(NSString *);
-
-static NSString *WinterBoardDisplayID = @"com.saurik.WinterBoard";
-
 extern NSString *PSTableCellKey;
 extern "C" UIImage *_UIImageWithName(NSString *);
 
@@ -145,6 +138,28 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) {
 /* }}} */
 
 /* Theme Settings Controller {{{ */
+@interface WBSThemesTableViewCell : UITableViewCell {
+}
+
+@end
+
+@implementation WBSThemesTableViewCell
+
+- (id) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuse {
+    if ((self = [super initWithFrame:frame reuseIdentifier:reuse]) != nil) {
+    } return self;
+}
+
+- (void) setTheme:(NSDictionary *)theme {
+    self.text = [theme objectForKey:@"Name"];
+    self.hidesAccessoryWhenEditing = NO;
+    NSNumber *active([theme objectForKey:@"Active"]);
+    BOOL inactive(active == nil || ![active boolValue]);
+    [self setImage:(inactive ? uncheckedImage : checkImage)];
+}
+
+@end
+
 @interface WBSThemesController: PSViewController <UITableViewDelegate, UITableViewDataSource> {
     UITableView *_tableView;
     NSMutableArray *_themes;
@@ -275,18 +290,14 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) {
 }
 
 - (id) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
-    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThemeCell"];
+    WBSThemesTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ThemeCell"];
     if (!cell) {
-        cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100) reuseIdentifier:@"ThemeCell"] autorelease];
+        cell = [[[WBSThemesTableViewCell alloc] initWithFrame:CGRectMake(0, 0, 100, 100) reuseIdentifier:@"ThemeCell"] autorelease];
         //[cell setTableViewStyle:UITableViewCellStyleDefault];
     }
 
     NSDictionary *theme([_themes objectAtIndex:indexPath.row]);
-    cell.text = [theme objectForKey:@"Name"];
-    cell.hidesAccessoryWhenEditing = NO;
-    NSNumber *active([theme objectForKey:@"Active"]);
-    BOOL inactive(active == nil || ![active boolValue]);
-    [cell setImage:(inactive ? uncheckedImage : checkImage)];
+    [cell setTheme:theme];
     return cell;
 }
 
@@ -438,13 +449,6 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) {
 
 @implementation WBSettingsController
 
-+ (void) load {
-    libhide = dlopen("/usr/lib/hide.dylib", RTLD_LAZY);
-    IsIconHiddenDisplayId = reinterpret_cast<BOOL (*)(NSString *)>(dlsym(libhide, "IsIconHiddenDisplayId"));
-    HideIconViaDisplayId = reinterpret_cast<BOOL (*)(NSString *)>(dlsym(libhide, "HideIconViaDisplayId"));
-    UnHideIconViaDisplayId = reinterpret_cast<BOOL (*)(NSString *)>(dlsym(libhide, "UnHideIconViaDisplayId"));
-}
-
 - (void) _wb$loadSettings {
     _plist = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()] retain];
     _settings = [NSMutableDictionary dictionaryWithContentsOfFile:_plist];
@@ -461,9 +465,6 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) {
 
     if ([_settings objectForKey:@"SummerBoard"] == nil)
         [_settings setObject:[NSNumber numberWithBool:set] forKey:@"SummerBoard"];
-
-    if (libhide != NULL)
-        [_settings setObject:[NSNumber numberWithBool:IsIconHiddenDisplayId(WinterBoardDisplayID)] forKey:@"IconHidden"];
 }
 
 - (id) initForContentSize:(CGSize)size {
@@ -488,9 +489,6 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) {
     if (![data writeToFile:_plist options:NSAtomicWrite error:NULL])
         return;
 
-    if (libhide != NULL)
-        ([[_settings objectForKey:@"IconHidden"] boolValue] ? HideIconViaDisplayId : UnHideIconViaDisplayId)(WinterBoardDisplayID);
-
     unlink("/User/Library/Caches/com.apple.springboard-imagecache-icons");
     unlink("/User/Library/Caches/com.apple.springboard-imagecache-icons.plist");
     unlink("/User/Library/Caches/com.apple.springboard-imagecache-smallicons");
@@ -509,6 +507,14 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) {
     system("rm -rf /User/Library/Caches/com.apple.IconsCache");
     system("rm -rf /User/Library/Caches/com.apple.newsstand");
     system("rm -rf /User/Library/Caches/com.apple.springboard.sharedimagecache");
+    system("rm -rf /User/Library/Caches/com.apple.UIStatusBar");
+
+    system("rm -rf /User/Library/Caches/BarDialer");
+    system("rm -rf /User/Library/Caches/BarDialer_selected");
+    system("rm -rf /User/Library/Caches/BarRecents");
+    system("rm -rf /User/Library/Caches/BarRecents_selected");
+    system("rm -rf /User/Library/Caches/BarVM");
+    system("rm -rf /User/Library/Caches/BarVM_selected");
 
     system("killall -9 lsd");