Skip to content

Commit

Permalink
0.2.236
Browse files Browse the repository at this point in the history
- Use WhiteList by default
- WhiteList contains only Finder and System Preferences atm
- Bug fixes
  • Loading branch information
w0lfschild committed Sep 7, 2017
1 parent 9baa9df commit 3ae2476
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 75 deletions.
21 changes: 21 additions & 0 deletions .gitignore
@@ -0,0 +1,21 @@

## Build generated
build/
DerivedData/

## Various settings
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata/

## Other
*.moved-aside
*.xccheckout
*.xcscmblueprint
*.DS_Store
16 changes: 13 additions & 3 deletions DoctorDark.xcodeproj/project.pbxproj
Expand Up @@ -74,7 +74,6 @@
FB520CE71D24A0F600FE378C /* Info.plist */,
);
name = DoctorDark;
path = zestyWin;
sourceTree = "<group>";
};
FB61D73F1C3CA27D00FA3C4C /* DoctorDark-GUI */ = {
Expand All @@ -88,7 +87,6 @@
FB520CEF1D24A10100FE378C /* Info.plist */,
);
name = "DoctorDark-GUI";
path = "zestyWin-GUI";
sourceTree = "<group>";
};
FBC27FE81E637D4B00F6516D /* ZKSwizzle */ = {
Expand Down Expand Up @@ -145,7 +143,7 @@
FB16B3441BA7D821009F455F /* Project object */ = {
isa = PBXProject;
attributes = {
LastUpgradeCheck = 0820;
LastUpgradeCheck = 0900;
ORGANIZATIONNAME = "Wolfgang Baird";
TargetAttributes = {
FB16B34B1BA7D821009F455F = {
Expand Down Expand Up @@ -265,14 +263,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -310,14 +314,20 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down
Binary file not shown.
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
Expand Down Expand Up @@ -65,6 +66,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0820"
LastUpgradeVersion = "0900"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -26,6 +26,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
Expand All @@ -36,6 +37,7 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
Expand Down
145 changes: 85 additions & 60 deletions DoctorDark/DoctorDark.m
Expand Up @@ -14,20 +14,28 @@
#define APP_BLACKLIST @[@"com.apple.loginwindow", @"com.apple.iTunes", @"com.apple.Terminal",\
@"com.sublimetext.2", @"com.sublimetext.3", @"com.googlecode.iterm2",\
@"com.google.Chrome.canary", @"com.google.Chrome", @"com.jriver.MediaCenter21",\
@"com.teamspeak.TeamSpeak3", @"com.cocoatech.PathFinder", @"com.apple.ActivityMonitor",\
@"com.github.GitHub"]
@"com.teamspeak.TeamSpeak3", @"com.cocoatech.PathFinder", @"com.github.GitHub",\
@"com.apple.ActivityMonitor"]

#define CLS_BLACKLIST @[@"NSStatusBarWindow", @"BookmarkBarFolderWindow", @"TShrinkToFitWindow", @"QLFullscreenWindow", @"QLPreviewPanel"]
#define APP_WHITELIST @[@"com.apple.finder", @"com.apple.systempreferences"]

#define CLS_BLACKLIST @[@"NSStatusBarWindow", @"BookmarkBarFolderWindow", @"TShrinkToFitWindow",\
@"QLFullscreenWindow", @"QLPreviewPanel", @"TDesktopWindow",\
@"TDesktopIcon", @"TDesktopTitleBubbleView", @"TIconSelectionView",\
@"TNewIconView", @"TBasicImageView", @"TDesktopIconSelectionView",\
@"TDesktopIconView"]

@interface drdark : NSObject
@end

drdark *plugin;
BOOL useWhitelist;
NSMutableArray *itemBlacklist;
NSMutableArray *itemWhitelist;
NSDictionary *sharedDict = nil;
static void *dd_isActive = &dd_isActive;
drdark *plugin;
BOOL resizing;
BOOL useWhitelist;
NSMutableArray *itemBlacklist;
NSMutableArray *itemWhitelist;
NSDictionary *sharedDict = nil;
static void *dd_isActive = &dd_isActive;
SEL setTFC;

@implementation drdark

Expand All @@ -42,9 +50,7 @@ + (drdark*) sharedInstance {
- (NSAppearance *)darkAppearance {
static NSAppearance *dark;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
dark = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
});
dispatch_once(&onceToken, ^{ dark = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark]; });
return dark;
}

