From: Daniel Carl Date: Wed, 12 Mar 2014 22:09:32 +0000 (+0100) Subject: Removed default.h and set default settings in init_settings(). X-Git-Url: https://git.owens.tech/assets/favicon.png/assets/favicon.png/git?a=commitdiff_plain;h=b08077f0c7f3ebe332bc78a333cb95e3269df750;p=vimb.git Removed default.h and set default settings in init_settings(). This saves some time spent on parsing the string values into the setting args. --- diff --git a/src/config.def.h b/src/config.def.h index 3540f62..cc0ab33 100644 --- a/src/config.def.h +++ b/src/config.def.h @@ -49,6 +49,11 @@ #define SETTING_MAX_CONNS 25 #define SETTING_MAX_CONNS_PER_HOST 5 +/* default font size for fonts in webview */ +#define SETTING_DEFAULT_FONT_SIZE 10 +#define SETTING_GUI_FONT_NORMAL "monospace normal 10" +#define SETTING_GUI_FONT_EMPH "monospace bold 10" +#define SETTING_HOME_PAGE "http://fanglingsu.github.io/vimb/" #define MAXIMUM_HINTS 500 diff --git a/src/default.h b/src/default.h deleted file mode 100644 index e699ce7..0000000 --- a/src/default.h +++ /dev/null @@ -1,78 +0,0 @@ -/** - * vimb - a webkit based vim like browser. - * - * Copyright (C) 2012-2014 Daniel Carl - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#ifndef _DEFAULT_H -#define _DEFAULT_H - -#include "stdlib.h" - -static char *default_config[] = { - "shortcut-add dl=https://duckduckgo.com/html/?q=$0", - "shortcut-add dd=https://duckduckgo.com/?q=$0", - "shortcut-default dl", - "set defaultencoding=utf-8", - "set fontsize=11", - "set monofontsize=11", - "set minimumfontsize=5", - "set useragent=" PROJECT "/" VERSION " (X11; Linux i686) AppleWebKit/535.22+ Compatible (Safari)", - "set stylesheet=on", - "set proxy=on", - "set pagecache=on", -#ifdef FEATURE_COOKIE - "set cookie-timeout=4800", -#endif - "set strict-ssl=on", - "set strict-focus=off", - "set scrollstep=40", - "set status-color-bg=#000", - "set status-color-fg=#fff", - "set status-font=monospace bold 8", - "set status-ssl-color-bg=#95e454", - "set status-ssl-color-fg=#000", - "set status-ssl-font=monospace bold 8", - "set status-sslinvalid-color-bg=#f77", - "set status-sslinvalid-color-fg=#000", - "set status-sslinvalid-font=monospace bold 8", - "set input-bg-normal=#fff", - "set input-bg-error=#f77", - "set input-fg-normal=#000", - "set input-fg-error=#000", - "set input-font-normal=monospace normal 8", - "set input-font-error=monospace bold 8", - "set completion-font=monospace normal 8", - "set completion-fg-normal=#f6f3e8", - "set completion-fg-active=#fff", - "set completion-bg-normal=#656565", - "set completion-bg-active=#777", - "set ca-bundle=/etc/ssl/certs/ca-certificates.crt", - "set home-page=http://fanglingsu.github.io/vimb/", - "set download-path=", - "set history-max-items=2000", - "set editor-command=x-terminal-emulator -e vi %s", -#if WEBKIT_CHECK_VERSION(2, 0, 0) - "set insecure-content-show=off", - "set insecure-content-run=off", -#endif - "set timeoutlen=1000", - "set previouspattern=/\\bprev\\|previous\\b/i,/^(<\\|<<\\|«)$/,/^(<\\|<<\\|«)/,/(<\\|<<\\|«)$/", - "set nextpattern=/\\bnext\\b/i,/^(>\\|>>\\|»)$/,/^(>\\|>>\\|»)/,/(>\\|>>\\|»)$/,/\\bmore\\b/i", - NULL -}; - -#endif /* end of include guard: _DEFAULT_H */ diff --git a/src/main.c b/src/main.c index 69dadf8..2d39ba5 100644 --- a/src/main.c +++ b/src/main.c @@ -34,7 +34,6 @@ #include "ex.h" #include "input.h" #include "map.h" -#include "default.h" #include "pass.h" #include "bookmark.h" #include "js.h" @@ -695,13 +694,6 @@ static void read_config(void) { char *line, **lines; - /* load default config */ - for (guint i = 0; default_config[i] != NULL; i++) { - if (!ex_run_string(default_config[i])) { - g_error("Invalid default config: '%s'", default_config[i]); - } - } - /* read config from config files */ lines = util_get_lines(vb.files[FILES_CONFIG]); diff --git a/src/setting.c b/src/setting.c index 8f318b6..4989e52 100644 --- a/src/setting.c +++ b/src/setting.c @@ -58,72 +58,72 @@ 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, {0}}, - {"cursivfont", "cursive-font-family", TYPE_CHAR, webkit, {0}}, - {"defaultencoding", "default-encoding", TYPE_CHAR, webkit, {0}}, - {"defaultfont", "default-font-family", TYPE_CHAR, webkit, {0}}, - {"fontsize", "default-font-size", TYPE_INTEGER, webkit, {0}}, - {"monofontsize", "default-monospace-font-size", TYPE_INTEGER, webkit, {0}}, - {"caret", "enable-caret-browsing", TYPE_BOOLEAN, webkit, {0}}, - {"webinspector", "enable-developer-extras", TYPE_BOOLEAN, webkit, {0}}, - {"offlinecache", "enable-offline-web-application-cache", TYPE_BOOLEAN, webkit, {0}}, - {"pagecache", "enable-page-cache", TYPE_BOOLEAN, webkit, {0}}, - {"plugins", "enable-plugins", TYPE_BOOLEAN, webkit, {0}}, - {"scripts", "enable-scripts", TYPE_BOOLEAN, webkit, {0}}, - {"xssauditor", "enable-xss-auditor", TYPE_BOOLEAN, webkit, {0}}, - {"minimumfontsize", "minimum-font-size", TYPE_INTEGER, webkit, {0}}, - {"monofont", "monospace-font-family", TYPE_CHAR, webkit, {0}}, - {NULL, "print-backgrounds", TYPE_BOOLEAN, webkit, {0}}, - {"sansfont", "sans-serif-font-family", TYPE_CHAR, webkit, {0}}, - {"seriffont", "serif-font-family", TYPE_CHAR, webkit, {0}}, - {"useragent", "user-agent", TYPE_CHAR, webkit, {0}}, - {"spacial-navigation", "enable-spatial-navigation", TYPE_BOOLEAN, webkit, {0}}, + {"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 = PROJECT "/" VERSION " (X11; Linux i686) AppleWebKit/535.22+ Compatible (Safari)"}}, + {"spacial-navigation", "enable-spatial-navigation", TYPE_BOOLEAN, webkit, {.i = 0}}, #if WEBKIT_CHECK_VERSION(2, 0, 0) - {"insecure-content-show", "enable-display-of-insecure-content", TYPE_BOOLEAN, webkit, {0}}, - {"insecure-content-run", "enable-running-of-insecure-content", TYPE_BOOLEAN, webkit, {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}}, #endif /* internal variables */ - {NULL, "stylesheet", TYPE_BOOLEAN, user_style, {0}}, + {NULL, "stylesheet", TYPE_BOOLEAN, user_style, {.i = 1}}, - {NULL, "proxy", TYPE_BOOLEAN, proxy, {0}}, + {NULL, "proxy", TYPE_BOOLEAN, proxy, {.i = 1}}, #ifdef FEATURE_COOKIE - {NULL, "cookie-accept", TYPE_CHAR, cookie_accept, {0}}, - {NULL, "cookie-timeout", TYPE_INTEGER, cookie_timeout, {0}}, + {NULL, "cookie-accept", TYPE_CHAR, cookie_accept, {.s = "always"}}, + {NULL, "cookie-timeout", TYPE_INTEGER, cookie_timeout, {.i = 4800}}, #endif - {NULL, "strict-ssl", TYPE_BOOLEAN, strict_ssl, {0}}, - {NULL, "strict-focus", TYPE_BOOLEAN, strict_focus, {0}}, - - {NULL, "scrollstep", TYPE_INTEGER, scrollstep, {0}}, - {NULL, "status-color-bg", TYPE_COLOR, status_color_bg, {0}}, - {NULL, "status-color-fg", TYPE_COLOR, status_color_fg, {0}}, - {NULL, "status-font", TYPE_FONT, status_font, {0}}, - {NULL, "status-ssl-color-bg", TYPE_COLOR, status_color_bg, {0}}, - {NULL, "status-ssl-color-fg", TYPE_COLOR, status_color_fg, {0}}, - {NULL, "status-ssl-font", TYPE_FONT, status_font, {0}}, - {NULL, "status-sslinvalid-color-bg", TYPE_COLOR, status_color_bg, {0}}, - {NULL, "status-sslinvalid-color-fg", TYPE_COLOR, status_color_fg, {0}}, - {NULL, "status-sslinvalid-font", TYPE_FONT, status_font, {0}}, - {NULL, "timeoutlen", TYPE_INTEGER, timeoutlen, {0}}, - {NULL, "input-bg-normal", TYPE_COLOR, input_style, {0}}, - {NULL, "input-bg-error", TYPE_COLOR, input_style, {0}}, - {NULL, "input-fg-normal", TYPE_COLOR, input_style, {0}}, - {NULL, "input-fg-error", TYPE_COLOR, input_style, {0}}, - {NULL, "input-font-normal", TYPE_FONT, input_style, {0}}, - {NULL, "input-font-error", TYPE_FONT, input_style, {0}}, - {NULL, "completion-font", TYPE_FONT, completion_style, {0}}, - {NULL, "completion-fg-normal", TYPE_COLOR, completion_style, {0}}, - {NULL, "completion-fg-active", TYPE_COLOR, completion_style, {0}}, - {NULL, "completion-bg-normal", TYPE_COLOR, completion_style, {0}}, - {NULL, "completion-bg-active", TYPE_COLOR, completion_style, {0}}, - {NULL, "ca-bundle", TYPE_CHAR, ca_bundle, {0}}, - {NULL, "home-page", TYPE_CHAR, home_page, {0}}, - {NULL, "download-path", TYPE_CHAR, download_path, {0}}, - {NULL, "history-max-items", TYPE_INTEGER, history_max_items, {0}}, - {NULL, "editor-command", TYPE_CHAR, editor_command, {0}}, - {NULL, "header", TYPE_CHAR, headers, {0}}, - {NULL, "nextpattern", TYPE_CHAR, nextpattern, {0}}, - {NULL, "previouspattern", TYPE_CHAR, nextpattern, {0}}, + {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, "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,/^(<\\|<<\\|«)$/,/^(<\\|<<\\|«)/,/(<\\|<<\\|«)$/"}}, }; void setting_init(void) @@ -136,6 +136,7 @@ void setting_init(void) s = &default_settings[i]; /* use alias as key if available */ g_hash_table_insert(settings, (gpointer)s->alias != NULL ? s->alias : s->name, s); + s->func(s, false); } }