#include "hsts.h"
#endif
- static GHashTable *settings;
-
extern VbCore vb;
- static Arg *char_to_arg(const char *str, const Type type);
- static void print_value(const Setting *s, void *value);
- static SettingStatus webkit(const Setting *s, const SettingType type);
+ static int setting_set_value(Setting *prop, void *value);
+ static gboolean setting_add(const char *name, Type type, void *value,
+ SettingFunction setter, void *data);
+ static void setting_print(Setting *s);
+ static void setting_free(Setting *s);
+ static int webkit(const char *name, Type type, void *value, void *data);
+ static int soup(const char *name, Type type, void *value, void *data);
+ static int internal(const char *name, Type type, void *value, void *data);
+ static int input_color(const char *name, Type type, void *value, void *data);
+ static int status_color(const char *name, Type type, void *value, void *data);
+ static int input_font(const char *name, Type type, void *value, void *data);
+ static int status_font(const char *name, Type type, void *value, void *data);
+ gboolean setting_fill_completion(GtkListStore *store, const char *input);
#ifdef FEATURE_COOKIE
- static SettingStatus cookie_accept(const Setting *s, const SettingType type);
- static SettingStatus cookie_timeout(const Setting *s, const SettingType type);
+ static int cookie_accept(const char *name, Type type, void *value, void *data);
#endif
- static SettingStatus scrollstep(const Setting *s, const SettingType type);
- static SettingStatus status_color_bg(const Setting *s, const SettingType type);
- static SettingStatus status_color_fg(const Setting *s, const SettingType type);
- static SettingStatus status_font(const Setting *s, const SettingType type);
- static SettingStatus input_style(const Setting *s, const SettingType type);
- static SettingStatus completion_style(const Setting *s, const SettingType type);
- static SettingStatus strict_ssl(const Setting *s, const SettingType type);
- static SettingStatus strict_focus(const Setting *s, const SettingType type);
- static SettingStatus ca_bundle(const Setting *s, const SettingType type);
- static SettingStatus home_page(const Setting *s, const SettingType type);
- static SettingStatus download_path(const Setting *s, const SettingType type);
- static SettingStatus proxy(const Setting *s, const SettingType type);
- static SettingStatus user_style(const Setting *s, const SettingType type);
- static SettingStatus history_max_items(const Setting *s, const SettingType type);
- static SettingStatus editor_command(const Setting *s, const SettingType type);
- static SettingStatus download_command(const Setting *s, const SettingType type);
- static SettingStatus download_use_external(const Setting *s, const SettingType type);
- static SettingStatus timeoutlen(const Setting *s, const SettingType type);
- static SettingStatus headers(const Setting *s, const SettingType type);
- static SettingStatus nextpattern(const Setting *s, const SettingType type);
- static SettingStatus fullscreen(const Setting *s, const SettingType type);
+ static int ca_bundle(const char *name, Type type, void *value, void *data);
+ static int proxy(const char *name, Type type, void *value, void *data);
+ static int user_style(const char *name, Type type, void *value, void *data);
+ static int headers(const char *name, Type type, void *value, void *data);
+ static int prevnext(const char *name, Type type, void *value, void *data);
+ static int fullscreen(const char *name, Type type, void *value, void *data);
#ifdef FEATURE_HSTS
- static SettingStatus hsts(const Setting *s, const SettingType type);
+ static int hsts(const char *name, Type type, void *value, void *data);
#endif
-
static gboolean validate_js_regexp_list(const char *pattern);
- static Setting default_settings[] = {
- /* webkit settings */
- /* alias, name, type, func, arg */
- {"images", "auto-load-images", TYPE_BOOLEAN, webkit, {.i = 1}},
- {"cursivfont", "cursive-font-family", TYPE_CHAR, webkit, {.s = "serif"}},
- {"defaultencoding", "default-encoding", TYPE_CHAR, webkit, {.s = "utf-8"}},
- {"defaultfont", "default-font-family", TYPE_CHAR, webkit, {.s = "sans-serif"}},
- {"fontsize", "default-font-size", TYPE_INTEGER, webkit, {.i = SETTING_DEFAULT_FONT_SIZE}},
- {"monofontsize", "default-monospace-font-size", TYPE_INTEGER, webkit, {.i = SETTING_DEFAULT_FONT_SIZE}},
- {"caret", "enable-caret-browsing", TYPE_BOOLEAN, webkit, {.i = 0}},
- {"webinspector", "enable-developer-extras", TYPE_BOOLEAN, webkit, {.i = 0}},
- {"offlinecache", "enable-offline-web-application-cache", TYPE_BOOLEAN, webkit, {.i = 1}},
- {"pagecache", "enable-page-cache", TYPE_BOOLEAN, webkit, {.i = 1}},
- {"plugins", "enable-plugins", TYPE_BOOLEAN, webkit, {.i = 1}},
- {"scripts", "enable-scripts", TYPE_BOOLEAN, webkit, {.i = 1}},
- {"xssauditor", "enable-xss-auditor", TYPE_BOOLEAN, webkit, {.i = 1}},
- {"minimumfontsize", "minimum-font-size", TYPE_INTEGER, webkit, {.i = 5}},
- {"monofont", "monospace-font-family", TYPE_CHAR, webkit, {.s = "monospace"}},
- {NULL, "print-backgrounds", TYPE_BOOLEAN, webkit, {.i = 1}},
- {"sansfont", "sans-serif-font-family", TYPE_CHAR, webkit, {.s = "sans-serif"}},
- {"seriffont", "serif-font-family", TYPE_CHAR, webkit, {.s = "serif"}},
- {"useragent", "user-agent", TYPE_CHAR, webkit, {.s = "Mozilla/5.0 (X11; Linux i686) AppleWebKit/538.15+ (KHTML, like Gecko) " PROJECT "/" VERSION " Safari/538.15 Version/6.0"}},
- {"spacial-navigation", "enable-spatial-navigation", TYPE_BOOLEAN, webkit, {.i = 0}},
+ void setting_init()
+ {
+ int i;
+ gboolean on = true, off = false;
+
+ vb.config.settings = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)setting_free);
+
+ setting_add("images", TYPE_BOOLEAN, &on, webkit, "auto-load-images");
+ setting_add("cursivfont", TYPE_CHAR, &"serif", webkit, "cursive-font-family");
+ setting_add("defaultencoding", TYPE_CHAR, &"utf-8", webkit, "default-encoding");
+ setting_add("defaultfont", TYPE_CHAR, &"sans-serif", webkit, "default-font-family");
+ i = SETTING_DEFAULT_FONT_SIZE;
+ setting_add("fontsize", TYPE_INTEGER, &i, webkit, "default-font-size");
+ setting_add("monofontsize", TYPE_INTEGER, &i, webkit, "default-monospace-font-size");
+ setting_add("caret", TYPE_BOOLEAN, &off, webkit, "enable-caret-browsing");
+ setting_add("webinspector", TYPE_BOOLEAN, &off, webkit, "enable-developer-extras");
+ setting_add("offlinecache", TYPE_BOOLEAN, &on, webkit, "enable-offline-web-application-cache");
+ setting_add("pagecache", TYPE_BOOLEAN, &on, webkit, "enable-page-cache");
+ setting_add("plugins", TYPE_BOOLEAN, &on, webkit, "enable-plugins");
+ setting_add("scripts", TYPE_BOOLEAN, &on, webkit, "enable-scripts");
+ setting_add("xssauditor", TYPE_BOOLEAN, &on, webkit, "enable-xss-auditor");
+ i = 5;
+ setting_add("minimumfontsize", TYPE_INTEGER, &i, webkit, "minimum-font-size");
+ setting_add("monofont", TYPE_CHAR, &"monospace", webkit, "monospace-font-family");
+ setting_add("print-backgrounds", TYPE_BOOLEAN, &on, webkit, "print-backgrounds");
+ setting_add("sansfont", TYPE_CHAR, &"sans-serif", webkit, "sans-serif-font-family");
+ setting_add("seriffont", TYPE_CHAR, &"serif", webkit, "serif-font-family");
+ setting_add("useragent", TYPE_CHAR, &"Mozilla/5.0 (X11; Linux i686) AppleWebKit/538.15+ (KHTML, like Gecko) " PROJECT "/" VERSION " Safari/538.15 Version/6.0", webkit, "user-agent");
+ setting_add("spacial-navigation", TYPE_BOOLEAN, &off, webkit, "enable-spatial-navigation");
#if WEBKIT_CHECK_VERSION(2, 0, 0)
- {"insecure-content-show", "enable-display-of-insecure-content", TYPE_BOOLEAN, webkit, {.i = 0}},
- {"insecure-content-run", "enable-running-of-insecure-content", TYPE_BOOLEAN, webkit, {.i = 0}},
+ setting_add("insecure-content-show", TYPE_BOOLEAN, &off, webkit, "enable-display-of-insecure-content");
+ setting_add("insecure-content-run", TYPE_BOOLEAN, &off, webkit, "enable-running-of-insecure-content");
#endif
-
/* internal variables */
- {NULL, "stylesheet", TYPE_BOOLEAN, user_style, {.i = 1}},
-
- {NULL, "proxy", TYPE_BOOLEAN, proxy, {.i = 1}},
+ setting_add("stylesheet", TYPE_BOOLEAN, &on, user_style, NULL);
+ setting_add("proxy", TYPE_BOOLEAN, &on, proxy, NULL);
#ifdef FEATURE_COOKIE
- {NULL, "cookie-accept", TYPE_CHAR, cookie_accept, {.s = "always"}},
- {NULL, "cookie-timeout", TYPE_INTEGER, cookie_timeout, {.i = 4800}},
+ setting_add("cookie-accept", TYPE_CHAR, &"always", cookie_accept, NULL);
+ i = 4800;
+ setting_add("cookie-timeout", TYPE_INTEGER, &i, internal, &vb.config.cookie_timeout);
#endif
- {NULL, "strict-ssl", TYPE_BOOLEAN, strict_ssl, {.i = 1}},
- {NULL, "strict-focus", TYPE_BOOLEAN, strict_focus, {.i = 0}},
-
- {NULL, "scrollstep", TYPE_INTEGER, scrollstep, {.i = 40}},
- {NULL, "status-color-bg", TYPE_COLOR, status_color_bg, {.s = "#000"}},
- {NULL, "status-color-fg", TYPE_COLOR, status_color_fg, {.s = "#fff"}},
- {NULL, "status-font", TYPE_FONT, status_font, {.s = SETTING_GUI_FONT_EMPH}},
- {NULL, "status-ssl-color-bg", TYPE_COLOR, status_color_bg, {.s = "#95e454"}},
- {NULL, "status-ssl-color-fg", TYPE_COLOR, status_color_fg, {.s = "#000"}},
- {NULL, "status-ssl-font", TYPE_FONT, status_font, {.s = SETTING_GUI_FONT_EMPH}},
- {NULL, "status-sslinvalid-color-bg", TYPE_COLOR, status_color_bg, {.s = "#f77"}},
- {NULL, "status-sslinvalid-color-fg", TYPE_COLOR, status_color_fg, {.s = "#000"}},
- {NULL, "status-sslinvalid-font", TYPE_FONT, status_font, {.s = SETTING_GUI_FONT_EMPH}},
- {NULL, "timeoutlen", TYPE_INTEGER, timeoutlen, {.i = 1000}},
- {NULL, "input-bg-normal", TYPE_COLOR, input_style, {.s = "#fff"}},
- {NULL, "input-bg-error", TYPE_COLOR, input_style, {.s = "#f77"}},
- {NULL, "input-fg-normal", TYPE_COLOR, input_style, {.s = "#000"}},
- {NULL, "input-fg-error", TYPE_COLOR, input_style, {.s = "#000"}},
- {NULL, "input-font-normal", TYPE_FONT, input_style, {.s = SETTING_GUI_FONT_NORMAL}},
- {NULL, "input-font-error", TYPE_FONT, input_style, {.s = SETTING_GUI_FONT_EMPH}},
- {NULL, "completion-font", TYPE_FONT, completion_style, {.s = SETTING_GUI_FONT_NORMAL}},
- {NULL, "completion-fg-normal", TYPE_COLOR, completion_style, {.s = "#f6f3e8"}},
- {NULL, "completion-fg-active", TYPE_COLOR, completion_style, {.s = "#fff"}},
- {NULL, "completion-bg-normal", TYPE_COLOR, completion_style, {.s = "#656565"}},
- {NULL, "completion-bg-active", TYPE_COLOR, completion_style, {.s = "#777"}},
- {NULL, "ca-bundle", TYPE_CHAR, ca_bundle, {.s = "/etc/ssl/certs/ca-certificates.crt"}},
- {NULL, "home-page", TYPE_CHAR, home_page, {.s = SETTING_HOME_PAGE}},
- {NULL, "download-path", TYPE_CHAR, download_path, {.s = ""}},
- {NULL, "history-max-items", TYPE_INTEGER, history_max_items, {.i = 2000}},
- {NULL, "editor-command", TYPE_CHAR, editor_command, {.s = "x-terminal-emulator -e vi %s"}},
- {NULL, "download-command", TYPE_CHAR, download_command, {.s = "/bin/sh -c \"curl -sLJOC - -A '$VIMB_USER_AGENT' -e '$VIMB_URI' -b '$VIMB_COOKIES' %s\""}},
- {NULL, "download-use-external", TYPE_BOOLEAN, download_use_external, {.i = 0}},
- {NULL, "header", TYPE_CHAR, headers, {.s = ""}},
- {NULL, "nextpattern", TYPE_CHAR, nextpattern, {.s = "/\\bnext\\b/i,/^(>\\|>>\\|»)$/,/^(>\\|>>\\|»)/,/(>\\|>>\\|»)$/,/\\bmore\\b/i"}},
- {NULL, "previouspattern", TYPE_CHAR, nextpattern, {.s = "/\\bprev\\|previous\\b/i,/^(<\\|<<\\|«)$/,/^(<\\|<<\\|«)/,/(<\\|<<\\|«)$/"}},
- {NULL, "fullscreen", TYPE_BOOLEAN, fullscreen, {.i = 0}},
+ setting_add("strict-ssl", TYPE_BOOLEAN, &on, soup, "ssl-strict");
+ setting_add("strict-focus", TYPE_BOOLEAN, &off, internal, &vb.config.strict_focus);
+ i = 40;
+ setting_add("scrollstep", TYPE_INTEGER, &i, internal, &vb.config.scrollstep);
+ setting_add("status-color-bg", TYPE_COLOR, &"#000000", status_color, &vb.style.status_bg[VB_STATUS_NORMAL]);
+ setting_add("status-color-fg", TYPE_COLOR, &"#ffffff", status_color, &vb.style.status_fg[VB_STATUS_NORMAL]);
+ setting_add("status-font", TYPE_FONT, &SETTING_GUI_FONT_EMPH, status_font, &vb.style.status_font[VB_STATUS_NORMAL]);
+ setting_add("status-ssl-color-bg", TYPE_COLOR, &"#95e454", status_color, &vb.style.status_bg[VB_STATUS_SSL_VALID]);
+ setting_add("status-ssl-color-fg", TYPE_COLOR, &"#000000", status_color, &vb.style.status_fg[VB_STATUS_SSL_VALID]);
+ setting_add("status-ssl-font", TYPE_FONT, &SETTING_GUI_FONT_EMPH, status_font, &vb.style.status_font[VB_STATUS_SSL_VALID]);
+ setting_add("status-sslinvalid-color-bg", TYPE_COLOR, &"#ff7777", status_color, &vb.style.status_bg[VB_STATUS_SSL_INVALID]);
+ setting_add("status-sslinvalid-color-fg", TYPE_COLOR, &"#000000", status_color, &vb.style.status_fg[VB_STATUS_SSL_INVALID]);
+ setting_add("status-sslinvalid-font", TYPE_FONT, &SETTING_GUI_FONT_EMPH, status_font, &vb.style.status_font[VB_STATUS_SSL_INVALID]);
+ i = 1000;
+ setting_add("timeoutlen", TYPE_INTEGER, &i, internal, &vb.config.timeoutlen);
+ setting_add("input-bg-normal", TYPE_COLOR, &"#ffffff", input_color, &vb.style.input_bg[VB_MSG_NORMAL]);
+ setting_add("input-bg-error", TYPE_COLOR, &"#ff7777", input_color, &vb.style.input_bg[VB_MSG_ERROR]);
+ setting_add("input-fg-normal", TYPE_COLOR, &"#000000", input_color, &vb.style.input_fg[VB_MSG_NORMAL]);
+ setting_add("input-fg-error", TYPE_COLOR, &"#000000", input_color, &vb.style.input_fg[VB_MSG_ERROR]);
+ setting_add("input-font-normal", TYPE_FONT, &SETTING_GUI_FONT_NORMAL, input_font, &vb.style.input_font[VB_MSG_NORMAL]);
+ setting_add("input-font-error", TYPE_FONT, &SETTING_GUI_FONT_EMPH, input_font, &vb.style.input_font[VB_MSG_ERROR]);
+ setting_add("completion-font", TYPE_FONT, &SETTING_GUI_FONT_NORMAL, input_font, &vb.style.comp_font);
+ setting_add("completion-fg-normal", TYPE_COLOR, &"#f6f3e8", input_color, &vb.style.comp_fg[VB_COMP_NORMAL]);
+ setting_add("completion-fg-active", TYPE_COLOR, &"#ffffff", input_color, &vb.style.comp_fg[VB_COMP_ACTIVE]);
+ setting_add("completion-bg-normal", TYPE_COLOR, &"#656565", input_color, &vb.style.comp_bg[VB_COMP_NORMAL]);
+ setting_add("completion-bg-active", TYPE_COLOR, &"#777777", input_color, &vb.style.comp_bg[VB_COMP_ACTIVE]);
+ setting_add("ca-bundle", TYPE_CHAR, &"/etc/ssl/certs/ca-certificates.crt", ca_bundle, NULL);
+ setting_add("home-page", TYPE_CHAR, &SETTING_HOME_PAGE, NULL, NULL);
+ setting_add("download-path", TYPE_CHAR, &"", internal, &vb.config.download_dir);
+ i = 2000;
+ setting_add("history-max-items", TYPE_INTEGER, &i, internal, &vb.config.history_max);
+ setting_add("editor-command", TYPE_CHAR, &"x-terminal-emulator -e -vi %s", NULL, NULL);
+ setting_add("header", TYPE_CHAR, &"", headers, NULL);
+ setting_add("nextpattern", TYPE_CHAR, &"/\\bnext\\b/i,/^(>\\|>>\\|»)$/,/^(>\\|>>\\|»)/,/(>\\|>>\\|»)$/,/\\bmore\\b/i", prevnext, NULL);
+ setting_add("previouspattern", TYPE_CHAR, &"/\\bprev\\|previous\\b/i,/^(<\\|<<\\|«)$/,/^(<\\|<<\\|«)/,/(<\\|<<\\|«)$/", prevnext, NULL);
+ setting_add("fullscreen", TYPE_BOOLEAN, &off, fullscreen, NULL);
++ setting_add("download-command", TYPE_CHAR, &"/bin/sh -c \"curl -sLJOC - -A '$VIMB_USER_AGENT' -e '$VIMB_URI' -b '$VIMB_COOKIES' %s\"", NULL, NULL);
++ setting_add("download-use-external", TYPE_BOOLEAN, &off, NULL, NULL);
#ifdef FEATURE_HSTS
- {NULL, "hsts", TYPE_BOOLEAN, hsts, {.i = 1}},
+ setting_add("hsts", TYPE_BOOLEAN, &on, hsts, NULL);
#endif
- };
-
- void setting_init(void)
- {
- Setting *s;
- unsigned int i;
- settings = g_hash_table_new(g_str_hash, g_str_equal);
-
- for (i = 0; i < LENGTH(default_settings); i++) {
- s = &default_settings[i];
- /* use alias as key if available */
- g_hash_table_insert(settings, (gpointer)s->alias != NULL ? s->alias : s->name, s);
- /* set the default settings */
- s->func(s, false);
- }
/* initialize the shortcuts and set the default shortcuts */
shortcut_init();