automatically enable UI_MODE_NIGHT when gtk-theme-name contains "dark"

gtk-theme-name is only checked once at start up
This commit is contained in:
Julian Winkler
2024-03-10 12:05:33 +01:00
parent f49922cf1b
commit 005e2299bd
8 changed files with 87 additions and 5 deletions

View File

@@ -0,0 +1,20 @@
#define _GNU_SOURCE
#include <gtk/gtk.h>
#include <string.h>
#include "../defines.h"
#include "../util.h"
#include "../generated_headers/android_content_Context.h"
JNIEXPORT void JNICALL Java_android_content_Context_native_1updateConfig(JNIEnv *env, jclass class, jobject config)
{
GtkSettings *settings = gtk_settings_get_default();
gchar *theme_name;
g_object_get(settings, "gtk-theme-name", &theme_name, NULL);
bool night_mode = strcasestr(theme_name, "dark") || strcasestr(theme_name, "black");
if (night_mode) {
_SET_INT_FIELD(config, "uiMode", /*UI_MODE_NIGHT_YES*/ 0x20);
}
}