Fix font preference not persisting when loading w/ dark mode

Previously, the initial dark mode toggle would cause the default
settings to be saved, before font preferences ever loaded.
This commit is contained in:
Matt Baer 2018-04-21 20:20:02 -04:00
parent c39c5e0742
commit 8076cb1c33

View File

@ -11,6 +11,8 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
private string fontstyle = "serif"; private string fontstyle = "serif";
private bool text_changed = false; private bool text_changed = false;
private bool is_initializing = true;
construct { construct {
header = new Gtk.HeaderBar(); header = new Gtk.HeaderBar();
header.title = "Write.as"; header.title = "Write.as";
@ -44,7 +46,8 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
return Source.CONTINUE; return Source.CONTINUE;
}); });
adjust_text_style(); adjust_text_style(false);
} }
public MainWindow(Gtk.Application app) { public MainWindow(Gtk.Application app) {
@ -57,6 +60,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
restore_styles(); restore_styles();
set_default_size(800, 600); set_default_size(800, 600);
is_initializing = false;
} }
private static void init_folder() { private static void init_folder() {
@ -101,7 +105,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
darkmode_button.toggled.connect(() => { darkmode_button.toggled.connect(() => {
settings.gtk_application_prefer_dark_theme = darkmode_button.active; settings.gtk_application_prefer_dark_theme = darkmode_button.active;
dark_mode = darkmode_button.active; dark_mode = darkmode_button.active;
adjust_text_style(); adjust_text_style(!is_initializing);
}); });
header.pack_end(darkmode_button); header.pack_end(darkmode_button);
@ -127,7 +131,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
option.activate.connect(() => { option.activate.connect(() => {
this.font = families; this.font = families;
this.fontstyle = fontstyle; this.fontstyle = fontstyle;
adjust_text_style(); adjust_text_style(!is_initializing);
}); });
var styles = option.get_style_context(); var styles = option.get_style_context();