@@ -77,8 +77,8 @@ public class PantheonShell.Appearance : Switchboard.SettingsPage {
7777 var default_preview = new DesktopPreview (" default" );
7878
7979 var prefer_default_radio = new Gtk .CheckButton () {
80- action_name = " desktop-appearance.prefers- color-scheme" ,
81- action_target = new Variant .int32 ( Granite . Settings . ColorScheme . NO_PREFERENCE )
80+ action_name = " desktop-appearance.color-scheme" ,
81+ action_target = new Variant .string ( " no-preference " )
8282 };
8383 prefer_default_radio. add_css_class (" image-button" );
8484
@@ -90,8 +90,8 @@ public class PantheonShell.Appearance : Switchboard.SettingsPage {
9090 var dark_preview = new DesktopPreview (" dark" );
9191
9292 var prefer_dark_radio = new Gtk .CheckButton () {
93- action_name = " desktop-appearance.prefers- color-scheme" ,
94- action_target = new Variant .int32 ( Granite . Settings . ColorScheme . DARK ),
93+ action_name = " desktop-appearance.color-scheme" ,
94+ action_target = new Variant .string ( " prefer-dark " ),
9595 group = prefer_default_radio
9696 };
9797 prefer_dark_radio. add_css_class (" image-button" );
@@ -121,12 +121,16 @@ public class PantheonShell.Appearance : Switchboard.SettingsPage {
121121 dim_box. append (dim_switch);
122122
123123 var schedule_disabled_radio = new Gtk .CheckButton .with_label (_(" Disabled" )) {
124+ action_name = " desktop-appearance.prefer-dark-schedule" ,
125+ action_target = new Variant .string (" disabled" ),
124126 margin_bottom = 3
125127 };
126128
127129 var schedule_sunset_radio = new Gtk .CheckButton .with_label (
128130 _(" Sunset to Sunrise" )
129131 ) {
132+ action_name = " desktop-appearance.prefer-dark-schedule" ,
133+ action_target = new Variant .string (" sunset-to-sunrise" ),
130134 group = schedule_disabled_radio
131135 };
132136
@@ -150,6 +154,8 @@ public class PantheonShell.Appearance : Switchboard.SettingsPage {
150154 schedule_manual_box. append (to_time);
151155
152156 var schedule_manual_radio = new Gtk .CheckButton () {
157+ action_name = " desktop-appearance.prefer-dark-schedule" ,
158+ action_target = new Variant .string (" manual" ),
153159 child = schedule_manual_box,
154160 group = schedule_disabled_radio
155161 };
@@ -196,74 +202,23 @@ public class PantheonShell.Appearance : Switchboard.SettingsPage {
196202 var grid = new Gtk .Grid () {
197203 row_spacing = 6
198204 };
205+ grid. attach (prefer_style_box, 0 , 2 , 2 );
206+ grid. attach (dim_box, 0 , 3 , 2 );
207+ grid. attach (schedule_label, 0 , 4 , 2 );
208+ grid. attach (schedule_box, 0 , 5 , 2 );
199209
200- if (((GLib . DBusProxy ) pantheon_act). get_cached_property (" PrefersColorScheme" ) != null ) {
201- grid. attach (prefer_style_box, 0 , 2 , 2 );
202- grid. attach (dim_box, 0 , 3 , 2 );
203- grid. attach (schedule_label, 0 , 4 , 2 );
204- grid. attach (schedule_box, 0 , 5 , 2 );
205-
206- var settings = new GLib .Settings (" io.elementary.settings-daemon.prefers-color-scheme" );
207-
208- settings. bind_with_mapping (
209- " prefer-dark-schedule" , schedule_disabled_radio, " active" , GLib . SettingsBindFlags . DEFAULT ,
210- (value , variant, user_data) = > {
211- value . set_boolean (variant. get_string () == " disabled" );
212- return true ;
213- },
214- (value , expected_type, user_data) = > {
215- if (value . get_boolean ()) {
216- return new Variant (" s" , " disabled" );
217- }
218-
219- return null ;
220- },
221- null , null
222- );
223-
224- settings. bind_with_mapping (
225- " prefer-dark-schedule" , schedule_manual_radio, " active" , GLib . SettingsBindFlags . DEFAULT ,
226- (value , variant, user_data) = > {
227- value . set_boolean (variant. get_string () == " manual" );
228- return true ;
229- },
230- (value , expected_type, user_data) = > {
231- if (value . get_boolean ()) {
232- return new Variant (" s" , " manual" );
233- }
234-
235- return null ;
236- },
237- null , null
238- );
239-
240- settings. bind_with_mapping (
241- " prefer-dark-schedule" , schedule_sunset_radio, " active" , GLib . SettingsBindFlags . DEFAULT ,
242- (value , variant, user_data) = > {
243- value . set_boolean (variant. get_string () == " sunset-to-sunrise" );
244- return true ;
245- },
246- (value , expected_type, user_data) = > {
247- if (value . get_boolean ()) {
248- return new Variant (" s" , " sunset-to-sunrise" );
249- }
210+ var settings = new GLib .Settings (" io.elementary.settings-daemon.prefers-color-scheme" );
250211
251- return null ;
252- },
253- null , null
254- );
255-
256- from_time. time = double_date_time (settings. get_double (" prefer-dark-schedule-from" ));
257- from_time. time_changed. connect (() = > {
258- settings. set_double (" prefer-dark-schedule-from" , date_time_double (from_time. time));
259- });
260- to_time. time = double_date_time (settings. get_double (" prefer-dark-schedule-to" ));
261- to_time. time_changed. connect (() = > {
262- settings. set_double (" prefer-dark-schedule-to" , date_time_double (to_time. time));
263- });
212+ from_time. time = double_date_time (settings. get_double (" prefer-dark-schedule-from" ));
213+ from_time. time_changed. connect (() = > {
214+ settings. set_double (" prefer-dark-schedule-from" , date_time_double (from_time. time));
215+ });
216+ to_time. time = double_date_time (settings. get_double (" prefer-dark-schedule-to" ));
217+ to_time. time_changed. connect (() = > {
218+ settings. set_double (" prefer-dark-schedule-to" , date_time_double (to_time. time));
219+ });
264220
265- schedule_manual_radio. bind_property (" active" , schedule_manual_box, " sensitive" , BindingFlags . SYNC_CREATE );
266- }
221+ schedule_manual_radio. bind_property (" active" , schedule_manual_box, " sensitive" , BindingFlags . SYNC_CREATE );
267222
268223 var interface_settings = new GLib .Settings (INTERFACE_SCHEMA );
269224 var current_stylesheet = interface_settings. get_string (STYLESHEET_KEY );
@@ -380,28 +335,25 @@ public class PantheonShell.Appearance : Switchboard.SettingsPage {
380335 background_settings.bind ("dim -wallpaper -in -dark -style ", dim_switch , "active ", DEFAULT );
381336
382337 var accent_color_action = new SimpleAction .stateful (" prefers-accent-color" , GLib . VariantType . INT32 , new Variant .int32 (AccentColor . NO_PREFERENCE ));
383- var color_scheme_action = new SimpleAction .stateful (" prefers-color-scheme" , GLib . VariantType . INT32 , new Variant .int32 (Granite . Settings . ColorScheme . NO_PREFERENCE ));
338+
339+ var color_scheme_action = settings.create_action ("color -scheme ");
340+ var prefer_dark_action = settings.create_action ("prefer -dark -schedule ");
384341
385342 var action_group = new SimpleActionGroup ();
386343 action_group.add_action (accent_color_action );
387344 action_group.add_action (color_scheme_action );
345+ action_group.add_action (prefer_dark_action );
388346
389347 insert_action_group ("desktop -appearance ", action_group );
390348
391349 if (pantheon_act != null ) {
392350 accent_color_action. set_state (new Variant .int32 (pantheon_act. prefers_accent_color));
393- color_scheme_action. set_state (new Variant .int32 (pantheon_act. prefers_color_scheme));
394351
395352 ((DBusProxy ) pantheon_act). g_properties_changed. connect ((changed, invalid) = > {
396353 var accent_color = changed. lookup_value (" PrefersAccentColor" , new VariantType (" i" ));
397354 if (accent_color != null && ! accent_color_action. get_state (). equal (accent_color)) {
398355 accent_color_action. set_state (accent_color);
399356 }
400-
401- var color_scheme = changed. lookup_value (" PrefersColorScheme" , new VariantType (" i" ));
402- if (color_scheme != null && ! color_scheme_action. get_state (). equal (color_scheme)) {
403- color_scheme_action. set_state (color_scheme);
404- }
405357 });
406358
407359 accent_color_action. activate. connect ((value ) = > {
@@ -417,18 +369,6 @@ public class PantheonShell.Appearance : Switchboard.SettingsPage {
417369 }
418370 }
419371 });
420-
421- color_scheme_action. activate. connect ((value ) = > {
422- if (! color_scheme_action. get_state (). equal (value )) {
423- color_scheme_action. set_state (value );
424- pantheon_act. prefers_color_scheme = value . get_int32 ();
425-
426- var mutter_settings = new GLib .Settings (" org.gnome.desktop.interface" );
427- mutter_settings. set_enum (" color-scheme" , (Granite . Settings . ColorScheme ) value . get_int32 ());
428-
429- schedule_disabled_radio. active = true ;
430- }
431- });
432372 }
433373 }
434374
0 commit comments