From: Daniel Carl Date: Thu, 27 Apr 2017 21:22:33 +0000 (+0200) Subject: Changed default-zoom behaviour. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=48e55c8fc865995c354086a275100da947fb3500;p=vimb.git Changed default-zoom behaviour. 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'. --- diff --git a/doc/vimb.1 b/doc/vimb.1 index 22a0a91..fa2f043 100644 --- a/doc/vimb.1 +++ b/doc/vimb.1 @@ -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] diff --git a/src/main.h b/src/main.h index 19a593c..6ff37f4 100644 --- a/src/main.h +++ b/src/main.h @@ -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; diff --git a/src/normal.c b/src/normal.c index 5a43836..156ef52 100644 --- a/src/normal.c +++ b/src/normal.c @@ -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; } diff --git a/src/setting.c b/src/setting.c index 62261cf..6b9cee2 100644 --- a/src/setting.c +++ b/src/setting.c @@ -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; }