From 8076cb1c330cdd19935ff2bb568c0ca1b71f095f Mon Sep 17 00:00:00 2001 From: Matt Baer Date: Sat, 21 Apr 2018 20:20:02 -0400 Subject: [PATCH] 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. --- src/window.vala | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/window.vala b/src/window.vala index 40c93f9..60568d1 100644 --- a/src/window.vala +++ b/src/window.vala @@ -11,6 +11,8 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow { private string fontstyle = "serif"; private bool text_changed = false; + private bool is_initializing = true; + construct { header = new Gtk.HeaderBar(); header.title = "Write.as"; @@ -44,7 +46,8 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow { return Source.CONTINUE; }); - adjust_text_style(); + adjust_text_style(false); + } public MainWindow(Gtk.Application app) { @@ -57,6 +60,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow { restore_styles(); set_default_size(800, 600); + is_initializing = false; } private static void init_folder() { @@ -101,7 +105,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow { darkmode_button.toggled.connect(() => { settings.gtk_application_prefer_dark_theme = darkmode_button.active; dark_mode = darkmode_button.active; - adjust_text_style(); + adjust_text_style(!is_initializing); }); header.pack_end(darkmode_button); @@ -127,7 +131,7 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow { option.activate.connect(() => { this.font = families; this.fontstyle = fontstyle; - adjust_text_style(); + adjust_text_style(!is_initializing); }); var styles = option.get_style_context();