+
+ NSMutableArray *themes = [NSMutableArray arrayWithCapacity:32];
+ [themes addObjectsFromArray:[manager contentsOfDirectoryAtPath:@"/Library/Themes" error:NULL]];
+ [themes addObjectsFromArray:[manager contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()] error:NULL]];
+
+ for (NSUInteger i(0), e([themes count]); i != e; ++i) {
+ NSString *theme = [themes objectAtIndex:i];
+ if ([theme hasSuffix:@".theme"])
+ [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];
+ [themesArray_ insertObject:[[NSDictionary dictionaryWithObjectsAndKeys:
+ theme, @"Name",
+ [NSNumber numberWithBool:NO], @"Active",
+ nil] mutableCopy] atIndex:0];
+ }