@@ -28,6 +28,10 @@ namespace Scratch.Widgets {
28
28
public Gtk . Button templates_button;
29
29
public Code . FormatBar format_bar;
30
30
31
+ private const string STYLE_SCHEME_HIGH_CONTRAST = " classic" ;
32
+ private const string STYLE_SCHEME_LIGHT = " solarized-light" ;
33
+ private const string STYLE_SCHEME_DARK = " solarized-dark" ;
34
+
31
35
public HeaderBar () {
32
36
Object (
33
37
has_subtitle: false ,
@@ -115,23 +119,26 @@ namespace Scratch.Widgets {
115
119
font_size_grid. add (zoom_default_button);
116
120
font_size_grid. add (zoom_in_button);
117
121
118
- var color_button_white = new Gtk .RadioButton (null );
122
+ // Intentionally never attached so we can have a non-selected state
123
+ var color_button_none = new Gtk .RadioButton (null );
124
+
125
+ var color_button_white = new Gtk .RadioButton .from_widget (color_button_none);
119
126
color_button_white. halign = Gtk . Align . CENTER ;
120
127
color_button_white. tooltip_text = _(" High Contrast" );
121
128
122
129
var color_button_white_context = color_button_white. get_style_context ();
123
130
color_button_white_context. add_class (" color-button" );
124
131
color_button_white_context. add_class (" color-white" );
125
132
126
- var color_button_light = new Gtk .RadioButton .from_widget (color_button_white );
133
+ var color_button_light = new Gtk .RadioButton .from_widget (color_button_none );
127
134
color_button_light. halign = Gtk . Align . CENTER ;
128
135
color_button_light. tooltip_text = _(" Solarized Light" );
129
136
130
137
var color_button_light_context = color_button_light. get_style_context ();
131
138
color_button_light_context. add_class (" color-button" );
132
139
color_button_light_context. add_class (" color-light" );
133
140
134
- var color_button_dark = new Gtk .RadioButton .from_widget (color_button_white );
141
+ var color_button_dark = new Gtk .RadioButton .from_widget (color_button_none );
135
142
color_button_dark. halign = Gtk . Align . CENTER ;
136
143
color_button_dark. tooltip_text = _(" Solarized Dark" );
137
144
@@ -214,32 +221,34 @@ namespace Scratch.Widgets {
214
221
var gtk_settings = Gtk . Settings . get_default ();
215
222
216
223
switch (Scratch . settings. get_string (" style-scheme" )) {
217
- case " high-contrast" :
218
- color_button_white. active = true ;
219
- break ;
220
- case " solarized-light" :
221
- color_button_light. active = true ;
222
- break ;
223
- case " solarized-dark" :
224
- color_button_dark. active = true ;
225
- break ;
224
+ case STYLE_SCHEME_HIGH_CONTRAST :
225
+ color_button_white. active = true ;
226
+ break ;
227
+ case STYLE_SCHEME_LIGHT :
228
+ color_button_light. active = true ;
229
+ break ;
230
+ case STYLE_SCHEME_DARK :
231
+ color_button_dark. active = true ;
232
+ break ;
233
+ default:
234
+ color_button_none. active = true ;
226
235
}
227
236
228
237
color_button_dark. clicked. connect (() = > {
229
238
Scratch . settings. set_boolean (" prefer-dark-style" , true );
230
- Scratch . settings. set_string (" style-scheme" , " solarized-dark " );
239
+ Scratch . settings. set_string (" style-scheme" , STYLE_SCHEME_DARK );
231
240
gtk_settings. gtk_application_prefer_dark_theme = true ;
232
241
});
233
242
234
243
color_button_light. clicked. connect (() = > {
235
244
Scratch . settings. set_boolean (" prefer-dark-style" , false );
236
- Scratch . settings. set_string (" style-scheme" , " solarized-light " );
245
+ Scratch . settings. set_string (" style-scheme" , STYLE_SCHEME_LIGHT );
237
246
gtk_settings. gtk_application_prefer_dark_theme = false ;
238
247
});
239
248
240
249
color_button_white. clicked. connect (() = > {
241
250
Scratch . settings. set_boolean (" prefer-dark-style" , false );
242
- Scratch . settings. set_string (" style-scheme" , " classic " );
251
+ Scratch . settings. set_string (" style-scheme" , STYLE_SCHEME_HIGH_CONTRAST );
243
252
gtk_settings. gtk_application_prefer_dark_theme = false ;
244
253
});
245
254
}
0 commit comments