[geary] Persist Conversation Viewer zoom level. Bug 714933



commit 4cf4ef8fcf738374b025070e2da36b5d9b27536e
Author: Gautier Pelloux-Prayer <gautier+git damsy net>
Date:   Fri Sep 16 16:26:39 2016 +0200

    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 46d5598..aa30ae2 100644
--- a/desktop/org.yorba.geary.gschema.xml
+++ b/desktop/org.yorba.geary.gschema.xml
@@ -116,7 +116,11 @@
         <summary>Advisory strategy for full-text searching</summary>
         <description>Acceptable values are EXACT, CONSERVATIVE, AGGRESSIVE, and HORIZON.</description>
     </key>
-    
+    <key name="conversation-viewer-zoom" type="d">
+        <default>1</default>
+        <summary>zoom of conversation viewer</summary>
+        <description>The zoom to apply on the conservation view.</description>
+    </key>
 </schema>
 
 </schemalist>
diff --git a/src/client/application/geary-config.vala b/src/client/application/geary-config.vala
index faa4943..8e8521e 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 b6c9cda..557e499 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") ?? "";


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