From deed001785c78316b8aa2afeb054bdf007f871ea Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Fri, 10 Jan 2014 04:29:55 -0800 Subject: [PATCH] Filter themes with kCFCoreFounderionVersionNumber. --- Black Navigation Bars.theme/Info.plist | 6 +++++ Dim Wallpaper.theme/Info.plist | 11 ++++++++ Settings.mm | 37 +++++++++++++++++++------- Solid Status Bar.theme/Info.plist | 6 +++++ White Icon Labels.theme/Info.plist | 6 +++++ 5 files changed, 56 insertions(+), 10 deletions(-) create mode 100644 Dim Wallpaper.theme/Info.plist diff --git a/Black Navigation Bars.theme/Info.plist b/Black Navigation Bars.theme/Info.plist index ab601e0..c68fa66 100644 --- a/Black Navigation Bars.theme/Info.plist +++ b/Black Navigation Bars.theme/Info.plist @@ -2,6 +2,12 @@ +CoreFoundationVersion + + 0 + 600 + + NavigationBarStyle-0 1 diff --git a/Dim Wallpaper.theme/Info.plist b/Dim Wallpaper.theme/Info.plist new file mode 100644 index 0000000..63e7935 --- /dev/null +++ b/Dim Wallpaper.theme/Info.plist @@ -0,0 +1,11 @@ + + + + +CoreFoundationVersion + + 0 + 600 + + + diff --git a/Settings.mm b/Settings.mm index cba01a4..160073d 100644 --- a/Settings.mm +++ b/Settings.mm @@ -48,6 +48,31 @@ static BOOL settingsChanged; static NSMutableDictionary *_settings; static NSString *_plist; +void AddThemes(NSMutableArray *themesOnDisk, NSString *folder) { + NSArray *themes([[NSFileManager defaultManager] contentsOfDirectoryAtPath:folder error:NULL]); + for (NSString *theme in themes) { + if (NSDictionary *info = [NSDictionary dictionaryWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/Info.plist", folder, theme]]) { + if (NSArray *version = [info objectForKey:@"CoreFoundationVersion"]) { + size_t count([version count]); + if (count == 0 || count > 2) + continue; + + double lower([[version objectAtIndex:0] doubleValue]); + if (kCFCoreFoundationVersionNumber < lower) + continue; + + if (count != 1) { + double upper([[version objectAtIndex:1] doubleValue]); + if (upper <= kCFCoreFoundationVersionNumber) + continue; + } + } + } + + [themesOnDisk addObject:theme]; + } +} + /* [NSObject yieldToSelector:(withObject:)] {{{*/ @interface NSObject (wb$yieldToSelector) - (id) wb$yieldToSelector:(SEL)selector withObject:(id)object; @@ -172,16 +197,8 @@ static NSString *_plist; } NSMutableArray *themesOnDisk([NSMutableArray array]); - - [themesOnDisk - addObjectsFromArray:[[NSFileManager defaultManager] - contentsOfDirectoryAtPath:@"/Library/Themes" error:NULL] - ]; - - [themesOnDisk addObjectsFromArray:[[NSFileManager defaultManager] - contentsOfDirectoryAtPath:[NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()] - error:NULL - ]]; + AddThemes(themesOnDisk, @"/Library/Themes"); + AddThemes(themesOnDisk, [NSString stringWithFormat:@"%@/Library/SummerBoard/Themes", NSHomeDirectory()]); for (int i = 0, count = [themesOnDisk count]; i < count; i++) { NSString *theme = [themesOnDisk objectAtIndex:i]; diff --git a/Solid Status Bar.theme/Info.plist b/Solid Status Bar.theme/Info.plist index b3c7578..7cfb188 100644 --- a/Solid Status Bar.theme/Info.plist +++ b/Solid Status Bar.theme/Info.plist @@ -2,6 +2,12 @@ +CoreFoundationVersion + + 0 + 600 + + StatusBarMode 0 diff --git a/White Icon Labels.theme/Info.plist b/White Icon Labels.theme/Info.plist index 2fb6904..f58cc73 100644 --- a/White Icon Labels.theme/Info.plist +++ b/White Icon Labels.theme/Info.plist @@ -2,6 +2,12 @@ +CoreFoundationVersion + + 0 + 600 + + UndockedIconLabelStyle color: white -- 2.45.2