You've already forked android_translation_layer
mirror of
https://gitlab.com/android_translation_layer/android_translation_layer.git
synced 2025-10-27 11:48:10 -07:00
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:
20
src/api-impl-jni/content/android_content_Context.c
Normal file
20
src/api-impl-jni/content/android_content_Context.c
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user