From 4cf4ef8fcf738374b025070e2da36b5d9b27536e Mon Sep 17 00:00:00 2001 From: Gautier Pelloux-Prayer Date: Fri, 16 Sep 2016 16:26:39 +0200 Subject: [PATCH] Persist Conversation Viewer zoom level. Bug 714933 --- desktop/org.yorba.geary.gschema.xml | 6 +++++- src/client/application/geary-config.vala | 7 +++++++ .../conversation-viewer/conversation-web-view.vala | 14 ++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/desktop/org.yorba.geary.gschema.xml b/desktop/org.yorba.geary.gschema.xml index 46d55985..aa30ae27 100644 --- a/desktop/org.yorba.geary.gschema.xml +++ b/desktop/org.yorba.geary.gschema.xml @@ -116,7 +116,11 @@ Advisory strategy for full-text searching Acceptable values are EXACT, CONSERVATIVE, AGGRESSIVE, and HORIZON. - + + 1 + zoom of conversation viewer + The zoom to apply on the conservation view. + diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala index faa49434..8e8521e3 100644 --- a/src/client/application/geary-config.vala +++ b/src/client/application/geary-config.vala @@ -25,6 +25,7 @@ public class Configuration { public const string COMPOSE_AS_HTML_KEY = "compose-as-html"; public const string SPELL_CHECK_VISIBLE_LANGUAGES = "spell-check-visible-languages"; public const string SPELL_CHECK_LANGUAGES = "spell-check-languages"; + public const string CONVERSATION_VIEWER_ZOOM_KEY = "conversation-viewer-zoom"; public Settings settings { get; private set; } public Settings gnome_interface; @@ -130,6 +131,12 @@ public class Configuration { set { set_boolean(COMPOSE_AS_HTML_KEY, value); } } + public double conversation_viewer_zoom { + get { return settings.get_double(CONVERSATION_VIEWER_ZOOM_KEY); } + set { settings.set_double(CONVERSATION_VIEWER_ZOOM_KEY, value); } + } + + // Creates a configuration object. public Configuration(string schema_id) { // Start GSettings. diff --git a/src/client/conversation-viewer/conversation-web-view.vala b/src/client/conversation-viewer/conversation-web-view.vala index b6c9cda6..557e4994 100644 --- a/src/client/conversation-viewer/conversation-web-view.vala +++ b/src/client/conversation-viewer/conversation-web-view.vala @@ -17,9 +17,16 @@ public class ConversationWebView : StylishWebView { // HTML element that contains message DIVs. public WebKit.DOM.HTMLDivElement? container { get; private set; default = null; } - + public string allow_prefix { get; private set; default = ""; } + // We need to wrap zoom_level (type float) because we cannot connect with float + // with double (cf https://bugzilla.gnome.org/show_bug.cgi?id=771534) + public double zoom_level_wrap { + get { return zoom_level; } + set { if (zoom_level != (float)value) zoom_level = (float)value; } + } + private FileMonitor? user_style_monitor = null; public signal void link_selected(string link); @@ -44,7 +51,10 @@ public class ConversationWebView : StylishWebView { web_inspector.inspect_web_view.connect(activate_inspector); document_font_changed.connect(on_document_font_changed); scroll_event.connect(on_scroll_event); - + + GearyApplication.instance.config.bind(Configuration.CONVERSATION_VIEWER_ZOOM_KEY, this, "zoom_level_wrap"); + notify["zoom-level"].connect(() => { zoom_level_wrap = zoom_level; }); + // Load the HTML into WebKit. // Note: load_finished signal MUST be hooked up before this call. string html_text = GearyApplication.instance.read_theme_file("message-viewer.html") ?? "";