+@interface WBAdvancedController: PSListController {
+}
+
+- (id) specifiers;
+- (void) settingsChanged;
+
+@end
+
+@implementation WBAdvancedController
+
+- (id) specifiers {
+ if (!_specifiers)
+ _specifiers = [[self loadSpecifiersFromPlistName:@"Advanced" target:self] retain];
+ return _specifiers;
+}
+
+- (void) settingsChanged {
+ settingsChanged = YES;
+}
+
+- (void) setPreferenceValue:(id)value specifier:(PSSpecifier *)spec {
+ NSString *key([spec propertyForKey:@"key"]);
+ if ([[spec propertyForKey:@"negate"] boolValue])
+ value = [NSNumber numberWithBool:(![value boolValue])];
+ [_settings setValue:value forKey:key];
+ [self settingsChanged];
+}
+
+- (id) readPreferenceValue:(PSSpecifier *)spec {
+ NSString *key([spec propertyForKey:@"key"]);
+ id defaultValue([spec propertyForKey:@"default"]);
+ id plistValue([_settings objectForKey:key]);
+ if (!plistValue)
+ return defaultValue;
+ if ([[spec propertyForKey:@"negate"] boolValue])
+ plistValue = [NSNumber numberWithBool:(![plistValue boolValue])];
+ return plistValue;
+}
+
+- (void) __optimizeThemes {
+ system("/usr/libexec/winterboard/Optimize");
+}
+
+- (void) optimizeThemes {
+ UIAlertView *alert([[[UIAlertView alloc]
+ initWithTitle:@"Optimize Themes"
+ message:@"Please note that this setting /replaces/ the PNG files that came with the theme. PNG files that have been iPhone-optimized cannot be viewed on a normal computer unless they are first deoptimized. You can use Cydia to reinstall themes that have been optimized in order to revert to the original PNG files."
+ delegate:self
+ cancelButtonTitle:@"Cancel"
+ otherButtonTitles:@"Optimize", nil
+ ] autorelease]);
+
+ [alert setContext:@"optimize"];
+ [alert setNumberOfRows:1];
+ [alert show];
+}
+
+- (void) _optimizeThemes {
+ UIView *view([self view]);
+ UIWindow *window([view window]);
+
+ UIProgressHUD *hud([[[UIProgressHUD alloc] initWithWindow:window] autorelease]);
+ [hud setText:@"Reticulating Splines\nPlease Wait (Minutes)"];
+
+ [window setUserInteractionEnabled:NO];
+
+ [window addSubview:hud];
+ [hud show:YES];
+ [self wb$yieldToSelector:@selector(__optimizeThemes)];
+ [hud removeFromSuperview];
+
+ [window setUserInteractionEnabled:YES];
+
+ [self settingsChanged];
+}
+
+- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button {
+ NSString *context([alert context]);
+
+ if ([context isEqualToString:@"optimize"]) {
+ if (button == [alert firstOtherButtonIndex]) {
+ [self performSelector:@selector(_optimizeThemes) withObject:nil afterDelay:0];
+ }
+
+ [alert dismissWithClickedButtonIndex:-1 animated:YES];
+ }
+ /*else if ([super respondsToSelector:@selector(alertView:clickedButtonAtIndex:)])
+ [super alertView:alert clickedButtonAtIndex:button];*/
+}
+
+@end
+