From 1490b52a6b96b6a69a0c4fe9e0515dc717425128 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Thu, 22 Mar 2012 09:34:34 +0000 Subject: NetSurf options rework (a=vince r=daniels,jmb) svn path=/trunk/netsurf/; revision=13548 --- desktop/browser.c | 39 ++--- desktop/netsurf.c | 6 +- desktop/options.c | 366 +++++++------------------------------------- desktop/options.h | 180 ++++++++++------------ desktop/options_main.h | 400 +++++++++++++++++++++++++++++++++++++++++++++++++ desktop/print.c | 12 +- desktop/tree.c | 25 ++-- 7 files changed, 573 insertions(+), 455 deletions(-) create mode 100644 desktop/options_main.h (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 6f35f7c97..dbdb725e2 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -158,7 +158,8 @@ bool browser_window_redraw(struct browser_window *bw, int x, int y, /* Browser window has content OR children (frames) */ - if (bw->window != NULL && ctx->plot->option_knockout) { + if ((bw->window != NULL) && + (ctx->plot->option_knockout)) { /* Root browser window: start knockout */ knockout_plot_start(ctx, &new_ctx); } @@ -725,7 +726,7 @@ void browser_window_initialise_common(struct browser_window *bw, bw->reformat_pending = false; bw->drag_type = DRAGGING_NONE; - bw->scale = (float) option_scale / 100.0; + bw->scale = (float) nsoption_int(scale) / 100.0; bw->scroll_x = NULL; bw->scroll_y = NULL; @@ -2157,7 +2158,7 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, if ((!(mouse & BROWSER_MOUSE_CLICK_2)) && (!((mouse & BROWSER_MOUSE_CLICK_2) && (mouse & BROWSER_MOUSE_MOD_2))) && - (!option_target_blank)) { + (!nsoption_bool(target_blank))) { /* not a mouse button 2 click * not a mouse button 1 click with ctrl pressed * configured to ignore target="_blank" */ @@ -2166,12 +2167,14 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, } /* handle reserved keywords */ - if (((option_button_2_tab) && (mouse & BROWSER_MOUSE_CLICK_2)) || - ((!option_button_2_tab) && - ((mouse & BROWSER_MOUSE_CLICK_1) && - (mouse & BROWSER_MOUSE_MOD_2))) || - ((option_button_2_tab) && ((target == TARGET_BLANK) || - (!strcasecmp(target, "_blank"))))) { + if (((nsoption_bool(button_2_tab)) && + (mouse & BROWSER_MOUSE_CLICK_2))|| + ((!nsoption_bool(button_2_tab)) && + ((mouse & BROWSER_MOUSE_CLICK_1) && + (mouse & BROWSER_MOUSE_MOD_2))) || + ((nsoption_bool(button_2_tab)) && + ((target == TARGET_BLANK) || + (!strcasecmp(target, "_blank"))))) { /* open in new tab if: * - button_2 opens in new tab and button_2 was pressed * OR @@ -2184,13 +2187,14 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, if (!bw_target) return bw; return bw_target; - } else if (((!option_button_2_tab) && - (mouse & BROWSER_MOUSE_CLICK_2)) || - ((option_button_2_tab) && - ((mouse & BROWSER_MOUSE_CLICK_1) && - (mouse & BROWSER_MOUSE_MOD_2))) || - ((!option_button_2_tab) && ((target == TARGET_BLANK) || - (!strcasecmp(target, "_blank"))))) { + } else if (((!nsoption_bool(button_2_tab)) && + (mouse & BROWSER_MOUSE_CLICK_2)) || + ((nsoption_bool(button_2_tab)) && + ((mouse & BROWSER_MOUSE_CLICK_1) && + (mouse & BROWSER_MOUSE_MOD_2))) || + ((!nsoption_bool(button_2_tab)) && + ((target == TARGET_BLANK) || + (!strcasecmp(target, "_blank"))))) { /* open in new window if: * - button_2 doesn't open in new tabs and button_2 was pressed * OR @@ -2231,8 +2235,9 @@ struct browser_window *browser_window_find_target(struct browser_window *bw, return bw_target; /* we require a new window using the target name */ - if (!option_target_blank) + if (!nsoption_bool(target_blank)) return bw; + bw_target = browser_window_create(NULL, bw, NULL, false, false); if (!bw_target) return bw; diff --git a/desktop/netsurf.c b/desktop/netsurf.c index 698606da1..7d498b50a 100644 --- a/desktop/netsurf.c +++ b/desktop/netsurf.c @@ -167,12 +167,12 @@ nserror netsurf_init(int *pargc, utsname.version, utsname.machine)); LOG(("Using '%s' for Options file", options)); - options_read(options); + nsoption_read(options); messages_load(messages); /* set up cache limits based on the memory cache size option */ - hlcache_parameters.limit = option_memory_cache_size; + hlcache_parameters.limit = nsoption_int(memory_cache_size); if (hlcache_parameters.limit < MINIMUM_MEMORY_CACHE_SIZE) { hlcache_parameters.limit = MINIMUM_MEMORY_CACHE_SIZE; @@ -228,7 +228,7 @@ nserror netsurf_init(int *pargc, /* Initialize system colours */ gui_system_colour_init(); - options_commandline(pargc, *pargv); + nsoption_commandline(pargc, *pargv); js_initialise(); diff --git a/desktop/options.c b/desktop/options.c index 0fbf40b32..82e08ebb2 100644 --- a/desktop/options.c +++ b/desktop/options.c @@ -31,206 +31,18 @@ #include #include #include + #include "css/css.h" -#include "desktop/options.h" #include "desktop/plot_style.h" #include "utils/log.h" #include "utils/utils.h" +#include "desktop/options.h" -#if defined(riscos) -#include "riscos/options.h" -#elif defined(nsgtk) -#include "gtk/options.h" -#elif defined(nsbeos) -#include "beos/options.h" -#elif defined(nsamiga) -#include "amiga/options.h" -#elif defined(nsframebuffer) -#include "framebuffer/options.h" -#elif defined(nsatari) -#include "atari/options.h" -#elif defined(nsmonkey) -#include "monkey/options.h" -#else -#define EXTRA_OPTION_DEFINE -#define EXTRA_OPTION_TABLE -#endif - - -/** An HTTP proxy should be used. */ -bool option_http_proxy = false; -/** Hostname of proxy. */ -char *option_http_proxy_host = 0; -/** Proxy port. */ -int option_http_proxy_port = 8080; -/** Proxy authentication method. */ -int option_http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE; -/** Proxy authentication user name */ -char *option_http_proxy_auth_user = 0; -/** Proxy authentication password */ -char *option_http_proxy_auth_pass = 0; -/** Default font size / 0.1pt. */ -int option_font_size = 128; -/** Minimum font size. */ -int option_font_min_size = 85; -/** Default sans serif font */ -char *option_font_sans; -/** Default serif font */ -char *option_font_serif; -/** Default monospace font */ -char *option_font_mono; -/** Default cursive font */ -char *option_font_cursive; -/** Default fantasy font */ -char *option_font_fantasy; -/** Accept-Language header. */ -char *option_accept_language = 0; -/** Accept-Charset header. */ -char *option_accept_charset = 0; -/** Preferred maximum size of memory cache / bytes. */ -int option_memory_cache_size = 12 * 1024 * 1024; -/** Preferred expiry age of disc cache / days. */ -int option_disc_cache_age = 28; -/** Whether to block advertisements */ -bool option_block_ads = false; -/** Minimum GIF animation delay */ -int option_minimum_gif_delay = 10; -/** Whether to send the referer HTTP header */ -bool option_send_referer = true; -/** Whether to fetch foreground images */ -bool option_foreground_images = true; -/** Whether to fetch background images */ -bool option_background_images = true; -/** Whether to animate images */ -bool option_animate_images = true; -/** How many days to retain URL data for */ -int option_expire_url = 28; -/** Default font family */ -int option_font_default = PLOT_FONT_FAMILY_SANS_SERIF; -/** ca-bundle location */ -char *option_ca_bundle = 0; -/** ca-path location */ -char *option_ca_path = 0; -/** Cookie file location */ -char *option_cookie_file = 0; -/** Cookie jar location */ -char *option_cookie_jar = 0; -/** Home page location */ -char *option_homepage_url = 0; -/** search web from url bar */ -bool option_search_url_bar = false; -/** URL completion in url bar */ -bool option_url_suggestion = true; -/** default web search provider */ -int option_search_provider = 0; -/** default x position of new windows */ -int option_window_x = 0; -/** default y position of new windows */ -int option_window_y = 0; -/** default width of new windows */ -int option_window_width = 0; -/** default height of new windows */ -int option_window_height = 0; -/** width of screen when above options were saved */ -int option_window_screen_width = 0; -/** height of screen when above options were saved */ -int option_window_screen_height = 0; -/** default size of status bar vs. h scroll bar */ -int option_toolbar_status_width = 6667; -/** default window scale */ -int option_scale = 100; -/* Whether to reflow web pages while objects are fetching */ -bool option_incremental_reflow = true; -/* Minimum time between HTML reflows while objects are fetching */ -#ifdef riscos -unsigned int option_min_reflow_period = 100; /* time in cs */ -#else -unsigned int option_min_reflow_period = 25; /* time in cs */ -#endif -bool option_core_select_menu = false; -/** top margin of exported page*/ -int option_margin_top = DEFAULT_MARGIN_TOP_MM; -/** bottom margin of exported page*/ -int option_margin_bottom = DEFAULT_MARGIN_BOTTOM_MM; -/** left margin of exported page*/ -int option_margin_left = DEFAULT_MARGIN_LEFT_MM; -/** right margin of exported page*/ -int option_margin_right = DEFAULT_MARGIN_RIGHT_MM; -/** scale of exported content*/ -int option_export_scale = DEFAULT_EXPORT_SCALE * 100; -/**suppressing images in printed content*/ -bool option_suppress_images = false; -/**turning off all backgrounds for printed content*/ -bool option_remove_backgrounds = false; -/**turning on content loosening for printed content*/ -bool option_enable_loosening = true; -/**compression of PDF documents*/ -bool option_enable_PDF_compression = true; -/**setting a password and encoding PDF documents*/ -bool option_enable_PDF_password = false; - -/* Fetcher configuration */ -/** Maximum simultaneous active fetchers */ -int option_max_fetchers = 24; -/** Maximum simultaneous active fetchers per host. - * (<=option_max_fetchers else it makes no sense) - * Note that rfc2616 section 8.1.4 says that there should be no more than - * two keepalive connections per host. None of the main browsers follow this - * as it slows page fetches down considerably. - * See https://bugzilla.mozilla.org/show_bug.cgi?id=423377#c4 - */ -int option_max_fetchers_per_host = 5; -/** Maximum number of inactive fetchers cached. - * The total number of handles netsurf will therefore have open - * is this plus option_max_fetchers. - */ -int option_max_cached_fetch_handles = 6; -/** Suppress debug output from cURL. */ -bool option_suppress_curl_debug = true; - -/** Whether to allow target="_blank" */ -bool option_target_blank = true; - -/** Whether second mouse button opens in new tab */ -bool option_button_2_tab = true; - -/* Interface colours */ -colour option_gui_colour_bg_1 = 0xFFCCBB; /** Background (bbggrr) */ -colour option_gui_colour_fg_1 = 0x000000; /** Foreground (bbggrr) */ -colour option_gui_colour_fg_2 = 0xFFFBF8; /** Foreground selected (bbggrr) */ - -/* system colours */ -colour option_sys_colour_ActiveBorder = 0x00000000; -colour option_sys_colour_ActiveCaption = 0x00000000; -colour option_sys_colour_AppWorkspace = 0x00000000; -colour option_sys_colour_Background = 0x00000000; -colour option_sys_colour_ButtonFace = 0x00000000; -colour option_sys_colour_ButtonHighlight = 0x00000000; -colour option_sys_colour_ButtonShadow = 0x00000000; -colour option_sys_colour_ButtonText = 0x00000000; -colour option_sys_colour_CaptionText = 0x0000000; -colour option_sys_colour_GrayText = 0x00000000; -colour option_sys_colour_Highlight = 0x00000000; -colour option_sys_colour_HighlightText = 0x00000000; -colour option_sys_colour_InactiveBorder = 0x00000000; -colour option_sys_colour_InactiveCaption = 0x00000000; -colour option_sys_colour_InactiveCaptionText = 0x00000000; -colour option_sys_colour_InfoBackground = 0x00000000; -colour option_sys_colour_InfoText = 0x00000000; -colour option_sys_colour_Menu = 0x00000000; -colour option_sys_colour_MenuText = 0x0000000; -colour option_sys_colour_Scrollbar = 0x0000000; -colour option_sys_colour_ThreeDDarkShadow = 0x000000; -colour option_sys_colour_ThreeDFace = 0x000000; -colour option_sys_colour_ThreeDHighlight = 0x000000; -colour option_sys_colour_ThreeDLightShadow = 0x000000; -colour option_sys_colour_ThreeDShadow = 0x000000; -colour option_sys_colour_Window = 0x000000; -colour option_sys_colour_WindowFrame = 0x000000; -colour option_sys_colour_WindowText = 0x000000; - - -EXTRA_OPTION_DEFINE +struct ns_options nsoptions = { + NSOPTION_MAIN_DEFAULTS, + NSOPTION_SYS_COLOUR_DEFAULTS, + NSOPTION_EXTRA_DEFAULTS +}; enum option_type_e { OPTION_BOOL, @@ -246,104 +58,8 @@ struct option_entry_s { }; struct option_entry_s option_table[] = { - { "http_proxy", OPTION_BOOL, &option_http_proxy }, - { "http_proxy_host", OPTION_STRING, &option_http_proxy_host }, - { "http_proxy_port", OPTION_INTEGER, &option_http_proxy_port }, - { "http_proxy_auth", OPTION_INTEGER, &option_http_proxy_auth }, - { "http_proxy_auth_user", OPTION_STRING, &option_http_proxy_auth_user }, - { "http_proxy_auth_pass", OPTION_STRING, &option_http_proxy_auth_pass }, - { "font_size", OPTION_INTEGER, &option_font_size }, - { "font_min_size", OPTION_INTEGER, &option_font_min_size }, - { "font_sans", OPTION_STRING, &option_font_sans }, - { "font_serif", OPTION_STRING, &option_font_serif }, - { "font_mono", OPTION_STRING, &option_font_mono }, - { "font_cursive", OPTION_STRING, &option_font_cursive }, - { "font_fantasy", OPTION_STRING, &option_font_fantasy }, - { "accept_language", OPTION_STRING, &option_accept_language }, - { "accept_charset", OPTION_STRING, &option_accept_charset }, - { "memory_cache_size", OPTION_INTEGER, &option_memory_cache_size }, - { "disc_cache_age", OPTION_INTEGER, &option_disc_cache_age }, - { "block_advertisements", OPTION_BOOL, &option_block_ads }, - { "minimum_gif_delay", OPTION_INTEGER, &option_minimum_gif_delay }, - { "send_referer", OPTION_BOOL, &option_send_referer }, - { "foreground_images", OPTION_BOOL, &option_foreground_images }, - { "background_images", OPTION_BOOL, &option_background_images }, - { "animate_images", OPTION_BOOL, &option_animate_images }, - { "expire_url", OPTION_INTEGER, &option_expire_url }, - { "font_default", OPTION_INTEGER, &option_font_default }, - { "ca_bundle", OPTION_STRING, &option_ca_bundle }, - { "ca_path", OPTION_STRING, &option_ca_path }, - { "cookie_file", OPTION_STRING, &option_cookie_file }, - { "cookie_jar", OPTION_STRING, &option_cookie_jar }, - { "homepage_url", OPTION_STRING, &option_homepage_url }, - { "search_url_bar", OPTION_BOOL, &option_search_url_bar}, - { "search_provider", OPTION_INTEGER, &option_search_provider}, - { "url_suggestion", OPTION_BOOL, &option_url_suggestion }, - { "window_x", OPTION_INTEGER, &option_window_x }, - { "window_y", OPTION_INTEGER, &option_window_y }, - { "window_width", OPTION_INTEGER, &option_window_width }, - { "window_height", OPTION_INTEGER, &option_window_height }, - { "window_screen_width", OPTION_INTEGER, &option_window_screen_width }, - { "window_screen_height", OPTION_INTEGER, &option_window_screen_height }, - { "toolbar_status_size", OPTION_INTEGER, &option_toolbar_status_width }, - { "scale", OPTION_INTEGER, &option_scale }, - { "incremental_reflow", OPTION_BOOL, &option_incremental_reflow }, - { "min_reflow_period", OPTION_INTEGER, &option_min_reflow_period }, - { "core_select_menu", OPTION_BOOL, &option_core_select_menu }, - /* Fetcher options */ - { "max_fetchers", OPTION_INTEGER, &option_max_fetchers }, - { "max_fetchers_per_host", OPTION_INTEGER, &option_max_fetchers_per_host }, - { "max_cached_fetch_handles", OPTION_INTEGER, &option_max_cached_fetch_handles }, - { "suppress_curl_debug",OPTION_BOOL, &option_suppress_curl_debug }, - { "target_blank", OPTION_BOOL, &option_target_blank }, - { "button_2_tab", OPTION_BOOL, &option_button_2_tab }, - /* PDF / Print options*/ - { "margin_top", OPTION_INTEGER, &option_margin_top}, - { "margin_bottom", OPTION_INTEGER, &option_margin_bottom}, - { "margin_left", OPTION_INTEGER, &option_margin_left}, - { "margin_right", OPTION_INTEGER, &option_margin_right}, - { "export_scale", OPTION_INTEGER, &option_export_scale}, - { "suppress_images", OPTION_BOOL, &option_suppress_images}, - { "remove_backgrounds", OPTION_BOOL, &option_remove_backgrounds}, - { "enable_loosening", OPTION_BOOL, &option_enable_loosening}, - { "enable_PDF_compression", OPTION_BOOL, &option_enable_PDF_compression}, - { "enable_PDF_password", OPTION_BOOL, &option_enable_PDF_password}, - /* Interface colours */ - { "gui_colour_bg_1", OPTION_COLOUR, &option_gui_colour_bg_1}, - { "gui_colour_fg_1", OPTION_COLOUR, &option_gui_colour_fg_1}, - { "gui_colour_fg_2", OPTION_COLOUR, &option_gui_colour_fg_2}, - - /* System colours */ - { "sys_colour_ActiveBorder",OPTION_COLOUR,&option_sys_colour_ActiveBorder }, - { "sys_colour_ActiveCaption",OPTION_COLOUR,&option_sys_colour_ActiveCaption }, - { "sys_colour_AppWorkspace",OPTION_COLOUR,&option_sys_colour_AppWorkspace }, - { "sys_colour_Background",OPTION_COLOUR,&option_sys_colour_Background }, - { "sys_colour_ButtonFace",OPTION_COLOUR,&option_sys_colour_ButtonFace }, - { "sys_colour_ButtonHighlight",OPTION_COLOUR,&option_sys_colour_ButtonHighlight }, - { "sys_colour_ButtonShadow",OPTION_COLOUR,&option_sys_colour_ButtonShadow }, - { "sys_colour_ButtonText",OPTION_COLOUR,&option_sys_colour_ButtonText }, - { "sys_colour_CaptionText",OPTION_COLOUR,&option_sys_colour_CaptionText }, - { "sys_colour_GrayText",OPTION_COLOUR,&option_sys_colour_GrayText }, - { "sys_colour_Highlight",OPTION_COLOUR,&option_sys_colour_Highlight }, - { "sys_colour_HighlightText",OPTION_COLOUR,&option_sys_colour_HighlightText }, - { "sys_colour_InactiveBorder",OPTION_COLOUR,&option_sys_colour_InactiveBorder }, - { "sys_colour_InactiveCaption",OPTION_COLOUR,&option_sys_colour_InactiveCaption }, - { "sys_colour_InactiveCaptionText",OPTION_COLOUR,&option_sys_colour_InactiveCaptionText }, - { "sys_colour_InfoBackground",OPTION_COLOUR,&option_sys_colour_InfoBackground }, - { "sys_colour_InfoText",OPTION_COLOUR,&option_sys_colour_InfoText }, - { "sys_colour_Menu",OPTION_COLOUR,&option_sys_colour_Menu }, - { "sys_colour_MenuText",OPTION_COLOUR,&option_sys_colour_MenuText }, - { "sys_colour_Scrollbar",OPTION_COLOUR,&option_sys_colour_Scrollbar }, - { "sys_colour_ThreeDDarkShadow",OPTION_COLOUR,&option_sys_colour_ThreeDDarkShadow }, - { "sys_colour_ThreeDFace",OPTION_COLOUR,&option_sys_colour_ThreeDFace }, - { "sys_colour_ThreeDHighlight",OPTION_COLOUR,&option_sys_colour_ThreeDHighlight }, - { "sys_colour_ThreeDLightShadow",OPTION_COLOUR,&option_sys_colour_ThreeDLightShadow }, - { "sys_colour_ThreeDShadow",OPTION_COLOUR,&option_sys_colour_ThreeDShadow }, - { "sys_colour_Window",OPTION_COLOUR,&option_sys_colour_Window }, - { "sys_colour_WindowFrame",OPTION_COLOUR,&option_sys_colour_WindowFrame }, - { "sys_colour_WindowText",OPTION_COLOUR,&option_sys_colour_WindowText }, - - EXTRA_OPTION_TABLE + NSOPTION_MAIN_TABLE, + NSOPTION_EXTRA_TABLE }; #define option_table_entries (sizeof option_table / sizeof option_table[0]) @@ -379,7 +95,12 @@ strtooption(const char *value, struct option_entry_s *option_entry) case OPTION_STRING: free(*((char **)option_entry->p)); - *((char **)option_entry->p) = strdup(value); + if (*value == 0) { + /* do not allow empty strings in text options */ + *((char **)option_entry->p) = NULL; + } else { + *((char **)option_entry->p) = strdup(value); + } ret = true; break; } @@ -387,8 +108,27 @@ strtooption(const char *value, struct option_entry_s *option_entry) return ret; } +static void nsoptions_validate(struct ns_options *opts) +{ + if (opts->font_size < 50) + opts->font_size = 50; + + if (1000 < opts->font_size) + opts->font_size = 1000; + + if (opts->font_min_size < 10) + opts->font_min_size = 10; + + if (500 < opts->font_min_size) + opts->font_min_size = 500; + + if (opts->memory_cache_size < 0) + opts->memory_cache_size = 0; + +} + /* exported interface documented in options.h */ -void options_read(const char *path) +void nsoption_read(const char *path) { char s[100]; FILE *fp; @@ -423,22 +163,12 @@ void options_read(const char *path) fclose(fp); - if (option_font_size < 50) - option_font_size = 50; - if (1000 < option_font_size) - option_font_size = 1000; - if (option_font_min_size < 10) - option_font_min_size = 10; - if (500 < option_font_min_size) - option_font_min_size = 500; - - if (option_memory_cache_size < 0) - option_memory_cache_size = 0; + nsoptions_validate(&nsoptions); } /* exported interface documented in options.h */ -void options_write(const char *path) +void nsoption_write(const char *path) { unsigned int entry; FILE *fp; @@ -496,7 +226,8 @@ void options_write(const char *path) * \param string The string in which to output the value. * \return The number of bytes written to string or -1 on error */ -static size_t options_output_value_html(struct option_entry_s *option, +static size_t +nsoption_output_value_html(struct option_entry_s *option, size_t size, size_t pos, char *string) { size_t slen = 0; /* length added to string */ @@ -548,7 +279,8 @@ static size_t options_output_value_html(struct option_entry_s *option, * \param string The string in which to output the value. * \return The number of bytes written to string or -1 on error */ -static size_t options_output_value_text(struct option_entry_s *option, +static size_t +nsoption_output_value_text(struct option_entry_s *option, size_t size, size_t pos, char *string) { size_t slen = 0; /* length added to string */ @@ -584,7 +316,8 @@ static size_t options_output_value_text(struct option_entry_s *option, } /* exported interface documented in options.h */ -void options_commandline(int *pargc, char **argv) +void +nsoption_commandline(int *pargc, char **argv) { char *arg; char *val; @@ -643,8 +376,8 @@ void options_commandline(int *pargc, char **argv) } /* exported interface documented in options.h */ -int options_snoptionf(char *string, size_t size, unsigned int option, - const char *fmt) +int +nsoption_snoptionf(char *string, size_t size, unsigned int option, const char *fmt) { size_t slen = 0; /* current output string length */ int fmtc = 0; /* current index into format string */ @@ -695,11 +428,11 @@ int options_snoptionf(char *string, size_t size, unsigned int option, case 'V': - slen += options_output_value_html(option_entry, + slen += nsoption_output_value_html(option_entry, size, slen, string); break; case 'v': - slen += options_output_value_text(option_entry, + slen += nsoption_output_value_text(option_entry, size, slen, string); break; } @@ -718,14 +451,15 @@ int options_snoptionf(char *string, size_t size, unsigned int option, } /* exported interface documented in options.h */ -void options_dump(FILE *outf) +void +nsoption_dump(FILE *outf) { char buffer[256]; int opt_loop = 0; int res; do { - res = options_snoptionf(buffer, sizeof buffer, opt_loop, + res = nsoption_snoptionf(buffer, sizeof buffer, opt_loop, "%k:%v\n"); if (res > 0) { fprintf(outf, "%s", buffer); diff --git a/desktop/options.h b/desktop/options.h index 42375f9ef..b96aaec52 100644 --- a/desktop/options.h +++ b/desktop/options.h @@ -35,116 +35,94 @@ #ifndef _NETSURF_DESKTOP_OPTIONS_H_ #define _NETSURF_DESKTOP_OPTIONS_H_ +#define _NETSURF_DESKTOP_OPTIONS_INCLUDING_ + #include #include + #include "desktop/plot_style.h" +#include "desktop/options_main.h" + +#if defined(riscos) +#include "riscos/options.h" +#elif defined(nsgtk) +#include "gtk/options.h" +#elif defined(nsbeos) +#include "beos/options.h" +#elif defined(nsamiga) +#include "amiga/options.h" +#elif defined(nsframebuffer) +#include "framebuffer/options.h" +#elif defined(nsatari) +#include "atari/options.h" +#elif defined(nsmonkey) +#include "monkey/options.h" +#else +#define NSOPTION_EXTRA_DEFINE +#define NSOPTION_EXTRA_DEFAULTS +#define NSOPTION_EXTRA_TABLE +#endif + +/* allow the colour defaults to be overidden by the frontends */ +#ifndef NSOPTION_SYS_COLOUR_DEFAULTS +#define NSOPTION_SYS_COLOUR_DEFAULTS NSOPTION_MAIN_SYS_COLOUR_DEFAULTS +#endif + +#undef _NETSURF_DESKTOP_OPTIONS_INCLUDING_ + enum { OPTION_HTTP_PROXY_AUTH_NONE = 0, OPTION_HTTP_PROXY_AUTH_BASIC = 1, OPTION_HTTP_PROXY_AUTH_NTLM = 2 }; -extern bool option_http_proxy; -extern char *option_http_proxy_host; -extern int option_http_proxy_port; -extern int option_http_proxy_auth; -extern char *option_http_proxy_auth_user; -extern char *option_http_proxy_auth_pass; -extern int option_font_size; -extern int option_font_min_size; -extern char *option_accept_language; -extern char *option_accept_charset; -extern int option_memory_cache_size; -extern int option_disc_cache_age; -extern bool option_block_ads; -extern int option_minimum_gif_delay; -extern bool option_send_referer; -extern bool option_foreground_images; -extern bool option_background_images; -extern bool option_animate_images; -extern int option_expire_url; -extern int option_font_default; /* a css_font_family */ -extern char *option_font_sans; -extern char *option_font_serif; -extern char *option_font_mono; -extern char *option_font_cursive; -extern char *option_font_fantasy; -extern char *option_ca_bundle; -extern char *option_ca_path; -extern char *option_cookie_file; -extern char *option_cookie_jar; -extern char *option_homepage_url; -extern bool option_search_url_bar; -extern int option_search_provider; -extern bool option_target_blank; -extern bool option_button_2_tab; -extern bool option_url_suggestion; -extern int option_window_x; -extern int option_window_y; -extern int option_window_width; -extern int option_window_height; -extern int option_window_screen_width; -extern int option_window_screen_height; -extern int option_toolbar_status_width; -extern int option_scale; -extern bool option_incremental_reflow; -extern unsigned int option_min_reflow_period; -extern bool option_core_select_menu; - -extern int option_margin_top; -extern int option_margin_bottom; -extern int option_margin_left; -extern int option_margin_right; -extern int option_export_scale; -extern bool option_suppress_images; -extern bool option_remove_backgrounds; -extern bool option_enable_loosening; -extern bool option_enable_PDF_compression; -extern bool option_enable_PDF_password; #define DEFAULT_MARGIN_TOP_MM 10 #define DEFAULT_MARGIN_BOTTOM_MM 10 #define DEFAULT_MARGIN_LEFT_MM 10 #define DEFAULT_MARGIN_RIGHT_MM 10 #define DEFAULT_EXPORT_SCALE 0.7 +#ifdef riscos +#define DEFAULT_REFLOW_PERIOD 100 /* time in cs */ +#else +#define DEFAULT_REFLOW_PERIOD 25 /* time in cs */ +#endif -/* Fetcher configuration. */ -extern int option_max_fetchers; -extern int option_max_fetchers_per_host; -extern int option_max_cached_fetch_handles; -extern bool option_suppress_curl_debug; - -/* Interface colours */ -extern colour option_gui_colour_bg_1; -extern colour option_gui_colour_fg_1; -extern colour option_gui_colour_fg_2; - -extern colour option_sys_colour_ActiveBorder; -extern colour option_sys_colour_ActiveCaption; -extern colour option_sys_colour_AppWorkspace; -extern colour option_sys_colour_Background; -extern colour option_sys_colour_ButtonFace; -extern colour option_sys_colour_ButtonHighlight; -extern colour option_sys_colour_ButtonShadow; -extern colour option_sys_colour_ButtonText; -extern colour option_sys_colour_CaptionText; -extern colour option_sys_colour_GrayText; -extern colour option_sys_colour_Highlight; -extern colour option_sys_colour_HighlightText; -extern colour option_sys_colour_InactiveBorder; -extern colour option_sys_colour_InactiveCaption; -extern colour option_sys_colour_InactiveCaptionText; -extern colour option_sys_colour_InfoBackground; -extern colour option_sys_colour_InfoText; -extern colour option_sys_colour_Menu; -extern colour option_sys_colour_MenuText; -extern colour option_sys_colour_Scrollbar; -extern colour option_sys_colour_ThreeDDarkShadow; -extern colour option_sys_colour_ThreeDFace; -extern colour option_sys_colour_ThreeDHighlight; -extern colour option_sys_colour_ThreeDLightShadow; -extern colour option_sys_colour_ThreeDShadow; -extern colour option_sys_colour_Window; -extern colour option_sys_colour_WindowFrame; -extern colour option_sys_colour_WindowText; +struct ns_options { + NSOPTION_MAIN_DEFINE; + NSOPTION_EXTRA_DEFINE; +}; + +/* global option struct */ +extern struct ns_options nsoptions; + +/* acessors */ +#define nsoption_bool(OPTION) (nsoptions.OPTION) +#define nsoption_int(OPTION) (nsoptions.OPTION) +#define nsoption_charp(OPTION) (nsoptions.OPTION) +#define nsoption_colour(OPTION) (nsoptions.OPTION) + +#define nsoption_set_bool(OPTION, VALUE) nsoptions.OPTION = VALUE +#define nsoption_set_int(OPTION, VALUE) nsoptions.OPTION = VALUE +#define nsoption_set_colour(OPTION, VALUE) nsoptions.OPTION = VALUE +#define nsoption_set_charp(OPTION, VALUE) do { \ + if (nsoptions.OPTION != NULL) { \ + free(nsoptions.OPTION); \ + } \ + nsoptions.OPTION = VALUE; \ + if (*nsoptions.OPTION == 0) { \ + free(nsoptions.OPTION); \ + nsoptions.OPTION = NULL; \ + } \ + } while (0) + +#define nsoption_setnull_charp(OPTION, VALUE) do { \ + if (nsoptions.OPTION == NULL) { \ + nsoptions.OPTION = VALUE; \ + if (*nsoptions.OPTION == 0) { \ + free(nsoptions.OPTION); \ + nsoptions.OPTION = NULL; \ + } \ + } \ + } while (0) /** @@ -155,7 +133,7 @@ extern colour option_sys_colour_WindowText; * Option variables corresponding to lines in the file are updated. Missing * options are unchanged. If the file fails to open, options are unchanged. */ -void options_read(const char *path); +void nsoption_read(const char *path); /** * Save options to a file. @@ -164,14 +142,14 @@ void options_read(const char *path); * * Errors are ignored. */ -void options_write(const char *path); +void nsoption_write(const char *path); /** * Dump user options to stream * * \param outf output stream to dump options to. */ -void options_dump(FILE *outf); +void nsoption_dump(FILE *outf); /** * Fill a buffer with an option using a format. @@ -189,13 +167,13 @@ void options_dump(FILE *outf); * \param fmt The format string. * \return The number of bytes written to \a string or -1 on error */ -int options_snoptionf(char *string, size_t size, unsigned int option, +int nsoption_snoptionf(char *string, size_t size, unsigned int option, const char *fmt); /** * Process commandline and set options approriately. */ -void options_commandline(int *pargc, char **argv); +void nsoption_commandline(int *pargc, char **argv); #endif diff --git a/desktop/options_main.h b/desktop/options_main.h new file mode 100644 index 000000000..fc7af3d28 --- /dev/null +++ b/desktop/options_main.h @@ -0,0 +1,400 @@ +/* + * Copyright 2004 James Bursa + * + * This file is part of NetSurf, http://www.netsurf-browser.org/ + * + * NetSurf 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; version 2 of the License. + * + * NetSurf 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 . + */ + +/** \file + * Option available on all platforms + * + * Non-platform specific options can be added by editing this file + * + * Platform specific options should be added in the platform options.h. + * + * The following types of options are supported: + * - bool (OPTION_BOOL) boolean + * - int (OPTION_INTEGER) integer + * - colour (OPTION_COLOUR) colour + * - char* (OPTION_STRING) must be allocated on heap, may be NULL + */ + +#ifndef _NETSURF_DESKTOP_OPTIONS_MAIN_H_ +#define _NETSURF_DESKTOP_OPTIONS_MAIN_H_ + +#define NSOPTION_MAIN_DEFINE \ + /** An HTTP proxy should be used. */ \ + bool http_proxy; \ + /** Hostname of proxy. */ \ + char *http_proxy_host; \ + /** Proxy port. */ \ + int http_proxy_port; \ + /** Proxy authentication method. */ \ + int http_proxy_auth; \ + /** Proxy authentication user name */ \ + char *http_proxy_auth_user; \ + /** Proxy authentication password */ \ + char *http_proxy_auth_pass; \ + /** Default font size / 0.1pt. */ \ + int font_size; \ + /** Minimum font size. */ \ + int font_min_size; \ + /** Default sans serif font */ \ + char *font_sans; \ + /** Default serif font */ \ + char *font_serif; \ + /** Default monospace font */ \ + char *font_mono; \ + /** Default cursive font */ \ + char *font_cursive; \ + /** Default fantasy font */ \ + char *font_fantasy; \ + /** Accept-Language header. */ \ + char *accept_language; \ + /** Accept-Charset header. */ \ + char *accept_charset; \ + /** Preferred maximum size of memory cache / bytes. */ \ + int memory_cache_size; \ + /** Preferred expiry age of disc cache / days. */ \ + int disc_cache_age; \ + /** Whether to block advertisements */ \ + bool block_ads; \ + /** Minimum GIF animation delay */ \ + int minimum_gif_delay; \ + /** Whether to send the referer HTTP header */ \ + bool send_referer; \ + /** Whether to fetch foreground images */ \ + bool foreground_images; \ + /** Whether to fetch background images */ \ + bool background_images; \ + /** Whether to animate images */ \ + bool animate_images; \ + /** How many days to retain URL data for */ \ + int expire_url; \ + /** Default font family */ \ + int font_default; \ + /** ca-bundle location */ \ + char *ca_bundle; \ + /** ca-path location */ \ + char *ca_path; \ + /** Cookie file location */ \ + char *cookie_file; \ + /** Cookie jar location */ \ + char *cookie_jar; \ + /** Home page location */ \ + char *homepage_url; \ + /** search web from url bar */ \ + bool search_url_bar; \ + /** URL completion in url bar */ \ + bool url_suggestion; \ + /** default web search provider */ \ + int search_provider; \ + /** default x position of new windows */ \ + int window_x; \ + /** default y position of new windows */ \ + int window_y; \ + /** default width of new windows */ \ + int window_width; \ + /** default height of new windows */ \ + int window_height; \ + /** width of screen when above options were saved */ \ + int window_screen_width; \ + /** height of screen when above options were saved */ \ + int window_screen_height; \ + /** default size of status bar vs. h scroll bar */ \ + int toolbar_status_width; \ + /** default window scale */ \ + int scale; \ + /* Whether to reflow web pages while objects are fetching */ \ + bool incremental_reflow; \ + /* Minimum time between HTML reflows while objects are fetching */ \ + unsigned int min_reflow_period; /* time in cs */ \ + bool core_select_menu; \ + /** top margin of exported page */ \ + int margin_top; \ + /** bottom margin of exported page */ \ + int margin_bottom; \ + /** left margin of exported page */ \ + int margin_left; \ + /** right margin of exported page*/ \ + int margin_right; \ + /** scale of exported content*/ \ + int export_scale; \ + /** suppressing images in printed content*/ \ + bool suppress_images; \ + /** turning off all backgrounds for printed content*/ \ + bool remove_backgrounds; \ + /** turning on content loosening for printed content*/ \ + bool enable_loosening; \ + /** compression of PDF documents*/ \ + bool enable_PDF_compression; \ + /** setting a password and encoding PDF documents*/ \ + bool enable_PDF_password; \ + \ + /* Fetcher configuration */ \ + /** Maximum simultaneous active fetchers */ \ + int max_fetchers; \ + /** Maximum simultaneous active fetchers per host. \ + * (<=option_max_fetchers else it makes no sense) Note that \ + * rfc2616 section 8.1.4 says that there should be no more \ + * than two keepalive connections per host. None of the main \ + * browsers follow this as it slows page fetches down \ + * considerably. See \ + * https://bugzilla.mozilla.org/show_bug.cgi?id=423377#c4 \ + */ \ + int max_fetchers_per_host; \ + /** Maximum number of inactive fetchers cached. The total \ + * number of handles netsurf will therefore have open is this \ + * plus option_max_fetchers. \ + */ \ + int max_cached_fetch_handles; \ + /** Suppress debug output from cURL. */ \ + bool suppress_curl_debug; \ + \ + /** Whether to allow target="_blank" */ \ + bool target_blank; \ + \ + /** Whether second mouse button opens in new tab */ \ + bool button_2_tab; \ + \ + /* Interface colours */ \ + colour gui_colour_bg_1; /** Background (bbggrr) */ \ + colour gui_colour_fg_1; /** Foreground (bbggrr) */ \ + colour gui_colour_fg_2; /** Foreground selected (bbggrr) */ \ + \ + /* system colours */ \ + colour sys_colour_ActiveBorder; \ + colour sys_colour_ActiveCaption; \ + colour sys_colour_AppWorkspace; \ + colour sys_colour_Background; \ + colour sys_colour_ButtonFace; \ + colour sys_colour_ButtonHighlight; \ + colour sys_colour_ButtonShadow; \ + colour sys_colour_ButtonText; \ + colour sys_colour_CaptionText; \ + colour sys_colour_GrayText; \ + colour sys_colour_Highlight; \ + colour sys_colour_HighlightText; \ + colour sys_colour_InactiveBorder; \ + colour sys_colour_InactiveCaption; \ + colour sys_colour_InactiveCaptionText; \ + colour sys_colour_InfoBackground; \ + colour sys_colour_InfoText; \ + colour sys_colour_Menu; \ + colour sys_colour_MenuText; \ + colour sys_colour_Scrollbar; \ + colour sys_colour_ThreeDDarkShadow; \ + colour sys_colour_ThreeDFace; \ + colour sys_colour_ThreeDHighlight; \ + colour sys_colour_ThreeDLightShadow; \ + colour sys_colour_ThreeDShadow; \ + colour sys_colour_Window; \ + colour sys_colour_WindowFrame; \ + colour sys_colour_WindowText + +#define NSOPTION_MAIN_DEFAULTS \ + .http_proxy = false, \ + .http_proxy_host = NULL, \ + .http_proxy_port = 8080, \ + .http_proxy_auth = OPTION_HTTP_PROXY_AUTH_NONE, \ + .http_proxy_auth_user = NULL, \ + .http_proxy_auth_pass = NULL, \ + .font_size = 128, \ + .font_min_size = 85, \ + .font_sans = NULL, \ + .font_serif = NULL, \ + .font_mono = NULL, \ + .font_cursive = NULL, \ + .font_fantasy = NULL, \ + .accept_language = NULL, \ + .accept_charset = NULL, \ + .memory_cache_size = 12 * 1024 * 1024, \ + .disc_cache_age = 28, \ + .block_ads = false, \ + .minimum_gif_delay = 10, \ + .send_referer = true, \ + .foreground_images = true, \ + .background_images = true, \ + .animate_images = true, \ + .expire_url = 28, \ + .font_default = PLOT_FONT_FAMILY_SANS_SERIF, \ + .ca_bundle = NULL, \ + .ca_path = NULL, \ + .cookie_file = NULL, \ + .cookie_jar = NULL, \ + .homepage_url = NULL, \ + .search_url_bar = false, \ + .url_suggestion = true, \ + .search_provider = 0, \ + .window_x = 0, \ + .window_y = 0, \ + .window_width = 0, \ + .window_height = 0, \ + .window_screen_width = 0, \ + .window_screen_height = 0, \ + .toolbar_status_width = 6667, \ + .scale = 100, \ + .incremental_reflow = true, \ + .min_reflow_period = DEFAULT_REFLOW_PERIOD, \ + .core_select_menu = false, \ + .margin_top = DEFAULT_MARGIN_TOP_MM, \ + .margin_bottom = DEFAULT_MARGIN_BOTTOM_MM, \ + .margin_left = DEFAULT_MARGIN_LEFT_MM, \ + .margin_right = DEFAULT_MARGIN_RIGHT_MM, \ + .export_scale = DEFAULT_EXPORT_SCALE * 100, \ + .suppress_images = false, \ + .remove_backgrounds = false, \ + .enable_loosening = true, \ + .enable_PDF_compression = true, \ + .enable_PDF_password = false, \ + .max_fetchers = 24, \ + .max_fetchers_per_host = 5, \ + .max_cached_fetch_handles = 6, \ + .suppress_curl_debug = true, \ + .target_blank = true, \ + .button_2_tab = true, \ + .gui_colour_bg_1 = 0xFFCCBB, \ + .gui_colour_fg_1 = 0x000000, \ + .gui_colour_fg_2 = 0xFFFBF8 + +#define NSOPTION_MAIN_SYS_COLOUR_DEFAULTS \ + .sys_colour_ActiveBorder = 0x00000000, \ + .sys_colour_ActiveCaption = 0x00000000, \ + .sys_colour_AppWorkspace = 0x00000000, \ + .sys_colour_Background = 0x00000000, \ + .sys_colour_ButtonFace = 0x00000000, \ + .sys_colour_ButtonHighlight = 0x00000000, \ + .sys_colour_ButtonShadow = 0x00000000, \ + .sys_colour_ButtonText = 0x00000000, \ + .sys_colour_CaptionText = 0x0000000, \ + .sys_colour_GrayText = 0x00000000, \ + .sys_colour_Highlight = 0x00000000, \ + .sys_colour_HighlightText = 0x00000000, \ + .sys_colour_InactiveBorder = 0x00000000, \ + .sys_colour_InactiveCaption = 0x00000000, \ + .sys_colour_InactiveCaptionText = 0x00000000, \ + .sys_colour_InfoBackground = 0x00000000, \ + .sys_colour_InfoText = 0x00000000, \ + .sys_colour_Menu = 0x00000000, \ + .sys_colour_MenuText = 0x0000000, \ + .sys_colour_Scrollbar = 0x0000000, \ + .sys_colour_ThreeDDarkShadow = 0x000000, \ + .sys_colour_ThreeDFace = 0x000000, \ + .sys_colour_ThreeDHighlight = 0x000000, \ + .sys_colour_ThreeDLightShadow = 0x000000, \ + .sys_colour_ThreeDShadow = 0x000000, \ + .sys_colour_Window = 0x000000, \ + .sys_colour_WindowFrame = 0x000000, \ + .sys_colour_WindowText = 0x000000 + + +#define NSOPTION_MAIN_TABLE \ + { "http_proxy", OPTION_BOOL, &nsoptions.http_proxy }, \ + { "http_proxy_host", OPTION_STRING, &nsoptions.http_proxy_host }, \ + { "http_proxy_port", OPTION_INTEGER, &nsoptions.http_proxy_port }, \ + { "http_proxy_auth", OPTION_INTEGER, &nsoptions.http_proxy_auth }, \ + { "http_proxy_auth_user", OPTION_STRING, &nsoptions.http_proxy_auth_user }, \ + { "http_proxy_auth_pass", OPTION_STRING, &nsoptions.http_proxy_auth_pass }, \ + { "font_size", OPTION_INTEGER, &nsoptions.font_size }, \ + { "font_min_size", OPTION_INTEGER, &nsoptions.font_min_size }, \ + { "font_sans", OPTION_STRING, &nsoptions.font_sans }, \ + { "font_serif", OPTION_STRING, &nsoptions.font_serif }, \ + { "font_mono", OPTION_STRING, &nsoptions.font_mono }, \ + { "font_cursive", OPTION_STRING, &nsoptions.font_cursive }, \ + { "font_fantasy", OPTION_STRING, &nsoptions.font_fantasy }, \ + { "accept_language", OPTION_STRING, &nsoptions.accept_language }, \ + { "accept_charset", OPTION_STRING, &nsoptions.accept_charset }, \ + { "memory_cache_size", OPTION_INTEGER, &nsoptions.memory_cache_size }, \ + { "disc_cache_age", OPTION_INTEGER, &nsoptions.disc_cache_age }, \ + { "block_advertisements", OPTION_BOOL, &nsoptions.block_ads }, \ + { "minimum_gif_delay", OPTION_INTEGER, &nsoptions.minimum_gif_delay }, \ + { "send_referer", OPTION_BOOL, &nsoptions.send_referer }, \ + { "foreground_images", OPTION_BOOL, &nsoptions.foreground_images }, \ + { "background_images", OPTION_BOOL, &nsoptions.background_images }, \ + { "animate_images", OPTION_BOOL, &nsoptions.animate_images }, \ + { "expire_url", OPTION_INTEGER, &nsoptions.expire_url }, \ + { "font_default", OPTION_INTEGER, &nsoptions.font_default }, \ + { "ca_bundle", OPTION_STRING, &nsoptions.ca_bundle }, \ + { "ca_path", OPTION_STRING, &nsoptions.ca_path }, \ + { "cookie_file", OPTION_STRING, &nsoptions.cookie_file }, \ + { "cookie_jar", OPTION_STRING, &nsoptions.cookie_jar }, \ + { "homepage_url", OPTION_STRING, &nsoptions.homepage_url }, \ + { "search_url_bar", OPTION_BOOL, &nsoptions.search_url_bar}, \ + { "search_provider", OPTION_INTEGER, &nsoptions.search_provider}, \ + { "url_suggestion", OPTION_BOOL, &nsoptions.url_suggestion }, \ + { "window_x", OPTION_INTEGER, &nsoptions.window_x }, \ + { "window_y", OPTION_INTEGER, &nsoptions.window_y }, \ + { "window_width", OPTION_INTEGER, &nsoptions.window_width }, \ + { "window_height", OPTION_INTEGER, &nsoptions.window_height }, \ + { "window_screen_width", OPTION_INTEGER, &nsoptions.window_screen_width }, \ + { "window_screen_height", OPTION_INTEGER, &nsoptions.window_screen_height }, \ + { "toolbar_status_size", OPTION_INTEGER, &nsoptions.toolbar_status_width }, \ + { "scale", OPTION_INTEGER, &nsoptions.scale }, \ + { "incremental_reflow", OPTION_BOOL, &nsoptions.incremental_reflow }, \ + { "min_reflow_period", OPTION_INTEGER, &nsoptions.min_reflow_period }, \ + { "core_select_menu", OPTION_BOOL, &nsoptions.core_select_menu }, \ + /* Fetcher options */ \ + { "max_fetchers", OPTION_INTEGER, &nsoptions.max_fetchers }, \ + { "max_fetchers_per_host", OPTION_INTEGER, &nsoptions.max_fetchers_per_host }, \ + { "max_cached_fetch_handles", OPTION_INTEGER, &nsoptions.max_cached_fetch_handles }, \ + { "suppress_curl_debug",OPTION_BOOL, &nsoptions.suppress_curl_debug }, \ + { "target_blank", OPTION_BOOL, &nsoptions.target_blank }, \ + { "button_2_tab", OPTION_BOOL, &nsoptions.button_2_tab }, \ + /* PDF / Print options*/ \ + { "margin_top", OPTION_INTEGER, &nsoptions.margin_top}, \ + { "margin_bottom", OPTION_INTEGER, &nsoptions.margin_bottom}, \ + { "margin_left", OPTION_INTEGER, &nsoptions.margin_left}, \ + { "margin_right", OPTION_INTEGER, &nsoptions.margin_right}, \ + { "export_scale", OPTION_INTEGER, &nsoptions.export_scale}, \ + { "suppress_images", OPTION_BOOL, &nsoptions.suppress_images}, \ + { "remove_backgrounds", OPTION_BOOL, &nsoptions.remove_backgrounds}, \ + { "enable_loosening", OPTION_BOOL, &nsoptions.enable_loosening}, \ + { "enable_PDF_compression", OPTION_BOOL, &nsoptions.enable_PDF_compression}, \ + { "enable_PDF_password", OPTION_BOOL, &nsoptions.enable_PDF_password}, \ + /* Interface colours */ \ + { "gui_colour_bg_1", OPTION_COLOUR, &nsoptions.gui_colour_bg_1}, \ + { "gui_colour_fg_1", OPTION_COLOUR, &nsoptions.gui_colour_fg_1}, \ + { "gui_colour_fg_2", OPTION_COLOUR, &nsoptions.gui_colour_fg_2}, \ + \ + /* System colours */ \ + { "sys_colour_ActiveBorder",OPTION_COLOUR,&nsoptions.sys_colour_ActiveBorder }, \ + { "sys_colour_ActiveCaption",OPTION_COLOUR,&nsoptions.sys_colour_ActiveCaption }, \ + { "sys_colour_AppWorkspace",OPTION_COLOUR,&nsoptions.sys_colour_AppWorkspace }, \ + { "sys_colour_Background",OPTION_COLOUR,&nsoptions.sys_colour_Background }, \ + { "sys_colour_ButtonFace",OPTION_COLOUR,&nsoptions.sys_colour_ButtonFace }, \ + { "sys_colour_ButtonHighlight",OPTION_COLOUR,&nsoptions.sys_colour_ButtonHighlight }, \ + { "sys_colour_ButtonShadow",OPTION_COLOUR,&nsoptions.sys_colour_ButtonShadow }, \ + { "sys_colour_ButtonText",OPTION_COLOUR,&nsoptions.sys_colour_ButtonText }, \ + { "sys_colour_CaptionText",OPTION_COLOUR,&nsoptions.sys_colour_CaptionText }, \ + { "sys_colour_GrayText",OPTION_COLOUR,&nsoptions.sys_colour_GrayText }, \ + { "sys_colour_Highlight",OPTION_COLOUR,&nsoptions.sys_colour_Highlight }, \ + { "sys_colour_HighlightText",OPTION_COLOUR,&nsoptions.sys_colour_HighlightText }, \ + { "sys_colour_InactiveBorder",OPTION_COLOUR,&nsoptions.sys_colour_InactiveBorder }, \ + { "sys_colour_InactiveCaption",OPTION_COLOUR,&nsoptions.sys_colour_InactiveCaption }, \ + { "sys_colour_InactiveCaptionText",OPTION_COLOUR,&nsoptions.sys_colour_InactiveCaptionText }, \ + { "sys_colour_InfoBackground",OPTION_COLOUR,&nsoptions.sys_colour_InfoBackground }, \ + { "sys_colour_InfoText",OPTION_COLOUR,&nsoptions.sys_colour_InfoText }, \ + { "sys_colour_Menu",OPTION_COLOUR,&nsoptions.sys_colour_Menu }, \ + { "sys_colour_MenuText",OPTION_COLOUR,&nsoptions.sys_colour_MenuText }, \ + { "sys_colour_Scrollbar",OPTION_COLOUR,&nsoptions.sys_colour_Scrollbar }, \ + { "sys_colour_ThreeDDarkShadow",OPTION_COLOUR,&nsoptions.sys_colour_ThreeDDarkShadow }, \ + { "sys_colour_ThreeDFace",OPTION_COLOUR,&nsoptions.sys_colour_ThreeDFace }, \ + { "sys_colour_ThreeDHighlight",OPTION_COLOUR,&nsoptions.sys_colour_ThreeDHighlight }, \ + { "sys_colour_ThreeDLightShadow", OPTION_COLOUR,&nsoptions.sys_colour_ThreeDLightShadow }, \ + { "sys_colour_ThreeDShadow", OPTION_COLOUR,&nsoptions.sys_colour_ThreeDShadow }, \ + { "sys_colour_Window", OPTION_COLOUR,&nsoptions.sys_colour_Window }, \ + { "sys_colour_WindowFrame", OPTION_COLOUR,&nsoptions.sys_colour_WindowFrame }, \ + { "sys_colour_WindowText", OPTION_COLOUR,&nsoptions.sys_colour_WindowText } + +#endif diff --git a/desktop/print.c b/desktop/print.c index ae0992ac0..4b8092b6f 100644 --- a/desktop/print.c +++ b/desktop/print.c @@ -126,7 +126,7 @@ bool print_draw_next_page(const struct printer *printer, struct content_redraw_data data; struct redraw_context ctx = { .interactive = false, - .background_images = !option_remove_backgrounds, + .background_images = !nsoption_bool(remove_backgrounds), .plot = printer->plotter }; @@ -288,18 +288,18 @@ struct print_settings *print_make_settings(print_configuration configuration, settings->page_height = DEFAULT_PAGE_HEIGHT; settings->copies = DEFAULT_COPIES; - settings->scale = (float)option_export_scale / 100; + settings->scale = (float)nsoption_int(export_scale) / 100; - length = INTTOFIX(option_margin_left); + length = INTTOFIX(nsoption_int(margin_left)); settings->margins[MARGINLEFT] = nscss_len2px(length, unit, NULL); - length = INTTOFIX(option_margin_right); + length = INTTOFIX(nsoption_int(margin_right)); settings->margins[MARGINRIGHT] = nscss_len2px(length, unit, NULL); - length = INTTOFIX(option_margin_top); + length = INTTOFIX(nsoption_int(margin_top)); settings->margins[MARGINTOP] = nscss_len2px(length, unit, NULL); - length = INTTOFIX(option_margin_bottom); + length = INTTOFIX(nsoption_int(margin_bottom)); settings->margins[MARGINBOTTOM] = nscss_len2px(length, unit, NULL); break; diff --git a/desktop/tree.c b/desktop/tree.c index bab474ded..8facdfd42 100644 --- a/desktop/tree.c +++ b/desktop/tree.c @@ -186,29 +186,30 @@ void tree_set_icon_dir(char *icon_dir) static void tree_setup_colours(void) { /* Background colour */ - plot_style_fill_tree_background.fill_colour = option_gui_colour_bg_1; + plot_style_fill_tree_background.fill_colour = nsoption_colour(gui_colour_bg_1); /* Selection background colour */ - plot_style_fill_tree_selected.fill_colour = option_gui_colour_fg_1; + plot_style_fill_tree_selected.fill_colour = nsoption_colour(gui_colour_fg_1); /* Furniture line colour */ plot_style_stroke_tree_furniture.stroke_colour = blend_colour( - option_gui_colour_bg_1, option_gui_colour_fg_1); + nsoption_colour(gui_colour_bg_1), + nsoption_colour(gui_colour_fg_1)); /* Furniture fill colour */ - plot_style_fill_tree_furniture.fill_colour = option_gui_colour_fg_2; + plot_style_fill_tree_furniture.fill_colour = nsoption_colour(gui_colour_fg_2); /* Text colour */ - plot_fstyle.foreground = option_gui_colour_fg_1; - plot_fstyle.background = option_gui_colour_bg_1; - plot_fstyle_def_folder.foreground = option_gui_colour_fg_1; - plot_fstyle_def_folder.background = option_gui_colour_bg_1; + plot_fstyle.foreground = nsoption_colour(gui_colour_fg_1); + plot_fstyle.background = nsoption_colour(gui_colour_bg_1); + plot_fstyle_def_folder.foreground = nsoption_colour(gui_colour_fg_1); + plot_fstyle_def_folder.background = nsoption_colour(gui_colour_bg_1); /* Selected text colour */ - plot_fstyle_selected.foreground = option_gui_colour_fg_2; - plot_fstyle_selected.background = option_gui_colour_fg_1; - plot_fstyle_selected_def_folder.foreground = option_gui_colour_fg_2; - plot_fstyle_selected_def_folder.background = option_gui_colour_fg_1; + plot_fstyle_selected.foreground = nsoption_colour(gui_colour_fg_2); + plot_fstyle_selected.background = nsoption_colour(gui_colour_fg_1); + plot_fstyle_selected_def_folder.foreground = nsoption_colour(gui_colour_fg_2); + plot_fstyle_selected_def_folder.background = nsoption_colour(gui_colour_fg_1); } -- cgit v1.2.3