diff options
author | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-03-06 00:55:43 -0500 |
---|---|---|
committer | ouwou <26526779+ouwou@users.noreply.github.com> | 2024-03-06 00:55:43 -0500 |
commit | 91e89c06958f1e058de445f9b53205e7eb341d3a (patch) | |
tree | bc485e5e663932fb5083a3d892e26ee0edcb573a /src/abaddon.cpp | |
parent | 3ace5d26e91c6158f99398c7d7dc8b7cd219eb4f (diff) | |
parent | e8bc60d9263e5b0dd213bcc85f9655ebebcedf49 (diff) | |
download | abaddon-portaudio-91e89c06958f1e058de445f9b53205e7eb341d3a.tar.gz abaddon-portaudio-91e89c06958f1e058de445f9b53205e7eb341d3a.zip |
Merge branch 'master' of https://github.com/uowuo/abaddon
Diffstat (limited to 'src/abaddon.cpp')
-rw-r--r-- | src/abaddon.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/abaddon.cpp b/src/abaddon.cpp index 26e33f3..f8c4b39 100644 --- a/src/abaddon.cpp +++ b/src/abaddon.cpp @@ -25,6 +25,23 @@ #include "remoteauth/remoteauthdialog.hpp" #include "util.hpp" +#if defined(__APPLE__) +#include <CoreFoundation/CoreFoundation.h> + +void macOSThemeChanged() { + CFPropertyListRef appearanceName = CFPreferencesCopyAppValue(CFSTR("AppleInterfaceStyle"), kCFPreferencesAnyApplication); + if (appearanceName != NULL && CFGetTypeID(appearanceName) == CFStringGetTypeID() && CFStringCompare((CFStringRef)appearanceName, CFSTR("Dark"), 0) == kCFCompareEqualTo) { + Gtk::Settings::get_default()->set_property("gtk-application-prefer-dark-theme", true); + } else { + Gtk::Settings::get_default()->set_property("gtk-application-prefer-dark-theme", false); + } +} + +void macOSThemeChangedCallback(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) { + macOSThemeChanged(); +} +#endif + #ifdef WITH_LIBHANDY #include <handy.h> #endif @@ -332,6 +349,17 @@ int Abaddon::StartGTK() { m_gtk_app->hold(); m_main_window->show(); +#if defined(__APPLE__) + CFNotificationCenterAddObserver(CFNotificationCenterGetDistributedCenter(), + NULL, + macOSThemeChangedCallback, + CFSTR("AppleInterfaceThemeChangedNotification"), + NULL, + CFNotificationSuspensionBehaviorCoalesce); + + macOSThemeChanged(); +#endif + RunFirstTimeDiscordStartup(); return m_gtk_app->run(*m_main_window); |