diff --git a/gitg/commit/gitg-commit-dialog.vala b/gitg/commit/gitg-commit-dialog.vala index e95e855c..35ebe200 100644 --- a/gitg/commit/gitg-commit-dialog.vala +++ b/gitg/commit/gitg-commit-dialog.vala @@ -81,6 +81,7 @@ class Dialog : Gtk.Dialog private GtkSpell.Checker? d_spell_checker; private Ggit.Diff d_diff; private bool d_infobar_shown; + private Gtk.CssProvider css_provider; public Ggit.Diff? diff { @@ -411,6 +412,8 @@ class Dialog : Gtk.Dialog construct { d_font_settings = new Settings("org.gnome.desktop.interface"); + css_provider = new Gtk.CssProvider(); + d_source_view_message.get_style_context().add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS); update_font_settings(); @@ -785,10 +788,17 @@ class Dialog : Gtk.Dialog private void update_font_settings() { - var mfont = d_font_settings.get_string("monospace-font-name"); - var desc = Pango.FontDescription.from_string(mfont); - - d_source_view_message.override_font(desc); + var fname = d_font_settings.get_string("monospace-font-name"); + var font_desc = Pango.FontDescription.from_string(fname); + var css = "textview { %s }".printf(Dazzle.pango_font_description_to_css(font_desc)); + try + { + css_provider.load_from_data(css); + } + catch(Error e) + { + warning("Error applying font: %s", e.message); + } } public void show_infobar(string primary_msg, diff --git a/gitg/gitg-create-tag-dialog.vala b/gitg/gitg-create-tag-dialog.vala index 9ab3b97b..e7b201d7 100644 --- a/gitg/gitg-create-tag-dialog.vala +++ b/gitg/gitg-create-tag-dialog.vala @@ -38,10 +38,13 @@ class CreateTagDialog : Gtk.Dialog private Gtk.TextTag d_info_tag; private bool d_is_showing_user_info; private Settings d_font_settings; + private Gtk.CssProvider css_provider; construct { d_font_settings = new Settings("org.gnome.desktop.interface"); + css_provider = new Gtk.CssProvider(); + d_text_view_message.get_style_context().add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS); update_font_settings(); @@ -87,10 +90,17 @@ class CreateTagDialog : Gtk.Dialog private void update_font_settings() { - var mfont = d_font_settings.get_string("monospace-font-name"); - var desc = Pango.FontDescription.from_string(mfont); - - d_text_view_message.override_font(desc); + var fname = d_font_settings.get_string("monospace-font-name"); + var font_desc = Pango.FontDescription.from_string(fname); + var css = "textview { %s }".printf(Dazzle.pango_font_description_to_css(font_desc)); + try + { + css_provider.load_from_data(css); + } + catch(Error e) + { + warning("Error applying font: %s", e.message); + } } private void show_user_info() diff --git a/gitg/meson.build b/gitg/meson.build index 0d01c4d7..3ccd68ed 100644 --- a/gitg/meson.build +++ b/gitg/meson.build @@ -60,6 +60,7 @@ deps = [ gtkspell_dep, libgitg_ext_dep, libpeas_dep, + libdazzle_dep, ] cflags = warn_flags + [ diff --git a/libgitg/gitg-diff-view-file-renderer-text.vala b/libgitg/gitg-diff-view-file-renderer-text.vala index b799093c..d35e5a67 100644 --- a/libgitg/gitg-diff-view-file-renderer-text.vala +++ b/libgitg/gitg-diff-view-file-renderer-text.vala @@ -54,6 +54,7 @@ class Gitg.DiffViewFileRendererText : Gtk.SourceView, DiffSelectable, DiffViewFi private Gtk.SourceBuffer? d_new_highlight_buffer; private bool d_old_highlight_ready; private bool d_new_highlight_ready; + private Gtk.CssProvider css_provider; private Region[] d_regions; private bool d_constructed; @@ -199,6 +200,9 @@ class Gitg.DiffViewFileRendererText : Gtk.SourceView, DiffSelectable, DiffViewFi var settings = Gtk.Settings.get_default(); settings.notify["gtk-application-prefer-dark-theme"].connect(update_theme); + css_provider = new Gtk.CssProvider(); + get_style_context().add_provider(css_provider,Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS); + update_theme(); if (can_select) @@ -456,7 +460,16 @@ 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)); + var font_desc = Pango.FontDescription.from_string(fname); + var css = "textview{%s}".printf(Dazzle.pango_font_description_to_css(font_desc)); + try + { + css_provider.load_from_data(css); + } + catch(Error e) + { + warning("Error applying font: %s", e.message); + } } private Settings? try_settings(string schema_id) diff --git a/libgitg/meson.build b/libgitg/meson.build index 2961f606..e2463f9c 100644 --- a/libgitg/meson.build +++ b/libgitg/meson.build @@ -13,6 +13,7 @@ common_deps = [ glib_dep, gtk_dep, libgit2_glib_dep, + libdazzle_dep, ] sources = files( diff --git a/meson.build b/meson.build index 0266af10..aeed1260 100644 --- a/meson.build +++ b/meson.build @@ -137,6 +137,7 @@ libpeas_dep = dependency('libpeas-1.0') libsecret_dep = dependency('libsecret-1') libsoup_dep = dependency('libsoup-2.4') libxml_dep = dependency('libxml-2.0', version: '>= 2.9.0') +libdazzle_dep = dependency('libdazzle-1.0') config_dep = valac.find_library('config', dirs: vapi_dir) gitg_platform_support_dep = valac.find_library('gitg-platform-support', dirs: vapi_dir) diff --git a/org.gnome.gitgDevel.json b/org.gnome.gitgDevel.json index ccaab62e..d3e5c73d 100644 --- a/org.gnome.gitgDevel.json +++ b/org.gnome.gitgDevel.json @@ -143,6 +143,24 @@ } ] }, + { + "name" : "libdazzle", + "config-opt" : [ + "--prefix=/opt/gnome", + "--libdir=/opt/gnome/lib" + ], + "buildsystem" : "meson", + "builddir" : true, + "cleanup" : [ + "/bin" + ], + "sources" : [ + { + "type" : "git", + "url" : "https://gitlab.gnome.org/GNOME/libdazzle.git" + } + ] + }, { "name" : "gitg", "buildsystem" : "meson", diff --git a/plugins/files/gitg-files.vala b/plugins/files/gitg-files.vala index 94b7e76a..6f0bece8 100644 --- a/plugins/files/gitg-files.vala +++ b/plugins/files/gitg-files.vala @@ -39,6 +39,7 @@ namespace GitgFiles private Gtk.Viewport d_imagevp; private Gtk.Image d_image; + private Gtk.CssProvider css_provider; private Gitg.WhenMapped d_whenMapped; construct @@ -87,7 +88,16 @@ namespace GitgFiles private void update_font() { var fname = d_fontsettings.get_string("monospace-font-name"); - d_source.override_font(Pango.FontDescription.from_string(fname)); + var font_desc = Pango.FontDescription.from_string(fname); + var css = "textview { %s }".printf(Dazzle.pango_font_description_to_css(font_desc)); + try + { + css_provider.load_from_data(css); + } + catch(Error e) + { + warning("Error applying font. %s", e.message); + } } private void update_style() @@ -139,6 +149,8 @@ namespace GitgFiles d_paned = ret["paned_files"] as Gtk.Paned; d_scrolled = ret["scrolled_window_file"] as Gtk.ScrolledWindow; + css_provider = new Gtk.CssProvider(); + d_source.get_style_context().add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_SETTINGS); d_imagevp = new Gtk.Viewport(null, null); d_image = new Gtk.Image(); d_imagevp.add(d_image); diff --git a/plugins/meson.build b/plugins/meson.build index 6ca3d33d..4b39d677 100644 --- a/plugins/meson.build +++ b/plugins/meson.build @@ -12,6 +12,7 @@ plugin_deps = [ libgitg_dep, libgitg_ext_dep, libpeas_dep, + libdazzle_dep, ] plugin_dir = join_paths(gitg_pkglibdir, 'plugins')