Set default_zoom via config
authorRobert Timm <mail@rtti.de>
Thu, 15 Sep 2016 22:47:16 +0000 (00:47 +0200)
committerRobert Timm <mail@rtti.de>
Thu, 15 Sep 2016 22:52:44 +0000 (00:52 +0200)
src/main.c
src/setting.c

index 301a80d..1349095 100644 (file)
@@ -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));
index 031ee9b..8bc8c7b 100644 (file)
@@ -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 <C-R>;", 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.