Expand All @@ -53,10 +59,12 @@ + (void)load {
/* Initialize an instance of our plugin */
plugin = [drdark sharedInstance];
NSInteger osx_ver = [[NSProcessInfo processInfo] operatingSystemVersion].minorVersion;
setTFC = NSSelectorFromString(@"setTitleFontColor:");
if (osx_ver >= 9) {
/* Check if our current bundleIdentifier is blacklisted */
[plugin dd_initializePrefs];
if (![itemBlacklist containsObject:[[NSBundle mainBundle] bundleIdentifier]]) {

if ([plugin shouldApply:@""]) {
/* Loop through all our windows and set their appearance */
for (NSWindow *win in [[NSApplication sharedApplication] windows])
[plugin dd_applyDarkAppearanceToWindow:win];
Expand Down Expand Up @@ -114,12 +122,12 @@ - (void)dd_updateDarkModeStateForTreeStartingAtView:(__kindof NSView *)rootView
[view performSelector:@selector(setBackgroundColor:) withObject:[NSColor colorWithCalibratedWhite:0.1 alpha:1.0]];
}

if ([view isKindOfClass:NSClassFromString(@"TStatusBarStackView")]) {
}
// if ([view isKindOfClass:NSClassFromString(@"TStatusBarStackView")]) {
//
// }

if ([view respondsToSelector:@selector(setTitleFontColor:)]) {
[view performSelector:@selector(setTitleFontColor:) withObject:[NSColor whiteColor]];
if ([view respondsToSelector:setTFC]) {
[view performSelector:setTFC withObject:[NSColor whiteColor]];
}

if ([view respondsToSelector:@selector(setTextColor:)]) {
Expand All @@ -138,33 +146,37 @@ -(void)dd_initializePrefs {
/* Load existing preferences for our bundle */
itemWhitelist = [[NSMutableArray alloc] init];
itemBlacklist = [[NSMutableArray alloc] init];
useWhitelist = false;
useWhitelist = true;

[itemBlacklist addObjectsFromArray:APP_BLACKLIST];

NSMutableDictionary *pluginPrefs = [NSMutableDictionary dictionaryWithContentsOfFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Preferences/org.w0lf.drdark.plist"]];
NSArray *addItems;
addItems = [pluginPrefs objectForKey:@"bundleWhitelist"];
[itemWhitelist addObjectsFromArray:addItems];
[itemWhitelist addObjectsFromArray:APP_WHITELIST];
addItems = [pluginPrefs objectForKey:@"bundleBlacklist"];
[itemBlacklist addObjectsFromArray:addItems];

useWhitelist = [[pluginPrefs objectForKey:@"useWhitelist"] boolValue];
[itemBlacklist addObjectsFromArray:APP_BLACKLIST];
useWhitelist = ![[pluginPrefs objectForKey:@"useBlacklist"] boolValue];

/* Loop through blacklist and add all items to preferences if they don't already exist */
// NSLog(@"wb_ %@", pluginPrefs);
// NSLog(@"wb_ %@", itemWhitelist);
// NSLog(@"wb_ %@", itemBlacklist);
}

-(BOOL)shouldApply:(NSString*) class {
BOOL result = true;
if (useWhitelist)
if (![itemWhitelist containsObject:[[NSBundle mainBundle] bundleIdentifier]])
result = false;
return false;
if ([itemBlacklist containsObject:class])
result = false;
return false;
if ([APP_BLACKLIST containsObject:[[NSBundle mainBundle] bundleIdentifier]])
result = false;
return result;
return false;
if ([CLS_BLACKLIST indexOfObject:class] != NSNotFound)
return false;
return true;
}

@end
Expand All @@ -183,25 +195,27 @@ - (void)drawWithFrame:(struct CGRect)arg1 inView:(id)arg2 {
@implementation wbdd_TView

- (void)setFrameSize:(struct CGSize)arg1 {
// NSLog(@"wbdd - tview - %@", self.className);
ZKOrig(void, arg1);
if ([plugin shouldApply:[self className]]) {
Boolean apply = true;
NSArray *bl = @[@"TDesktopIcon", @"TDesktopTitleBubbleView", @"TIconSelectionView", @"TNewIconView"];
for (NSString *cls in bl) {
if ([self isKindOfClass:NSClassFromString(cls)]) {
apply = false;
break;
if (!resizing) {
if ([plugin shouldApply:[self className]]) {
NSLog(@"wbdd - tview - %@ - %@", self.className, NSStringFromSelector(_cmd));

Boolean apply = true;
for (NSString *cls in CLS_BLACKLIST) {
if ([self isKindOfClass:NSClassFromString(cls)]) {
apply = false;
break;
}
}

if ([self isKindOfClass:NSClassFromString(@"TNewIconView")]) {
[self performSelector:setTFC withObject:[NSColor whiteColor]];
}

if (apply) {
[self performSelector:@selector(setBackgroundColor:) withObject:[NSColor colorWithCalibratedWhite:0.1 alpha:1.0]];
[plugin dd_updateDarkModeStateForTreeStartingAtView:self];
}
}

if ([self isKindOfClass:NSClassFromString(@"TNewIconView")]) {
[self performSelector:@selector(setTitleFontColor:) withObject:[NSColor whiteColor]];
}

if (apply) {
[self performSelector:@selector(setBackgroundColor:) withObject:[NSColor colorWithCalibratedWhite:0.1 alpha:1.0]];
[plugin dd_updateDarkModeStateForTreeStartingAtView:self];
}
}
}
Expand All @@ -212,7 +226,7 @@ - (void)setFrameSize:(struct CGSize)arg1 {
@implementation wbdd_TBrowserTableView

- (void)reloadData {
// NSLog(@"wbdd - tbrowsertableview - %@", self.className);
NSLog(@"wbdd - TBrowserTableView - %@ - %@", self.className, NSStringFromSelector(_cmd));
ZKOrig(void);
if ([plugin shouldApply:[self className]]) {
[self performSelector:@selector(setBackgroundColor:) withObject:[NSColor colorWithCalibratedWhite:0.1 alpha:1.0]];
Expand All @@ -225,26 +239,37 @@ - (void)reloadData {
@implementation wbdd_NSView

- (void)setFrameSize:(struct CGSize)arg1 {
// NSLog(@"wbdd - nsview - %@", self.className);
ZKOrig(void, arg1);
if ([plugin shouldApply:[self className]]) {
Boolean apply = true;
NSArray *bl = @[@"TDesktopIcon", @"TDesktopTitleBubbleView", @"TIconSelectionView", @"TNewIconView"];
for (NSString *cls in bl) {
if ([self isKindOfClass:NSClassFromString(cls)]) {
apply = false;
break;
if (!resizing) {
if ([plugin shouldApply:[self className]]) {
NSLog(@"wbdd - nsview - %@", self.className);
Boolean apply = true;
for (NSString *cls in CLS_BLACKLIST) {
if ([self isKindOfClass:NSClassFromString(cls)]) {
apply = false;
break;
}
}

if ([self isKindOfClass:NSClassFromString(@"TNewIconView")]) {
[self performSelector:setTFC withObject:[NSColor whiteColor]];
}

if (apply) {
[plugin dd_updateDarkModeStateForTreeStartingAtView:(NSView*)self];
}
}

if ([self isKindOfClass:NSClassFromString(@"TNewIconView")]) {
[self performSelector:@selector(setTitleFontColor:) withObject:[NSColor whiteColor]];
}

if (apply) {
[plugin dd_updateDarkModeStateForTreeStartingAtView:(NSView*)self];
}
}
}

@end

ZKSwizzleInterface(wbdd_NSWindow, NSWindow, NSObject)
@implementation wbdd_NSWindow

- (BOOL)_inLiveResize {
resizing = ZKOrig(BOOL);
return ZKOrig(BOOL);
}

@end
4 changes: 2 additions & 2 deletions DoctorDark/Info.plist
Expand Up @@ -15,11 +15,11 @@
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>0.2.193</string>
<string>0.2.236</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>0.2.193</string>
<string>0.2.236</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Wolfgang Baird. All rights reserved.</string>
<key>NSPrincipalClass</key>
Expand Down

0 comments on commit 3ae2476

Please sign in to comment.