@@ -17,10 +17,13 @@ static constexpr char kAlwaysUse24HourFormatKey[] = "alwaysUse24HourFormat";
17
17
static constexpr char kPlatformBrightnessKey [] = " platformBrightness" ;
18
18
static constexpr char kPlatformBrightnessLight [] = " light" ;
19
19
static constexpr char kPlatformBrightnessDark [] = " dark" ;
20
+ static constexpr char kPreferLightKey [] = " prefer-light" ;
21
+ static constexpr char kPreferDarkKey [] = " prefer-dark" ;
20
22
21
23
static constexpr char kDesktopInterfaceSchema [] = " org.gnome.desktop.interface" ;
22
24
static constexpr char kDesktopTextScalingFactorKey [] = " text-scaling-factor" ;
23
25
static constexpr char kDesktopClockFormatKey [] = " clock-format" ;
26
+ static constexpr char kDesktopColorSchemeKey [] = " color-scheme" ;
24
27
static constexpr char kClockFormat24Hour [] = " 24h" ;
25
28
26
29
enum class Brightness { Light, Dark };
@@ -89,18 +92,27 @@ static bool is_dark_theme() {
89
92
static void update_settings (FlSettingsPlugin* self) {
90
93
gdouble scaling_factor = 1.0 ;
91
94
gboolean always_use_24hr = FALSE ;
92
- const gchar* platform_brightness = kPlatformBrightnessLight ;
95
+ const gchar* platform_brightness = nullptr ;
93
96
94
97
if (self->interface_settings != nullptr ) {
95
98
scaling_factor = g_settings_get_double (self->interface_settings ,
96
99
kDesktopTextScalingFactorKey );
97
100
g_autofree gchar* clock_format =
98
101
g_settings_get_string (self->interface_settings , kDesktopClockFormatKey );
99
102
always_use_24hr = g_strcmp0 (clock_format, kClockFormat24Hour ) == 0 ;
103
+
104
+ g_autofree gchar* color_scheme =
105
+ g_settings_get_string (self->interface_settings , kDesktopColorSchemeKey );
106
+ if (g_strcmp0 (color_scheme, kPreferLightKey ) == 0 ) {
107
+ platform_brightness = kPlatformBrightnessLight ;
108
+ } else if (g_strcmp0 (color_scheme, kPreferDarkKey ) == 0 ) {
109
+ platform_brightness = kPlatformBrightnessDark ;
110
+ }
100
111
}
101
112
102
- if (is_dark_theme ()) {
103
- platform_brightness = kPlatformBrightnessDark ;
113
+ if (platform_brightness == nullptr ) {
114
+ platform_brightness =
115
+ is_dark_theme () ? kPlatformBrightnessDark : kPlatformBrightnessLight ;
104
116
}
105
117
106
118
g_autoptr (FlValue) message = fl_value_new_map ();
@@ -155,7 +167,7 @@ void fl_settings_plugin_start(FlSettingsPlugin* self) {
155
167
GSettingsSchemaSource* source = g_settings_schema_source_get_default ();
156
168
if (source != nullptr ) {
157
169
g_autoptr (GSettingsSchema) schema =
158
- g_settings_schema_source_lookup (source, kDesktopInterfaceSchema , FALSE );
170
+ g_settings_schema_source_lookup (source, kDesktopInterfaceSchema , TRUE );
159
171
if (schema != nullptr ) {
160
172
self->interface_settings = g_settings_new_full (schema, nullptr , nullptr );
161
173
gulong new_connections[] = {
@@ -168,6 +180,9 @@ void fl_settings_plugin_start(FlSettingsPlugin* self) {
168
180
g_signal_connect_object (
169
181
self->interface_settings , " changed::gtk-theme" ,
170
182
G_CALLBACK (update_settings), self, G_CONNECT_SWAPPED),
183
+ g_signal_connect_object (
184
+ self->interface_settings , " changed::color-scheme" ,
185
+ G_CALLBACK (update_settings), self, G_CONNECT_SWAPPED),
171
186
};
172
187
g_array_append_vals (self->connections , new_connections,
173
188
sizeof (new_connections) / sizeof (gulong));
0 commit comments