X-Git-Url: https://git.saurik.com/winterboard.git/blobdiff_plain/9741cf15b650fefc2c436dd903f820a99d335d9a..8e4d2f42c06dc61bad263c6c01a26c6debdcce17:/Library.mm diff --git a/Library.mm b/Library.mm index 65a7994..b36ec0f 100644 --- a/Library.mm +++ b/Library.mm @@ -101,6 +101,8 @@ bool _itv; #import +#include + extern "C" void __clear_cache (char *beg, char *end); @protocol WinterBoard @@ -135,6 +137,7 @@ Class $SBIconController; Class $SBIconLabel; Class $SBIconList; Class $SBIconModel; +Class $SBIconView; //Class $SBImageCache; Class $SBSearchView; Class $SBSearchTableViewCell; @@ -145,6 +148,8 @@ Class $SBStatusBarTimeView; Class $SBUIController; Class $SBWidgetApplicationIcon; +#define SBIconView SBIcon + static bool IsWild_; static bool Four_; @@ -773,8 +778,19 @@ MSHook(id, SBUIController$init, SBUIController *self, SEL sel) { if (self == nil) return nil; - UIDevice *device([UIDevice currentDevice]); - IsWild_ = [device respondsToSelector:@selector(isWildcat)] && [device isWildcat]; + { + size_t size; + sysctlbyname("hw.machine", NULL, &size, NULL, 0); + char *machine = new char[size]; + + if (sysctlbyname("hw.machine", machine, &size, NULL, 0) == -1) { + perror("sysctlbyname(\"hw.machine\", ?)"); + delete [] machine; + machine = NULL; + } + + IsWild_ = machine != NULL && strncmp(machine, "iPad", 4) == 0; + } BOOL (*GSSystemHasCapability)(CFStringRef) = reinterpret_cast(dlsym(RTLD_DEFAULT, "GSSystemHasCapability")); @@ -1080,6 +1096,29 @@ WBDelegate(badge_) @end /* }}} */ +MSHook(void, SBIconView$setIconImageAlpha$, SBIconView *self, SEL sel, float alpha) { + if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"]) + alpha = [number floatValue]; + return _SBIconView$setIconImageAlpha$(self, sel, alpha); +} + +MSHook(void, SBIconView$setIconLabelAlpha$, SBIconView *self, SEL sel, float alpha) { + if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"]) + alpha = [number floatValue]; + return _SBIconView$setIconLabelAlpha$(self, sel, alpha); +} + +MSHook(id, SBIconView$initWithDefaultSize, SBIconView *self, SEL sel) { + if ((self = _SBIconView$initWithDefaultSize(self, sel)) != nil) { + if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"]) { + // XXX: note: this is overridden above, which is silly + float alpha([number floatValue]); + [self setIconImageAlpha:alpha]; + [self setIconLabelAlpha:alpha]; + } + } return self; +} + MSHook(void, SBIcon$setAlpha$, SBIcon *self, SEL sel, float alpha) { if (NSNumber *number = [Info_ objectForKey:@"IconAlpha"]) alpha = [number floatValue]; @@ -1748,6 +1787,7 @@ extern "C" void WBInitialize() { $SBIconLabel = objc_getClass("SBIconLabel"); $SBIconList = objc_getClass("SBIconList"); $SBIconModel = objc_getClass("SBIconModel"); + $SBIconView = objc_getClass("SBIconView"); //$SBImageCache = objc_getClass("SBImageCache"); $SBSearchView = objc_getClass("SBSearchView"); $SBSearchTableViewCell = objc_getClass("SBSearchTableViewCell"); @@ -1758,6 +1798,9 @@ extern "C" void WBInitialize() { $SBUIController = objc_getClass("SBUIController"); $SBWidgetApplicationIcon = objc_getClass("SBWidgetApplicationIcon"); + if ($SBIconView == nil) + $SBIconView = $SBIcon; + Four_ = $SBDockIconListView != nil; WBRename(WebCoreFrameBridge, renderedSizeOfNode:constrainedToWidth:, renderedSizeOfNode$constrainedToWidth$); @@ -1774,6 +1817,9 @@ extern "C" void WBInitialize() { WBRename(SBIcon, setAlpha:, setAlpha$); WBRename(SBIconBadge, initWithBadge:, initWithBadge$); WBRename(SBIconController, noteNumberOfIconListsChanged, noteNumberOfIconListsChanged); + WBRename(SBIconView, initWithDefaultSize, initWithDefaultSize); + WBRename(SBIconView, setIconImageAlpha:, setIconImageAlpha$); + WBRename(SBIconView, setIconLabelAlpha:, setIconLabelAlpha$); WBRename(SBUIController, init, init); WBRename(SBWidgetApplicationIcon, icon, icon);