From: Robert Timm Date: Thu, 15 Sep 2016 22:47:16 +0000 (+0200) Subject: Set default_zoom via config X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=4b520f3f3ccf326cad77bb25f676f9cba11bfe58;p=vimb.git Set default_zoom via config --- diff --git a/src/main.c b/src/main.c index 301a80d..1349095 100644 --- a/src/main.c +++ b/src/main.c @@ -1133,8 +1133,6 @@ static void init_core(void) g_object_set(G_OBJECT(setting), "enable-default-context-menu", false, NULL); } - vb.config.default_zoom = 1.0; - #ifdef FEATURE_HIGH_DPI /* fix for high dpi displays */ GdkScreen *screen = gdk_window_get_screen(gtk_widget_get_window(vb.gui.window)); diff --git a/src/setting.c b/src/setting.c index 031ee9b..8bc8c7b 100644 --- a/src/setting.c +++ b/src/setting.c @@ -90,6 +90,9 @@ static int hsts(const char *name, int type, void *value, void *data); #ifdef FEATURE_SOUP_CACHE static int soup_cache(const char *name, int type, void *value, void *data); #endif +#ifdef FEATURE_DEFAULT_ZOOM +static int default_zoom(const char *name, int type, void *value, void *data); +#endif static gboolean validate_js_regexp_list(const char *pattern); void setting_init() @@ -229,6 +232,11 @@ void setting_init() #endif setting_add("x-hint-command", TYPE_CHAR, &":o ;", NULL, 0, NULL); +#ifdef FEATURE_DEFAULT_ZOOM + i = 100; + setting_add("default_zoom", TYPE_INTEGER, &i, default_zoom, 0, &vb.config.default_zoom); +#endif + /* initialize the shortcuts and set the default shortcuts */ shortcut_init(); shortcut_add("dl", "https://duckduckgo.com/html/?q=$0"); @@ -905,6 +913,18 @@ static int soup_cache(const char *name, int type, void *value, void *data) } #endif +#ifdef FEATURE_DEFAULT_ZOOM +static int default_zoom(const char *name, int type, void *value, void *data) +{ + *(float*)data = (float)*(int*)value / 100.0; + + webkit_web_view_set_full_content_zoom(vb.gui.webview, true); + webkit_web_view_set_zoom_level(vb.gui.webview, vb.config.default_zoom); + + return VB_CMD_SUCCESS; +} +#endif + /** * Validated syntax given list of JavaScript RegExp patterns. * If validation fails, the error is shown to the user.