X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/f4b021a2d1df286aa07e1ab1ec147f1dabbeaaf7..59d5ae48171dea0f94985deab5fa29cc9e18fefe:/Settings.mm diff --git a/Settings.mm b/Settings.mm index c2599a0..7beb1f3 100644 --- a/Settings.mm +++ b/Settings.mm @@ -28,16 +28,10 @@ #import #import +#include #include #include -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 *); @@ -146,23 +140,55 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) { /* Theme Settings Controller {{{ */ @interface WBSThemesTableViewCell : UITableViewCell { + UIImageView *checkmark_; + UIImageView *icon_; + UILabel *name_; } @end @implementation WBSThemesTableViewCell +- (void) dealloc { + [super dealloc]; + [checkmark_ release]; + [icon_ release]; + [name_ release]; +} + - (id) initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuse { if ((self = [super initWithFrame:frame reuseIdentifier:reuse]) != nil) { + CGFloat border(48), check(40), icon(64); + UIView *content([self contentView]); + CGSize size([content frame].size); + + checkmark_ = [[UIImageView alloc] initWithFrame:CGRectMake(std::floor((border - check) / 2), 0, check, size.height)]; + [checkmark_ setAutoresizingMask:UIViewAutoresizingFlexibleHeight]; + [content addSubview:checkmark_]; + + name_ = [[UILabel alloc] initWithFrame:CGRectMake(border, 0, 0, size.height)]; + [name_ setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight)]; + [content addSubview:name_]; + + icon_ = [[UIImageView alloc] initWithFrame:CGRectMake(size.width - icon - 48, 0, icon, icon)]; + [content addSubview:icon_]; } return self; } +- (void) setCheck:(bool)inactive { + [self setImage:(inactive ? uncheckedImage : checkImage)]; +} + - (void) setTheme:(NSDictionary *)theme { - self.text = [theme objectForKey:@"Name"]; - self.hidesAccessoryWhenEditing = NO; + [name_ setText:[theme objectForKey:@"Name"]]; + NSNumber *active([theme objectForKey:@"Active"]); BOOL inactive(active == nil || ![active boolValue]); - [self setImage:(inactive ? uncheckedImage : checkImage)]; + [self setCheck:inactive]; + + CGRect area([name_ frame]); + area.size.width = ([icon_ image] == nil ? self.contentView.frame.size.width : icon_.frame.origin.x) - area.origin.x - 9; + [name_ setFrame:area]; } @end @@ -254,7 +280,8 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) { nil] atIndex:0]; } - _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-64) style:UITableViewStyleGrouped]; + _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 480-64) style:UITableViewStylePlain]; + [_tableView setRowHeight:48]; [_tableView setDataSource:self]; [_tableView setDelegate:self]; [_tableView setEditing:YES]; @@ -456,13 +483,6 @@ void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) { @implementation WBSettingsController -+ (void) load { - libhide = dlopen("/usr/lib/hide.dylib", RTLD_LAZY); - IsIconHiddenDisplayId = reinterpret_cast(dlsym(libhide, "IsIconHiddenDisplayId")); - HideIconViaDisplayId = reinterpret_cast(dlsym(libhide, "HideIconViaDisplayId")); - UnHideIconViaDisplayId = reinterpret_cast(dlsym(libhide, "UnHideIconViaDisplayId")); -} - - (void) _wb$loadSettings { _plist = [[NSString stringWithFormat:@"%@/Library/Preferences/com.saurik.WinterBoard.plist", NSHomeDirectory()] retain]; _settings = [NSMutableDictionary dictionaryWithContentsOfFile:_plist]; @@ -479,9 +499,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 { @@ -506,9 +523,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");