Mercurial > minori
annotate src/sys/osx/dark_theme.cc @ 327:b5d6c27c308f
anime: refactor Anime::SeriesSeason to Season class
ToLocalString has also been altered to take in both season
and year because lots of locales actually treat formatting
seasons differently! most notably is Russian which adds a
suffix at the end to notate seasons(??)
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Thu, 13 Jun 2024 01:49:18 -0400 |
parents | 22f9aacf6ac1 |
children |
rev | line source |
---|---|
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
1 #include "sys/osx/dark_theme.h" |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
2 |
258 | 3 #include <objc/message.h> |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
4 #include <objc/runtime.h> |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
5 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
6 #include <CoreFoundation/CoreFoundation.h> |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
7 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
8 namespace osx { |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
9 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
10 typedef id (*object_message_send)(id, SEL, ...); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
11 typedef id (*class_message_send)(Class, SEL, ...); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
12 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
13 static const object_message_send obj_send = reinterpret_cast<object_message_send>(objc_msgSend); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
14 static const class_message_send cls_send = reinterpret_cast<class_message_send>(objc_msgSend); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
15 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
16 static CFStringRef NSAppearanceNameAqua = nullptr; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
17 static CFStringRef NSAppearanceNameDarkAqua = nullptr; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
18 |
195
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
194
diff
changeset
|
19 static const CFStringRef kAppKitBundleID = CFSTR("com.apple.AppKit"); |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
20 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
21 bool RetrieveAppearanceNames() { |
195
975a3f0965e2
locale: only attempt loading locales after QApplication is init'd
Paper <mrpapersonic@gmail.com>
parents:
194
diff
changeset
|
22 CFBundleRef appkit_bundle = CFBundleGetBundleWithIdentifier(kAppKitBundleID); |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
23 if (!appkit_bundle) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
24 return false; |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
25 |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
26 auto aqua_appearance = reinterpret_cast<CFStringRef*>(CFBundleGetDataPointerForName(appkit_bundle, CFSTR("NSAppearanceNameAqua"))); |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
27 if (!aqua_appearance) |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
28 return false; |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
29 NSAppearanceNameAqua = *aqua_appearance; |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
30 |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
31 auto dark_aqua_appearance = reinterpret_cast<CFStringRef*>( |
258 | 32 CFBundleGetDataPointerForName(appkit_bundle, CFSTR("NSAppearanceNameDarkAqua"))); |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
33 if (!dark_aqua_appearance) |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
34 return false; |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
35 NSAppearanceNameDarkAqua = *dark_aqua_appearance; |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
36 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
37 return true; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
38 } |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
39 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
40 bool DarkThemeAvailable() { |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
41 if (__builtin_available(macOS 10.14, *)) { |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
42 return true; |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
43 } else { |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
44 return false; |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
45 } |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
46 } |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
47 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
48 bool IsInDarkTheme() { |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
49 if (!DarkThemeAvailable()) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
50 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
51 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
52 if (!NSAppearanceNameAqua || !NSAppearanceNameDarkAqua) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
53 if (!RetrieveAppearanceNames()) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
54 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
55 |
196
f0ff06a45c42
date: use std::optional for values
Paper <mrpapersonic@gmail.com>
parents:
195
diff
changeset
|
56 // NSArray* array = @[NSAppearanceNameAqua, NSAppearanceNameDarkAqua]; |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
57 CFArrayRef array = []() -> CFArrayRef { |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
58 CFStringRef refs[] = {NSAppearanceNameAqua, NSAppearanceNameDarkAqua}; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
59 return CFArrayCreate(NULL, reinterpret_cast<const void**>(refs), 2, &kCFTypeArrayCallBacks); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
60 }(); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
61 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
62 // NSApplication* app = [NSApplication sharedApplication]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
63 const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
64 if (!app) |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
65 return false; |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
66 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
67 // NSAppearance* effectiveAppearance = [app effectiveAppearance]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
68 const id effectiveAppearance = obj_send(app, sel_getUid("effectiveAppearance")); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
69 if (!effectiveAppearance) { |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
70 CFRelease(array); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
71 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
72 } |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
73 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
74 // NSAppearance* appearance = [effectiveAppearance bestMatchFromAppearancesWithNames: array]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
75 const id appearance = obj_send(effectiveAppearance, sel_getUid("bestMatchFromAppearancesWithNames:"), array); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
76 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
77 CFRelease(array); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
78 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
79 if (!appearance) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
80 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
81 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
82 return CFEqual(appearance, NSAppearanceNameDarkAqua); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
83 } |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
84 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
85 bool SetToDarkTheme() { |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
86 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
87 if (!DarkThemeAvailable()) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
88 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
89 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
90 if (!NSAppearanceNameAqua || !NSAppearanceNameDarkAqua) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
91 if (!RetrieveAppearanceNames()) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
92 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
93 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
94 // NSApplication* app = [NSApplication sharedApplication]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
95 const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
96 if (!app) |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
97 return false; |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
98 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
99 // NSAppearance* appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua]; |
258 | 100 const id appearance = |
101 cls_send(objc_getClass("NSAppearance"), sel_getUid("appearanceNamed:"), NSAppearanceNameDarkAqua); | |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
102 if (!appearance) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
103 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
104 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
105 // [app setAppearance: appearance]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
106 obj_send(app, sel_getUid("setAppearance:"), appearance); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
107 return true; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
108 } |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
109 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
110 bool SetToLightTheme() { |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
111 // https://stackoverflow.com/questions/55925862/how-can-i-set-my-os-x-application-theme-in-code |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
112 if (!DarkThemeAvailable()) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
113 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
114 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
115 if (!NSAppearanceNameAqua || !NSAppearanceNameDarkAqua) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
116 if (!RetrieveAppearanceNames()) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
117 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
118 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
119 // NSApplication* app = [NSApplication sharedApplication]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
120 const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
121 if (!app) |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
122 return false; |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
123 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
124 // NSAppearance* appearance = [NSAppearance appearanceNamed: NSAppearanceNameDarkAqua]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
125 const id appearance = cls_send(objc_getClass("NSAppearance"), sel_getUid("appearanceNamed:"), NSAppearanceNameAqua); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
126 if (!appearance) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
127 return false; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
128 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
129 // [app setAppearance: appearance]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
130 obj_send(app, sel_getUid("setAppearance:"), appearance); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
131 return true; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
132 } |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
133 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
134 void SetToAutoTheme() { |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
135 if (!DarkThemeAvailable()) |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
136 return; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
137 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
138 // NSApplication* app = [NSApplication sharedApplication]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
139 const id app = cls_send(objc_getClass("NSApplication"), sel_getUid("sharedApplication")); |
275
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
140 if (!app) |
22f9aacf6ac1
osx: don't dereference NULL pointers
Paper <paper@paper.us.eu.org>
parents:
273
diff
changeset
|
141 return; |
194
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
142 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
143 // [app setAppearance: null]; |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
144 obj_send(app, sel_getUid("setAppearance:"), nullptr); |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
145 } |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
146 |
8548dc425697
sys/osx: remove all objective-c++ stuff
Paper <mrpapersonic@gmail.com>
parents:
diff
changeset
|
147 } // namespace osx |