Changed default-zoom behaviour.
authorDaniel Carl <danielcarl@gmx.de>
Thu, 27 Apr 2017 21:22:33 +0000 (23:22 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 27 Apr 2017 21:22:33 +0000 (23:22 +0200)
In the previous implementation the default-zoom was only a initial full
content zoom applied to the webview. But in case the user changed the
zooming and reset it back by using 'zz' the webkit zoom level was set to
1.0 (100%) and not to the initial zoom level like on startup of vimb.
This behaviour is strange to under stand and does not fit toe the
setting name 'default-zoom'.
To make the default-zoom to a real default, the zoom is also applied in
case the zoom is reseted by the user via 'zz'.

doc/vimb.1
src/main.h
src/normal.c
src/setting.c

index 22a0a91..fa2f043 100644 (file)
@@ -702,6 +702,9 @@ All settings listed below can be set with the `:set' command.
 .B closed-max-items (int)
 Maximum number of stored last closed URLs.
 If closed-max-items is set to 0, closed URLs will not be stored.
+.TP
+.B default-zoom (int)
+Default Full-Content zoom level in percent. Default is 100.
 .SH FILES
 .TP
 .IR $XDG_CONFIG_HOME/vimb[/PROFILE]
index 19a593c..6ff37f4 100644 (file)
@@ -230,6 +230,7 @@ struct Client {
         GdkRGBA                 comp_fg[COMP_LAST];
         GdkRGBA                 comp_bg[COMP_LAST];
         PangoFontDescription    *comp_font;
+        guint                   default_zoom;   /* default zoom level in percent */
     } config;
     struct {
         GSList      *list;
index 5a43836..156ef52 100644 (file)
@@ -805,8 +805,10 @@ static VbResult normal_zoom(Client *c, const NormalCmdInfo *info)
 
     count = info->count ? (float)info->count : 1.0;
 
-    if (info->key2 == 'z') { /* zz reset zoom */
-        webkit_web_view_set_zoom_level(view, 1.0);
+    /* zz reset zoom to it's default zoom level */
+    if (info->key2 == 'z') {
+        webkit_settings_set_zoom_text_only(webkit_web_view_get_settings(view), FALSE);
+        webkit_web_view_set_zoom_level(view, c->config.default_zoom / 100.0);
 
         return RESULT_COMPLETE;
     }
index 62261cf..6b9cee2 100644 (file)
@@ -507,10 +507,12 @@ static int cookie_accept(Client *c, const char *name, DataType type, void *value
 
 static int default_zoom(Client *c, const char *name, DataType type, void *value, void *data)
 {
-    float zoom = (float)*(int*)value / 100.0;
+    /* Store the percent value in the client config. */
+    c->config.default_zoom = *(int*)value;
 
+    /* Apply the default zoom to the webview. */
     webkit_settings_set_zoom_text_only(webkit_web_view_get_settings(c->webview), FALSE);
-    webkit_web_view_set_zoom_level(c->webview, zoom);
+    webkit_web_view_set_zoom_level(c->webview, c->config.default_zoom / 100.0);
 
     return CMD_SUCCESS;
 }