static NSString *plist_;
static NSMutableDictionary *settings_;
+static BOOL changed_;
@interface WBThemeTableViewCell : UITableViewCell {
UILabel *label;
}
- (void) applicationWillTerminate:(UIApplication *)application {
- [settings_ writeToFile:plist_ atomically:YES];
- system("killall SpringBoard");
+ if (changed_) {
+ if (![settings_ writeToFile:plist_ atomically:YES])
+ NSLog(@"WB:Error:writeToFile");
+ system("killall SpringBoard");
+ }
}
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
[theme setObject:[NSNumber numberWithBool:inactive] forKey:@"Active"];
cell.accessoryType = inactive ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
[themesTable_ deselectRowAtIndexPath:(NSIndexPath *)indexPath animated:YES];
+ changed_ = YES;
}
- (NSInteger) tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section {
NSMutableDictionary *theme = [[[themesArray_ objectAtIndex:fromIndex] retain] autorelease];
[themesArray_ removeObjectAtIndex:fromIndex];
[themesArray_ insertObject:theme atIndex:toIndex];
+ changed_ = YES;
}
- (BOOL) tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
] retain];
settings_ = [[NSMutableDictionary alloc] initWithContentsOfFile:plist_];
+ if (settings_ == nil)
+ settings_ = [[NSMutableDictionary alloc] initWithCapacity:16];
themesArray_ = [settings_ objectForKey:@"Themes"];
if (themesArray_ == nil) {
[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) {
+ for (NSUInteger i(0), e([themes count]); i != e; ++i) {
+ NSString *theme = [themes objectAtIndex:i];
if ([theme hasSuffix:@".theme"])
- theme = [theme substringWithRange:NSMakeRange(0, [theme length] - 6)];
+ [themes replaceObjectAtIndex:i withObject:[theme substringWithRange:NSMakeRange(0, [theme length] - 6)]];
+ }
+
+ for (NSUInteger i(0), e([themesArray_ count]); i != e; ++i) {
+ NSMutableDictionary *theme = [themesArray_ objectAtIndex:i];
+ NSString *name = [theme objectForKey:@"Name"];
+ if (name == nil || ![themes containsObject:name]) {
+ [themesArray_ removeObjectAtIndex:i];
+ --i; --e;
+ }
+ }
+
+ for (NSString *theme in themes) {
if ([themesSet containsObject:theme])
continue;
[themesSet addObject:theme];
@end
-bool Debug_ = true;
+bool Debug_ = false;
bool Engineer_ = false;
/* WinterBoard Backend {{{ */
- (NSString *) _iconLabelStyle {
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]) {
NSString *style = [NSString stringWithFormat:@""
"font-family: Helvetica; "
}
- (void) drawInRect:(CGRect)rect withStyle:(NSString *)style {
- _trace();
if (NSString *custom = [self _iconLabelStyle]) {
NSString *combined = [NSString stringWithFormat:@"%@; %@", style, custom];
if (Debug_)
[Info_ setObject:[info objectForKey:key] forKey:key];
}
+ if ([Info_ objectForKey:@"UndockedIconLabels"] == nil)
+ [Info_ setObject:[NSNumber numberWithBool:(
+ [Info_ objectForKey:@"DockedIconLabelStyle"] != nil ||
+ [Info_ objectForKey:@"UndockedIconLabelStyle"] != nil
+ )] forKey:@"UndockedIconLabels"];
+
+ if (![Info_ boolForKey:@"UndockedIconLabels"])
if (Debug_)
NSLog(@"WB:Debug:Info = %@", [Info_ description]);