[geary/wip/713746-document-font] Initial commit from patch (bgo#713746)
- From: Jim Nelson <jnelson src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/713746-document-font] Initial commit from patch (bgo#713746)
- Date: Tue, 21 Jan 2014 19:21:17 +0000 (UTC)
commit 9950a4f35b7d4a1b0ea16ecad8877bc819752499
Author: Timo Kluck <tkluck infty nl>
Date: Tue Jan 21 11:21:09 2014 -0800
Initial commit from patch (bgo#713746)
src/client/application/geary-config.vala | 2 +-
.../conversation-viewer/conversation-web-view.vala | 43 ++++++++++++++++++++
2 files changed, 44 insertions(+), 1 deletions(-)
---
diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala
index 16d98ce..156a404 100644
--- a/src/client/application/geary-config.vala
+++ b/src/client/application/geary-config.vala
@@ -20,8 +20,8 @@ public class Configuration {
public const string COMPOSE_AS_HTML_KEY = "compose-as-html";
public Settings settings { get; private set; }
+ public Settings gnome_interface { get; private set; }
- private Settings gnome_interface;
private Settings? indicator_datetime;
public int window_width {
diff --git a/src/client/conversation-viewer/conversation-web-view.vala
b/src/client/conversation-viewer/conversation-web-view.vala
index 7c85a90..d5331e0 100644
--- a/src/client/conversation-viewer/conversation-web-view.vala
+++ b/src/client/conversation-viewer/conversation-web-view.vala
@@ -14,6 +14,9 @@ public class ConversationWebView : WebKit.WebView {
private const string STYLE_NAME = "STYLE";
private const string PREVENT_HIDE_STYLE = "nohide";
+ private const double MM_PER_INCH = 25.4;
+ private const double POINTS_PER_INCH = 72.0;
+
// HTML element that contains message DIVs.
public WebKit.DOM.HTMLDivElement? container { get; private set; default = null; }
@@ -34,6 +37,9 @@ public class ConversationWebView : WebKit.WebView {
config.enable_plugins = false;
config.enable_developer_extras = Args.inspector;
settings = config;
+
+ Configuration geary_config = GearyApplication.instance.config;
+ geary_config.gnome_interface.bind("document-font-name", this, "desktop-document-font",
SettingsBindFlags.DEFAULT);
// Hook up signals.
load_finished.connect(on_load_finished);
@@ -150,6 +156,43 @@ public class ConversationWebView : WebKit.WebView {
set_icon_src("#link_warning_template .close_link_warning", "close-symbolic");
}
+ private double get_screen_dpi() {
+ Gdk.Screen screen = get_screen();
+ if (screen == null)
+ return 96.0;
+ double dpi = screen.get_resolution();
+ if (dpi != -1)
+ return dpi;
+
+ double dp = Math.hypot(screen.get_width(), screen.get_height());
+ double di = Math.hypot(screen.get_width_mm(), screen.get_height_mm()) / MM_PER_INCH;
+
+ return dp / di;
+ }
+
+ private string _desktop_document_font;
+ public string desktop_document_font {
+ set {
+ Pango.FontDescription font_desc = Pango.FontDescription.from_string(value);
+ double dpi = get_screen_dpi();
+ double size_in_pixels;
+ if (font_desc.get_size_is_absolute()) {
+ size_in_pixels = font_desc.get_size() / (double) Pango.SCALE;
+ } else {
+ size_in_pixels = font_desc.get_size() * (dpi / POINTS_PER_INCH) / Pango.SCALE;
+ }
+ WebKit.WebSettings config = settings;
+ config.default_font_family = font_desc.get_family();
+ config.default_font_size = (int) size_in_pixels;
+ settings = config;
+ _desktop_document_font = value;
+ }
+
+ get {
+ return _desktop_document_font;
+ }
+ }
+
private void load_user_style() {
try {
WebKit.DOM.Document document = get_dom_document();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]