Persist Conversation Viewer zoom level. Bug 714933

This commit is contained in:
Gautier Pelloux-Prayer 2016-09-16 16:26:39 +02:00 committed by Michael James Gratton
parent 832a1b7fbd
commit 4cf4ef8fcf
3 changed files with 24 additions and 3 deletions

View file

@ -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>

View file

@ -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.

View file

@ -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") ?? "";