[gitg] Respect system fonts



commit 51d16acd5f3e8ca6b4f1ef30194bd3d61690d31c
Author: Gaurav Agrawal <agrawalgaurav1999 gmail com>
Date:   Tue Feb 26 10:23:58 2019 +0000

    Respect system fonts

 libgitg/gitg-diff-view-file-renderer-text.vala | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
---
diff --git a/libgitg/gitg-diff-view-file-renderer-text.vala b/libgitg/gitg-diff-view-file-renderer-text.vala
index 6b68bb6b..b799093c 100644
--- a/libgitg/gitg-diff-view-file-renderer-text.vala
+++ b/libgitg/gitg-diff-view-file-renderer-text.vala
@@ -60,6 +60,8 @@ class Gitg.DiffViewFileRendererText : Gtk.SourceView, DiffSelectable, DiffViewFi
 
        private Settings? d_stylesettings;
 
+       private Settings? d_fontsettings;
+
        public bool new_is_workdir { get; construct set; }
 
        public bool wrap_lines
@@ -395,7 +397,15 @@ class Gitg.DiffViewFileRendererText : Gtk.SourceView, DiffSelectable, DiffViewFi
 
                buffer.language = language;
                buffer.highlight_syntax = true;
+               d_fontsettings = try_settings("org.gnome.desktop.interface");
+               if (d_fontsettings != null)
+               {
+                       d_fontsettings.changed["monospace-font-name"].connect((s, k) => {
+                               update_font();
+                       });
 
+                       update_font();
+               }
                d_stylesettings = try_settings(Gitg.Config.APPLICATION_ID + ".preferences.interface");
                if (d_stylesettings != null)
                {
@@ -443,6 +453,12 @@ class Gitg.DiffViewFileRendererText : Gtk.SourceView, DiffSelectable, DiffViewFi
                }
        }
 
+       private void update_font()
+       {
+               var fname = d_fontsettings.get_string("monospace-font-name");
+               this.override_font(Pango.FontDescription.from_string(fname));
+       }
+
        private Settings? try_settings(string schema_id)
        {
                var source = SettingsSchemaSource.get_default();


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