[gnome-calculator/wip/cdavis/gtk4: 9/9] math-equation: Match style scheme with dark preference




commit 55be48ddf8e2ba912d63373c555f5eb96ac23737
Author: Christopher Davis <christopherdavis gnome org>
Date:   Thu Oct 21 23:19:21 2021 -0700

    math-equation: Match style scheme with dark preference

 lib/math-equation.vala | 10 ++++++++++
 lib/meson.build        |  1 +
 2 files changed, 11 insertions(+)
---
diff --git a/lib/math-equation.vala b/lib/math-equation.vala
index 9fa1fade..88778718 100644
--- a/lib/math-equation.vala
+++ b/lib/math-equation.vala
@@ -128,6 +128,9 @@ public class MathEquation : Gtk.SourceBuffer
     private Gtk.TextMark? ans_start_mark = null;
     private Gtk.TextMark? ans_end_mark = null;
 
+    private Gtk.SourceStyleScheme? light_scheme;
+    private Gtk.SourceStyleScheme? dark_scheme;
+
     private MathEquationState state;  /* Equation state */
     private List<MathEquationState> undo_stack; /* History of expression mode states */
     private List<MathEquationState> redo_stack;
@@ -200,6 +203,13 @@ public class MathEquation : Gtk.SourceBuffer
         state.ans_base = 10;
 
         ans_tag = create_tag (null, "weight", Pango.Weight.BOLD, null);
+
+        var style_manager = Adw.StyleManager.get_default ();
+        var style_scheme_manager = Gtk.SourceStyleSchemeManager.get_default ();
+        light_scheme = style_scheme_manager.get_scheme ("Classic");
+        dark_scheme = style_scheme_manager.get_scheme ("Classic-dark");
+
+        set_style_scheme (style_manager.dark ? dark_scheme : light_scheme);
     }
 
     public void display_selected (string selected)
diff --git a/lib/meson.build b/lib/meson.build
index 8f9e05d4..f7f5f117 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -28,6 +28,7 @@ libcalculator_deps = [
   gobject,
   gtk,
   gtksourceview,
+  libadwaita,
   libsoup,
   libxml,
   mpc,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]